diff options
author | Cary Coutant <ccoutant@google.com> | 2010-07-09 01:34:31 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2010-07-09 01:34:31 +0000 |
commit | ce279a62c420e20c2d33e89641b6d9ed581a90c2 (patch) | |
tree | 10299dc3eb7f6c0fddb969fa11ae0dc079165aa0 /gold/symtab.cc | |
parent | 2ee2fea80422d6e481541aa20a5d4e26ca8f0192 (diff) | |
download | gdb-ce279a62c420e20c2d33e89641b6d9ed581a90c2.zip gdb-ce279a62c420e20c2d33e89641b6d9ed581a90c2.tar.gz gdb-ce279a62c420e20c2d33e89641b6d9ed581a90c2.tar.bz2 |
* resolve.cc (Symbol_table::resolve): Remember whether undef was
weak when resolving to a dynamic def.
(Symbol_table::should_override): Add adjust_dyndef flag; set it
for weak undef/dynamic def cases. Adjust callers.
* symtab.cc (Symbol::init_fields): Initialize undef_binding_set_ and
undef_binding_weak_.
(Symbol_table::sized_write_globals): Adjust symbol binding.
(Symbol_table::sized_write_symbol): Add binding parameter.
* symtab.h (Symbol::set_undef_binding): New method.
(Symbol::is_undef_binding_weak): New method.
(Symbol::undef_binding_set_, Symbol::undef_binding_weak_): New members.
(Symbol_table::should_override): Add new parameter.
(Symbol_table::sized_write_symbol): Add new parameter.
* testsuite/weak_undef_file1.cc: Add new test case.
* testsuite/weak_undef_file2.cc: Fix header comment.
* testsuite/weak_undef_test.cc: Add new test case.
Diffstat (limited to 'gold/symtab.cc')
-rw-r--r-- | gold/symtab.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/gold/symtab.cc b/gold/symtab.cc index c721ae4..a29e6ad 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -76,6 +76,8 @@ Symbol::init_fields(const char* name, const char* version, this->is_ordinary_shndx_ = false; this->in_real_elf_ = false; this->is_defined_in_discarded_section_ = false; + this->undef_binding_set_ = false; + this->undef_binding_weak_ = false; } // Return the demangled version of the symbol's name, but only @@ -2697,6 +2699,7 @@ Symbol_table::sized_write_globals(const Stringpool* sympool, unsigned int shndx; typename elfcpp::Elf_types<size>::Elf_Addr sym_value = sym->value(); typename elfcpp::Elf_types<size>::Elf_Addr dynsym_value = sym_value; + elfcpp::STB binding = sym->binding(); switch (sym->source()) { case Symbol::FROM_OBJECT: @@ -2720,6 +2723,8 @@ Symbol_table::sized_write_globals(const Stringpool* sympool, if (sym->needs_dynsym_value()) dynsym_value = target.dynsym_value(sym); shndx = elfcpp::SHN_UNDEF; + if (sym->is_undef_binding_weak()) + binding = elfcpp::STB_WEAK; } else if (symobj->pluginobj() != NULL) shndx = elfcpp::SHN_UNDEF; @@ -2800,7 +2805,7 @@ Symbol_table::sized_write_globals(const Stringpool* sympool, gold_assert(sym_index < output_count); unsigned char* ps = psyms + (sym_index * sym_size); this->sized_write_symbol<size, big_endian>(sym, sym_value, shndx, - sympool, ps); + binding, sympool, ps); } if (dynsym_index != -1U) @@ -2809,7 +2814,7 @@ Symbol_table::sized_write_globals(const Stringpool* sympool, gold_assert(dynsym_index < dynamic_count); unsigned char* pd = dynamic_view + (dynsym_index * sym_size); this->sized_write_symbol<size, big_endian>(sym, dynsym_value, shndx, - dynpool, pd); + binding, dynpool, pd); } } @@ -2827,6 +2832,7 @@ Symbol_table::sized_write_symbol( Sized_symbol<size>* sym, typename elfcpp::Elf_types<size>::Elf_Addr value, unsigned int shndx, + elfcpp::STB binding, const Stringpool* pool, unsigned char* p) const { @@ -2847,7 +2853,7 @@ Symbol_table::sized_write_symbol( if (sym->is_forced_local()) osym.put_st_info(elfcpp::elf_st_info(elfcpp::STB_LOCAL, type)); else - osym.put_st_info(elfcpp::elf_st_info(sym->binding(), type)); + osym.put_st_info(elfcpp::elf_st_info(binding, type)); osym.put_st_other(elfcpp::elf_st_other(sym->visibility(), sym->nonvis())); osym.put_st_shndx(shndx); } |