<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 - foo@v1 and foo@@v1 aren't handled properly"
href="https://bugs.llvm.org/show_bug.cgi?id=48361">48361</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>foo@v1 and foo@@v1 aren't handled properly
</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>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</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>hjl.tools@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>i@maskray.me, llvm-bugs@lists.llvm.org, smithp352@googlemail.com
</td>
</tr></table>
<p>
<div>
<pre>[hjl@gnu-cfl-2 pr26978]$ cat main.c
extern void foo (void);
int
main ()
{
foo ();
return 0;
}
[hjl@gnu-cfl-2 pr26978]$ cat ver
v1 {};
[hjl@gnu-cfl-2 pr26978]$ cat def1w.s
.text
.weak foo
.symver foo, foo@@@v1
.type foo, %object
foo:
hlt
[hjl@gnu-cfl-2 pr26978]$ cat hid1.s
.text
.globl foo_v1
.symver foo_v1, foo@v1
.type foo_v1, %object
foo_v1:
ret
[hjl@gnu-cfl-2 pr26978]$
ld correctly rejects:
[hjl@gnu-cfl-2 pr26978]$ make
cc -c -o main.o main.c
as -o def1w.o def1w.s
as -o hid1.o hid1.s
ld -shared -o libfoo.so --version-script=ver def1w.o hid1.o
ld: hid1.o:(.text+0x0): multiple definition of `foo@v1'
ld: hid1.o:(*IND*+0x0): multiple definition of `foo'
make: *** [Makefile:10: libfoo.so] Error 1
[hjl@gnu-cfl-2 pr26978]$
lld generates a bogus libfoo.so:
[hjl@gnu-cfl-2 pr26978]$ make LD=ld.lld
ld.lld -shared -o libfoo.so --version-script=ver def1w.o hid1.o
cc -o x main.o libfoo.so -Wl,-R,.
/usr/local/bin/ld: libfoo.so:(.text+0x1): multiple definition of `foo@v1'
/usr/local/bin/ld: libfoo.so:(*IND*+0x0): multiple definition of `foo'
collect2: error: ld returned 1 exit status
make: *** [Makefile:7: x] Error 1
[hjl@gnu-cfl-2 pr26978]$
[hjl@gnu-cfl-2 pr26978]$ readelf --dyn-syms libfoo.so
Symbol table '.dynsym' contains 4 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 000000000000130d 0 OBJECT WEAK DEFAULT 7 foo@@v1
2: 000000000000130e 0 OBJECT GLOBAL DEFAULT 7 foo_v1
3: 000000000000130e 0 OBJECT GLOBAL DEFAULT 7 foo@v1
[hjl@gnu-cfl-2 pr26978]$
foo@@v1 and foo@v1 define the same symbol. lld doesn't check the bogus
libfoo.so and let the weak definition to override the non-weak one:
[hjl@gnu-cfl-2 pr26978]$ cc -o x main.o libfoo.so -Wl,-R,. -fuse-ld=lld
[hjl@gnu-cfl-2 pr26978]$ ./x
Segmentation fault (core dumped)
[hjl@gnu-cfl-2 pr26978]$</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>