diff options
author | Ian Lance Taylor <iant@google.com> | 2008-02-07 01:51:25 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2008-02-07 01:51:25 +0000 |
commit | 88dd47ac00ee5a932bca9abbd2245c429dfd8f5b (patch) | |
tree | 494b3493adc0f1449c5a33f48002692a9e74ab17 /gold/testsuite | |
parent | 2e444beaa07a2428b6409225840ce12d437d7805 (diff) | |
download | gdb-88dd47ac00ee5a932bca9abbd2245c429dfd8f5b.zip gdb-88dd47ac00ee5a932bca9abbd2245c429dfd8f5b.tar.gz gdb-88dd47ac00ee5a932bca9abbd2245c429dfd8f5b.tar.bz2 |
Implement --just-symbols, including -R FILE. Fix symbol values when
doing a relocatable link.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 9 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 38 | ||||
-rw-r--r-- | gold/testsuite/justsyms.t | 31 | ||||
-rw-r--r-- | gold/testsuite/justsyms_1.cc | 54 | ||||
-rw-r--r-- | gold/testsuite/justsyms_2.cc | 27 |
5 files changed, 153 insertions, 6 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index b0b149d..c1a081c 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -541,6 +541,15 @@ script_test_2_SOURCES = script_test_2.cc script_test_2a.cc script_test_2b.cc script_test_2_DEPENDENCIES = gcctestdir/ld script_test_2.t script_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_2.t +check_PROGRAMS += justsyms +justsyms_SOURCES = justsyms_1.cc +justsyms_DEPENDENCIES = gcctestdir/ld justsyms_2r.o +justsyms_LDFLAGS = -Bgcctestdir/ -Wl,-R,justsyms_2r.o +justsyms_2.o: justsyms_2.cc + $(CXXCOMPILE) -c -o $@ $< +justsyms_2r.o: justsyms_2.o gcctestdir/ld + gcctestdir/ld -o $@ -r -T $(srcdir)/justsyms.t justsyms_2.o + if OBJDUMP_AND_CPPFILT check_SCRIPTS += ver_matching_test.sh check_DATA += ver_matching_test.stdout diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index fe30a06..10119eb 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -176,7 +176,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) $(am__EXEEXT_1) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile_and_compress_debug_sections \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test script_test_1 \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2 +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2 justsyms @GCC_FALSE@script_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \ @GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ @GCC_FALSE@ $(am__DEPENDENCIES_1) @@ -191,6 +191,13 @@ check_PROGRAMS = object_unittest$(EXEEXT) $(am__EXEEXT_1) \ @NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \ @NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \ @NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) +@GCC_FALSE@justsyms_DEPENDENCIES = libgoldtest.a ../libgold.a \ +@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ +@GCC_FALSE@ $(am__DEPENDENCIES_1) +@NATIVE_LINKER_FALSE@justsyms_DEPENDENCIES = libgoldtest.a \ +@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \ +@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \ +@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) @GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@am__append_11 = ver_matching_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@ script_test_3.sh @GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@am__append_12 = ver_matching_test.stdout \ @@ -264,7 +271,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile_and_compress_debug_sections$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_1$(EXEEXT) \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2$(EXEEXT) +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@am__EXEEXT_8 = script_test_3$(EXEEXT) basic_pic_test_SOURCES = basic_pic_test.c basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT) @@ -375,6 +383,11 @@ flagstest_o_specialfile_and_compress_debug_sections_LDADD = $(LDADD) flagstest_o_specialfile_and_compress_debug_sections_DEPENDENCIES = \ libgoldtest.a ../libgold.a ../../libiberty/libiberty.a \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +am__justsyms_SOURCES_DIST = justsyms_1.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_justsyms_OBJECTS = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms_1.$(OBJEXT) +justsyms_OBJECTS = $(am_justsyms_OBJECTS) +justsyms_LDADD = $(LDADD) am_object_unittest_OBJECTS = object_unittest.$(OBJEXT) object_unittest_OBJECTS = $(am_object_unittest_OBJECTS) object_unittest_LDADD = $(LDADD) @@ -573,9 +586,10 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \ $(exception_static_test_SOURCES) $(exception_test_SOURCES) \ flagstest_compress_debug_sections.c flagstest_o_specialfile.c \ flagstest_o_specialfile_and_compress_debug_sections.c \ - $(object_unittest_SOURCES) $(script_test_1_SOURCES) \ - $(script_test_2_SOURCES) script_test_3.c \ - $(tls_pic_test_SOURCES) $(tls_shared_ie_test_SOURCES) \ + $(justsyms_SOURCES) $(object_unittest_SOURCES) \ + $(script_test_1_SOURCES) $(script_test_2_SOURCES) \ + script_test_3.c $(tls_pic_test_SOURCES) \ + $(tls_shared_ie_test_SOURCES) \ $(tls_shared_nonpic_test_SOURCES) $(tls_shared_test_SOURCES) \ $(tls_static_pic_test_SOURCES) $(tls_static_test_SOURCES) \ $(tls_test_SOURCES) $(two_file_mixed_2_shared_test_SOURCES) \ @@ -609,7 +623,8 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \ $(am__exception_test_SOURCES_DIST) \ flagstest_compress_debug_sections.c flagstest_o_specialfile.c \ flagstest_o_specialfile_and_compress_debug_sections.c \ - $(object_unittest_SOURCES) $(am__script_test_1_SOURCES_DIST) \ + $(am__justsyms_SOURCES_DIST) $(object_unittest_SOURCES) \ + $(am__script_test_1_SOURCES_DIST) \ $(am__script_test_2_SOURCES_DIST) script_test_3.c \ $(am__tls_pic_test_SOURCES_DIST) \ $(am__tls_shared_ie_test_SOURCES_DIST) \ @@ -1007,6 +1022,9 @@ object_unittest_SOURCES = object_unittest.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_2_SOURCES = script_test_2.cc script_test_2a.cc script_test_2b.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_2_DEPENDENCIES = gcctestdir/ld script_test_2.t @GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_2.t +@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_SOURCES = justsyms_1.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_DEPENDENCIES = gcctestdir/ld justsyms_2r.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_LDFLAGS = -Bgcctestdir/ -Wl,-R,justsyms_2r.o all: all-am .SUFFIXES: @@ -1119,6 +1137,9 @@ exception_test$(EXEEXT): $(exception_test_OBJECTS) $(exception_test_DEPENDENCIES @NATIVE_LINKER_FALSE@flagstest_o_specialfile_and_compress_debug_sections$(EXEEXT): $(flagstest_o_specialfile_and_compress_debug_sections_OBJECTS) $(flagstest_o_specialfile_and_compress_debug_sections_DEPENDENCIES) @NATIVE_LINKER_FALSE@ @rm -f flagstest_o_specialfile_and_compress_debug_sections$(EXEEXT) @NATIVE_LINKER_FALSE@ $(LINK) $(flagstest_o_specialfile_and_compress_debug_sections_LDFLAGS) $(flagstest_o_specialfile_and_compress_debug_sections_OBJECTS) $(flagstest_o_specialfile_and_compress_debug_sections_LDADD) $(LIBS) +justsyms$(EXEEXT): $(justsyms_OBJECTS) $(justsyms_DEPENDENCIES) + @rm -f justsyms$(EXEEXT) + $(CXXLINK) $(justsyms_LDFLAGS) $(justsyms_OBJECTS) $(justsyms_LDADD) $(LIBS) object_unittest$(EXEEXT): $(object_unittest_OBJECTS) $(object_unittest_DEPENDENCIES) @rm -f object_unittest$(EXEEXT) $(CXXLINK) $(object_unittest_LDFLAGS) $(object_unittest_OBJECTS) $(object_unittest_LDADD) $(LIBS) @@ -1236,6 +1257,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_compress_debug_sections.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_o_specialfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_o_specialfile_and_compress_debug_sections.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/justsyms_1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object_unittest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_test_1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_test_2.Po@am__quote@ @@ -1692,6 +1714,10 @@ uninstall-am: uninstall-info-am @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_4.o: ver_test_4.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_2.o: justsyms_2.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_2r.o: justsyms_2.o gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gcctestdir/ld -o $@ -r -T $(srcdir)/justsyms.t justsyms_2.o @GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@ver_matching_def.so: ver_matching_def.cc gcctestdir/ld @GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@ $(CXXLINK) -O0 -Bgcctestdir/ -shared $(srcdir)/ver_matching_def.cc -Wl,--version-script=$(srcdir)/version_script.map @GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@ver_matching_test.stdout: ver_matching_def.so diff --git a/gold/testsuite/justsyms.t b/gold/testsuite/justsyms.t new file mode 100644 index 0000000..4d68893 --- /dev/null +++ b/gold/testsuite/justsyms.t @@ -0,0 +1,31 @@ +/* justsyms.t -- test --just-symbols for gold. + + Copyright 2008 Free Software Foundation, Inc. + Written by Ian Lance Taylor <iant@google.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. */ + +SECTIONS +{ + /* This script is only used for a .o file. */ + . = 0x10000; + .gold_test : { *(.gold_test) } + .text : { *(.text) } + .data : { *(.data) } + .bss : { *(.bss) } +} diff --git a/gold/testsuite/justsyms_1.cc b/gold/testsuite/justsyms_1.cc new file mode 100644 index 0000000..599d8c9 --- /dev/null +++ b/gold/testsuite/justsyms_1.cc @@ -0,0 +1,54 @@ +// justsyms_1.cc -- test --just-symbols for gold + +// Copyright 2008 Free Software Foundation, Inc. +// Written by Ian Lance Taylor <iant@google.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. + +// The Linux kernel builds an object file using a linker script, and +// then links against that object file using the -R option. This is a +// test for that usage. + +#include <cassert> +#include <csignal> +#include <cstddef> +#include <cstdlib> +#include <stdint.h> + +extern char justsyms_string[]; + +// We expect to get a SIGSEGV. +static void +handle_sigsegv(int) +{ + exit(0); +} + +int +main(int, char**) +{ + // The linker script should arrange for this symbol to be exactly at + // address 0x10000. + assert(reinterpret_cast<uintptr_t>(justsyms_string) == 0x10000); + + // However, since the file was linked with --just-symbols, we should + // not be able to actually access the symbol. + signal(SIGSEGV, handle_sigsegv); + char c = justsyms_string[0]; + exit(c == '\0' ? 1 : c); +} diff --git a/gold/testsuite/justsyms_2.cc b/gold/testsuite/justsyms_2.cc new file mode 100644 index 0000000..dbbf4b5 --- /dev/null +++ b/gold/testsuite/justsyms_2.cc @@ -0,0 +1,27 @@ +// justsyms_2.cc -- test --just-symbols for gold + +// Copyright 2008 Free Software Foundation, Inc. +// Written by Ian Lance Taylor <iant@google.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 test goes with justsyms_1.cc. We compile this file, then +// apply a linker script with -r to set the section addresses. + +char justsyms_string[] __attribute__ ((section(".gold_test"))) = + "justsyms string"; |