aboutsummaryrefslogtreecommitdiff
path: root/ld/ldexp.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-11-27 18:43:03 +1030
committerAlan Modra <amodra@gmail.com>2017-11-28 22:56:59 +1030
commitcd5b2babea487b0a71a14b593af98330efd8d73e (patch)
tree736755eaaa569004fd116c748d77e2e0ac8f023f /ld/ldexp.h
parenta83ef4d139c377e0e87d105977d85c6ef9fbb162 (diff)
downloadgdb-cd5b2babea487b0a71a14b593af98330efd8d73e.zip
gdb-cd5b2babea487b0a71a14b593af98330efd8d73e.tar.gz
gdb-cd5b2babea487b0a71a14b593af98330efd8d73e.tar.bz2
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.
Diffstat (limited to 'ld/ldexp.h')
-rw-r--r--ld/ldexp.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/ld/ldexp.h b/ld/ldexp.h
index 5ff0fa0..189570a 100644
--- a/ld/ldexp.h
+++ b/ld/ldexp.h
@@ -163,6 +163,11 @@ struct ldexp_control {
does the false branch of a trinary expression. */
const char *assign_name;
+ /* If evaluating an assignment, the source if it is an expression
+ referencing single etree_name NAME, or a trinary expression where
+ the true branch references a single etree_name NAME. */
+ struct bfd_link_hash_entry *assign_src;
+
/* Working results. */
etree_value_type result;
bfd_vma dot;