https://sourceware.org/bugzilla/show_bug.cgi?id=23169
Bug ID: 23169 Summary: IFUNC pointer should be allowed in executable Product: binutils Version: 2.31 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: hjl.tools at gmail dot com Target Milestone: --- [hjl@gnu-cfl-1 ifunc-exec]$ cat main.c extern int (*func_p) (void); extern int func (void); extern void foo (void); void bar (void) { if (func_p != &func || func_p () != 0xbadbeef) __builtin_abort (); } int main () { func_p = &func; foo (); bar (); return 0; } [hjl@gnu-cfl-1 ifunc-exec]$ cat func.c static int ifunc (void) { return 0xbadbeef; } void func(void) __attribute__((ifunc("resolve_func"))); static void * resolve_func (void) { return ifunc; } [hjl@gnu-cfl-1 ifunc-exec]$ cat foo.c int (*func_p) (void); extern int func (void); void foo (void) { if (func_p != &func || func_p () != 0xbadbeef) __builtin_abort (); } [hjl@gnu-cfl-1 ifunc-exec]$ make gcc -g -c -o main.o main.c gcc -g -c -o func.o func.c gcc -g -fPIC -c -o foo.o foo.c gcc -shared -o libfoo.so foo.o gcc -o x main.o func.o libfoo.so -Wl,-R,. /usr/local/bin/ld: dynamic STT_GNU_IFUNC symbol `func' with pointer equality in `func.o' can not be used when making an executable; recompile with -fPIE and relink with -pie collect2: error: ld returned 1 exit status make: *** [Makefile:17: x] Error 1 [hjl@gnu-cfl-1 ifunc-exec]$ If STT_GNU_IFUNC symbol is defined in executable, backend should change it to the normal function and set its address to its PLT entry which should be resolved by R_*_IRELATIVE at run-time. All external references should be resolved to its PLT in executable. -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils