diff options
Diffstat (limited to 'gold')
-rw-r--r-- | gold/ChangeLog | 23 | ||||
-rw-r--r-- | gold/testsuite/Makefile.am | 13 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 27 | ||||
-rw-r--r-- | gold/x86_64.cc | 41 |
4 files changed, 96 insertions, 8 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index 97ac696..5724e59 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,26 @@ +2013-11-17 H.J. Lu <hongjiu.lu@intel.com> + + * x86_64.cc (Target_x86_64<size>::Scan::get_reference_flags): + Handle R_X86_64_PC32_BND and R_X86_64_PLT32_BND just like + R_X86_64_PC32 and R_X86_64_PLT32, respectively. + (Target_x86_64<size>::Scan::local): Likewise. + (Target_x86_64<size>::Scan::global): Likewise. + (Target_x86_64<size>::Relocate::relocate): Likewise. + (Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc): + Likewise. + (Target_x86_64<size>::Scan::check_non_pic(): Handle + R_X86_64_PC32_BND. + + * testsuite/Makefile.am (check_PROGRAMS): Add + exception_x86_64_bnd_test. + (exception_x86_64_bnd_test_SOURCES): New macro. + (exception_x86_64_bnd_test_DEPENDENCIES): Likewise. + (exception_x86_64_bnd_test_LDFLAGS): Likewise. + (exception_x86_64_bnd_test_LDADD): Likewise. + (exception_x86_64_bnd_1.o): New rule. + (exception_x86_64_bnd_2.o): Likewise. + * testsuite/Makefile.in: Regenerated. + 2013-11-15 Alan Modra <amodra@gmail.com> * powerpc.cc (Target_powerpc::glink_section): Provide non-const diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 0d40e3f..2b7b5ae 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -2256,6 +2256,19 @@ incremental_comdat_test_1: incr_comdat_test_1.o incr_comdat_test_2_v1.o incr_com endif DEFAULT_TARGET_X86_64 +if DEFAULT_TARGET_X86_64 +check_PROGRAMS += exception_x86_64_bnd_test +exception_x86_64_bnd_test_SOURCES = exception_test_main.cc +exception_x86_64_bnd_test_DEPENDENCIES = exception_x86_64_bnd_1.o \ + exception_x86_64_bnd_2.o +exception_x86_64_bnd_test_LDFLAGS = $(exception_test_LDFLAGS) +exception_x86_64_bnd_test_LDADD = $(exception_x86_64_bnd_test_DEPENDENCIES) +exception_x86_64_bnd_1.o: exception_test_1.cc + $(CXXCOMPILE) -c -fpic -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $< +exception_x86_64_bnd_2.o: exception_test_2.cc + $(CXXCOMPILE) -c -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $< +endif DEFAULT_TARGET_X86_64 + endif GCC endif NATIVE_LINKER diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 07bb534..b7798c4 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -549,7 +549,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_6 \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_copy_test \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_common_test_1 \ -@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_comdat_test_1 +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_comdat_test_1 \ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_x86_64_bnd_test @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_71 = two_file_test_tmp_2.o \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_tmp_3.o \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_4.base \ @@ -885,7 +886,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_6$(EXEEXT) \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_copy_test$(EXEEXT) \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_common_test_1$(EXEEXT) \ -@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_comdat_test_1$(EXEEXT) +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_comdat_test_1$(EXEEXT) \ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_x86_64_bnd_test$(EXEEXT) basic_pic_test_SOURCES = basic_pic_test.c basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT) basic_pic_test_LDADD = $(LDADD) @@ -1014,6 +1016,11 @@ exception_static_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ exception_test_OBJECTS = $(am_exception_test_OBJECTS) exception_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ $(exception_test_LDFLAGS) $(LDFLAGS) -o $@ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am_exception_x86_64_bnd_test_OBJECTS = exception_test_main.$(OBJEXT) +exception_x86_64_bnd_test_OBJECTS = \ + $(am_exception_x86_64_bnd_test_OBJECTS) +exception_x86_64_bnd_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ + $(exception_x86_64_bnd_test_LDFLAGS) $(LDFLAGS) -o $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@am_exclude_libs_test_OBJECTS = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ exclude_libs_test.$(OBJEXT) exclude_libs_test_OBJECTS = $(am_exclude_libs_test_OBJECTS) @@ -1772,6 +1779,7 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \ $(exception_shared_1_test_SOURCES) \ $(exception_shared_2_test_SOURCES) \ $(exception_static_test_SOURCES) $(exception_test_SOURCES) \ + $(exception_x86_64_bnd_test_SOURCES) \ $(exclude_libs_test_SOURCES) \ flagstest_compress_debug_sections.c flagstest_o_specialfile.c \ flagstest_o_specialfile_and_compress_debug_sections.c \ @@ -2590,6 +2598,12 @@ LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncvar_DEPENDENCIES = gcctestdir/ld ifuncvar.so @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncvar_LDFLAGS = -Bgcctestdir/ -Wl,-R,. @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncvar_LDADD = ifuncvar.so +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_SOURCES = exception_test_main.cc +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_DEPENDENCIES = exception_x86_64_bnd_1.o \ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_x86_64_bnd_2.o + +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_LDFLAGS = $(exception_test_LDFLAGS) +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_LDADD = $(exception_x86_64_bnd_test_DEPENDENCIES) @DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 all: $(BUILT_SOURCES) @@ -2718,6 +2732,9 @@ exception_static_test$(EXEEXT): $(exception_static_test_OBJECTS) $(exception_sta exception_test$(EXEEXT): $(exception_test_OBJECTS) $(exception_test_DEPENDENCIES) @rm -f exception_test$(EXEEXT) $(exception_test_LINK) $(exception_test_OBJECTS) $(exception_test_LDADD) $(LIBS) +exception_x86_64_bnd_test$(EXEEXT): $(exception_x86_64_bnd_test_OBJECTS) $(exception_x86_64_bnd_test_DEPENDENCIES) + @rm -f exception_x86_64_bnd_test$(EXEEXT) + $(exception_x86_64_bnd_test_LINK) $(exception_x86_64_bnd_test_OBJECTS) $(exception_x86_64_bnd_test_LDADD) $(LIBS) exclude_libs_test$(EXEEXT): $(exclude_libs_test_OBJECTS) $(exclude_libs_test_DEPENDENCIES) @rm -f exclude_libs_test$(EXEEXT) $(exclude_libs_test_LINK) $(exclude_libs_test_OBJECTS) $(exclude_libs_test_LDADD) $(LIBS) @@ -4231,6 +4248,8 @@ incremental_common_test_1.log: incremental_common_test_1$(EXEEXT) @p='incremental_common_test_1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) incremental_comdat_test_1.log: incremental_comdat_test_1$(EXEEXT) @p='incremental_comdat_test_1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +exception_x86_64_bnd_test.log: exception_x86_64_bnd_test$(EXEEXT) + @p='exception_x86_64_bnd_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) .test.log: @p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @@ -5390,6 +5409,10 @@ uninstall-am: @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ @sleep 1 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ cp -f incr_comdat_test_2_v3.o incr_comdat_test_1_tmp.o @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_1.o: exception_test_1.cc +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $< +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_2.o: exception_test_2.cc +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $< @NATIVE_OR_CROSS_LINKER_TRUE@script_test_10.o: script_test_10.s @NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -o $@ $< @NATIVE_OR_CROSS_LINKER_TRUE@script_test_10: $(srcdir)/script_test_10.t script_test_10.o gcctestdir/ld diff --git a/gold/x86_64.cc b/gold/x86_64.cc index b9f9f17..a0c4fce 100644 --- a/gold/x86_64.cc +++ b/gold/x86_64.cc @@ -2113,12 +2113,14 @@ Target_x86_64<size>::Scan::get_reference_flags(unsigned int r_type) case elfcpp::R_X86_64_PC64: case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: case elfcpp::R_X86_64_PC16: case elfcpp::R_X86_64_PC8: case elfcpp::R_X86_64_GOTOFF64: return Symbol::RELATIVE_REF; case elfcpp::R_X86_64_PLT32: + case elfcpp::R_X86_64_PLT32_BND: case elfcpp::R_X86_64_PLTOFF64: return Symbol::FUNCTION_CALL | Symbol::RELATIVE_REF; @@ -2200,6 +2202,7 @@ Target_x86_64<size>::Scan::check_non_pic(Relobj* object, unsigned int r_type, // glibc supports these reloc types, but they can overflow. case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: // A PC relative reference is OK against a local symbol or if // the symbol is defined locally. if (gsym == NULL @@ -2219,12 +2222,28 @@ Target_x86_64<size>::Scan::check_non_pic(Relobj* object, unsigned int r_type, object->error(_("requires dynamic R_X86_64_32 reloc which may " "overflow at runtime; recompile with -fPIC")); else - object->error(_("requires dynamic %s reloc against '%s' which may " - "overflow at runtime; recompile with -fPIC"), - (r_type == elfcpp::R_X86_64_32 - ? "R_X86_64_32" - : "R_X86_64_PC32"), - gsym->name()); + { + const char *r_name; + switch (r_type) + { + case elfcpp::R_X86_64_32: + r_name = "R_X86_64_32"; + break; + case elfcpp::R_X86_64_PC32: + r_name = "R_X86_64_PC32"; + break; + case elfcpp::R_X86_64_PC32_BND: + r_name = "R_X86_64_PC32_BND"; + break; + default: + gold_unreachable(); + break; + } + object->error(_("requires dynamic %s reloc against '%s' " + "which may overflow at runtime; recompile " + "with -fPIC"), + r_name, gsym->name()); + } this->issued_non_pic_error_ = true; return; @@ -2368,11 +2387,13 @@ Target_x86_64<size>::Scan::local(Symbol_table* symtab, case elfcpp::R_X86_64_PC64: case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: case elfcpp::R_X86_64_PC16: case elfcpp::R_X86_64_PC8: break; case elfcpp::R_X86_64_PLT32: + case elfcpp::R_X86_64_PLT32_BND: // Since we know this is a local symbol, we can handle this as a // PC32 reloc. break; @@ -2765,6 +2786,7 @@ Target_x86_64<size>::Scan::global(Symbol_table* symtab, case elfcpp::R_X86_64_PC64: case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: case elfcpp::R_X86_64_PC16: case elfcpp::R_X86_64_PC8: { @@ -2869,6 +2891,7 @@ Target_x86_64<size>::Scan::global(Symbol_table* symtab, break; case elfcpp::R_X86_64_PLT32: + case elfcpp::R_X86_64_PLT32_BND: // If the symbol is fully resolved, this is just a PC32 reloc. // Otherwise we need a PLT entry. if (gsym->final_value_is_known()) @@ -3217,6 +3240,8 @@ Target_x86_64<size>::Relocate::relocate( if (this->skip_call_tls_get_addr_) { if ((r_type != elfcpp::R_X86_64_PLT32 + && r_type != elfcpp::R_X86_64_PLT32_BND + && r_type != elfcpp::R_X86_64_PC32_BND && r_type != elfcpp::R_X86_64_PC32) || gsym == NULL || strcmp(gsym->name(), "__tls_get_addr") != 0) @@ -3320,6 +3345,7 @@ Target_x86_64<size>::Relocate::relocate( break; case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: Relocate_functions<size, false>::pcrela32(view, object, psymval, addend, address); break; @@ -3343,6 +3369,7 @@ Target_x86_64<size>::Relocate::relocate( break; case elfcpp::R_X86_64_PLT32: + case elfcpp::R_X86_64_PLT32_BND: gold_assert(gsym == NULL || gsym->has_plt_offset() || gsym->final_value_is_known() @@ -4151,7 +4178,9 @@ Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc( case elfcpp::R_X86_64_32: case elfcpp::R_X86_64_32S: case elfcpp::R_X86_64_PC32: + case elfcpp::R_X86_64_PC32_BND: case elfcpp::R_X86_64_PLT32: + case elfcpp::R_X86_64_PLT32_BND: case elfcpp::R_X86_64_GOTPC32: case elfcpp::R_X86_64_GOT32: return 4; |