bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gold/23268] gold doesn't handle symbol versions like BFD ld when li


From: mh-sourceware at glandium dot org
Subject: [Bug gold/23268] gold doesn't handle symbol versions like BFD ld when linking executable with both -E and --version-script
Date: Thu, 07 Jun 2018 04:49:02 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=23268

--- Comment #1 from Mike Hommey <mh-sourceware at glandium dot org> ---
As for what kind of subtle problem this can cause:

$ cat foo.c
#include <stdlib.h>

void* malloc_hook(size_t s) {
    abort();
}
void* (*__malloc_hook)(size_t s) = malloc_hook;

int main() { malloc(1);}

$ cat ver
hidden {
    local: main;
};

$ gcc -o foo foo.c -rdynamic -Wl,--version-script,ver
# Aborted means we got in the hook.
$ ./foo
Aborted

$ gcc -o foo foo.c -rdynamic -Wl,--version-script,ver -fuse-ld=gold
$ ./foo

No output in this case, because the hook is not found by ld.so:
$ LD_DEBUG=bindings ./foo 2>&1 | grep malloc_hook
      1531:     binding file /lib/x86_64-linux-gnu/libc.so.6 [0] to
/lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `__malloc_hook'
[GLIBC_2.2.5]

The reason being that since __malloc_hook has a symbol version (that thanks to
bug 23267, neither objdump nor readelf show), ld.so doesn't pick it up because
the symbol version doesn't match GLIBC_2.2.5.

(Yes, the version script is a little contrived, for $reasons ; but this would
happen with a version script that exports other symbols with a symbol version
too)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]