Bug 2362

Summary: SH: Hidden symbol in DSO does not be forced local
Product: binutils Reporter: sugioka
Component: ldAssignee: unassigned
Status: NEW ---    
Severity: normal CC: bug-binutils
Priority: P2    
Version: 2.16   
Target Milestone: ---   
Host: sh4-unknown-linux Target: sh4-unknown-linux
Build: sh4-unknown-linux Last reconfirmed:

Description sugioka 2006-02-20 01:08:46 UTC
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);
main()
{
	bar();
	return 0;
}

---- bar.c ----
extern void func(void) __attribute((visibility("hidden")));
void bar(void)
{
	func();
}

---- bar-2.c ----
void func(void) __attribute((visibility("hidden")));
void func(void)
{
}

---- bar.ver ----
{global:
bar;
func;
local:*;};

---- 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
LD_LIBRARY_PATH=. ./foo

---- environment ----
linux-2.6.15.3 on sh4
gcc-3.4.5
binutils-2.16.91.0.5
glibc-2.3.4

---- 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
Comment 1 drow@false.org 2006-02-24 14:28:27 UTC
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.

Comment 2 sugioka 2006-02-25 02:00:16 UTC
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.