This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/20218] Can't use __attribute__ ((visibility ("hidden"))) to hide a symbol
- From: "hjl at lucon dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Dec 2006 23:33:12 -0000
- Subject: [Bug middle-end/20218] Can't use __attribute__ ((visibility ("hidden"))) to hide a symbol
- References: <bug-20218-682@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #32 from hjl at lucon dot org 2006-12-05 23:33 -------
(In reply to comment #31)
> (In reply to comment #27)
> > (In reply to comment #26)
> > > Created an attachment (id=12714)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12714&action=view) [edit]
> > > main_skel.o
> > >
> >
> > It looks OK. Please provide a complete testcase. It could be a gcc bug,
> > a linker bug and/or a problem on your system.
>
>
> http://minus.ds14.agh.edu.pl/~pluto/bug.tar.bz2
>
> $ g++ -shared main.o main_skel.o ./libqt-mt.so.3.3.7
> /usr/bin/ld: main_skel.o: relocation R_X86_64_PC32 against `_ZTV9QMemArrayIcE'
> can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: final link failed: Bad value
> collect2: ld returned 1 exit status
>
> gcc-4.2.0-0.20061119r118994.1.x86_64
> binutils-2.17.50.0.8-1.x86_64
>
[hjl@gnu-2 bug]$ ld -shared main.o main_skel.o
ld: main_skel.o: relocation R_X86_64_PC32 against `_ZTV9QMemArrayIcE' can not
be used when making a shared object; recompile with -fPIC
ld: final link failed: Bad value
[hjl@gnu-2 bug]$ readelf -a main.o | grep _ZTV9QMemArrayIcE
COMDAT group section [ 35] `.group' [_ZTV9QMemArrayIcE] contains 1 sections:
[ 114] .data.rel.ro._ZTV9QMemArrayIcE
00000000083e 00c300000009 R_X86_64_GOTPCREL 0000000000000000 _ZTV9QMemArrayIcE
+ fffffffffffffffc
000000000003 00c300000009 R_X86_64_GOTPCREL 0000000000000000 _ZTV9QMemArrayIcE
+ fffffffffffffffc
000000000003 00c300000009 R_X86_64_GOTPCREL 0000000000000000 _ZTV9QMemArrayIcE
+ fffffffffffffffc
Relocation section '.rela.data.rel.ro._ZTV9QMemArrayIcE' at offset 0xe75c8
contains 6 entries:
195: 0000000000000000 56 OBJECT WEAK DEFAULT 114 _ZTV9QMemArrayIcE
[hjl@gnu-2 bug]$ readelf -a main_skel.o | grep _ZTV9QMemArrayIcE
[11] _ZTV9QMemArrayIcE GROUP 0000000000000000 00000090
COMDAT group section [ 11] `_ZTV9QMemArrayIcE' [_ZTV9QMemArrayIcE] contains 1
sections:
[ 40] .data.rel.ro._ZTV9QMemArrayIcE
000000000179 002c00000002 R_X86_64_PC32 0000000000000000 _ZTV9QMemArrayIcE
+ c
000000000195 002c00000002 R_X86_64_PC32 0000000000000000 _ZTV9QMemArrayIcE
+ c
000000000003 002c00000002 R_X86_64_PC32 0000000000000000 _ZTV9QMemArrayIcE
+ c
000000000003 002c00000002 R_X86_64_PC32 0000000000000000 _ZTV9QMemArrayIcE
+ c
Relocation section '.rela.data.rel.ro._ZTV9QMemArrayIcE' at offset 0x2dd0
contains 6 entries:
44: 0000000000000000 56 OBJECT WEAK HIDDEN 40 _ZTV9QMemArrayIcE
[hjl@gnu-2 bug]$ ld -shared main_skel.o main.o
[hjl@gnu-2 bug]$
The hidden definition in main_skel.o is ignored due to COMDAT group.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20218