<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 - LLD-linked binary segfaults at runtime on alpine linux"
href="https://bugs.llvm.org/show_bug.cgi?id=36991">36991</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLD-linked binary segfaults at runtime on alpine linux
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>superjoe30@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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!
I also have a repro.tar.xz: <a href="https://superjoe.s3.amazonaws.com/temp/repro.tar.xz">https://superjoe.s3.amazonaws.com/temp/repro.tar.xz</a></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>