[PATCH] D55276: ELF: allow non allocated sections to go into allocated sections

Andrew Kelley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 4 08:41:32 PST 2018


andrewrk created this revision.
andrewrk added a reviewer: ruiu.
Herald added subscribers: llvm-commits, JDevlieghere, arichardson, aprantl, emaste.
Herald added a reviewer: espindola.

For context, see https://bugs.llvm.org/show_bug.cgi?id=39862

The use case is embedded / OS programming where the kernel wants
access to its own debug info via mapped dwarf info. I have a proof of
concept of this working, using this linker script snippet:

  .rodata : ALIGN(4K) {
      *(.rodata)
      __debug_info_start = .;
      KEEP(*(.debug_info))
      __debug_info_end = .;
      __debug_abbrev_start = .;
      KEEP(*(.debug_abbrev))
      __debug_abbrev_end = .;
      __debug_str_start = .;
      KEEP(*(.debug_str))
      __debug_str_end = .;
      __debug_line_start = .;
      KEEP(*(.debug_line))
      __debug_line_end = .;
      __debug_ranges_start = .;
      KEEP(*(.debug_ranges))
      __debug_ranges_end = .;
  }


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D55276

Files:
  ELF/OutputSections.cpp


Index: ELF/OutputSections.cpp
===================================================================
--- ELF/OutputSections.cpp
+++ ELF/OutputSections.cpp
@@ -95,7 +95,7 @@
     Flags = IS->Flags;
   } else {
     // Otherwise, check if new type or flags are compatible with existing ones.
-    unsigned Mask = SHF_ALLOC | SHF_TLS | SHF_LINK_ORDER;
+    unsigned Mask = SHF_TLS | SHF_LINK_ORDER;
     if ((Flags & Mask) != (IS->Flags & Mask))
       error("incompatible section flags for " + Name + "\n>>> " + toString(IS) +
             ": 0x" + utohexstr(IS->Flags) + "\n>>> output section " + Name +


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55276.176647.patch
Type: text/x-patch
Size: 600 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181204/0bfc0bf7/attachment.bin>


More information about the llvm-commits mailing list