[lld] 1417558 - [ELF] Improve the condition to create .interp

Fāng-ruì Sòng via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 27 14:42:18 PST 2019


The binary will be useful.

On Fri, Dec 27, 2019 at 2:38 PM Reid Kleckner <rnk at google.com> wrote:

> The command is just the Sanitizer-x86_64-Test-Nolibc binary with no args.
> You can see it failed here:
> https://ci.chromium.org/p/chromium/builders/try/linux_upload_clang/740
>  The binary would crash on startup in the loader.
>
> Eric says he was able to reproduce it as well. I can send you the binary
> offline if it's useful to inspect it.
>
> On Fri, Dec 27, 2019 at 1:34 PM Fangrui Song <maskray at google.com> wrote:
>
>> Do you have a reproduce command line?
>>
>> I am at commit c3dbd782f1e0578c7ebc342f2e92f54d9644cff7 (your revert).
>> With it rolled forward locally, check-sanitizer works here.
>> (-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=on)
>>
>> Running
>> projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-x86_64-Test-Nolibc
>> directly is also fine.
>>
>> On 2019-12-27, Reid Kleckner wrote:
>> >I ended up reverting this because it causes some check-sanitizer nolibc
>> test to
>> >fail, hopefully it reproduces for you locally, let me know if it
>> doesn't. The
>> >"nolibc" version crashes on startup.
>> >
>> >On Thu, Dec 26, 2019 at 1:28 PM Fangrui Song via llvm-commits <
>> >llvm-commits at lists.llvm.org> wrote:
>> >
>> >    Author: Fangrui Song
>> >    Date: 2019-12-26T13:26:43-08:00
>> >    New Revision: 1417558e4a61794347c6bfbafaff7cd96985b2c3
>> >
>> >    URL: https://github.com/llvm/llvm-project/commit/
>> >    1417558e4a61794347c6bfbafaff7cd96985b2c3
>> >    DIFF: https://github.com/llvm/llvm-project/commit/
>> >    1417558e4a61794347c6bfbafaff7cd96985b2c3.diff
>> >
>> >    LOG: [ELF] Improve the condition to create .interp
>> >
>> >    Similar to rL362355, but with the `!config->shared` guard.
>> >
>> >    (1) {gcc,clang} -fuse-ld=bfd -pie -fPIE -nostdlib a.c => .interp
>> created
>> >    (2) {gcc,clang} -fuse-ld=lld -pie -fPIE -nostdlib a.c => .interp not
>> >    created
>> >    (3) {gcc,clang} -fuse-ld=lld -pie -fPIE -nostdlib a.c a.so => .interp
>> >    created
>> >
>> >    The inconsistency of (2) is due to the condition `!Config->
>> >    SharedFiles.empty()`.
>> >    To make lld behave more like ld.bfd, we could change the condition
>> to:
>> >
>> >        config->hasDynSymTab && !config->dynamicLinker.empty() &&
>> script->
>> >    needsInterpSection();
>> >
>> >    However, that would bring another inconsistency as can be observed
>> with:
>> >
>> >    (4) {gcc,clang} -fuse-ld=bfd -no-pie -nostdlib a.c => .interp not
>> created
>> >
>> >    Added:
>> >
>> >    Modified:
>> >        lld/ELF/Writer.cpp
>> >        lld/test/ELF/dynamic-linker.s
>> >        lld/test/ELF/ppc64-func-entry-points.s
>> >
>> >    Removed:
>> >
>> >
>> ###########################################################################
>> >    #####
>> >    diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
>> >    index c0ad33473747..c20b74821d9c 100644
>> >    --- a/lld/ELF/Writer.cpp
>> >    +++ b/lld/ELF/Writer.cpp
>> >    @@ -135,7 +135,7 @@ StringRef getOutputSectionName(const
>> InputSectionBase
>> >    *s) {
>> >     }
>> >
>> >     static bool needsInterpSection() {
>> >    -  return !sharedFiles.empty() && !config->dynamicLinker.empty() &&
>> >    +  return !config->shared && !config->dynamicLinker.empty() &&
>> >              script->needsInterpSection();
>> >     }
>> >
>> >    diff  --git a/lld/test/ELF/dynamic-linker.s
>> b/lld/test/ELF/dynamic-linker.s
>> >    index d0da77fab295..b5e9f5f55e98 100644
>> >    --- a/lld/test/ELF/dynamic-linker.s
>> >    +++ b/lld/test/ELF/dynamic-linker.s
>> >    @@ -1,6 +1,4 @@
>> >     # REQUIRES: x86
>> >    -# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux
>> %p/Inputs/shared.s -o
>> >    %t1.o
>> >    -# RUN: ld.lld -shared %t1.o -o %t.so
>> >     # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
>> >
>> >     # RUN: ld.lld --dynamic-linker foo %t.o %t.so -o %t
>> >    @@ -11,11 +9,11 @@
>> >
>> >     # CHECK: [Requesting program interpreter: foo]
>> >
>> >    -# RUN: ld.lld %t.o %t.so -o %t
>> >    +# RUN: ld.lld %t.o -o %t
>> >     # RUN: llvm-readelf -program-headers %t | FileCheck
>> --check-prefix=NO %s
>> >
>> >    -# RUN: ld.lld --dynamic-linker foo --no-dynamic-linker %t.o %t.so
>> -o %t
>> >    -# RUN: llvm-readelf -program-headers %t | FileCheck
>> --check-prefix=NO %s
>> >    +# RUN: ld.lld --dynamic-linker foo --no-dynamic-linker %t.o -o %t
>> >    +# RUN: llvm-readelf --program-headers %t | FileCheck
>> --check-prefix=NO %s
>> >
>> >     # NO-NOT: PT_INTERP
>> >
>> >    diff  --git a/lld/test/ELF/ppc64-func-entry-points.s b/lld/test/ELF/
>> >    ppc64-func-entry-points.s
>> >    index 1411cbe1c058..c322f6563426 100644
>> >    --- a/lld/test/ELF/ppc64-func-entry-points.s
>> >    +++ b/lld/test/ELF/ppc64-func-entry-points.s
>> >    @@ -3,13 +3,13 @@
>> >     // RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s
>> -o %t.o
>> >     // RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux
>> %p/Inputs/
>> >    ppc64-func-global-entry.s -o %t2.o
>> >     // RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux
>> %p/Inputs/
>> >    ppc64-func-local-entry.s -o %t3.o
>> >    -// RUN: ld.lld -dynamic-linker /lib64/ld64.so.2 %t.o %t2.o %t3.o -o
>> %t
>> >    +// RUN: ld.lld %t.o %t2.o %t3.o -o %t
>> >     // RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
>> >
>> >     // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o
>> %t.o
>> >     // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux
>> %p/Inputs/
>> >    ppc64-func-global-entry.s -o %t2.o
>> >     // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux
>> %p/Inputs/
>> >    ppc64-func-local-entry.s -o %t3.o
>> >    -// RUN: ld.lld -dynamic-linker /lib64/ld64.so.2 %t.o %t2.o %t3.o -o
>> %t
>> >    +// RUN: ld.lld %t.o %t2.o %t3.o -o %t
>> >     // RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
>> >
>> >            .text
>> >
>> >    _______________________________________________
>> >    llvm-commits mailing list
>> >    llvm-commits at lists.llvm.org
>> >    https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>> >
>>
>

-- 
宋方睿
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191227/d0e92684/attachment-0001.html>


More information about the llvm-commits mailing list