@@ -919,54 +919,57 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
919
919
}
920
920
921
921
template <typename ELFT>
922
- static void parseGnuPropertyNote (Ctx &ctx, uint32_t &featureAndType, ArrayRef<uint8_t > &desc, ELFFileBase *f, const uint8_t *base, ArrayRef<uint8_t > *data = nullptr ) {
922
+ static void parseGnuPropertyNote (Ctx &ctx, uint32_t &featureAndType,
923
+ ArrayRef<uint8_t > &desc, ELFFileBase *f,
924
+ const uint8_t *base,
925
+ ArrayRef<uint8_t > *data = nullptr ) {
923
926
auto err = [&](const uint8_t *place) -> ELFSyncStream {
924
927
auto diag = Err (ctx);
925
928
diag << f->getName () << " :(" << " .note.gnu.properties" << " +0x"
926
929
<< Twine::utohexstr (place - base) << " ): " ;
927
930
return diag;
928
931
};
929
932
930
- while (!desc.empty ()) {
931
- const uint8_t *place = desc.data ();
932
- if (desc.size () < 8 )
933
- return void (err (place) << " program property is too short" );
934
- uint32_t type = read32<ELFT::Endianness>(desc.data ());
935
- uint32_t size = read32<ELFT::Endianness>(desc.data () + 4 );
936
- desc = desc.slice (8 );
937
- if (desc.size () < size)
938
- return void (err (place) << " program property is too short" );
939
-
940
- if (type == featureAndType) {
941
- // We found a FEATURE_1_AND field. There may be more than one of these
942
- // in a .note.gnu.property section, for a relocatable object we
943
- // accumulate the bits set.
944
- if (size < 4 )
945
- return void (err (place) << " FEATURE_1_AND entry is too short" );
946
- f->andFeatures |= read32<ELFT::Endianness>(desc.data ());
947
- } else if (ctx.arg .emachine == EM_AARCH64 &&
948
- type == GNU_PROPERTY_AARCH64_FEATURE_PAUTH) {
949
- // If the file being parsed is a SharedFile, we cannot pass in
950
- // the data variable as there is no InputSection to collect the
951
- // data from. As such, these are ignored. They are needed either
952
- // when loading a shared library oject.
953
- if (!f->aarch64PauthAbiCoreInfo .empty () && data != nullptr ) {
954
- return void (
955
- err (data->data ())
956
- << " multiple GNU_PROPERTY_AARCH64_FEATURE_PAUTH entries are "
957
- " not supported" );
958
- } else if (size != 16 && data != nullptr ) {
959
- return void (err (data->data ())
960
- << " GNU_PROPERTY_AARCH64_FEATURE_PAUTH entry "
961
- " is invalid: expected 16 bytes, but got "
962
- << size);
963
- }
964
- f->aarch64PauthAbiCoreInfo = desc;
933
+ while (!desc.empty ()) {
934
+ const uint8_t *place = desc.data ();
935
+ if (desc.size () < 8 )
936
+ return void (err (place) << " program property is too short" );
937
+ uint32_t type = read32<ELFT::Endianness>(desc.data ());
938
+ uint32_t size = read32<ELFT::Endianness>(desc.data () + 4 );
939
+ desc = desc.slice (8 );
940
+ if (desc.size () < size)
941
+ return void (err (place) << " program property is too short" );
942
+
943
+ if (type == featureAndType) {
944
+ // We found a FEATURE_1_AND field. There may be more than one of these
945
+ // in a .note.gnu.property section, for a relocatable object we
946
+ // accumulate the bits set.
947
+ if (size < 4 )
948
+ return void (err (place) << " FEATURE_1_AND entry is too short" );
949
+ f->andFeatures |= read32<ELFT::Endianness>(desc.data ());
950
+ } else if (ctx.arg .emachine == EM_AARCH64 &&
951
+ type == GNU_PROPERTY_AARCH64_FEATURE_PAUTH) {
952
+ // If the file being parsed is a SharedFile, we cannot pass in
953
+ // the data variable as there is no InputSection to collect the
954
+ // data from. As such, these are ignored. They are needed either
955
+ // when loading a shared library oject.
956
+ if (!f->aarch64PauthAbiCoreInfo .empty () && data != nullptr ) {
957
+ return void (
958
+ err (data->data ())
959
+ << " multiple GNU_PROPERTY_AARCH64_FEATURE_PAUTH entries are "
960
+ " not supported" );
961
+ } else if (size != 16 && data != nullptr ) {
962
+ return void (err (data->data ())
963
+ << " GNU_PROPERTY_AARCH64_FEATURE_PAUTH entry "
964
+ " is invalid: expected 16 bytes, but got "
965
+ << size);
965
966
}
966
-
967
- // Padding is present in the note descriptor, if necessary.
968
- desc = desc.slice (alignTo<(ELFT::Is64Bits ? 8 : 4 )>(size));
967
+ f->aarch64PauthAbiCoreInfo = desc;
969
968
}
969
+
970
+ // Padding is present in the note descriptor, if necessary.
971
+ desc = desc.slice (alignTo<(ELFT::Is64Bits ? 8 : 4 )>(size));
972
+ }
970
973
}
971
974
// Read the following info from the .note.gnu.property section and write it to
972
975
// the corresponding fields in `ObjFile`:
@@ -1443,8 +1446,8 @@ std::vector<uint32_t> SharedFile::parseVerneed(const ELFFile<ELFT> &obj,
1443
1446
// be collected from this is irrelevant for a dynamic object.
1444
1447
template <typename ELFT>
1445
1448
void SharedFile::parseGnuAndFeatures (const uint8_t *base,
1446
- const typename ELFT::PhdrRange headers,
1447
- const typename ELFT::Shdr *sHeader ) {
1449
+ const typename ELFT::PhdrRange headers,
1450
+ const typename ELFT::Shdr *sHeader ) {
1448
1451
if (numElfPhdrs == 0 || sHeader == nullptr )
1449
1452
return ;
1450
1453
uint32_t featureAndType = ctx.arg .emachine == EM_AARCH64
0 commit comments