From: Ian Lance Taylor Date: Wed, 15 Dec 2010 15:35:27 +0000 (+0000) Subject: PR gold/12324 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2fbb4320cae80e68bd80064cac06588f33546e6f;p=binutils-gdb.git PR gold/12324 * x86_64.cc (Target_x86_64::Scan::check_non_pic): Give an error for R_X86_64_32 and R_X86_64_PC32. * testsuite/Makefile.am (ver_matching_def.so): Depend on and use ver_matching_def_pic.o. (ver_matching_def_pic.o): New target. --- diff --git a/gold/ChangeLog b/gold/ChangeLog index 526fb78ae7b..d07c7f7454e 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,12 @@ +2010-12-15 Ian Lance Taylor + + PR gold/12324 + * x86_64.cc (Target_x86_64::Scan::check_non_pic): Give an error + for R_X86_64_32 and R_X86_64_PC32. + * testsuite/Makefile.am (ver_matching_def.so): Depend on and use + ver_matching_def_pic.o. + (ver_matching_def_pic.o): New target. + 2010-12-14 Ralf Wildenhues * fileread.cc (file_counts_lock, file_counts_initialize_lock) diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 530b5bea1ae..561dd5a98da 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -1146,8 +1146,10 @@ binary.txt: $(srcdir)/binary.in check_SCRIPTS += ver_matching_test.sh check_DATA += ver_matching_test.stdout MOSTLYCLEANFILES += ver_matching_test.stdout -ver_matching_def.so: ver_matching_def.cc $(srcdir)/version_script.map gcctestdir/ld - $(CXXLINK) -O0 -Bgcctestdir/ -shared $(srcdir)/ver_matching_def.cc -Wl,--version-script=$(srcdir)/version_script.map +ver_matching_def.so: ver_matching_def_pic.o $(srcdir)/version_script.map gcctestdir/ld + $(CXXLINK) -O0 -Bgcctestdir/ -shared ver_matching_def_pic.o -Wl,--version-script=$(srcdir)/version_script.map +ver_matching_def_pic.o: ver_matching_def.cc + $(CXXCOMPILE) -O0 -c -fpic -o $@ $< ver_matching_test.stdout: ver_matching_def.so $(TEST_OBJDUMP) -T ver_matching_def.so | $(TEST_CXXFILT) > ver_matching_test.stdout diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 44f38265a8f..10bed592fbf 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -4215,8 +4215,10 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@binary.txt: $(srcdir)/binary.in @GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LN_S) $< $@ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_matching_def.so: ver_matching_def.cc $(srcdir)/version_script.map gcctestdir/ld -@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -O0 -Bgcctestdir/ -shared $(srcdir)/ver_matching_def.cc -Wl,--version-script=$(srcdir)/version_script.map +@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_matching_def.so: ver_matching_def_pic.o $(srcdir)/version_script.map gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -O0 -Bgcctestdir/ -shared ver_matching_def_pic.o -Wl,--version-script=$(srcdir)/version_script.map +@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_matching_def_pic.o: ver_matching_def.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -fpic -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@ver_matching_test.stdout: ver_matching_def.so @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_OBJDUMP) -T ver_matching_def.so | $(TEST_CXXFILT) > ver_matching_test.stdout @GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_3: basic_test.o gcctestdir/ld script_test_3.t diff --git a/gold/x86_64.cc b/gold/x86_64.cc index 2dd9611901e..5ba15c45d0e 100644 --- a/gold/x86_64.cc +++ b/gold/x86_64.cc @@ -1329,7 +1329,8 @@ Target_x86_64::Scan::check_non_pic(Relobj* object, unsigned int r_type) { switch (r_type) { - // These are the relocation types supported by glibc for x86_64. + // These are the relocation types supported by glibc for x86_64 + // which should always work. case elfcpp::R_X86_64_RELATIVE: case elfcpp::R_X86_64_IRELATIVE: case elfcpp::R_X86_64_GLOB_DAT: @@ -1338,9 +1339,18 @@ Target_x86_64::Scan::check_non_pic(Relobj* object, unsigned int r_type) case elfcpp::R_X86_64_DTPOFF64: case elfcpp::R_X86_64_TPOFF64: case elfcpp::R_X86_64_64: + case elfcpp::R_X86_64_COPY: + return; + + // glibc supports these reloc types, but they can overflow. case elfcpp::R_X86_64_32: case elfcpp::R_X86_64_PC32: - case elfcpp::R_X86_64_COPY: + if (this->issued_non_pic_error_) + return; + gold_assert(parameters->options().output_is_position_independent()); + object->error(_("requires dynamic reloc which may overflow at runtime; " + "recompile with -fPIC")); + this->issued_non_pic_error_ = true; return; default: