diff options
author | Cary Coutant <ccoutant@google.com> | 2014-07-08 22:34:27 -0700 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2014-07-08 22:52:37 -0700 |
commit | e051745c838bf29e564fb2665339f97c8383b9e8 (patch) | |
tree | f95cb0a6f37660cfa33bacef128b335f4dc678e3 /gold/script.cc | |
parent | ecf3e831f71257e8ff7bf794f394f23b26d75137 (diff) | |
download | gdb-e051745c838bf29e564fb2665339f97c8383b9e8.zip gdb-e051745c838bf29e564fb2665339f97c8383b9e8.tar.gz gdb-e051745c838bf29e564fb2665339f97c8383b9e8.tar.bz2 |
Fix --defsym to copy symbol attributes.
Alan Modra committed a patch to Gnu ld to fix a problem encountered on
PPC where the --defsym option wasn't copying the st_other bits to the
newly-defined symbol.
https://sourceware.org/ml/binutils/2014-07/msg00094.html
Gold has the same problem, and additionally wasn't copying the symbol type.
This patch fixes both problems, by copying the symbol type, visibility, and
the remaining st_other bits to the new symbol for --defsym=sym1=sym2
assignments.
gold/
* expression.cc (struct Expression::Expression_eval_info): Add
new fields type_pointer, vis_pointer, and nonvis_pointer.
(Expression::eval_maybe_dot): Add type_pointer, vis_pointer, and
nonvis_pointer parameters. Adjust all calls.
(Symbol_expression::value): Update type, visibility, and nonvis bits
in caller.
* script.cc (Symbol_assignment::sized_finalize): Update type,
visibility, and remaining st_other bits for new symbol.
* script.h: (Expression::eval_maybe_dot): Add type_pointer,
vis_pointer, and nonvis_pointer parameters.
* symtab.h (Symbol::set_type): New method.
* testsuite/Makefile.am (defsym_test): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/defsym_test.c: New file.
* testsuite/defsym_test.sh: New file.
Diffstat (limited to 'gold/script.cc')
-rw-r--r-- | gold/script.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/gold/script.cc b/gold/script.cc index b4a6aff..eff9a81 100644 --- a/gold/script.cc +++ b/gold/script.cc @@ -980,12 +980,19 @@ Symbol_assignment::sized_finalize(Symbol_table* symtab, const Layout* layout, Output_section* dot_section) { Output_section* section; + elfcpp::STT type = elfcpp::STT_NOTYPE; + elfcpp::STV vis = elfcpp::STV_DEFAULT; + unsigned char nonvis = 0; uint64_t final_val = this->val_->eval_maybe_dot(symtab, layout, true, is_dot_available, dot_value, dot_section, - §ion, NULL, false); + §ion, NULL, &type, + &vis, &nonvis, false); Sized_symbol<size>* ssym = symtab->get_sized_symbol<size>(this->sym_); ssym->set_value(final_val); + ssym->set_type(type); + ssym->set_visibility(vis); + ssym->set_nonvis(nonvis); if (section != NULL) ssym->set_output_section(section); } @@ -1005,7 +1012,7 @@ Symbol_assignment::set_if_absolute(Symbol_table* symtab, const Layout* layout, uint64_t val = this->val_->eval_maybe_dot(symtab, layout, false, is_dot_available, dot_value, dot_section, &val_section, NULL, - false); + NULL, NULL, NULL, false); if (val_section != NULL && val_section != dot_section) return; |