aboutsummaryrefslogtreecommitdiff
path: root/bfd
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 /bfd
parenta83ef4d139c377e0e87d105977d85c6ef9fbb162 (diff)
downloadbinutils-cd5b2babea487b0a71a14b593af98330efd8d73e.zip
binutils-cd5b2babea487b0a71a14b593af98330efd8d73e.tar.gz
binutils-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 'bfd')
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/elf64-mmix.c3
2 files changed, 7 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index abd7c96..dc3aa2f 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+2017-11-28 Alan Modra <amodra@gmail.com>
+
+ * elf64-mmix.c (bfd_elf64_bfd_copy_link_hash_symbol_type): Define.
+
2017-11-28 H.J. Lu <hongjiu.lu@intel.com>
PR ld/22502
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index c057d34..ae6afc2 100644
--- a/bfd/elf64-mmix.c
+++ b/bfd/elf64-mmix.c
@@ -2908,6 +2908,9 @@ mmix_elf_relax_section (bfd *abfd,
#define elf_backend_omit_section_dynsym \
((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
+#define bfd_elf64_bfd_copy_link_hash_symbol_type \
+ _bfd_generic_copy_link_hash_symbol_type
+
#define bfd_elf64_bfd_is_local_label_name \
mmix_elf_is_local_label_name