Bug 531269 - ld fails to merge different visibility for the same symbol in distinct object files
ld fails to merge different visibility for the same symbol in distinct object...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: binutils (Show other bugs)
5.4
All Linux
medium Severity medium
: rc
: ---
Assigned To: Andreas Schwab
qe-baseos-tools
:
Depends On:
Blocks: 561822
  Show dependency treegraph
 
Reported: 2009-10-27 10:29 EDT by Martin Osvald
Modified: 2011-05-13 09:20 EDT (History)
5 users (show)

See Also:
Fixed In Version: binutils-2.17.50.0.6-13.el5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 561822 (view as bug list)
Environment:
Last Closed: 2010-03-30 05:04:39 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)
the patch which fixes the bug (829 bytes, patch)
2009-10-27 10:29 EDT, Martin Osvald
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
Sourceware 3666 None None None Never

  None (edit)
Description Martin Osvald 2009-10-27 10:29:01 EDT
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.
Comment 1 Martin Osvald 2009-10-27 10:39:01 EDT
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
Comment 4 RHEL Product and Program Management 2009-11-06 14:12:09 EST
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 "?".
Comment 6 RHEL Product and Program Management 2009-11-27 14:28:42 EST
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 "?".
Comment 7 RHEL Product and Program Management 2009-11-27 14:48:51 EST
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 "?".
Comment 16 errata-xmlrpc 2010-03-30 05:04:39 EDT
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

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