Issue |
157987
|
Summary |
LLD will silently ignore undefined references to a versioned symbol if there is an unversioned equivalent
|
Labels |
lld
|
Assignees |
|
Reporter |
Kartatz
|
## Steps to reproduce
### Step 1
Create a versioned `libfoo`:
```bash
echo 'void foo(void) {}' > foo.c
cat << code > 'libfoo.ver'
VERSION_1.0 {
global:
foo;
local:
*;
};
code
gcc foo.c -shared -o libfoo.so -Wl,--version-script=libfoo.ver
```
### Step 2
Create a library that depends on `libfoo` (`libbar`):
```
cat << code > bar.c
void foo(void);
void bar(void) { foo(); }
code
gcc bar.c -shared -o libbar.so -lfoo -L.
```
### Step 3
Finally, create an executable that depends on `libbar`:
```bash
cat << code > main.c
void bar(void);
int main(void) { bar(); }
code
```
### Step 4
Confirm that linking with both BFD and LLD works:
```bash
$ gcc main.c -o main -lbar -L. -fuse-ld=bfd
<succeeds>
$ gcc main.c -o main -lbar -L. -fuse-ld=lld
<succeeds>
```
### Step 5
Now recompile `libfoo`, this time without symbol versioning:
```bash
$ gcc foo.c -shared -o libfoo.so
```
Linking with BFD now reports an undefined symbol (expected behavior):
```bash
$ gcc main.c -o main -lbar -L. -fuse-ld=bfd
ld: ./libbar.so: undefined reference to `foo@VERSION_1.0'
collect2: error: ld returned 1 exit status
```
LLD, however, links without reporting any errors (unexpected behavior):
```bash
$ gcc main.c -o main -lbar -L. -fuse-ld=lld
<succeeds>
```
## LLD version
```
$ ld.lld --version
LLD 21.1.0 (compatible with GNU linkers)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs