@@ -370,7 +370,8 @@ static uint64_t scanCortexA53Errata843419(InputSection *isec, uint64_t &off,
370370
371371class elf ::Patch843419Section final : public SyntheticSection {
372372public:
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(
530533static 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 ;
0 commit comments