* symtab.h (Symbol::needs_dynamic_reloc): Non-PIC calls from
authorCary Coutant <ccoutant@google.com>
Sun, 12 Sep 2010 19:58:02 +0000 (19:58 +0000)
committerCary Coutant <ccoutant@google.com>
Sun, 12 Sep 2010 19:58:02 +0000 (19:58 +0000)
position-independent executables to shared libraries need dynamic
relocations.
(Symbol::may_need_copy_reloc): Do not generate COPY relocs in
position-independent executables.
* testsuite/Makefile.am (two_file_mixed_pie_test): New test.
* testsuite/Makefile.in: Regenerate.

gold/ChangeLog
gold/symtab.h
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in

index df34bcf693dd609627f6c8c93453bd7c83778526..6c78bcfdc8c71ec18be1eea00b0f561e193380e7 100644 (file)
@@ -1,3 +1,13 @@
+2010-09-12  Cary Coutant  <ccoutant@google.com>
+
+       * symtab.h (Symbol::needs_dynamic_reloc): Non-PIC calls from
+       position-independent executables to shared libraries need dynamic
+       relocations.
+       (Symbol::may_need_copy_reloc): Do not generate COPY relocs in
+       position-independent executables.
+       * testsuite/Makefile.am (two_file_mixed_pie_test): New test.
+       * testsuite/Makefile.in: Regenerate.
+
 2010-09-10  Nick Clifton  <nickc@redhat.com>
 
        PR gold/11997
index e64fa1ac052225c02e51f6142aba54a0807e0574..e355b2a75cd6b89d1a6e3c823b42259f7a1fb1b6 100644 (file)
@@ -657,7 +657,8 @@ class Symbol
     // shared library cannot use a PLT entry.
     if ((flags & FUNCTION_CALL)
         && this->has_plt_offset()
-        && !((flags & NON_PIC_REF) && parameters->options().shared()))
+        && !((flags & NON_PIC_REF)
+             && parameters->options().output_is_position_independent()))
       return false;
 
     // A reference to any PLT entry in a non-position-independent executable
