[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/23169] New: IFUNC pointer should be allowed in executable
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug ld/23169] New: IFUNC pointer should be allowed in executable |
Date: |
Fri, 11 May 2018 16:12:47 +0000 |
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: ---
address@hidden 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;
}
address@hidden 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;
}
address@hidden 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 ();
}
address@hidden 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
address@hidden 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 ld/23169] New: IFUNC pointer should be allowed in executable,
hjl.tools at gmail dot com <=