[llvm-bugs] [Bug 37609] New: ld.lld crash while linking baremetal ARM .o files

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 28 03:18:49 PDT 2018


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

            Bug ID: 37609
           Summary: ld.lld crash while linking baremetal ARM .o files
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: eblot.ml at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20347
  --> https://bugs.llvm.org/attachment.cgi?id=20347&action=edit
Sample archive to reproduce the crash

Hi,

Using LLD 6.0.0 (host: macOS, target: armv7em bare metal), LLD crashed (while
trying to reproduce a sample example for bug
https://bugs.llvm.org/show_bug.cgi?id=37608).

I'm not sure the .o file are valid (although they seem), but I guess LLD is not
expected to crash even in such an event.

$ ./build.sh
LLD 6.0.0 (compatible with GNU linkers)
0  ld.lld                   0x0000000101dcf83c
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1  ld.lld                   0x0000000101dcfe29
PrintStackTraceSignalHandler(void*) + 25
2  ld.lld                   0x0000000101dcb459 llvm::sys::RunSignalHandlers() +
425
3  ld.lld                   0x0000000101dd03f2 SignalHandler(int) + 354
4  libsystem_platform.dylib 0x00007fff605e8f5a _sigtramp + 26
5  ld.lld                   0x00000001022b5345
lld::elf::SyntheticSection::classof(lld::elf::SectionBase const*) + 21
6  ld.lld                   0x00000001020be645 void
lld::elf::OutputSection::finalize<llvm::object::ELFType<(llvm::support::endianness)1,
false> >() + 677
7  ld.lld                   0x00000001022b8fbc (anonymous
namespace)::Writer<llvm::object::ELFType<(llvm::support::endianness)1, false>
>::finalizeSections() + 7660
8  ld.lld                   0x00000001022b32d1 (anonymous
namespace)::Writer<llvm::object::ELFType<(llvm::support::endianness)1, false>
>::run() + 177
9  ld.lld                   0x00000001022b31ea void
lld::elf::writeResult<llvm::object::ELFType<(llvm::support::endianness)1,
false> >() + 26
10 ld.lld                   0x0000000101f4f115 void
lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1,
false> >(llvm::opt::InputArgList&) + 9189
11 ld.lld                   0x0000000101f3fd9d
lld::elf::LinkerDriver::main(llvm::ArrayRef<char const*>, bool) + 3885
12 ld.lld                   0x0000000101f3ea93
lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&) + 4483
13 ld.lld                   0x0000000101c84fdb main + 411
14 libdyld.dylib            0x00007fff602da015 start + 1
15 libdyld.dylib            0x000000000000000c start + 2681364472
Stack dump:
0.      Program arguments: ld.lld -v --warn-common --gc-sections
--no-whole-archive crt0.o main.c.o -Bstatic -T target.ld -o ldtest.elf
./build.sh: line 3: 20137 Segmentation fault: 11  ld.lld -v --warn-common
--gc-sections --no-whole-archive crt0.o main.c.o -Bstatic -T target.ld -o
ldtest.elf



 lldb -- /usr/local/opt/arm-none-eabi-llvm/bin/ld.lld -v main.c.o --warn-common
--gc-sections --no-whole-archive crt0.o -Bstatic -T target.ld -o ldtest.elf
(lldb) target create "/usr/local/opt/arm-none-eabi-llvm/bin/ld.lld"
Current executable set to '/usr/local/opt/arm-none-eabi-llvm/bin/ld.lld'
(x86_64).
(lldb) settings set -- target.run-args  "-v" "main.c.o" "--warn-common"
"--gc-sections" "--no-whole-archive" "crt0.o" "-Bstatic" "-T" "target.ld" "-o"
"ldtest.elf"
(lldb) run
Process 20169 launched: '/usr/local/opt/arm-none-eabi-llvm/bin/ld.lld' (x86_64)
LLD 6.0.0 (compatible with GNU linkers)
Process 20169 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x20)
    frame #0: 0x00000001003c4c63
ld.lld`lld::elf::InputSectionBase::getLinkOrderDep() const + 19
ld.lld`lld::elf::InputSectionBase::getLinkOrderDep:
->  0x1003c4c63 <+19>: movq   0x20(%rdi), %rax
    0x1003c4c67 <+23>: andq   $0x80, %rax
    0x1003c4c6d <+29>: cmpq   $0x0, %rax
    0x1003c4c71 <+33>: movq   %rdi, -0xe8(%rbp)
Target 0: (ld.lld) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x20)
  * frame #0: 0x00000001003c4c63
ld.lld`lld::elf::InputSectionBase::getLinkOrderDep() const + 19
    frame #1: 0x000000010043b645 ld.lld`void
lld::elf::OutputSection::finalize<llvm::object::ELFType<(llvm::support::endianness)1,
false> >() + 677
    frame #2: 0x0000000100635fbc ld.lld`(anonymous
namespace)::Writer<llvm::object::ELFType<(llvm::support::endianness)1, false>
>::finalizeSections() + 7660
    frame #3: 0x00000001006302d1 ld.lld`(anonymous
namespace)::Writer<llvm::object::ELFType<(llvm::support::endianness)1, false>
>::run() + 177
    frame #4: 0x00000001006301ea ld.lld`void
lld::elf::writeResult<llvm::object::ELFType<(llvm::support::endianness)1,
false> >() + 26
    frame #5: 0x00000001002cc115 ld.lld`void
lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1,
false> >(llvm::opt::InputArgList&) + 9189
    frame #6: 0x00000001002bcd9d
ld.lld`lld::elf::LinkerDriver::main(llvm::ArrayRef<char const*>, bool) + 3885
    frame #7: 0x00000001002bba93 ld.lld`lld::elf::link(llvm::ArrayRef<char
const*>, bool, llvm::raw_ostream&) + 4483
    frame #8: 0x0000000100001fdb ld.lld`main + 411
    frame #9: 0x00007fff602da015 libdyld.dylib`start + 1
    frame #10: 0x00007fff602da015 libdyld.dylib`start + 1
(lldb)

I'm attaching a tiny tarball that reproduces the problem with two lightweight
object files.

-- 
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/20180528/3afdb8a9/attachment-0001.html>


More information about the llvm-bugs mailing list