[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gold/24462] New: Gold linker does not handle symbol versioning prop
From: |
olim at ucla dot edu |
Subject: |
[Bug gold/24462] New: Gold linker does not handle symbol versioning properly |
Date: |
Wed, 17 Apr 2019 21:24:44 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=24462
Bug ID: 24462
Summary: Gold linker does not handle symbol versioning properly
Product: binutils
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gold
Assignee: ccoutant at gmail dot com
Reporter: olim at ucla dot edu
CC: ian at airs dot com
Target Milestone: ---
The gold linker does not appear to grab the correct symbol version when when
using the --wrap option and multiple versions of the same symbol are available.
For example, using `--wrap=memcpy` with the following code produces an infinite
recursion.
```
#include <string.h>
asm (".symver old_memcpy, address@hidden"); // hook old_memcpy as
address@hidden
void *old_memcpy(void *, const void *, size_t );
void *__wrap_memcpy(void *dest, const void *src, size_t n) // then export
memcpy
{
return old_memcpy(dest, src, n);
}
int main()
{
int v1 = 1;
int v2 = 0;
__wrap_memcpy(v1, v2, sizeof(v1));
return 0;
}
```
$ gcc -fuse-ld=gold -Wl,--wrap=memcpy main.c
$ readelf -a a.out | grep memcpy
5: 0000000000400660 2 FUNC GLOBAL DEFAULT 11 __wrap_memcpy
23: 0000000000400660 2 FUNC GLOBAL DEFAULT 11 __wrap_memcpy
Using the BFD linker everything behaves as expected:
$ gcc -fuse-ld=bfd -Wl,--wrap=memcpy main.c
$ readelf -a a.out | grep memcpy
000000600fe0 000100000007 R_X86_64_JUMP_SLO 0000000000000000
address@hidden + 0
1: 0000000000000000 0 FUNC GLOBAL DEFAULT UND address@hidden
(2)
51: 0000000000000000 0 FUNC GLOBAL DEFAULT UND address@hidden
53: 0000000000400710 5 FUNC GLOBAL DEFAULT 13 __wrap_memcpy
Using the gold linker again, but replacing
asm (".symver old_memcpy, address@hidden");
with
asm (".symver old_memcpy, address@hidden");
avoid the infinite recursion, but links against the wrong version
$ readelf -a a.out | grep memcpy
000000401ff0 000200000007 R_X86_64_JUMP_SLO 0000000000000000 address@hidden
+ 0
2: 0000000000000000 0 FUNC GLOBAL DEFAULT UND address@hidden
(3)
7: 0000000000400790 5 FUNC GLOBAL DEFAULT 13 __wrap_memcpy
23: 0000000000000000 0 FUNC GLOBAL DEFAULT UND memcpy
25: 0000000000400790 5 FUNC GLOBAL DEFAULT 13 __wrap_memcpy
Which is linking to the memcpy in GLIBC_2.14 instead of the memcpy in
GLIBC_2.2.5. Is there a different symbol versioning syntax needed when using
the gold linker?
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug gold/24462] New: Gold linker does not handle symbol versioning properly,
olim at ucla dot edu <=