Created attachment 366277 [details] the patch which fixes the bug Description of problem: When a symbol in a comdat/linkonce section has different visibility in different files, linker doesn't merge symbol visibility. Version-Release number of selected component (if applicable): RHEL5 x86_64 How reproducible: always Steps to Reproduce: 1. create 2 files with the following content: $ cat foo.c int foo __attribute__ ((section (".gnu.linkonce.d.1"))) = 1; int __attribute__ ((section (".gnu.linkonce.t.1"))) bar () { return 1; } $ cat bar.c int foo __attribute__ ((section (".gnu.linkonce.d.1"), visibility ("hidden"))) = 1; int __attribute__ ((section (".gnu.linkonce.t.1"), visibility ("hidden"))) bar () { return 1; } int get_foo () { return foo; } int get_bar () { return bar (); } 2. compile and link the source code: $ gcc -fPIC -c -o foo.o foo.c $ gcc -fPIC -c -o bar.o bar.c Actual results: $ ld -shared -o foobar.so foo.o bar.o ld: bar.o: relocation R_X86_64_PC32 against `foo' can not be used when making a shared object; recompile with -fPIC ld: final link failed: Bad value $ Expected results: should link without error Additional info: This has been fixed by the upstream already. I have attached a patch, which exactly corresponds to changes we can find in the newest upstream sources and it fixes the bug.
I am sorry I forgot to mention the command for linking the object files. The whole second point should look like: 2. compile and link the source code: $ gcc -fPIC -c -o foo.o foo.c $ gcc -fPIC -c -o bar.o bar.c $ ld -shared -o foobar.so foo.o bar.o
This request was evaluated by Red Hat Product Management for inclusion, but this component is not scheduled to be updated in the current Red Hat Enterprise Linux release. If you would like this request to be reviewed for the next minor release, ask your support representative to set the next rhel-x.y flag to "?".
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2010-0304.html