<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - ld.lld crash while linking baremetal ARM .o files"
href="https://bugs.llvm.org/show_bug.cgi?id=37609">37609</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ld.lld crash while linking baremetal ARM .o files
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>ELF
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>eblot.ml@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=20347" name="attach_20347" title="Sample archive to reproduce the crash">attachment 20347</a> <a href="attachment.cgi?id=20347&action=edit" title="Sample archive to reproduce the crash">[details]</a></span>
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
<a class="bz_bug_link
bz_status_NEW "
title="NEW - LLD does not update section start address"
href="show_bug.cgi?id=37608">https://bugs.llvm.org/show_bug.cgi?id=37608</a>).
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>
<span class="quote">>::finalizeSections() + 7660</span >
8 ld.lld 0x00000001022b32d1 (anonymous
namespace)::Writer<llvm::object::ELFType<(llvm::support::endianness)1, false>
<span class="quote">>::run() + 177</span >
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>
<span class="quote">>::finalizeSections() + 7660</span >
frame #3: 0x00000001006302d1 ld.lld`(anonymous
namespace)::Writer<llvm::object::ELFType<(llvm::support::endianness)1, false>
<span class="quote">>::run() + 177</span >
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>