@@ -1330,22 +1330,6 @@ void elf::processArmCmseSymbols(Ctx &ctx) {
13301330 });
13311331}
13321332
1333- class elf ::ArmCmseSGVeneer {
1334- public:
1335- ArmCmseSGVeneer (Symbol *sym, Symbol *acleSeSym,
1336- std::optional<uint64_t > addr = std::nullopt )
1337- : sym(sym), acleSeSym(acleSeSym), entAddr{addr} {}
1338- static const size_t size{ACLESESYM_SIZE};
1339- const std::optional<uint64_t > getAddr () const { return entAddr; };
1340-
1341- Symbol *sym;
1342- Symbol *acleSeSym;
1343- uint64_t offset = 0 ;
1344-
1345- private:
1346- const std::optional<uint64_t > entAddr;
1347- };
1348-
13491333ArmCmseSGSection::ArmCmseSGSection (Ctx &ctx)
13501334 : SyntheticSection(ctx, llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR,
13511335 llvm::ELF::SHT_PROGBITS,
@@ -1389,19 +1373,19 @@ void ArmCmseSGSection::addSGVeneer(Symbol *acleSeSym, Symbol *sym) {
13891373 return ;
13901374 // Only secure symbols with values equal to that of it's non-secure
13911375 // counterpart needs to be in the .gnu.sgstubs section.
1392- ArmCmseSGVeneer *ss = nullptr ;
1376+ std::unique_ptr< ArmCmseSGVeneer> ss ;
13931377 if (ctx.symtab ->cmseImportLib .count (sym->getName ())) {
13941378 Defined *impSym = ctx.symtab ->cmseImportLib [sym->getName ()];
1395- ss = make <ArmCmseSGVeneer>(sym, acleSeSym, impSym->value );
1379+ ss = std::make_unique <ArmCmseSGVeneer>(sym, acleSeSym, impSym->value );
13961380 } else {
1397- ss = make <ArmCmseSGVeneer>(sym, acleSeSym);
1381+ ss = std::make_unique <ArmCmseSGVeneer>(sym, acleSeSym);
13981382 ++newEntries;
13991383 }
1400- sgVeneers.emplace_back (ss );
1384+ sgVeneers.emplace_back (std::move (ss) );
14011385}
14021386
14031387void ArmCmseSGSection::writeTo (uint8_t *buf) {
1404- for (ArmCmseSGVeneer * s : sgVeneers) {
1388+ for (std::unique_ptr< ArmCmseSGVeneer> & s : sgVeneers) {
14051389 uint8_t *p = buf + s->offset ;
14061390 write16 (ctx, p + 0 , 0xe97f ); // SG
14071391 write16 (ctx, p + 2 , 0xe97f );
@@ -1430,8 +1414,8 @@ void ArmCmseSGSection::finalizeContents() {
14301414
14311415 auto it =
14321416 std::stable_partition (sgVeneers.begin (), sgVeneers.end (),
1433- [](auto * i) { return i->getAddr ().has_value (); });
1434- std::sort (sgVeneers.begin (), it, [](auto * a, auto * b) {
1417+ [](auto & i) { return i->getAddr ().has_value (); });
1418+ std::sort (sgVeneers.begin (), it, [](auto & a, auto & b) {
14351419 return a->getAddr ().value () < b->getAddr ().value ();
14361420 });
14371421 // This is the partition of the veneers with fixed addresses.
@@ -1441,13 +1425,12 @@ void ArmCmseSGSection::finalizeContents() {
14411425 // Check if the start address of '.gnu.sgstubs' correspond to the
14421426 // linker-synthesized veneer with the lowest address.
14431427 if ((getVA () & ~1 ) != (addr & ~1 )) {
1444- ErrAlways (ctx)
1428+ Err (ctx)
14451429 << " start address of '.gnu.sgstubs' is different from previous link" ;
14461430 return ;
14471431 }
14481432
1449- for (size_t i = 0 ; i < sgVeneers.size (); ++i) {
1450- ArmCmseSGVeneer *s = sgVeneers[i];
1433+ for (auto [i, s] : enumerate(sgVeneers)) {
14511434 s->offset = i * s->size ;
14521435 Defined (ctx, file, StringRef (), s->sym ->binding , s->sym ->stOther ,
14531436 s->sym ->type , s->offset | 1 , s->size , this )
0 commit comments