Bug 599449 - gcc hidden visibility doesn't work
Summary: gcc hidden visibility doesn't work
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: gcc4
Version: 5.6
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Jakub Jelinek
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-06-03 09:26 UTC by Danny Feng
Modified: 2011-05-13 12:53 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-06-03 09:36:29 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Danny Feng 2010-06-03 09:26:38 UTC
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 09:36:29 UTC
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.