Linker plugins should be aware of --defsym during symbol resolution

Sriraman Tallam via binutils binutils@sourceware.org
Thu Feb 15 23:31:00 GMT 2018


On Thu, Feb 15, 2018 at 2:21 PM, Cary Coutant <ccoutant@gmail.com> wrote:
>> * 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.
>
> +// Populates the set with symbols used in defsym LHS.
> +
> +void Script_options::find_defsym_defs(Unordered_set<std::string>& defsym_set)
> +{
> +  for (Symbol_assignments::const_iterator p =
> this->symbol_assignments_.begin();
> +       p != this->symbol_assignments_.end();
> +       ++p)
> +    {
> +      if ((*p)->is_defsym())
> +        defsym_set.insert((*p)->name());
> +    }
> +}
> +
> +void
> +Script_options::set_defsym_uses_in_real_elf(Symbol_table* symtab) const
> +{
> +  for (Symbol_assignments::const_iterator p =
> this->symbol_assignments_.begin();
> +       p != this->symbol_assignments_.end();
> +       ++p)
> +    {
> +      if ((*p)->is_defsym())
> +        (*p)->value()->set_expr_sym_in_real_elf(symtab);
> +    }
> +}
>
> Are you intentionally excluding symbols defined in scripts? It seems
> to me that they should be treated the same as --defsym.

Ok,  it is just that I do not have test cases with scripts and I
haven't looked into creating a few yet.  If this is as simple as
omitting the is_defsym() check then I can make that change.


>
> +  // 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; }
>
> Omit "return;".
>
> -cary



More information about the Binutils mailing list