@@ -1330,22 +1330,6 @@ void elf::processArmCmseSymbols(Ctx &ctx) {
1330
1330
});
1331
1331
}
1332
1332
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
-
1349
1333
ArmCmseSGSection::ArmCmseSGSection (Ctx &ctx)
1350
1334
: SyntheticSection(ctx, llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR,
1351
1335
llvm::ELF::SHT_PROGBITS,
@@ -1389,19 +1373,19 @@ void ArmCmseSGSection::addSGVeneer(Symbol *acleSeSym, Symbol *sym) {
1389
1373
return ;
1390
1374
// Only secure symbols with values equal to that of it's non-secure
1391
1375
// counterpart needs to be in the .gnu.sgstubs section.
1392
- ArmCmseSGVeneer *ss = nullptr ;
1376
+ std::unique_ptr< ArmCmseSGVeneer> ss ;
1393
1377
if (ctx.symtab ->cmseImportLib .count (sym->getName ())) {
1394
1378
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 );
1396
1380
} else {
1397
- ss = make <ArmCmseSGVeneer>(sym, acleSeSym);
1381
+ ss = std::make_unique <ArmCmseSGVeneer>(sym, acleSeSym);
1398
1382
++newEntries;
1399
1383
}
1400
- sgVeneers.emplace_back (ss );
1384
+ sgVeneers.emplace_back (std::move (ss) );
1401
1385
}
1402
1386
1403
1387
void ArmCmseSGSection::writeTo (uint8_t *buf) {
1404
- for (ArmCmseSGVeneer * s : sgVeneers) {
1388
+ for (std::unique_ptr< ArmCmseSGVeneer> & s : sgVeneers) {
1405
1389
uint8_t *p = buf + s->offset ;
1406
1390
write16 (ctx, p + 0 , 0xe97f ); // SG
1407
1391
write16 (ctx, p + 2 , 0xe97f );
@@ -1430,8 +1414,8 @@ void ArmCmseSGSection::finalizeContents() {
1430
1414
1431
1415
auto it =
1432
1416
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) {
1435
1419
return a->getAddr ().value () < b->getAddr ().value ();
1436
1420
});
1437
1421
// This is the partition of the veneers with fixed addresses.
@@ -1441,13 +1425,12 @@ void ArmCmseSGSection::finalizeContents() {
1441
1425
// Check if the start address of '.gnu.sgstubs' correspond to the
1442
1426
// linker-synthesized veneer with the lowest address.
1443
1427
if ((getVA () & ~1 ) != (addr & ~1 )) {
1444
- ErrAlways (ctx)
1428
+ Err (ctx)
1445
1429
<< " start address of '.gnu.sgstubs' is different from previous link" ;
1446
1430
return ;
1447
1431
}
1448
1432
1449
- for (size_t i = 0 ; i < sgVeneers.size (); ++i) {
1450
- ArmCmseSGVeneer *s = sgVeneers[i];
1433
+ for (auto [i, s] : enumerate(sgVeneers)) {
1451
1434
s->offset = i * s->size ;
1452
1435
Defined (ctx, file, StringRef (), s->sym ->binding , s->sym ->stOther ,
1453
1436
s->sym ->type , s->offset | 1 , s->size , this )
0 commit comments