aboutsummaryrefslogtreecommitdiff
path: root/gold/script.h
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2018-02-15 17:35:16 -0800
committerSriraman Tallam <tmsriram@google.com>2018-02-15 17:35:16 -0800
commit3281b315c89caf1d539a316e41cc095e46482f75 (patch)
treec324284c8a21bf2bac30f2bb5678cbb430e63867 /gold/script.h
parent43859909e2982252d136e19258431f3aa8afb890 (diff)
downloadgdb-3281b315c89caf1d539a316e41cc095e46482f75.zip
gdb-3281b315c89caf1d539a316e41cc095e46482f75.tar.gz
gdb-3281b315c89caf1d539a316e41cc095e46482f75.tar.bz2
Fix symbol resolution with linker plugins for defsym symbols.
2018-02-07 Sriraman Tallam <tmsriram@google.com> * 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.
Diffstat (limited to 'gold/script.h')
-rw-r--r--gold/script.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/gold/script.h b/gold/script.h
index ec8ce8e..aaf825a 100644
--- a/gold/script.h
+++ b/gold/script.h
@@ -129,13 +129,17 @@ class Expression
virtual uint64_t
value(const Expression_eval_info*) = 0;
+ // Sets all symbols used in expressions as seen in a real ELF object.
+ virtual void
+ set_expr_sym_in_real_elf(Symbol_table*) const
+ { return; }
+
private:
// May not be copied.
Expression(const Expression&);
Expression& operator=(const Expression&);
};
-
// Version_script_info stores information parsed from the version
// script, either provided by --version-script or as part of a linker
// script. A single Version_script_info object per target is owned by
@@ -344,6 +348,14 @@ class Symbol_assignment
void
finalize(Symbol_table*, const Layout*);
+ bool
+ is_defsym() const
+ { return is_defsym_; }
+
+ Expression *
+ value() const
+ { return val_; }
+
// Finalize the symbol value when it can refer to the dot symbol.
void
finalize_with_dot(Symbol_table*, const Layout*, uint64_t dot_value,
@@ -454,6 +466,13 @@ class Script_options
bool
define_symbol(const char* definition);
+ // Populates the set with symbol names used in LHS of defsym.
+ void
+ find_defsym_defs(Unordered_set<std::string>&);
+
+ // Set symbols used in defsym expressions as seen in a real ELF object.
+ void set_defsym_uses_in_real_elf(Symbol_table*) const;
+
// Create sections required by any linker scripts.
void
create_script_sections(Layout*);