diff options
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
| -rw-r--r-- | lld/ELF/InputFiles.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 12a77736aba7..44e77bf57183 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -968,7 +968,7 @@ static void parseGnuPropertyNote(Ctx &ctx, ELFFileBase &f, } // Read the following info from the .note.gnu.property section and write it to // the corresponding fields in `ObjFile`: -// - Feature flags (32 bits) representing x86 or AArch64 features for +// - Feature flags (32 bits) representing x86, AArch64 or RISC-V features for // hardware-assisted call flow control; // - AArch64 PAuth ABI core info (16 bytes). template <class ELFT> @@ -977,6 +977,22 @@ static void readGnuProperty(Ctx &ctx, const InputSection &sec, using Elf_Nhdr = typename ELFT::Nhdr; using Elf_Note = typename ELFT::Note; + uint32_t featureAndType; + switch (ctx.arg.emachine) { + case EM_386: + case EM_X86_64: + featureAndType = GNU_PROPERTY_X86_FEATURE_1_AND; + break; + case EM_AARCH64: + featureAndType = GNU_PROPERTY_AARCH64_FEATURE_1_AND; + break; + case EM_RISCV: + featureAndType = GNU_PROPERTY_RISCV_FEATURE_1_AND; + break; + default: + return; + } + ArrayRef<uint8_t> data = sec.content(); auto err = [&](const uint8_t *place) -> ELFSyncStream { auto diag = Err(ctx); @@ -997,10 +1013,6 @@ static void readGnuProperty(Ctx &ctx, const InputSection &sec, continue; } - uint32_t featureAndType = ctx.arg.emachine == EM_AARCH64 - ? GNU_PROPERTY_AARCH64_FEATURE_1_AND - : GNU_PROPERTY_X86_FEATURE_1_AND; - // Read a body of a NOTE record, which consists of type-length-value fields. ArrayRef<uint8_t> desc = note.getDesc(sec.addralign); const uint8_t *base = sec.content().data(); @@ -1064,9 +1076,9 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(uint32_t idx, } // Object files that use processor features such as Intel Control-Flow - // Enforcement (CET) or AArch64 Branch Target Identification BTI, use a - // .note.gnu.property section containing a bitfield of feature bits like the - // GNU_PROPERTY_X86_FEATURE_1_IBT flag. Read a bitmap containing the flag. + // Enforcement (CET), AArch64 Branch Target Identification BTI or RISC-V + // Zicfilp/Zicfiss extensions, use a .note.gnu.property section containing + // a bitfield of feature bits like the GNU_PROPERTY_X86_FEATURE_1_IBT flag. // // Since we merge bitmaps from multiple object files to create a new // .note.gnu.property containing a single AND'ed bitmap, we discard an input |
