Bug 531269 - ld fails to merge different visibility for the same symbol in distinct object files
Summary: ld fails to merge different visibility for the same symbol in distinct object...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: binutils
Version: 5.4
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Andreas Schwab
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks: 561822
TreeView+ depends on / blocked
 
Reported: 2009-10-27 14:29 UTC by Martin Osvald 🛹
Modified: 2018-10-27 15:58 UTC (History)
5 users (show)

Fixed In Version: binutils-2.17.50.0.6-13.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 561822 (view as bug list)
Environment:
Last Closed: 2010-03-30 09:04:39 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
the patch which fixes the bug (829 bytes, patch)
2009-10-27 14:29 UTC, Martin Osvald 🛹
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2010:0304 0 normal SHIPPED_LIVE binutils bug fix update 2010-03-29 14:32:07 UTC
Sourceware 3666 0 'P2' 'RESOLVED' 'Comdat/linkonce doesn''t merge symbol visibility' 2019-11-18 07:27:33 UTC

Description Martin Osvald 🛹 2009-10-27 14:29:01 UTC
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 14:39:01 UTC
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 Program Management 2009-11-06 19:12:09 UTC
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 Program Management 2009-11-27 19:28:42 UTC
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 Program Management 2009-11-27 19:48:51 UTC
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 09:04:39 UTC
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.