Skip to content

Commit 572e5f4

Browse files
committed
move reading .note.gnu.property to the parse loop
1 parent 5cb1940 commit 572e5f4

File tree

1 file changed

+12
-31
lines changed

1 file changed

+12
-31
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -749,26 +749,20 @@ template <class ELFT> void ObjFile<ELFT>::parse(bool ignoreComdats) {
749749
for (size_t i = 0; i != size; ++i) {
750750
const Elf_Shdr &sec = objSections[i];
751751

752-
// Collect GNU properties data.
753-
// GNU properties might be processed in this loop, or only later on (e.g. in
754-
// initializeSections) Therefore there is no guarantee that the GNU
755-
// properties data will be ready after this loop end, so it has to be
756-
// collected here.
752+
// Object files that use processor features such as Intel Control-Flow
753+
// Enforcement (CET) or AArch64 Branch Target Identification BTI, use a
754+
// .note.gnu.property section containing a bitfield of feature bits like the
755+
// GNU_PROPERTY_X86_FEATURE_1_IBT flag. Read a bitmap containing the flag.
757756
if (check(obj.getSectionName(sec, shstrtab)) == ".note.gnu.property") {
758-
if (0 == this->andFeatures && this->aarch64PauthAbiCoreInfo.empty()) {
759-
gnuPropertiesInformation = readGnuProperty(
760-
ctx,
761-
InputSection(*this, sec, check(obj.getSectionName(sec, shstrtab))),
762-
*this);
763-
// Restore state
764-
this->andFeatures = 0;
765-
this->aarch64PauthAbiCoreInfo = {};
766-
} else {
767-
gnuPropertiesInformation.andFeatures = this->andFeatures;
768-
gnuPropertiesInformation.aarch64PauthAbiCoreInfo =
769-
this->aarch64PauthAbiCoreInfo;
770-
}
757+
gnuPropertiesInformation = readGnuProperty(
758+
ctx,
759+
InputSection(*this, sec, check(obj.getSectionName(sec, shstrtab))),
760+
*this);
771761
hasGNUProperties = true;
762+
// Since we merge bitmaps from multiple object files to create a new
763+
// .note.gnu.property containing a single AND'ed bitmap, we discard an
764+
// input file's .note.gnu.property section.
765+
sections[i] = &InputSection::discarded;
772766
}
773767

774768
if (LLVM_LIKELY(sec.sh_type == SHT_PROGBITS))
@@ -1207,19 +1201,6 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(uint32_t idx,
12071201
return &InputSection::discarded;
12081202
}
12091203

1210-
// Object files that use processor features such as Intel Control-Flow
1211-
// Enforcement (CET) or AArch64 Branch Target Identification BTI, use a
1212-
// .note.gnu.property section containing a bitfield of feature bits like the
1213-
// GNU_PROPERTY_X86_FEATURE_1_IBT flag. Read a bitmap containing the flag.
1214-
//
1215-
// Since we merge bitmaps from multiple object files to create a new
1216-
// .note.gnu.property containing a single AND'ed bitmap, we discard an input
1217-
// file's .note.gnu.property section.
1218-
if (name == ".note.gnu.property") {
1219-
readGnuProperty<ELFT>(ctx, InputSection(*this, sec, name), *this);
1220-
return &InputSection::discarded;
1221-
}
1222-
12231204
// Split stacks is a feature to support a discontiguous stack,
12241205
// commonly used in the programming language Go. For the details,
12251206
// see https://gcc.gnu.org/wiki/SplitStacks. An object file compiled

0 commit comments

Comments
 (0)