This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: Symbol visibility revised
- To: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Subject: Re: Symbol visibility revised
- From: "H . J . Lu" <hjl at valinux dot com>
- Date: Mon, 1 May 2000 11:28:16 -0700
- Cc: binutils at sourceware dot cygnus dot com, chip at valinux dot com,Ulrich Drepper <drepper at cygnus dot com>
- References: <200005011738.TAA10412@loewis.home.cs.tu-berlin.de>
On Mon, May 01, 2000 at 07:38:18PM +0200, Martin v. Loewis wrote:
> This patch implements some of the symbol visibility aspects in the
> static linker, which my previous patch assumed as the dynamic linker's
> responsibility. It includes the patch Chip sent last month. The
> immediate need for this patch is GCC's usage of .hidden as part of the
> new C++ ABI, and the lack for .hidden support in dynamic linkers.
>
Here is the testcase. It failed with your patch.
# ./foo
zsh: 4370 segmentation fault ./foo
# objdump --dynamic-reloc libfoo.so
libfoo.so: file format elf32-i386
zsh: 4366 segmentation fault objdump --dynamic-reloc libfoo.so
# readelf -r libfoo.so
......
Relocation section '.rel.plt' at offset 0x634 contains 6 entries:
Offset Info Type Symbol's Value Symbol's Name
000018fc 01907 R_386_JUMP_SLOT 00000000 atexit
00001900 01b07 R_386_JUMP_SLOT 00000000 __register_frame_info
00001904 01e07 R_386_JUMP_SLOT 00000000 __deregister_frame_info
00001908 02107 R_386_JUMP_SLOT 00000000 printf
0000190c ffffff07 R_386_JUMP_SLOT bad symbol index: 00ffffff
00001910 02907 R_386_JUMP_SLOT 00000000 __gmon_start__
You have to fix the PLT entries for hidden symbols.
H.J.
----
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2000-04-07 21:10 PDT by <hjl@osmium.su.varesearch.com>.
# Source directory was `/home/hjl/bugs/gas/hidden'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 65 -rw-r--r-- foo.c
# 54 -rw-r--r-- main.c
# 438 -rw-r--r-- Makefile
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
if test "$gettext_dir" = FAILED && test -f $dir/gettext \
&& ($dir/gettext --version >/dev/null 2>&1)
then
set `$dir/gettext --version 2>&1`
if test "$3" = GNU
then
gettext_dir=$dir
fi
fi
if test "$locale_dir" = FAILED && test -f $dir/shar \
&& ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
then
locale_dir=`$dir/shar --print-text-domain-dir`
fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
echo=echo
else
TEXTDOMAINDIR=$locale_dir
export TEXTDOMAINDIR
TEXTDOMAIN=sharutils
export TEXTDOMAIN
echo="$gettext_dir/gettext -s"
fi
if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then
shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then
shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then
shar_touch='touch -am $3$4$5$6$2 "$8"'
else
shar_touch=:
echo
$echo 'WARNING: not restoring timestamps. Consider getting and'
$echo "installing GNU \`touch', distributed in GNU File Utilities..."
echo
fi
rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch
#
if mkdir _sh00820; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
exit 1
fi
# ============= foo.c ==============
if test -f 'foo.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'foo.c' '(file already exists)'
else
$echo 'x -' extracting 'foo.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'foo.c' &&
void
bar ()
{
X printf ("Hello\n");
}
X
void
foo ()
{
X bar ();
}
SHAR_EOF
(set 20 00 04 07 21 10 28 'foo.c'; eval "$shar_touch") &&
chmod 0644 'foo.c' ||
$echo 'restore of' 'foo.c' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'foo.c:' 'MD5 check failed'
dcc44729d5741c566699aea1f88e2b02 foo.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'foo.c'`"
test 65 -eq "$shar_count" ||
$echo 'foo.c:' 'original size' '65,' 'current size' "$shar_count!"
fi
fi
# ============= main.c ==============
if test -f 'main.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'main.c' '(file already exists)'
else
$echo 'x -' extracting 'main.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'main.c' &&
void foo ();
X
int
main ()
{
X
X foo ();
X
X return 0;
}
SHAR_EOF
(set 20 00 04 07 20 11 37 'main.c'; eval "$shar_touch") &&
chmod 0644 'main.c' ||
$echo 'restore of' 'main.c' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'main.c:' 'MD5 check failed'
ffad46a6b66294bd257c1317767a44f6 main.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'main.c'`"
test 54 -eq "$shar_count" ||
$echo 'main.c:' 'original size' '54,' 'current size' "$shar_count!"
fi
fi
# ============= Makefile ==============
if test -f 'Makefile' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'Makefile' '(file already exists)'
else
$echo 'x -' extracting 'Makefile' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
CFLAGS=-O -B./
X
PROGS= foo
X
all: $(PROGS)
X for f in $(PROGS); do echo "Running: $$f"; ./$$f; \
X if [ $$? != 0 ]; then echo Failed; fi; done
X
foo: libfoo.so main.c
X $(CC) -o $@ $(CFLAGS) $^ -Wl,-rpath,. -rdynamic
X
libfoo.so: foo.o
X $(CC) -shared -o $@ $(CFLAGS) $^
X
foo.o: foo.s
X $(CC) -c $^
X
foo.s: foo.c
X $(CC) -S -fPIC $(CFLAGS) $^
X echo ".hidden bar" >> $@
X
clean:
X rm -f $(PROGS) *.so *.o *.s
X
X
shar:
X shar *.c Makefile > bug.shar
SHAR_EOF
(set 20 00 04 07 21 09 40 'Makefile'; eval "$shar_touch") &&
chmod 0644 'Makefile' ||
$echo 'restore of' 'Makefile' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'Makefile:' 'MD5 check failed'
be6c034589a395c2b5be84245e795435 Makefile
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'Makefile'`"
test 438 -eq "$shar_count" ||
$echo 'Makefile:' 'original size' '438,' 'current size' "$shar_count!"
fi
fi
rm -fr _sh00820
exit 0