issue with references to weak symbols in PIEs
Mike Frysinger
vapier@gentoo.org
Thu Jan 26 01:47:00 GMT 2006
before people dismiss this as a Gentoo-specific issue, the code fails with
Redhat and Debian toolchains as well. tested gcc 3.4.5, 4.0.3, and a snap of
4.1.x dated 20060120.
we were playing with arrays of pointers to weak functions in a utility program
when we noticed the code started crashing whenever built with a Gentoo
hardened toolchain. Gentoo vanilla toolchains would produce code that ran
nicely and as expected. tracing it back, the references to the undefined
weak functions were not being set to NULL as they should have been. then we
reproduced the issue with a Gentoo vanilla toolchain by simply building the
test code as a PIE. i'm not sure if this is an issue in gcc or glibc ldso or
a bug at all (i'm pretty sure it's a bug), so i'm starting with gcc :)
ive attached the test code we are playing with ... here's some example runs on
my Gentoo amd64 box:
$ gcc-4.1.0-beta20060120 -pie -fPIE weak-test.c -DOK1 && ./a.out
this should be null: (nil)
$ gcc-4.1.0-beta20060120 -pie -fPIE weak-test.c -DOK2 && ./a.out
this should be null: (nil)
this should be null: (nil)
$ gcc-4.1.0-beta20060120 -pie -fPIE weak-test.c -DBROKEN && ./a.out
this should be null: 0xe23bc395000
$ gcc-4.1.0-beta20060120 weak-test.c -DBROKEN && ./a.out
this should be null: (nil)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: weak-test.c
Type: text/x-csrc
Size: 397 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20060126/f7204356/attachment.bin>
More information about the Gcc
mailing list