Bug 83110 - Relocation error when taking address of protected function in shared library.
Summary: Relocation error when taking address of protected function in shared library.
Status: RESOLVED DUPLICATE of bug 19520
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2017-11-22 16:40 UTC by Yichao Yu
Modified: 2017-11-23 18:19 UTC (History)
1 user (show)

See Also:
Target: x86_64-*-*, i?86-*-*
Known to work:
Known to fail: 3.4.6
Last reconfirmed: 2017-11-23 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Yichao Yu 2017-11-22 16:40:51 UTC
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

void f()

// __attribute__((visibility("protected")))
// int f;

void f2(void (*cb)(void*))

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
Comment 1 Richard Biener 2017-11-23 09:23:44 UTC
Confirmed.  Never worked.  Not sure if this is invalid source or not.
Comment 2 Yichao Yu 2017-11-23 17:42:00 UTC
What might be invalid about the source?
Comment 3 H.J. Lu 2017-11-23 18:19:10 UTC

*** This bug has been marked as a duplicate of bug 19520 ***