Bug 599449 - gcc hidden visibility doesn't work
gcc hidden visibility doesn't work
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: gcc4 (Show other bugs)
5.6
All Linux
low Severity medium
: rc
: ---
Assigned To: Jakub Jelinek
qe-baseos-tools
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-03 05:26 EDT by Danny Feng
Modified: 2011-05-13 08:53 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-06-03 05:36:29 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Danny Feng 2010-06-03 05:26:38 EDT
Description of problem:
gcc hidden visibility doesn't work on rhel5. This blocks kernel build with hidden visibility. I've made a simplified reproduce step for it.

Version-Release number of selected component (if applicable):
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)

How reproducible:
each time

Steps to Reproduce:
$ cat A.c
void hidden_fn(void) { return; }

$ cat B.c
extern void __attribute__((visibility("hidden"))) hidden_fn(void);
void fn(void) { hidden_fn(); }

$ cat C.c
extern void hidden_fn(void);
void fn(void) { hidden_fn(); }gcc -Wall -O2 -fPIC -c A.c -o A.o
$ gcc -Wall -O2 -fPIC -c B.c -o B.o
$ gcc -Wall -O2 -fPIC -c C.c -o C.o
$ gcc -Wall -O2 -shared -fPIC A.o B.o -o
  
Actual results:
/usr/bin/ld: B.o: relocation R_X86_64_PC32 against `hidden_fn' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

Expected results:
pass compile

Additional info:
I'd like to know if there's a way to workaround this
Comment 1 Jakub Jelinek 2010-06-03 05:36:29 EDT
This is a user error.  If you declare some function with hidden visibility somewhere, you must also ensure that the definition has hidden visibility as well
(that can be done either by making sure the prototype with the hidden attribute
is in the CU that defines the function, or using the attribute also on the definition).

Note You need to log in before you can comment on or make changes to this bug.