Correct handling of GOT references in a regular object.
This commit is contained in:
parent
4247714778
commit
386c048c7a
5 changed files with 60 additions and 4 deletions
|
@ -1046,9 +1046,10 @@ Target_i386::Scan::global(const General_options& options,
|
|||
if (!gsym->final_value_is_known())
|
||||
{
|
||||
Reloc_section* rel_dyn = target->rel_dyn_section(layout);
|
||||
if (gsym->is_preemptible())
|
||||
rel_dyn->add_global(gsym, elfcpp::R_386_GLOB_DAT, got,
|
||||
gsym->got_offset());
|
||||
if (gsym->is_from_dynobj()
|
||||
|| gsym->is_preemptible())
|
||||
rel_dyn->add_global(gsym, elfcpp::R_386_GLOB_DAT, got,
|
||||
gsym->got_offset());
|
||||
else
|
||||
{
|
||||
rel_dyn->add_local(object, 0, elfcpp::R_386_RELATIVE,
|
||||
|
|
|
@ -405,6 +405,10 @@ class Symbol
|
|||
bool
|
||||
is_preemptible() const
|
||||
{
|
||||
// It doesn't make sense to ask whether a symbol defined in
|
||||
// another object is preemptible.
|
||||
gold_assert(!this->is_from_dynobj());
|
||||
|
||||
return (this->visibility_ != elfcpp::STV_INTERNAL
|
||||
&& this->visibility_ != elfcpp::STV_HIDDEN
|
||||
&& this->visibility_ != elfcpp::STV_PROTECTED
|
||||
|
|
|
@ -42,6 +42,8 @@ NATIVE_PROGS = \
|
|||
two_file_pic_test \
|
||||
two_file_shared_1_test \
|
||||
two_file_shared_2_test \
|
||||
two_file_shared_1_pic_2_test \
|
||||
two_file_shared_2_pic_1_test \
|
||||
two_file_same_shared_test \
|
||||
two_file_separate_shared_12_test \
|
||||
two_file_separate_shared_21_test \
|
||||
|
@ -182,6 +184,18 @@ two_file_shared_2_test_DEPENDENCIES = gcctestdir/ld two_file_shared_2.so
|
|||
two_file_shared_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
|
||||
two_file_shared_2_test_LDADD = two_file_shared_2.so
|
||||
|
||||
two_file_shared_1_pic_2_test_SOURCES = two_file_test_main.cc
|
||||
two_file_shared_1_pic_2_test_DEPENDENCIES = \
|
||||
gcctestdir/ld two_file_shared_1.so two_file_test_1_pic.o
|
||||
two_file_shared_1_pic_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
|
||||
two_file_shared_1_pic_2_test_LDADD = two_file_test_1_pic.o two_file_shared_2.so
|
||||
|
||||
two_file_shared_2_pic_1_test_SOURCES = two_file_test_main.cc
|
||||
two_file_shared_2_pic_1_test_DEPENDENCIES = \
|
||||
gcctestdir/ld two_file_shared_2.so two_file_test_2_pic.o
|
||||
two_file_shared_2_pic_1_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
|
||||
two_file_shared_2_pic_1_test_LDADD = two_file_test_2_pic.o two_file_shared_1.so
|
||||
|
||||
two_file_same_shared_test_SOURCES = two_file_test_main.cc
|
||||
two_file_same_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared.so
|
||||
two_file_same_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
|
||||
|
|
|
@ -156,6 +156,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
|
|||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_pic_test$(EXEEXT) \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared_1_test$(EXEEXT) \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared_2_test$(EXEEXT) \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared_1_pic_2_test$(EXEEXT) \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared_2_pic_1_test$(EXEEXT) \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_same_shared_test$(EXEEXT) \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_12_test$(EXEEXT) \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_21_test$(EXEEXT) \
|
||||
|
@ -302,6 +304,11 @@ am__two_file_shared_1_nonpic_test_SOURCES_DIST = two_file_test_2.cc \
|
|||
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_main.$(OBJEXT)
|
||||
two_file_shared_1_nonpic_test_OBJECTS = \
|
||||
$(am_two_file_shared_1_nonpic_test_OBJECTS)
|
||||
am__two_file_shared_1_pic_2_test_SOURCES_DIST = two_file_test_main.cc
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_two_file_shared_1_pic_2_test_OBJECTS = \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_main.$(OBJEXT)
|
||||
two_file_shared_1_pic_2_test_OBJECTS = \
|
||||
$(am_two_file_shared_1_pic_2_test_OBJECTS)
|
||||
am__two_file_shared_1_test_SOURCES_DIST = two_file_test_2.cc \
|
||||
two_file_test_main.cc
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_two_file_shared_1_test_OBJECTS = \
|
||||
|
@ -314,6 +321,11 @@ am__two_file_shared_2_nonpic_test_SOURCES_DIST = two_file_test_1.cc \
|
|||
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_main.$(OBJEXT)
|
||||
two_file_shared_2_nonpic_test_OBJECTS = \
|
||||
$(am_two_file_shared_2_nonpic_test_OBJECTS)
|
||||
am__two_file_shared_2_pic_1_test_SOURCES_DIST = two_file_test_main.cc
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_two_file_shared_2_pic_1_test_OBJECTS = \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_main.$(OBJEXT)
|
||||
two_file_shared_2_pic_1_test_OBJECTS = \
|
||||
$(am_two_file_shared_2_pic_1_test_OBJECTS)
|
||||
am__two_file_shared_2_test_SOURCES_DIST = two_file_test_1.cc \
|
||||
two_file_test_main.cc
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_two_file_shared_2_test_OBJECTS = \
|
||||
|
@ -375,8 +387,10 @@ SOURCES = $(libgoldtest_a_SOURCES) $(constructor_static_test_SOURCES) \
|
|||
$(two_file_separate_shared_21_nonpic_test_SOURCES) \
|
||||
$(two_file_separate_shared_21_test_SOURCES) \
|
||||
$(two_file_shared_1_nonpic_test_SOURCES) \
|
||||
$(two_file_shared_1_pic_2_test_SOURCES) \
|
||||
$(two_file_shared_1_test_SOURCES) \
|
||||
$(two_file_shared_2_nonpic_test_SOURCES) \
|
||||
$(two_file_shared_2_pic_1_test_SOURCES) \
|
||||
$(two_file_shared_2_test_SOURCES) \
|
||||
$(two_file_static_test_SOURCES) $(two_file_test_SOURCES) \
|
||||
$(weak_test_SOURCES)
|
||||
|
@ -404,8 +418,10 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) \
|
|||
$(am__two_file_separate_shared_21_nonpic_test_SOURCES_DIST) \
|
||||
$(am__two_file_separate_shared_21_test_SOURCES_DIST) \
|
||||
$(am__two_file_shared_1_nonpic_test_SOURCES_DIST) \
|
||||
$(am__two_file_shared_1_pic_2_test_SOURCES_DIST) \
|
||||
$(am__two_file_shared_1_test_SOURCES_DIST) \
|
||||
$(am__two_file_shared_2_nonpic_test_SOURCES_DIST) \
|
||||
$(am__two_file_shared_2_pic_1_test_SOURCES_DIST) \
|
||||
$(am__two_file_shared_2_test_SOURCES_DIST) \
|
||||
$(am__two_file_static_test_SOURCES_DIST) \
|
||||
$(am__two_file_test_SOURCES_DIST) \
|
||||
|
@ -564,6 +580,8 @@ TESTS = object_unittest $(am__append_1) $(NATIVE_TESTING)
|
|||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_pic_test \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared_1_test \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared_2_test \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared_1_pic_2_test \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared_2_pic_1_test \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_same_shared_test \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_12_test \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_21_test \
|
||||
|
@ -626,6 +644,18 @@ object_unittest_SOURCES = object_unittest.cc
|
|||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_2_test_DEPENDENCIES = gcctestdir/ld two_file_shared_2.so
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_2_test_LDADD = two_file_shared_2.so
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_1_pic_2_test_SOURCES = two_file_test_main.cc
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_1_pic_2_test_DEPENDENCIES = \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gcctestdir/ld two_file_shared_1.so two_file_test_1_pic.o
|
||||
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_1_pic_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_1_pic_2_test_LDADD = two_file_test_1_pic.o two_file_shared_2.so
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_2_pic_1_test_SOURCES = two_file_test_main.cc
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_2_pic_1_test_DEPENDENCIES = \
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gcctestdir/ld two_file_shared_2.so two_file_test_2_pic.o
|
||||
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_2_pic_1_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_2_pic_1_test_LDADD = two_file_test_2_pic.o two_file_shared_1.so
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_same_shared_test_SOURCES = two_file_test_main.cc
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_same_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared.so
|
||||
@GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_same_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
|
||||
|
@ -871,12 +901,18 @@ two_file_separate_shared_21_test$(EXEEXT): $(two_file_separate_shared_21_test_OB
|
|||
two_file_shared_1_nonpic_test$(EXEEXT): $(two_file_shared_1_nonpic_test_OBJECTS) $(two_file_shared_1_nonpic_test_DEPENDENCIES)
|
||||
@rm -f two_file_shared_1_nonpic_test$(EXEEXT)
|
||||
$(CXXLINK) $(two_file_shared_1_nonpic_test_LDFLAGS) $(two_file_shared_1_nonpic_test_OBJECTS) $(two_file_shared_1_nonpic_test_LDADD) $(LIBS)
|
||||
two_file_shared_1_pic_2_test$(EXEEXT): $(two_file_shared_1_pic_2_test_OBJECTS) $(two_file_shared_1_pic_2_test_DEPENDENCIES)
|
||||
@rm -f two_file_shared_1_pic_2_test$(EXEEXT)
|
||||
$(CXXLINK) $(two_file_shared_1_pic_2_test_LDFLAGS) $(two_file_shared_1_pic_2_test_OBJECTS) $(two_file_shared_1_pic_2_test_LDADD) $(LIBS)
|
||||
two_file_shared_1_test$(EXEEXT): $(two_file_shared_1_test_OBJECTS) $(two_file_shared_1_test_DEPENDENCIES)
|
||||
@rm -f two_file_shared_1_test$(EXEEXT)
|
||||
$(CXXLINK) $(two_file_shared_1_test_LDFLAGS) $(two_file_shared_1_test_OBJECTS) $(two_file_shared_1_test_LDADD) $(LIBS)
|
||||
two_file_shared_2_nonpic_test$(EXEEXT): $(two_file_shared_2_nonpic_test_OBJECTS) $(two_file_shared_2_nonpic_test_DEPENDENCIES)
|
||||
@rm -f two_file_shared_2_nonpic_test$(EXEEXT)
|
||||
$(CXXLINK) $(two_file_shared_2_nonpic_test_LDFLAGS) $(two_file_shared_2_nonpic_test_OBJECTS) $(two_file_shared_2_nonpic_test_LDADD) $(LIBS)
|
||||
two_file_shared_2_pic_1_test$(EXEEXT): $(two_file_shared_2_pic_1_test_OBJECTS) $(two_file_shared_2_pic_1_test_DEPENDENCIES)
|
||||
@rm -f two_file_shared_2_pic_1_test$(EXEEXT)
|
||||
$(CXXLINK) $(two_file_shared_2_pic_1_test_LDFLAGS) $(two_file_shared_2_pic_1_test_OBJECTS) $(two_file_shared_2_pic_1_test_LDADD) $(LIBS)
|
||||
two_file_shared_2_test$(EXEEXT): $(two_file_shared_2_test_OBJECTS) $(two_file_shared_2_test_DEPENDENCIES)
|
||||
@rm -f two_file_shared_2_test$(EXEEXT)
|
||||
$(CXXLINK) $(two_file_shared_2_test_LDFLAGS) $(two_file_shared_2_test_OBJECTS) $(two_file_shared_2_test_LDADD) $(LIBS)
|
||||
|
|
|
@ -1020,7 +1020,8 @@ Target_x86_64::Scan::global(const General_options& options,
|
|||
if (!gsym->final_value_is_known())
|
||||
{
|
||||
Reloc_section* rela_dyn = target->rela_dyn_section(layout);
|
||||
if (gsym->is_preemptible())
|
||||
if (gsym->is_from_dynobj()
|
||||
|| gsym->is_preemptible())
|
||||
rela_dyn->add_global(gsym, elfcpp::R_X86_64_GLOB_DAT, got,
|
||||
gsym->got_offset(), 0);
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue