https://sourceware.org/bugzilla/show_bug.cgi?id=18841
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
This usage is ill defined. Small changes change the run-time
behavior:
1. Use -O2 causes it to pass with ld:
[hjl@gnu-6 pr18841]$ make
gcc -B./ -O2 -g -c -o main.o main.c
gcc -B./ -O2 -g -fpic -c -o foo.o foo.c
gcc -B./ -shared -o libfoo.so foo.o
gcc -B./ -o main main.o libfoo.so -Wl,-R.
./main
[hjl@gnu-6 pr18841]$
2. Make pz file scope causes it to fail with gold and ld:
[hjl@gnu-6 pr18841-bad]$ cat foo.c
void foo() __attribute__((ifunc("resolve_foo")));
static void foo_impl() {}
extern void zoo(void);
void (*pz)(void) = zoo;
void test()
{
void (*pg)(void) = foo;
pg();
}
static void* resolve_foo()
{
pz();
return foo_impl;
}
[hjl@gnu-6 pr18841-bad]$ make
gcc -B./ -fuse-ld=gold -g -fpic -c -o foo.o foo.c
gcc -B./ -fuse-ld=gold -shared -o libfoo.so foo.o
gcc -B./ -fuse-ld=gold -o main main.o libfoo.so -Wl,-R.
./main
Makefile:17: recipe for target 'all' failed
make: *** [all] Segmentation fault
[hjl@gnu-6 pr18841-bad]$
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils