Copying symbol type in ld script assignments
authorAlan Modra <amodra@gmail.com>
Mon, 27 Nov 2017 08:13:03 +0000 (18:43 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 28 Nov 2017 12:26:59 +0000 (22:56 +1030)
commitcd5b2babea487b0a71a14b593af98330efd8d73e
tree736755eaaa569004fd116c748d77e2e0ac8f023f
parenta83ef4d139c377e0e87d105977d85c6ef9fbb162
Copying symbol type in ld script assignments

There is a call to update_definedness between code that evaluates an
assignment expression value and code that transfers symbol
attributes.  When script assignment expressions contain DEFINED, that
can mean the wrong symbol type is copied.  This patch tracks symbols
read during expression evaluation, rather than examining the
expression and re-evaluating conditionals.  Not only does this
simplify the code, it also means ld can now copy symbol types in more
complex expressions.

An unfortunate side effect of copying symbol type for more complex
expressions affects mmix, which uses
 PROVIDE (Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : _start.));
in a default script.  So now _start or _start. symbol type may be
copied, losing the function type specially set up for Main.  This can
be avoided by making bfd_copy_link_hash_symbol_type do nothing for
mmix.

bfd/
* elf64-mmix.c (bfd_elf64_bfd_copy_link_hash_symbol_type): Define.
ld/
* ldexp.h (struct ldexp_control): Add "assign_src".
* ldexp.c (fold_trinary): Save and restore assign_src around
condition evaluation.
(fold_name <NAME>): Set expld.assign_src.
(try_copy_symbol_type): Delete.
(exp_fold_tree_1): Set symbol type using expld.assign_src.
bfd/ChangeLog
bfd/elf64-mmix.c
ld/ChangeLog
ld/ldexp.c
ld/ldexp.h
This page took 0.036294 seconds and 4 git commands to generate.