This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi,
We have a problem where we use --warn-unresolved-symbols to tide
over an issue where we know the symbol is undefined but we also know
that the it is never accessed.
Example:
extern int foo();
int (*p)() = NULL;
int main() {
if (p == &foo)
foo();
return 0;
}
Now,
$ g++ -O2 foo.cc
foo.cc:function main: warning: undefined reference to 'foo()'
gives the right warning but builds a.out just fine and runs fine as
long as p is not equal to foo which is our case.
However, with -fPIE
$ g++ -O2 -fPIE foo.cc -pie
foo.cc:function main: warning: undefined reference to 'foo()'
but
$./a.out
./a.out: symbol lookup error: ./a.out: undefined symbol: _Z3foov
because with fPIE, a function pointer access is using a GOTPCREL
relocation which creates a GOT entry and a dynamic relocation for it.
The dynamic linker does not like the unresolved symbol any more.
I have attached a patch to prevent creation of GOT and dynamic
relocation entries with --warn-unresolved-symbols in general. Is this
reasonable?
Thanks
Sri
Attachment:
warn_unresolved.txt
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |