[Bug target/83110] New: Relocation error when taking address of protected function in shared library.
yyc1992 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Nov 22 16:40:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83110
Bug ID: 83110
Summary: Relocation error when taking address of protected
function in shared library.
Product: gcc
Version: 7.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: yyc1992 at gmail dot com
Target Milestone: ---
This is very similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248
although that one is marked as fixed.
(This could be a dup of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19520 but
I can't really tell...)
The difference from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248 is that
this now only happens for me with protected functions and not global variables.
The code to reproduce is
```
__attribute__((visibility("protected")))
void f()
{
}
// __attribute__((visibility("protected")))
// int f;
void f2(void (*cb)(void*))
{
cb((void*)&f);
}
```
Which gives the error
```
% LANG=C g++ a.cpp -o liba.so -pthread -fPIC -shared
/bin/ld: /tmp/ccvUACGZ.o: relocation R_X86_64_PC32 against protected symbol
`_Z1fv' can not be used when making a shared object
/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
```
More information about the Gcc-bugs
mailing list