[llvm-bugs] [Bug 47455] New: lld sets interpreter even with -static

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 7 18:02:04 PDT 2020


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

            Bug ID: 47455
           Summary: lld sets interpreter even with -static
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: mforney at mforney.org
                CC: llvm-bugs at lists.llvm.org, smithp352 at googlemail.com

I noticed that as of lld 10.0, if --dynamic-linker is specified on the
command-line, a PT_INTERP header gets added even if -static is used.

GNU ld does not add the interpreter header in this case. For example

$ ld.lld --version
LLD 10.0.1 (https://github.com/NetBSD/pkgsrc.git
375d1b4fafaee2e9c6003be296b6e92aae92e268) (compatible with GNU linkers)
$ ld.lld --dynamic-linker /lib/ld-musl-x86_64.so.1 -static -o t /lib/crt1.o
/lib/crti.o t.o /lib/libc.a /lib/crtn.o
$ readelf -l t | grep interpreter
      [Requesting program interpreter: /lib/ld-musl-x86_64.so.1]
$

$ ld --version | head -n 1
GNU ld (GNU Binutils) 2.35
$ ld --dynamic-linker /lib/ld-musl-x86_64.so.1 -static -o t /lib/crt1.o
/lib/crti.o t.o /lib/libc.a /lib/crtn.o
$ readelf -l t | grep interpreter
$

I believe this is caused by
https://github.com/llvm/llvm-project/commit/dce7a362bed866ceefc3c65924250233695d6fd4.
The commit message of the referenced first attempt
https://github.com/llvm/llvm-project/commit/1417558e4a61794347c6bfbafaff7cd96985b2c3
mentions improving compatibility with GNU ld, so this looks like an unintended
regression.

Perhaps this could be fixed by adding `&& !config->isStatic` to the condition
in ELF/Writer.cpp:needsInterpSection?

This issue was reported by a user of my hobby C compiler (cproc), which always
passes --dynamic-linker to ld, expecting it to add the PT_INTERP header only
when it is appropriate.

-- 
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/20200908/6de2548a/attachment.html>


More information about the llvm-bugs mailing list