Skip to content

Commit 9cec7f4

Browse files
author
Tarcisio Fischer
committed
Apply clang-format and other review suggestions
1 parent 6dd5bee commit 9cec7f4

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

lld/ELF/AArch64ErrataFix.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ static uint64_t scanCortexA53Errata843419(InputSection *isec, uint64_t &off,
370370

371371
class elf::Patch843419Section final : public SyntheticSection {
372372
public:
373-
Patch843419Section(Ctx &, InputSection *p, uint64_t off, Defined* patcheeCodeSym);
373+
Patch843419Section(Ctx &, InputSection *p, uint64_t off,
374+
Defined *patcheeCodeSym);
374375

375376
void writeTo(uint8_t *buf) override;
376377

@@ -390,7 +391,8 @@ class elf::Patch843419Section final : public SyntheticSection {
390391
Symbol *patchSym;
391392
};
392393

393-
Patch843419Section::Patch843419Section(Ctx &ctx, InputSection *p, uint64_t off, Defined* patcheeCodeSym)
394+
Patch843419Section::Patch843419Section(Ctx &ctx, InputSection *p, uint64_t off,
395+
Defined *patcheeCodeSym)
394396
: SyntheticSection(ctx, ".text.patch", SHT_PROGBITS,
395397
SHF_ALLOC | SHF_EXECINSTR, 4),
396398
patchee(p), patcheeOffset(off) {
@@ -399,7 +401,8 @@ Patch843419Section::Patch843419Section(Ctx &ctx, InputSection *p, uint64_t off,
399401
ctx, ctx.saver.save("__CortexA53843419_" + utohexstr(getLDSTAddr())),
400402
STT_FUNC, 0, getSize(), *this);
401403
addSyntheticLocal(ctx, ctx.saver.save("$x"), STT_NOTYPE, 0, 0, *this);
402-
int64_t retToPatcheeSymOffset = (getLDSTAddr() - p->getVA(patcheeCodeSym->value)) + 4;
404+
int64_t retToPatcheeSymOffset =
405+
getLDSTAddr() - p->getVA(patcheeCodeSym->value) + 4;
403406
addReloc({R_PC, R_AARCH64_JUMP26, 4, retToPatcheeSymOffset, patcheeCodeSym});
404407
}
405408

@@ -455,7 +458,7 @@ void AArch64Err843419Patcher::init() {
455458
// the same type. For example we must remove the redundant $d.1 from $x.0
456459
// $d.0 $d.1 $x.1.
457460
for (auto &kv : sectionMap) {
458-
std::vector<Defined *> &mapSyms = kv.second.second;
461+
auto &mapSyms = kv.second.second;
459462
llvm::stable_sort(mapSyms, [](const Defined *a, const Defined *b) {
460463
return a->value < b->value;
461464
});
@@ -530,7 +533,7 @@ void AArch64Err843419Patcher::insertPatches(
530533
static void implementPatch(Ctx &ctx, uint64_t adrpAddr, uint64_t patcheeOffset,
531534
InputSection *isec,
532535
std::vector<Patch843419Section *> &patches,
533-
Defined* patcheeCodeSym) {
536+
Defined *patcheeCodeSym) {
534537
// There may be a relocation at the same offset that we are patching. There
535538
// are four cases that we need to consider.
536539
// Case 1: R_AARCH64_JUMP26 branch relocation. We have already patched this
@@ -585,11 +588,12 @@ AArch64Err843419Patcher::patchInputSectionDescription(
585588
// mapping symbols of the same type. Our range of executable instructions to
586589
// scan is therefore [codeSym->value, dataSym->value) or [codeSym->value,
587590
// section size).
588-
auto &[sectionSym, mapSyms] = sectionMap[isec];
589-
if (sectionSym == nullptr)
591+
auto [it, inserted] = sectionMap.try_emplace(
592+
isec, std::make_pair(nullptr, SmallVector<Defined *, 0>{}));
593+
auto &[sectionSym, mapSyms] = it->second;
594+
if (inserted || sectionSym == nullptr)
590595
sectionSym = addSyntheticLocal(ctx, "", STT_SECTION, 0, 0, *isec);
591596

592-
593597
auto codeSym = mapSyms.begin();
594598
while (codeSym != mapSyms.end()) {
595599
auto dataSym = std::next(codeSym);
@@ -601,7 +605,8 @@ AArch64Err843419Patcher::patchInputSectionDescription(
601605
uint64_t startAddr = isec->getVA(off);
602606
if (uint64_t patcheeOffset =
603607
scanCortexA53Errata843419(isec, off, limit))
604-
implementPatch(ctx, startAddr, patcheeOffset, isec, patches, sectionSym);
608+
implementPatch(ctx, startAddr, patcheeOffset, isec, patches,
609+
sectionSym);
605610
}
606611
if (dataSym == mapSyms.end())
607612
break;

lld/ELF/AArch64ErrataFix.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ class AArch64Err843419Patcher {
4040
// the mapping symbols (second) defined by the InputSection sorted in order
4141
// of ascending value with redundant symbols removed. These describe the
4242
// ranges of code and data in an executable InputSection.
43-
llvm::DenseMap<InputSection *, std::pair<Defined*, std::vector<Defined *>>> sectionMap;
43+
llvm::DenseMap<InputSection *,
44+
std::pair<Defined *, SmallVector<Defined *, 0>>>
45+
sectionMap;
4446

4547
bool initialized = false;
4648
};

lld/ELF/Arch/AArch64.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ bool elf::isAArch64BTILandingPad(Ctx &ctx, Symbol &s, int64_t a) {
4848
if (off >= isec->getSize())
4949
return true;
5050
const uint8_t *buf = isec->content().begin();
51-
// Synthetic sections may have a size but empty data - Assume that they won't contain a landing pad
51+
// Synthetic sections may have a size but empty data - Assume that they won't
52+
// contain a landing pad
5253
if (buf == nullptr && isa<SyntheticSection>(isec))
5354
return false;
5455

lld/ELF/Relocations.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ ThunkSection *ThunkCreator::getISThunkSec(InputSection *isec) {
19221922
if (isec->outSecOff < first->outSecOff || last->outSecOff < isec->outSecOff)
19231923
continue;
19241924

1925-
ts = addThunkSection(tos, isd, isec->outSecOff, /* isPrefix */ true);
1925+
ts = addThunkSection(tos, isd, isec->outSecOff, /*isPrefix=*/true);
19261926
thunkedSections[isec] = ts;
19271927
return ts;
19281928
}
@@ -1981,8 +1981,7 @@ void ThunkCreator::createInitialThunkSections(
19811981

19821982
ThunkSection *ThunkCreator::addThunkSection(OutputSection *os,
19831983
InputSectionDescription *isd,
1984-
uint64_t off,
1985-
bool isPrefix) {
1984+
uint64_t off, bool isPrefix) {
19861985
auto *ts = make<ThunkSection>(ctx, os, off);
19871986
ts->partition = os->partition;
19881987
if ((ctx.arg.fixCortexA53Errata843419 || ctx.arg.fixCortexA8) &&

0 commit comments

Comments
 (0)