diff options
author | Ian Lance Taylor <ian@airs.com> | 2010-03-03 19:31:54 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2010-03-03 19:31:54 +0000 |
commit | d3bbad62650d8da0396b2df5308271efc7fdb317 (patch) | |
tree | f92ee0062cef565cb8575aff98486d7cd09b5a66 /gold/testsuite | |
parent | e8f781e22753a21b7d4d5afd6c4217e711b8da80 (diff) | |
download | gdb-d3bbad62650d8da0396b2df5308271efc7fdb317.zip gdb-d3bbad62650d8da0396b2df5308271efc7fdb317.tar.gz gdb-d3bbad62650d8da0396b2df5308271efc7fdb317.tar.bz2 |
* target-reloc.h (relocate_section): Check the symbol table index
for -1U before setting the local symbol index.
(scan_relocatable_relocs): If copying the relocation, record that
the local symbol is required.
* object.h (Symbol_value::is_output_symtab_index_set): New
function.
(Symbol_value::may_be_discarded_from_output_symtab): New
function.
(Symbol_value::has_output_symtab_entry): New function.
(Symbol_value::needs_output_symtab_entry): Remove.
(Symbol_value::output_symtab_index): Make sure the symbol index is
set.
(Symbol_value::set_output_symtab_index): Make sure the symbol
index is not set. Make sure the new index is valid.
(Symbol_value::set_must_have_output_symtab_entry): New function.
(Symbol_value::has_output_dynsym_entry): New function.
(Symbol_value::set_output_dynsym_index): Make sure the new index
is valid.
(Sized_relobj::set_must_have_output_symtab_entry): New function.
* object.cc (Sized_relobj::do_count_local_symbols): Only discard a
local symbol if permitted.
(Sized_relobj::do_finalize_local_symbols): Call
is_output_symtab_index_set rather than needs_output_symtab_entry.
(Sized_relobj::write_local_symbols): Call has_output_symtab_entry
rather than needs_output_symtab_entry. Call
has_output_dynsym_entry rather than needs_output_dynsym_entry.
* arm.cc (Arm_relobj::update_output_local_symbol_count): Call
is_output_symtab_index_set rather than needs_output_symtab_entry.
* testsuite/discard_locals_relocatable_test.c: New file.
* testsuite/discard_locals_test.sh: Test -r.
* testsuite/Makefile.am (check_DATA): Add
discard_locals_relocatable_test1.syms,
discard_local_relocatable_test2.syms.
(MOSTLYCLEANFILES): Likewise. Also add
discard_locals_relocatable_test1.lout and
discard_locals_relocatable_test2.out.
(discard_locals_relocatable_test1.syms): New target.
(discard_locals_relocatable_test.o): New target.
(discard_locals_relocatable_test1.out): New target.
(discard_locals_relocatable_test2.syms): New target.
(discard_locals_relocatable_test2.out): New target.
(various): Add missing ../ld-new dependencies.
* testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 44 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 40 | ||||
-rw-r--r-- | gold/testsuite/discard_locals_relocatable_test.c | 43 | ||||
-rwxr-xr-x | gold/testsuite/discard_locals_test.sh | 25 |
4 files changed, 125 insertions, 27 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index c9e2d1c..a083bc4 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -1285,8 +1285,14 @@ local_labels_test: local_labels_test.o check_PROGRAMS += discard_locals_test check_SCRIPTS += discard_locals_test.sh -check_DATA += discard_locals_test.syms -MOSTLYCLEANFILES += discard_locals_test.syms +check_DATA += discard_locals_test.syms \ + discard_locals_relocatable_test1.syms \ + discard_locals_relocatable_test2.syms +MOSTLYCLEANFILES += discard_locals_test.syms \ + discard_locals_relocatable_test1.syms \ + discard_locals_relocatable_test2.syms \ + discard_locals_relocatable_test1.out \ + discard_locals_relocatable_test2.out discard_locals_test_SOURCES = discard_locals_test.c discard_locals_test_LDFLAGS = -Bgcctestdir/ -Wl,--discard-locals discard_locals_test.syms: discard_locals_test @@ -1295,6 +1301,18 @@ discard_locals_test.syms: discard_locals_test discard_locals_test.o: discard_locals_test.c $(COMPILE) -c -Wa,-L -o $@ $< +discard_locals_relocatable_test1.syms: discard_locals_relocatable_test1.out + $(TEST_READELF) -sW $< >$@ 2>/dev/null +discard_locals_relocatable_test.o: discard_locals_relocatable_test.c + $(COMPILE) -c -Wa,-L -fPIC -o $@ $< +discard_locals_relocatable_test1.out: discard_locals_relocatable_test.o ../ld-new + ../ld-new --discard-locals -relocatable -o $@ $< + +discard_locals_relocatable_test2.syms: discard_locals_relocatable_test2.out + $(TEST_READELF) -sW $< >$@ 2>/dev/null +discard_locals_relocatable_test2.out: discard_locals_relocatable_test.o ../ld-new + ../ld-new --discard-all -relocatable -o $@ $< + if MCMODEL_MEDIUM check_PROGRAMS += large large_SOURCES = large.c @@ -1456,11 +1474,11 @@ check_SCRIPTS += arm_abs_global.sh check_DATA += arm_abs_global.stdout arm_abs_lib.o: arm_abs_lib.s $(TEST_AS) -march=armv7-a -o $@ $< -libarm_abs.so: arm_abs_lib.o +libarm_abs.so: arm_abs_lib.o ../ld-new ../ld-new -shared -o $@ arm_abs_lib.o arm_abs_global.o: arm_abs_global.s $(TEST_AS) -march=armv7-a -o $@ $< -arm_abs_global: arm_abs_global.o libarm_abs.so +arm_abs_global: arm_abs_global.o libarm_abs.so ../ld-new ../ld-new -o $@ arm_abs_global.o -L. -larm_abs arm_abs_global.stdout: arm_abs_global $(TEST_READELF) -r $< > $@ @@ -1475,7 +1493,7 @@ check_DATA += arm_bl_in_range.stdout arm_bl_out_of_range.stdout \ arm_bl_in_range.stdout: arm_bl_in_range $(TEST_OBJDUMP) -D $< > $@ -arm_bl_in_range: arm_bl_in_range.o +arm_bl_in_range: arm_bl_in_range.o ../ld-new ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $< arm_bl_in_range.o: arm_bl_in_range.s @@ -1484,7 +1502,7 @@ arm_bl_in_range.o: arm_bl_in_range.s arm_bl_out_of_range.stdout: arm_bl_out_of_range $(TEST_OBJDUMP) -S $< > $@ -arm_bl_out_of_range: arm_bl_out_of_range.o +arm_bl_out_of_range: arm_bl_out_of_range.o ../ld-new ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $< arm_bl_out_of_range.o: arm_bl_out_of_range.s @@ -1493,7 +1511,7 @@ arm_bl_out_of_range.o: arm_bl_out_of_range.s thumb_bl_in_range.stdout: thumb_bl_in_range $(TEST_OBJDUMP) -D $< > $@ -thumb_bl_in_range: thumb_bl_in_range.o +thumb_bl_in_range: thumb_bl_in_range.o ../ld-new ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $< thumb_bl_in_range.o: thumb_bl_in_range.s @@ -1502,7 +1520,7 @@ thumb_bl_in_range.o: thumb_bl_in_range.s thumb_bl_out_of_range.stdout: thumb_bl_out_of_range $(TEST_OBJDUMP) -D $< > $@ -thumb_bl_out_of_range: thumb_bl_in_range.o +thumb_bl_out_of_range: thumb_bl_in_range.o ../ld-new ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $< thumb_bl_out_of_range.o: thumb_bl_in_range.s @@ -1511,7 +1529,7 @@ thumb_bl_out_of_range.o: thumb_bl_in_range.s thumb2_bl_in_range.stdout: thumb2_bl_in_range $(TEST_OBJDUMP) -D $< > $@ -thumb2_bl_in_range: thumb2_bl_in_range.o +thumb2_bl_in_range: thumb2_bl_in_range.o ../ld-new ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $< thumb2_bl_in_range.o: thumb_bl_in_range.s @@ -1520,7 +1538,7 @@ thumb2_bl_in_range.o: thumb_bl_in_range.s thumb2_bl_out_of_range.stdout: thumb2_bl_out_of_range $(TEST_OBJDUMP) -D $< > $@ -thumb2_bl_out_of_range: thumb2_bl_in_range.o +thumb2_bl_out_of_range: thumb2_bl_in_range.o ../ld-new ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $< thumb2_bl_out_of_range.o: thumb_bl_in_range.s @@ -1536,7 +1554,7 @@ check_DATA += arm_fix_v4bx.stdout arm_fix_v4bx_interworking.stdout \ arm_fix_v4bx.stdout: arm_fix_v4bx $(TEST_OBJDUMP) -D -j.text $< > $@ -arm_fix_v4bx: arm_fix_v4bx.o +arm_fix_v4bx: arm_fix_v4bx.o ../ld-new ../ld-new --fix-v4bx -o $@ $< arm_fix_v4bx.o: arm_fix_v4bx.s @@ -1545,13 +1563,13 @@ arm_fix_v4bx.o: arm_fix_v4bx.s arm_fix_v4bx_interworking.stdout: arm_fix_v4bx_interworking $(TEST_OBJDUMP) -D -j.text $< > $@ -arm_fix_v4bx_interworking: arm_fix_v4bx.o +arm_fix_v4bx_interworking: arm_fix_v4bx.o ../ld-new ../ld-new --fix-v4bx-interworking -o $@ $< arm_no_fix_v4bx.stdout: arm_no_fix_v4bx $(TEST_OBJDUMP) -D -j.text $< > $@ -arm_no_fix_v4bx: arm_fix_v4bx.o +arm_no_fix_v4bx: arm_fix_v4bx.o ../ld-new ../ld-new -o $@ $< MOSTLYCLEANFILES += arm_fix_v4bx arm_fix_v4bx_interworking arm_no_fix_v4bx diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 10730f3..d21b32b 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -276,6 +276,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ no_version_test.sh @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_28 = exclude_libs_test.syms \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test.syms \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_relocatable_test1.syms \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_relocatable_test2.syms \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ hidden_test.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ no_version_test.stdout @@ -284,6 +286,10 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/libexclude_libs_test_3.a \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test.syms \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_relocatable_test1.syms \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_relocatable_test2.syms \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_relocatable_test1.out \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_relocatable_test2.out \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ hidden_test hidden_test.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test.in \ @@ -3142,6 +3148,18 @@ uninstall-am: # '-Wa,-L' is required to preserve the local label used for testing. @GCC_TRUE@@NATIVE_LINKER_TRUE@discard_locals_test.o: discard_locals_test.c @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c -Wa,-L -o $@ $< + +@GCC_TRUE@@NATIVE_LINKER_TRUE@discard_locals_relocatable_test1.syms: discard_locals_relocatable_test1.out +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null +@GCC_TRUE@@NATIVE_LINKER_TRUE@discard_locals_relocatable_test.o: discard_locals_relocatable_test.c +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c -Wa,-L -fPIC -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@discard_locals_relocatable_test1.out: discard_locals_relocatable_test.o ../ld-new +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ../ld-new --discard-locals -relocatable -o $@ $< + +@GCC_TRUE@@NATIVE_LINKER_TRUE@discard_locals_relocatable_test2.syms: discard_locals_relocatable_test2.out +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null +@GCC_TRUE@@NATIVE_LINKER_TRUE@discard_locals_relocatable_test2.out: discard_locals_relocatable_test.o ../ld-new +@GCC_TRUE@@NATIVE_LINKER_TRUE@ ../ld-new --discard-all -relocatable -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@libhidden.so: hidden_test_1.c gcctestdir/ld @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -Bgcctestdir/ -g -shared -fPIC -w -o $@ $(srcdir)/hidden_test_1.c @GCC_TRUE@@NATIVE_LINKER_TRUE@hidden_test: hidden_test_main.o libhidden.so gcctestdir/ld @@ -3231,11 +3249,11 @@ uninstall-am: @DEFAULT_TARGET_X86_64_TRUE@ ../ld-new -r split_x86_64_1.o split_x86_64_n.o -o split_x86_64_r > $@ 2>&1 || exit 0 @DEFAULT_TARGET_ARM_TRUE@arm_abs_lib.o: arm_abs_lib.s @DEFAULT_TARGET_ARM_TRUE@ $(TEST_AS) -march=armv7-a -o $@ $< -@DEFAULT_TARGET_ARM_TRUE@libarm_abs.so: arm_abs_lib.o +@DEFAULT_TARGET_ARM_TRUE@libarm_abs.so: arm_abs_lib.o ../ld-new @DEFAULT_TARGET_ARM_TRUE@ ../ld-new -shared -o $@ arm_abs_lib.o @DEFAULT_TARGET_ARM_TRUE@arm_abs_global.o: arm_abs_global.s @DEFAULT_TARGET_ARM_TRUE@ $(TEST_AS) -march=armv7-a -o $@ $< -@DEFAULT_TARGET_ARM_TRUE@arm_abs_global: arm_abs_global.o libarm_abs.so +@DEFAULT_TARGET_ARM_TRUE@arm_abs_global: arm_abs_global.o libarm_abs.so ../ld-new @DEFAULT_TARGET_ARM_TRUE@ ../ld-new -o $@ arm_abs_global.o -L. -larm_abs @DEFAULT_TARGET_ARM_TRUE@arm_abs_global.stdout: arm_abs_global @DEFAULT_TARGET_ARM_TRUE@ $(TEST_READELF) -r $< > $@ @@ -3243,7 +3261,7 @@ uninstall-am: @DEFAULT_TARGET_ARM_TRUE@arm_bl_in_range.stdout: arm_bl_in_range @DEFAULT_TARGET_ARM_TRUE@ $(TEST_OBJDUMP) -D $< > $@ -@DEFAULT_TARGET_ARM_TRUE@arm_bl_in_range: arm_bl_in_range.o +@DEFAULT_TARGET_ARM_TRUE@arm_bl_in_range: arm_bl_in_range.o ../ld-new @DEFAULT_TARGET_ARM_TRUE@ ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $< @DEFAULT_TARGET_ARM_TRUE@arm_bl_in_range.o: arm_bl_in_range.s @@ -3252,7 +3270,7 @@ uninstall-am: @DEFAULT_TARGET_ARM_TRUE@arm_bl_out_of_range.stdout: arm_bl_out_of_range @DEFAULT_TARGET_ARM_TRUE@ $(TEST_OBJDUMP) -S $< > $@ -@DEFAULT_TARGET_ARM_TRUE@arm_bl_out_of_range: arm_bl_out_of_range.o +@DEFAULT_TARGET_ARM_TRUE@arm_bl_out_of_range: arm_bl_out_of_range.o ../ld-new @DEFAULT_TARGET_ARM_TRUE@ ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $< @DEFAULT_TARGET_ARM_TRUE@arm_bl_out_of_range.o: arm_bl_out_of_range.s @@ -3261,7 +3279,7 @@ uninstall-am: @DEFAULT_TARGET_ARM_TRUE@thumb_bl_in_range.stdout: thumb_bl_in_range @DEFAULT_TARGET_ARM_TRUE@ $(TEST_OBJDUMP) -D $< > $@ -@DEFAULT_TARGET_ARM_TRUE@thumb_bl_in_range: thumb_bl_in_range.o +@DEFAULT_TARGET_ARM_TRUE@thumb_bl_in_range: thumb_bl_in_range.o ../ld-new @DEFAULT_TARGET_ARM_TRUE@ ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $< @DEFAULT_TARGET_ARM_TRUE@thumb_bl_in_range.o: thumb_bl_in_range.s @@ -3270,7 +3288,7 @@ uninstall-am: @DEFAULT_TARGET_ARM_TRUE@thumb_bl_out_of_range.stdout: thumb_bl_out_of_range @DEFAULT_TARGET_ARM_TRUE@ $(TEST_OBJDUMP) -D $< > $@ -@DEFAULT_TARGET_ARM_TRUE@thumb_bl_out_of_range: thumb_bl_in_range.o +@DEFAULT_TARGET_ARM_TRUE@thumb_bl_out_of_range: thumb_bl_in_range.o ../ld-new @DEFAULT_TARGET_ARM_TRUE@ ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $< @DEFAULT_TARGET_ARM_TRUE@thumb_bl_out_of_range.o: thumb_bl_in_range.s @@ -3279,7 +3297,7 @@ uninstall-am: @DEFAULT_TARGET_ARM_TRUE@thumb2_bl_in_range.stdout: thumb2_bl_in_range @DEFAULT_TARGET_ARM_TRUE@ $(TEST_OBJDUMP) -D $< > $@ -@DEFAULT_TARGET_ARM_TRUE@thumb2_bl_in_range: thumb2_bl_in_range.o +@DEFAULT_TARGET_ARM_TRUE@thumb2_bl_in_range: thumb2_bl_in_range.o ../ld-new @DEFAULT_TARGET_ARM_TRUE@ ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $< @DEFAULT_TARGET_ARM_TRUE@thumb2_bl_in_range.o: thumb_bl_in_range.s @@ -3288,7 +3306,7 @@ uninstall-am: @DEFAULT_TARGET_ARM_TRUE@thumb2_bl_out_of_range.stdout: thumb2_bl_out_of_range @DEFAULT_TARGET_ARM_TRUE@ $(TEST_OBJDUMP) -D $< > $@ -@DEFAULT_TARGET_ARM_TRUE@thumb2_bl_out_of_range: thumb2_bl_in_range.o +@DEFAULT_TARGET_ARM_TRUE@thumb2_bl_out_of_range: thumb2_bl_in_range.o ../ld-new @DEFAULT_TARGET_ARM_TRUE@ ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $< @DEFAULT_TARGET_ARM_TRUE@thumb2_bl_out_of_range.o: thumb_bl_in_range.s @@ -3297,7 +3315,7 @@ uninstall-am: @DEFAULT_TARGET_ARM_TRUE@arm_fix_v4bx.stdout: arm_fix_v4bx @DEFAULT_TARGET_ARM_TRUE@ $(TEST_OBJDUMP) -D -j.text $< > $@ -@DEFAULT_TARGET_ARM_TRUE@arm_fix_v4bx: arm_fix_v4bx.o +@DEFAULT_TARGET_ARM_TRUE@arm_fix_v4bx: arm_fix_v4bx.o ../ld-new @DEFAULT_TARGET_ARM_TRUE@ ../ld-new --fix-v4bx -o $@ $< @DEFAULT_TARGET_ARM_TRUE@arm_fix_v4bx.o: arm_fix_v4bx.s @@ -3306,13 +3324,13 @@ uninstall-am: @DEFAULT_TARGET_ARM_TRUE@arm_fix_v4bx_interworking.stdout: arm_fix_v4bx_interworking @DEFAULT_TARGET_ARM_TRUE@ $(TEST_OBJDUMP) -D -j.text $< > $@ -@DEFAULT_TARGET_ARM_TRUE@arm_fix_v4bx_interworking: arm_fix_v4bx.o +@DEFAULT_TARGET_ARM_TRUE@arm_fix_v4bx_interworking: arm_fix_v4bx.o ../ld-new @DEFAULT_TARGET_ARM_TRUE@ ../ld-new --fix-v4bx-interworking -o $@ $< @DEFAULT_TARGET_ARM_TRUE@arm_no_fix_v4bx.stdout: arm_no_fix_v4bx @DEFAULT_TARGET_ARM_TRUE@ $(TEST_OBJDUMP) -D -j.text $< > $@ -@DEFAULT_TARGET_ARM_TRUE@arm_no_fix_v4bx: arm_fix_v4bx.o +@DEFAULT_TARGET_ARM_TRUE@arm_no_fix_v4bx: arm_fix_v4bx.o ../ld-new @DEFAULT_TARGET_ARM_TRUE@ ../ld-new -o $@ $< # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/gold/testsuite/discard_locals_relocatable_test.c b/gold/testsuite/discard_locals_relocatable_test.c new file mode 100644 index 0000000..d46151e --- /dev/null +++ b/gold/testsuite/discard_locals_relocatable_test.c @@ -0,0 +1,43 @@ +/* discard_locals_relocatable_test.c -- test --discard-locals/--discard-all -r + + Copyright 2010 Free Software Foundation, Inc. + Viktor Kutuzov <vkutuzov@accesssoftek.com>. + + This file is part of gold. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. + + This is a test of a common symbol in the main program and a + versioned symbol in a shared library. The common symbol in the + main program should override the shared library symbol. */ + +/* Note: use GCC -fPIC option to compile this test. */ + +/* Local symbol format for generic ELF target. + Use GCC -Wa,-L option to preserve this local symbol + in the output object file. */ +asm (".Lshould_be_discarded:"); + +extern void print_func (const char* s); + +extern int func (void); + +int +func (void) +{ + print_func ("local string"); + return 0; +} diff --git a/gold/testsuite/discard_locals_test.sh b/gold/testsuite/discard_locals_test.sh index c09f833..3fc679a 100755 --- a/gold/testsuite/discard_locals_test.sh +++ b/gold/testsuite/discard_locals_test.sh @@ -27,11 +27,12 @@ # the resulting executable and check that symbols from two test library # archives are correctly hidden or left unmodified. -check() +check_discarded() { file=$1 + sym=$2 - found=`egrep "should_be_discarded" $file` + found=`egrep $sym $file` if test -n "$found"; then echo "These local symbols are not discarded in $file:" echo "$found" @@ -39,6 +40,24 @@ check() fi } -check "discard_locals_test.syms" +check_non_discarded() +{ + file=$1 + sym=$2 + + found=`egrep $sym $file` + if test -z "$found"; then + echo "This local symbol is discarded in $file:" + echo "$2" + exit 1 + fi +} + +check_discarded "discard_locals_test.syms" "should_be_discarded" + +check_non_discarded "discard_locals_relocatable_test1.syms" ".LC0" +check_discarded "discard_locals_relocatable_test1.syms" "should_be_discarded" +check_non_discarded "discard_locals_relocatable_test2.syms" ".LC0" +check_discarded "discard_locals_relocatable_test2.syms" "should_be_discarded" exit 0 |