[lld] [ELF] Reject certain unknown section types (PR #85173)
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 14 09:25:02 PDT 2024
================
@@ -741,6 +741,31 @@ template <class ELFT> void ObjFile<ELFT>::initializeJustSymbols() {
sections.resize(numELFShdrs);
}
+static bool isKnownSpecificSectionType(uint32_t t, uint32_t flags) {
+ if (SHT_LOUSER <= t && t <= SHT_HIUSER && !(flags & SHF_ALLOC))
+ return true;
+ if (SHT_LOOS <= t && t <= SHT_HIOS && !(flags & SHF_OS_NONCONFORMING))
+ return true;
+ switch (config->emachine) {
+ case EM_ARM:
+ return t == SHT_ARM_EXIDX || t == SHT_ARM_ATTRIBUTES;
+ case EM_AARCH64:
+ return t == SHT_AARCH64_MEMTAG_GLOBALS_STATIC;
----------------
smithp35 wrote:
GNU ld will accept SHT_AARCH64_ATTRIBUTES in AArch64 too. This is reserved for the spec and can be ignored if a linker does not understand the contents. It would be useful to add this so that when SHT_AARCH64_ATTRIBUTES is added lld doesn't choke on them.
This may be the case for other LOPROC/HIPROC values that lld doesn't currently understand, but I'm only familiar with Arm and AArch64.
Of the ones in AArch64 there is also `SHT_AARCH64_AUTH_RELR` defined in https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#7section-types
I know there is a pull-request to add LLD support for that. May be worth adding as a constant until the symbolic value is known.
The other section types in https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst not implemented by LLD don't need to be added as these are linker generated sections for the benefit of debuggers/post-link tools.
https://github.com/llvm/llvm-project/pull/85173
More information about the llvm-commits
mailing list