On sh4-unknown-linux target, hidden symbol in DSO does not be kept local
if the symbol appeared at global section in the version script.
The hidden function is accessed directly at compile time, but global function
in DSO should be accessed through PLT, as the result, segmentation fault occurs
on execution time.
Here is a simple test case.
---- foo.c ----
extern void bar(void);
---- bar.c ----
extern void func(void) __attribute((visibility("hidden")));
---- bar-2.c ----
void func(void) __attribute((visibility("hidden")));
---- bar.ver ----
---- build and exec ----
gcc -g -c foo.c
gcc -g -fPIC -c bar.c
gcc -g -fPIC -c bar-2.c
gcc -o bar.so -shared bar.o bar-2.o -Wl,--version-script -Wl,bar.ver
gcc -o foo foo.o bar.so
---- environment ----
linux-18.104.22.168 on sh4
---- binutils configuration ----
../configure sh4-unknown-linux --prefix=/usr --exec-prefix=/usr
--bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share
--includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec
--localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --disable-werror
Subject: Re: New: SH: Hidden symbol in DSO does not be forced local
On Mon, Feb 20, 2006 at 01:08:46AM -0000, sugioka at itonet dot co dot jp wrote:
> On sh4-unknown-linux target, hidden symbol in DSO does not be kept local
> if the symbol appeared at global section in the version script.
> The hidden function is accessed directly at compile time, but global function
> in DSO should be accessed through PLT, as the result, segmentation fault occurs
> on execution time.
I'm pretty sure your test is invalid. If the compiler is told a symbol
is hidden, it can't be forced global later without risking wrong code.
I am saying that hidden symbol should not be globalized by vesion script.
On x86, hidden symbols can not be globalized even if they appeared in global
section of the version script,
But on SH, they can be globalized and the result is segmentation fault.
So it should be explicitly disabled as x86 do in bfd libs.
I found this problem while building glib-2.9.2.