From 3281b315c89caf1d539a316e41cc095e46482f75 Mon Sep 17 00:00:00 2001 From: Sriraman Tallam Date: Thu, 15 Feb 2018 17:35:16 -0800 Subject: Fix symbol resolution with linker plugins for defsym symbols. 2018-02-07 Sriraman Tallam * expression.cc (Symbol_expression::set_expr_sym_in_real_elf): New method. (Unary_expression::set_expr_sym_in_real_elf): New method. (Binary_expression::set_expr_sym_in_real_elf): New method. (Trinary_expression::set_expr_sym_in_real_elf): New method. * plugin.cc (get_symbol_resolution_info): Fix symbol resolution if defined or used in defsyms. * plugin.h (Plugin_manager::is_defsym_def): New method. (Plugin_manager::Plugin_manager): Initialize defsym_defines_set_. (Plugin_manager::defsym_defines_set_): New member. (Plugin_manager::Defsym_defines_set): New typedef. * script.cc (Script_options::set_defsym_uses_in_real_elf): New method. (Script_options::find_defsym_defs): New method. * script.h (Expression::set_expr_sym_in_real_elf): New method. (Symbol_assignment::is_defsym): New method. (Symbol_assignment::value): New method. (Script_options::find_defsym_defs): New method. (Script_options::set_defsym_uses_in_real_elf): New method. * testsuite/Makefile.am (plugin_test_defsym): New test. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c: Check for new symbol resolution. * testsuite/plugin_test_defsym.sh: New script. * testsuite/plugin_test_defsym.c: New test source. --- gold/expression.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'gold/expression.cc') diff --git a/gold/expression.cc b/gold/expression.cc index d764cc2..bbfaa1e 100644 --- a/gold/expression.cc +++ b/gold/expression.cc @@ -206,6 +206,14 @@ class Symbol_expression : public Expression value(const Expression_eval_info*); void + set_expr_sym_in_real_elf(Symbol_table* symtab) const + { + Symbol* sym = symtab->lookup(this->name_.c_str()); + if (sym != NULL) + sym->set_in_real_elf(); + } + + void print(FILE* f) const { fprintf(f, "%s", this->name_.c_str()); } @@ -318,6 +326,10 @@ class Unary_expression : public Expression arg_print(FILE* f) const { this->arg_->print(f); } + void + set_expr_sym_in_real_elf(Symbol_table* symtab) const + { return this->arg_->set_expr_sym_in_real_elf(symtab); } + private: Expression* arg_; }; @@ -437,6 +449,13 @@ class Binary_expression : public Expression fprintf(f, ")"); } + void + set_expr_sym_in_real_elf(Symbol_table* symtab) const + { + this->left_->set_expr_sym_in_real_elf(symtab); + this->right_->set_expr_sym_in_real_elf(symtab); + } + private: Expression* left_; Expression* right_; @@ -622,6 +641,14 @@ class Trinary_expression : public Expression arg3_print(FILE* f) const { this->arg3_->print(f); } + void + set_expr_sym_in_real_elf(Symbol_table* symtab) const + { + this->arg1_->set_expr_sym_in_real_elf(symtab); + this->arg2_->set_expr_sym_in_real_elf(symtab); + this->arg3_->set_expr_sym_in_real_elf(symtab); + } + private: Expression* arg1_; Expression* arg2_; -- cgit v1.1