@@ -798,7 +799,7 @@ class Symbol
   bool
   may_need_copy_reloc() const
   {
-    return (!parameters->options().shared()
+    return (!parameters->options().output_is_position_independent()
            && parameters->options().copyreloc()
            && this->is_from_dynobj()
            && !this->is_func());
index c79c85640b676987b20fe14c848a6add3cfa74da..064f44d40f2219e2a37f21cf6a1599f3d048c045 100644 (file)
@@ -461,6 +461,11 @@ two_file_mixed_2_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared_mixed_
 two_file_mixed_2_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
 two_file_mixed_2_shared_test_LDADD = two_file_shared_mixed_1.so two_file_shared_2.so
 
+check_PROGRAMS += two_file_mixed_pie_test
+two_file_mixed_pie_test: two_file_test_1.o two_file_test_1b_pie.o \
+               two_file_test_main_pie.o two_file_shared_2.so gcctestdir/ld
+       $(CXXLINK) -Bgcctestdir/ -Wl,-R,. -pie two_file_test_1.o two_file_test_1b_pie.o two_file_test_main_pie.o two_file_shared_2.so
+
 endif FN_PTRS_IN_SO_WITHOUT_PIC
 
 check_PROGRAMS += two_file_strip_test
index cc591ef3a0bc162806fa369ccbcaa5476b3c0dc1..7f62404201f3d1d500bad73018ac9842eb2b7864 100644 (file)
@@ -160,7 +160,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_12_nonpic_test \
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_21_nonpic_test \
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_mixed_shared_test \
-@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_mixed_2_shared_test
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_mixed_2_shared_test \
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_mixed_pie_test
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_6 = two_file_strip_test \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_same_shared_strip_test \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ common_test_1 common_test_2 \
@@ -592,7 +593,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_12_nonpic_test$(EXEEXT) \
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_21_nonpic_test$(EXEEXT) \
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_mixed_shared_test$(EXEEXT) \
-@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_mixed_2_shared_test$(EXEEXT)
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_mixed_2_shared_test$(EXEEXT) \
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_mixed_pie_test$(EXEEXT)
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_3 =  \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_strip_test$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_same_shared_strip_test$(EXEEXT) \
@@ -1269,6 +1271,12 @@ two_file_mixed_2_shared_test_OBJECTS =  \
 two_file_mixed_2_shared_test_LINK = $(CXXLD) $(AM_CXXFLAGS) \
        $(CXXFLAGS) $(two_file_mixed_2_shared_test_LDFLAGS) $(LDFLAGS) \
        -o $@
+two_file_mixed_pie_test_SOURCES = two_file_mixed_pie_test.c
+two_file_mixed_pie_test_OBJECTS = two_file_mixed_pie_test.$(OBJEXT)
+two_file_mixed_pie_test_LDADD = $(LDADD)
+two_file_mixed_pie_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am_two_file_mixed_shared_test_OBJECTS = two_file_test_main.$(OBJEXT)
 two_file_mixed_shared_test_OBJECTS =  \
        $(am_two_file_mixed_shared_test_OBJECTS)
@@ -1518,6 +1526,7 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \
        $(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) \
+       two_file_mixed_pie_test.c \
        $(two_file_mixed_shared_test_SOURCES) \
        $(two_file_pic_test_SOURCES) two_file_pie_test.c \
        $(two_file_relocatable_test_SOURCES) \
@@ -2765,6 +2774,15 @@ tls_test$(EXEEXT): $(tls_test_OBJECTS) $(tls_test_DEPENDENCIES)
 two_file_mixed_2_shared_test$(EXEEXT): $(two_file_mixed_2_shared_test_OBJECTS) $(two_file_mixed_2_shared_test_DEPENDENCIES) 
        @rm -f two_file_mixed_2_shared_test$(EXEEXT)
        $(two_file_mixed_2_shared_test_LINK) $(two_file_mixed_2_shared_test_OBJECTS) $(two_file_mixed_2_shared_test_LDADD) $(LIBS)
+@FN_PTRS_IN_SO_WITHOUT_PIC_FALSE@two_file_mixed_pie_test$(EXEEXT): $(two_file_mixed_pie_test_OBJECTS) $(two_file_mixed_pie_test_DEPENDENCIES) 
+@FN_PTRS_IN_SO_WITHOUT_PIC_FALSE@      @rm -f two_file_mixed_pie_test$(EXEEXT)
+@FN_PTRS_IN_SO_WITHOUT_PIC_FALSE@      $(LINK) $(two_file_mixed_pie_test_OBJECTS) $(two_file_mixed_pie_test_LDADD) $(LIBS)
+@GCC_FALSE@two_file_mixed_pie_test$(EXEEXT): $(two_file_mixed_pie_test_OBJECTS) $(two_file_mixed_pie_test_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f two_file_mixed_pie_test$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(two_file_mixed_pie_test_OBJECTS) $(two_file_mixed_pie_test_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@two_file_mixed_pie_test$(EXEEXT): $(two_file_mixed_pie_test_OBJECTS) $(two_file_mixed_pie_test_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f two_file_mixed_pie_test$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(two_file_mixed_pie_test_OBJECTS) $(two_file_mixed_pie_test_LDADD) $(LIBS)
 two_file_mixed_shared_test$(EXEEXT): $(two_file_mixed_shared_test_OBJECTS) $(two_file_mixed_shared_test_DEPENDENCIES) 
        @rm -f two_file_mixed_shared_test$(EXEEXT)
        $(two_file_mixed_shared_test_LINK) $(two_file_mixed_shared_test_OBJECTS) $(two_file_mixed_shared_test_LDADD) $(LIBS)
@@ -2956,6 +2974,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test_file2.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test_main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two_file_mixed_pie_test.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two_file_pie_test.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two_file_strip_test.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two_file_test_1.Po@am__quote@
@@ -3380,6 +3399,8 @@ two_file_mixed_shared_test.log: two_file_mixed_shared_test$(EXEEXT)
        @p='two_file_mixed_shared_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 two_file_mixed_2_shared_test.log: two_file_mixed_2_shared_test$(EXEEXT)
        @p='two_file_mixed_2_shared_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+two_file_mixed_pie_test.log: two_file_mixed_pie_test$(EXEEXT)
+       @p='two_file_mixed_pie_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 two_file_strip_test.log: two_file_strip_test$(EXEEXT)
        @p='two_file_strip_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 two_file_same_shared_strip_test.log: two_file_same_shared_strip_test$(EXEEXT)
@@ -3877,6 +3898,9 @@ uninstall-am:
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2.o
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_mixed_1.so: two_file_test_1.o two_file_test_1b_pic.o two_file_shared_2.so gcctestdir/ld
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1.o two_file_test_1b_pic.o two_file_shared_2.so
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_mixed_pie_test: two_file_test_1.o two_file_test_1b_pie.o \
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@         two_file_test_main_pie.o two_file_shared_2.so gcctestdir/ld
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,-R,. -pie two_file_test_1.o two_file_test_1b_pie.o two_file_test_main_pie.o two_file_shared_2.so
 @GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_strip_test: two_file_test
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_STRIP) -o two_file_strip_test two_file_test
 @GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_strip.so: two_file_shared.so