[lld] [ELF] Reject certain unknown section types (PR #85173)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 15 03:03:27 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:

That's an interesting question. It is a pity there isn't a `SHF_PROC_NONCONFORMING` flag that would make this easier to reason about.

I think allowing processor section types would be an easier way to introduce this patch as it wouldn't need all the processor specific looked over, which may be difficult to do. Perhaps start with it this way, then as we get more information we could perhaps limit to the section types that we know exist in the specifications.

I know at Arm we are reluctant to introduce new section types because of the problem of older, and other proprietary linkers, that may not want to suppport them. I expect many other processor namespace ABIs think similarly.


https://github.com/llvm/llvm-project/pull/85173


More information about the llvm-commits mailing list