@@ -922,11 +922,10 @@ template <typename ELFT>
922
922
static void parseGnuPropertyNote (Ctx &ctx, uint32_t &featureAndType,
923
923
ArrayRef<uint8_t > &desc, ELFFileBase *f,
924
924
const uint8_t *base,
925
- ArrayRef<uint8_t > *data = nullptr ,
926
- StringRef sectionName = " .note.gnu.property" ) {
925
+ ArrayRef<uint8_t > *data = nullptr ) {
927
926
auto err = [&](const uint8_t *place) -> ELFSyncStream {
928
927
auto diag = Err (ctx);
929
- diag << f->getName () << " :(" << sectionName << " +0x"
928
+ diag << f->getName () << " :(" << " .note.gnu.property +0x"
930
929
<< Twine::utohexstr (place - base) << " ): " ;
931
930
return diag;
932
931
};
@@ -954,13 +953,14 @@ static void parseGnuPropertyNote(Ctx &ctx, uint32_t &featureAndType,
954
953
// the data variable as there is no InputSection to collect the
955
954
// data from. As such, these are ignored. They are needed either
956
955
// when loading a shared library oject.
957
- if (!f->aarch64PauthAbiCoreInfo .empty () && data != nullptr ) {
956
+ ArrayRef<uint8_t > contents = data ? *data : desc;
957
+ if (!f->aarch64PauthAbiCoreInfo .empty ()) {
958
958
return void (
959
- err (data-> data ())
959
+ err (contents. data ())
960
960
<< " multiple GNU_PROPERTY_AARCH64_FEATURE_PAUTH entries are "
961
961
" not supported" );
962
- } else if (size != 16 && data != nullptr ) {
963
- return void (err (data-> data ())
962
+ } else if (size != 16 ) {
963
+ return void (err (contents. data ())
964
964
<< " GNU_PROPERTY_AARCH64_FEATURE_PAUTH entry "
965
965
" is invalid: expected 16 bytes, but got "
966
966
<< size);
@@ -1010,8 +1010,7 @@ static void readGnuProperty(Ctx &ctx, const InputSection &sec,
1010
1010
// Read a body of a NOTE record, which consists of type-length-value fields.
1011
1011
ArrayRef<uint8_t > desc = note.getDesc (sec.addralign );
1012
1012
const uint8_t *base = sec.content ().data ();
1013
- parseGnuPropertyNote<ELFT>(ctx, featureAndType, desc, &f, base, &data,
1014
- sec.name );
1013
+ parseGnuPropertyNote<ELFT>(ctx, featureAndType, desc, &f, base, &data);
1015
1014
1016
1015
// Go to next NOTE record to look for more FEATURE_1_AND descriptions.
1017
1016
data = data.slice (nhdr->getSize (sec.addralign ));
@@ -1448,9 +1447,8 @@ std::vector<uint32_t> SharedFile::parseVerneed(const ELFFile<ELFT> &obj,
1448
1447
// be collected from this is irrelevant for a dynamic object.
1449
1448
template <typename ELFT>
1450
1449
void SharedFile::parseGnuAndFeatures (const uint8_t *base,
1451
- const typename ELFT::PhdrRange headers,
1452
- const typename ELFT::Shdr *sHeader ) {
1453
- if (numElfPhdrs == 0 || sHeader == nullptr )
1450
+ const typename ELFT::PhdrRange headers) {
1451
+ if (numElfPhdrs == 0 )
1454
1452
return ;
1455
1453
uint32_t featureAndType = ctx.arg .emachine == EM_AARCH64
1456
1454
? GNU_PROPERTY_AARCH64_FEATURE_1_AND
@@ -1461,12 +1459,12 @@ void SharedFile::parseGnuAndFeatures(const uint8_t *base,
1461
1459
continue ;
1462
1460
const typename ELFT::Note note (
1463
1461
*reinterpret_cast <const typename ELFT::Nhdr *>(base +
1464
- headers[i].p_vaddr ));
1462
+ headers[i].p_offset ));
1465
1463
if (note.getType () != NT_GNU_PROPERTY_TYPE_0 || note.getName () != " GNU" )
1466
1464
continue ;
1467
1465
1468
1466
// Read a body of a NOTE record, which consists of type-length-value fields.
1469
- ArrayRef<uint8_t > desc = note.getDesc (sHeader -> sh_addralign );
1467
+ ArrayRef<uint8_t > desc = note.getDesc (headers[i]. p_align );
1470
1468
parseGnuPropertyNote<ELFT>(ctx, featureAndType, desc, this , base);
1471
1469
}
1472
1470
}
@@ -1520,7 +1518,6 @@ template <class ELFT> void SharedFile::parse() {
1520
1518
const Elf_Shdr *versymSec = nullptr ;
1521
1519
const Elf_Shdr *verdefSec = nullptr ;
1522
1520
const Elf_Shdr *verneedSec = nullptr ;
1523
- const Elf_Shdr *noteSec = nullptr ;
1524
1521
symbols = std::make_unique<Symbol *[]>(numSymbols);
1525
1522
1526
1523
// Search for .dynsym, .dynamic, .symtab, .gnu.version and .gnu.version_d.
@@ -1541,9 +1538,6 @@ template <class ELFT> void SharedFile::parse() {
1541
1538
case SHT_GNU_verneed:
1542
1539
verneedSec = &sec;
1543
1540
break ;
1544
- case SHT_NOTE:
1545
- noteSec = &sec;
1546
- break ;
1547
1541
}
1548
1542
}
1549
1543
@@ -1590,7 +1584,7 @@ template <class ELFT> void SharedFile::parse() {
1590
1584
1591
1585
verdefs = parseVerdefs<ELFT>(obj.base (), verdefSec);
1592
1586
std::vector<uint32_t > verneeds = parseVerneed<ELFT>(obj, verneedSec);
1593
- parseGnuAndFeatures<ELFT>(obj.base (), getELFPhdrs<ELFT>(), noteSec );
1587
+ parseGnuAndFeatures<ELFT>(obj.base (), getELFPhdrs<ELFT>());
1594
1588
1595
1589
// Parse ".gnu.version" section which is a parallel array for the symbol
1596
1590
// table. If a given file doesn't have a ".gnu.version" section, we use
0 commit comments