diff options
author | Cary Coutant <ccoutant@google.com> | 2013-04-15 16:34:12 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2013-04-15 16:34:12 +0000 |
commit | 502e8a84302cfcc70166bd60cc6465a3e913cb8c (patch) | |
tree | 0602206c4e18bf6cab9f900cce1ed97f87fd61b9 /gold | |
parent | 4d40cad2035955599e42cb853b5d331eeefd6622 (diff) | |
download | gdb-502e8a84302cfcc70166bd60cc6465a3e913cb8c.zip gdb-502e8a84302cfcc70166bd60cc6465a3e913cb8c.tar.gz gdb-502e8a84302cfcc70166bd60cc6465a3e913cb8c.tar.bz2 |
gold/
* symtab.cc (Symbol_table::sized_write_globals): Subtract
section starting address for relocatable link.
* testsuite/Makefile.am (script_test_11): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/script_test_11.c: New source file.
* testsuite/script_test_11.t: New linker script.
Diffstat (limited to 'gold')
-rw-r--r-- | gold/ChangeLog | 9 | ||||
-rw-r--r-- | gold/symtab.cc | 27 | ||||
-rw-r--r-- | gold/testsuite/Makefile.am | 11 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 33 | ||||
-rw-r--r-- | gold/testsuite/script_test_11.c | 16 | ||||
-rw-r--r-- | gold/testsuite/script_test_11.t | 8 |
6 files changed, 91 insertions, 13 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index 2605874..a635214 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,12 @@ +2013-04-15 Cary Coutant <ccoutant@google.com> + + * symtab.cc (Symbol_table::sized_write_globals): Subtract + section starting address for relocatable link. + * testsuite/Makefile.am (script_test_11): New test. + * testsuite/Makefile.in: Regenerate. + * testsuite/script_test_11.c: New source file. + * testsuite/script_test_11.t: New linker script. + 2013-04-13 Alan Modra <amodra@gmail.com> * powerpc.cc (Stub_control::can_add_to_stub_group): Don't set diff --git a/gold/symtab.cc b/gold/symtab.cc index 17a0f55..2e17529 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -2940,15 +2940,24 @@ Symbol_table::sized_write_globals(const Stringpool* sympool, break; case Symbol::IN_OUTPUT_DATA: - shndx = sym->output_data()->out_shndx(); - if (shndx >= elfcpp::SHN_LORESERVE) - { - if (sym_index != -1U) - symtab_xindex->add(sym_index, shndx); - if (dynsym_index != -1U) - dynsym_xindex->add(dynsym_index, shndx); - shndx = elfcpp::SHN_XINDEX; - } + { + Output_data* od = sym->output_data(); + + shndx = od->out_shndx(); + if (shndx >= elfcpp::SHN_LORESERVE) + { + if (sym_index != -1U) + symtab_xindex->add(sym_index, shndx); + if (dynsym_index != -1U) + dynsym_xindex->add(dynsym_index, shndx); + shndx = elfcpp::SHN_XINDEX; + } + + // In object files symbol values are section + // relative. + if (parameters->options().relocatable()) + sym_value -= od->address(); + } break; case Symbol::IN_OUTPUT_SEGMENT: diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 5b5c86b..4d02925 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -1398,7 +1398,6 @@ script_test_8: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t script_test_8.stdout: script_test_8 $(TEST_READELF) -SlW script_test_8 > script_test_8.stdout - check_SCRIPTS += script_test_9.sh check_DATA += script_test_9.stdout MOSTLYCLEANFILES += script_test_9 @@ -1409,6 +1408,16 @@ script_test_9: gcctestdir/ld $(srcdir)/script_test_9.t script_test_9.o script_test_9.stdout: script_test_9 $(TEST_READELF) -lW script_test_9 > script_test_9.stdout +# Test scripts with a relocatable link. +# The -g option is necessary to trigger a bug where a section +# declared in a script file is assigned a non-zero starting address. +check_PROGRAMS += script_test_11 +script_test_11: gcctestdir/ld script_test_11_r.o + $(LINK) -Bgcctestdir/ script_test_11_r.o +script_test_11_r.o: gcctestdir/ld $(srcdir)/script_test_11.t script_test_11.o + gcctestdir/ld -r -o $@ -T $(srcdir)/script_test_11.t script_test_11.o +script_test_11.o: script_test_11.c + $(COMPILE) -c -g -o $@ $< # Test --dynamic-list, --dynamic-list-data, --dynamic-list-cpp-new, # and --dynamic-list-cpp-typeinfo diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index ec0acb9..fa9e80f 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -288,6 +288,10 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ # Test -TText and -Tdata. # Test symbol versioning. + +# Test scripts with a relocatable link. +# The -g option is necessary to trigger a bug where a section +# declared in a script file is assigned a non-zero starting address. @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_32 = flagstest_o_ttext_1 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test ver_test_2 ver_test_6 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_8 ver_test_9 \ @@ -300,7 +304,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms_exec binary_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_phdrs_script_test \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_script_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_script_test script_test_11 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2 @GCC_FALSE@script_test_1_DEPENDENCIES = @@ -800,6 +804,7 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_phdrs_script_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_script_test$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_11$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__EXEEXT_23 = plugin_test_1$(EXEEXT) \ @@ -1398,6 +1403,12 @@ relro_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ script_test_1_OBJECTS = $(am_script_test_1_OBJECTS) script_test_1_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ $(script_test_1_LDFLAGS) $(LDFLAGS) -o $@ +script_test_11_SOURCES = script_test_11.c +script_test_11_OBJECTS = script_test_11.$(OBJEXT) +script_test_11_LDADD = $(LDADD) +script_test_11_DEPENDENCIES = libgoldtest.a ../libgold.a \ + ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) @GCC_TRUE@@NATIVE_LINKER_TRUE@am_script_test_2_OBJECTS = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2.$(OBJEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2a.$(OBJEXT) \ @@ -1764,8 +1775,9 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \ plugin_test_8.c $(protected_1_SOURCES) $(protected_2_SOURCES) \ $(relro_now_test_SOURCES) $(relro_script_test_SOURCES) \ $(relro_strip_test_SOURCES) $(relro_test_SOURCES) \ - $(script_test_1_SOURCES) $(script_test_2_SOURCES) \ - script_test_3.c $(searched_file_test_SOURCES) start_lib_test.c \ + $(script_test_1_SOURCES) script_test_11.c \ + $(script_test_2_SOURCES) script_test_3.c \ + $(searched_file_test_SOURCES) start_lib_test.c \ $(thin_archive_test_1_SOURCES) $(thin_archive_test_2_SOURCES) \ $(tls_phdrs_script_test_SOURCES) $(tls_pic_test_SOURCES) \ tls_pie_pic_test.c tls_pie_test.c $(tls_script_test_SOURCES) \ @@ -3149,6 +3161,12 @@ relro_test$(EXEEXT): $(relro_test_OBJECTS) $(relro_test_DEPENDENCIES) script_test_1$(EXEEXT): $(script_test_1_OBJECTS) $(script_test_1_DEPENDENCIES) @rm -f script_test_1$(EXEEXT) $(script_test_1_LINK) $(script_test_1_OBJECTS) $(script_test_1_LDADD) $(LIBS) +@GCC_FALSE@script_test_11$(EXEEXT): $(script_test_11_OBJECTS) $(script_test_11_DEPENDENCIES) +@GCC_FALSE@ @rm -f script_test_11$(EXEEXT) +@GCC_FALSE@ $(LINK) $(script_test_11_OBJECTS) $(script_test_11_LDADD) $(LIBS) +@NATIVE_LINKER_FALSE@script_test_11$(EXEEXT): $(script_test_11_OBJECTS) $(script_test_11_DEPENDENCIES) +@NATIVE_LINKER_FALSE@ @rm -f script_test_11$(EXEEXT) +@NATIVE_LINKER_FALSE@ $(LINK) $(script_test_11_OBJECTS) $(script_test_11_LDADD) $(LIBS) script_test_2$(EXEEXT): $(script_test_2_OBJECTS) $(script_test_2_DEPENDENCIES) @rm -f script_test_2$(EXEEXT) $(script_test_2_LINK) $(script_test_2_OBJECTS) $(script_test_2_LDADD) $(LIBS) @@ -3432,6 +3450,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protected_main_3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relro_test_main.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_11.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_test_2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_test_2a.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_test_2b.Po@am__quote@ @@ -4032,6 +4051,8 @@ tls_phdrs_script_test.log: tls_phdrs_script_test$(EXEEXT) @p='tls_phdrs_script_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) tls_script_test.log: tls_script_test$(EXEEXT) @p='tls_script_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +script_test_11.log: script_test_11$(EXEEXT) + @p='script_test_11$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) thin_archive_test_1.log: thin_archive_test_1$(EXEEXT) @p='thin_archive_test_1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) thin_archive_test_2.log: thin_archive_test_2$(EXEEXT) @@ -4833,6 +4854,12 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ script_test_9.o -T $(srcdir)/script_test_9.t @GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_9.stdout: script_test_9 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -lW script_test_9 > script_test_9.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_11: gcctestdir/ld script_test_11_r.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ script_test_11_r.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_11_r.o: gcctestdir/ld $(srcdir)/script_test_11.t script_test_11.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gcctestdir/ld -r -o $@ -T $(srcdir)/script_test_11.t script_test_11.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_11.o: script_test_11.c +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c -g -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list: basic_test.o gcctestdir/ld $(srcdir)/dynamic_list.t @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ basic_test.o \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ -Wl,--dynamic-list $(srcdir)/dynamic_list.t \ diff --git a/gold/testsuite/script_test_11.c b/gold/testsuite/script_test_11.c new file mode 100644 index 0000000..d932813 --- /dev/null +++ b/gold/testsuite/script_test_11.c @@ -0,0 +1,16 @@ +static unsigned int buffer1[256] __attribute((used)); +static unsigned int buffer2[256] __attribute((used)) = { 1 }; + +unsigned int foo __attribute__((section(".foo"))); +extern char __foo_start; +extern char __foo_end; + +int +main (void) +{ + if (&__foo_end - &__foo_start != sizeof(foo)) + return 1; + if (&__foo_start != (char *)&foo) + return 2; + return 0; +} diff --git a/gold/testsuite/script_test_11.t b/gold/testsuite/script_test_11.t new file mode 100644 index 0000000..0ec6bcd --- /dev/null +++ b/gold/testsuite/script_test_11.t @@ -0,0 +1,8 @@ +SECTIONS +{ + .foo : { + __foo_start = .; + KEEP(*(.foo)) + __foo_end = .; + } +} |