Andrew Kelley via llvm-dev
2018-Apr-02 16:18 UTC
[llvm-dev] LLD-linked binary segfaults at runtime on alpine linux
Alpine linux is a distribution that uses musl libc instead glibc. Here are my steps to reproduce: On Alpine linux, download LLVM, Clang, LLD 6.0.0 from releases.llvm.org, and build them from source. $ clang -c hello_world.c $ ld.lld --gc-sections -m elf_x86_64 -o hello_world /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/Scrt1.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crti.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtbegin.o -L /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib -L /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0 -dynamic-linker /lib/../lib/ld-musl-x86_64.so.1 hello_world.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lm -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtend.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crtn.o $ ./hello_world Segmentation fault (core dumped) Now try with binutils: $ ld --gc-sections -m elf_x86_64 -o hello_world /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/Scrt1.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crti.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtbegin.o -L /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib -L /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0 -dynamic-linker /lib/../lib/ld-musl-x86_64.so.1 hello_world.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lm -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtend.o /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crtn.o $ ./hello_world Hello, World! Does the linker line look ok? Should I file a bug? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180402/d3666e25/attachment.html>
Rui Ueyama via llvm-dev
2018-Apr-02 17:26 UTC
[llvm-dev] LLD-linked binary segfaults at runtime on alpine linux
Can you add `--reproduce=repro` to lld command line? That generates repro.tar in your current directory which contains all input files. And then please compress and upload it somewhere so that we can take a look. On Mon, Apr 2, 2018 at 9:18 AM Andrew Kelley via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Alpine linux is a distribution that uses musl libc instead glibc. Here are > my steps to reproduce: > > On Alpine linux, download LLVM, Clang, LLD 6.0.0 from releases.llvm.org, > and build them from source. > > $ clang -c hello_world.c > $ ld.lld --gc-sections -m elf_x86_64 -o hello_world > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/Scrt1.o > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crti.o > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtbegin.o -L > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib -L > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0 -dynamic-linker > /lib/../lib/ld-musl-x86_64.so.1 hello_world.o -lgcc --as-needed -lgcc_s > --no-as-needed -lc -lm -lgcc --as-needed -lgcc_s --no-as-needed > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtend.o > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crtn.o > $ ./hello_world > Segmentation fault (core dumped) > > Now try with binutils: > $ ld --gc-sections -m elf_x86_64 -o hello_world > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/Scrt1.o > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crti.o > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtbegin.o -L > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib -L > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0 -dynamic-linker > /lib/../lib/ld-musl-x86_64.so.1 hello_world.o -lgcc --as-needed -lgcc_s > --no-as-needed -lc -lm -lgcc --as-needed -lgcc_s --no-as-needed > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtend.o > /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crtn.o > $ ./hello_world > Hello, World! > > > Does the linker line look ok? Should I file a bug? > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180402/61bae1fb/attachment.html>
Andrew Kelley via llvm-dev
2018-Apr-02 19:04 UTC
[llvm-dev] LLD-linked binary segfaults at runtime on alpine linux
https://superjoe.s3.amazonaws.com/temp/repro.tar.xz On Mon, Apr 2, 2018 at 1:26 PM, Rui Ueyama <ruiu at google.com> wrote:> Can you add `--reproduce=repro` to lld command line? That generates > repro.tar in your current directory which contains all input files. And > then please compress and upload it somewhere so that we can take a look. > > > On Mon, Apr 2, 2018 at 9:18 AM Andrew Kelley via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Alpine linux is a distribution that uses musl libc instead glibc. Here >> are my steps to reproduce: >> >> On Alpine linux, download LLVM, Clang, LLD 6.0.0 from releases.llvm.org, >> and build them from source. >> >> $ clang -c hello_world.c >> $ ld.lld --gc-sections -m elf_x86_64 -o hello_world >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/Scrt1.o >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crti.o >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtbegin.o -L >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib -L >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0 -dynamic-linker >> /lib/../lib/ld-musl-x86_64.so.1 hello_world.o -lgcc --as-needed -lgcc_s >> --no-as-needed -lc -lm -lgcc --as-needed -lgcc_s --no-as-needed >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtend.o >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crtn.o >> $ ./hello_world >> Segmentation fault (core dumped) >> >> Now try with binutils: >> $ ld --gc-sections -m elf_x86_64 -o hello_world >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/Scrt1.o >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crti.o >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtbegin.o -L >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib -L >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0 -dynamic-linker >> /lib/../lib/ld-musl-x86_64.so.1 hello_world.o -lgcc --as-needed -lgcc_s >> --no-as-needed -lc -lm -lgcc --as-needed -lgcc_s --no-as-needed >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/crtend.o >> /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../lib/crtn.o >> $ ./hello_world >> Hello, World! >> >> >> Does the linker line look ok? Should I file a bug? >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180402/e99bab99/attachment.html>
Reasonably Related Threads
- LLD-linked binary segfaults at runtime on alpine linux
- LLD-linked binary segfaults at runtime on alpine linux
- Trying to create a pure LLVM toolchain on musl based distribution
- Trying to create a pure LLVM toolchain on musl based distribution
- [LLVMdev] Customize Standard C Library Using LLVM (to support llvm backend optimization)