[llvm-bugs] [Bug 42933] New: LLD refuses to link discarded ELF PHDRs

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 8 07:28:46 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42933

            Bug ID: 42933
           Summary: LLD refuses to link discarded ELF PHDRs
           Product: lld
           Version: unspecified
          Hardware: All
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: ftee at flametop.co.uk
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org

Created attachment 22359
  --> https://bugs.llvm.org/attachment.cgi?id=22359&action=edit
Example linker script

The change:

  https://reviews.llvm.org/rL311586

  Petr Hosek, 2 years ago   (August 23rd, 2017 7:44pm)

  [ELF] Don't output headers into a segment if there's no space for them

Implemented the routine 'LinkerScript::allocateHeaders' and in its
documentation details a technique used to discard headers;

// When using the default layout, we check if the headers fit below the first
// allocated section. When using a linker script, we also check if the headers
// are covered by the output section. This allows omitting the headers by not
// leaving enough space for them in the linker script; this pattern is common
// in embedded systems.

We have an system that uses just such a technique via the attached linker 
script.

Change:

 https://reviews.llvm.org/rL326441

 Rafael Espindola, a year ago   (March 1st, 2018 3:25pm)

 Don't allocate a header bellow address 0.

Appears to have intended to catch an underflow which could allocate the PHDRs
at a negative address. However, this change also catches the case of the 
PHDRs being discarded from address zero as detailed in the technique above.

Attempting to link the attached simple test program with the attached 'user.ld'
linker script results in the error:

  ld -nostdlib -T user.ld test.o
  ld: error: could not allocate headers

Neither GNU LD or GOLD generate any error in this case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190808/08e9d55e/attachment.html>


More information about the llvm-bugs mailing list