From: Ian Lance Taylor Date: Wed, 13 Feb 2008 01:20:38 +0000 (+0000) Subject: Assignments in linker scripts override definitions from object files. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=caa9d5d9191af934ff7949fea080d72524c92cfa;p=binutils-gdb.git Assignments in linker scripts override definitions from object files. --- diff --git a/gold/dynobj.cc b/gold/dynobj.cc index b07a53030a8..780e0c902bd 100644 --- a/gold/dynobj.cc +++ b/gold/dynobj.cc @@ -1437,7 +1437,7 @@ Versions::finalize(Symbol_table* symtab, unsigned int dynsym_index, elfcpp::STT_OBJECT, elfcpp::STB_GLOBAL, elfcpp::STV_DEFAULT, 0, - false); + false, false); vsym->set_needs_dynsym_entry(); vsym->set_dynsym_index(dynsym_index); ++dynsym_index; diff --git a/gold/script.cc b/gold/script.cc index 128acae7468..321311570d6 100644 --- a/gold/script.cc +++ b/gold/script.cc @@ -895,6 +895,10 @@ class Script_unblock : public Task // necessarily evaluate the expression until all ordinary symbols have // been finalized. +// The GNU linker lets symbol assignments in the linker script +// silently override defined symbols in object files. We are +// compatible. FIXME: Should we issue a warning? + void Symbol_assignment::add_to_table(Symbol_table* symtab) { @@ -907,7 +911,8 @@ Symbol_assignment::add_to_table(Symbol_table* symtab) elfcpp::STB_GLOBAL, vis, 0, // nonvis - this->provide_); + this->provide_, + true); // force_override } // Finalize a symbol value. diff --git a/gold/symtab.cc b/gold/symtab.cc index 86d8b112fcd..86b69b4ded1 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -1332,14 +1332,16 @@ Symbol_table::define_as_constant(const char* name, elfcpp::STB binding, elfcpp::STV visibility, unsigned char nonvis, - bool only_if_ref) + bool only_if_ref, + bool force_override) { if (parameters->get_size() == 32) { #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG) return this->do_define_as_constant<32>(name, version, value, symsize, type, binding, - visibility, nonvis, only_if_ref); + visibility, nonvis, only_if_ref, + force_override); #else gold_unreachable(); #endif @@ -1349,7 +1351,8 @@ Symbol_table::define_as_constant(const char* name, #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG) return this->do_define_as_constant<64>(name, version, value, symsize, type, binding, - visibility, nonvis, only_if_ref); + visibility, nonvis, only_if_ref, + force_override); #else gold_unreachable(); #endif @@ -1371,7 +1374,8 @@ Symbol_table::do_define_as_constant( elfcpp::STB binding, elfcpp::STV visibility, unsigned char nonvis, - bool only_if_ref) + bool only_if_ref, + bool force_override) { Sized_symbol* sym; Sized_symbol* oldsym; @@ -1411,7 +1415,7 @@ Symbol_table::do_define_as_constant( return sym; } - if (Symbol_table::should_override_with_special(oldsym)) + if (force_override || Symbol_table::should_override_with_special(oldsym)) this->override_with_special(oldsym, sym); delete sym; return oldsym; @@ -1436,7 +1440,8 @@ Symbol_table::define_symbols(const Layout* layout, int count, else this->define_as_constant(p->name, NULL, 0, p->size, p->type, p->binding, p->visibility, p->nonvis, - only_if_ref || p->only_if_ref); + only_if_ref || p->only_if_ref, + false); } } @@ -1461,7 +1466,8 @@ Symbol_table::define_symbols(const Layout* layout, int count, else this->define_as_constant(p->name, NULL, 0, p->size, p->type, p->binding, p->visibility, p->nonvis, - only_if_ref || p->only_if_ref); + only_if_ref || p->only_if_ref, + false); } } diff --git a/gold/symtab.h b/gold/symtab.h index b2417f665b0..8da7a780abc 100644 --- a/gold/symtab.h +++ b/gold/symtab.h @@ -1078,7 +1078,8 @@ class Symbol_table define_as_constant(const char* name, const char* version, uint64_t value, uint64_t symsize, elfcpp::STT type, elfcpp::STB binding, elfcpp::STV visibility, - unsigned char nonvis, bool only_if_ref); + unsigned char nonvis, bool only_if_ref, + bool force_override); // Define a set of symbols in output sections. If ONLY_IF_REF is // true, only define them if they are referenced. @@ -1294,7 +1295,7 @@ class Symbol_table typename elfcpp::Elf_types::Elf_WXword ssize, elfcpp::STT type, elfcpp::STB binding, elfcpp::STV visibility, unsigned char nonvis, - bool only_if_ref); + bool only_if_ref, bool force_override); // Allocate the common symbols, sized version. template