diff options
author | Alan Modra <amodra@gmail.com> | 2017-11-27 13:40:43 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-11-28 22:57:00 +1030 |
commit | 165f707ac88916aedecc96fa518be8879704d6da (patch) | |
tree | 8ca3d6cbc5f8a0a0154ff5686e71a964a932966d /ld/ldlang.c | |
parent | Copying symbol type in ld script assignments (diff) | |
download | binutils-gdb-165f707ac88916aedecc96fa518be8879704d6da.tar.gz binutils-gdb-165f707ac88916aedecc96fa518be8879704d6da.tar.bz2 binutils-gdb-165f707ac88916aedecc96fa518be8879704d6da.zip |
PR22471, undefined reference to linker-defined symbols
This patch processes linker script assignment statements before ld
opens DT_NEEDED libraries, in order to define symbols like __bss_start
that might also be defined by a library, falsely triggering an error
about "DSO missing from command line".
The initial value won't be correct when assigning a symbol from dot,
and I make no attempt to handle all expressions. For example, an
assignment like "_start_foo = ADDR (.foo)" isn't valid until sections
are laid out, so won't define _start_foo early. What's here should be
enough for most common scripts, and hopefully won't perturb fragile
scripts.
bfd/
PR 22471
* elflink.c (_bfd_elf_merge_symbol): Allow weak symbols to override
early passes over linker script symbols.
* linker.c (_bfd_generic_link_add_one_symbol): Allow symbols to
override early passes over linker script symbols. Clear ldscript_def
on symbol definitions.
ld/
PR 22471
* ldexp.c (struct definedness_hash_entry): Delete "by_script". Make
"iteration" an 8-bit field, and update mask in all uses.
(definedness_newfunc): Don't init "by_script".
(update_definedness): Test ldscript_def rather than by_script.
(is_sym_value): Likewise.
(fold_name <DEFINED>): Return a result for first phase. Test
ldscript_def.
(fold_name <NAME>): Return a result for first phase.
* ldlang.c (open_input_bfds): Process all assignments, not just
defsym.
(lang_process): Increment lang_statement_iteration before
open_input_bfds.
* testsuite/ld-mips-elf/tlsdyn-o32-1.d: Adjust for larger .dynsym.
* testsuite/ld-mips-elf/tlsdyn-o32-1.got: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-2.d: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-2.got: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-3.d: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-3.got: Likewise.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c index 674004ee389..bf1b5d31ed5 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -3359,9 +3359,7 @@ open_input_bfds (lang_statement_union_type *s, enum open_bfd_mode mode) #endif break; case lang_assignment_statement_enum: - if (s->assignment_statement.exp->type.node_class != etree_assert - && s->assignment_statement.exp->assign.defsym) - /* This is from a --defsym on the command line. */ + if (s->assignment_statement.exp->type.node_class != etree_assert) exp_fold_tree_no_dot (s->assignment_statement.exp); break; default: @@ -7167,6 +7165,7 @@ lang_process (void) /* Create a bfd for each input file. */ current_target = default_target; + lang_statement_iteration++; open_input_bfds (statement_list.head, OPEN_BFD_NORMAL); #ifdef ENABLE_PLUGINS @@ -7222,6 +7221,7 @@ lang_process (void) /* Rescan archives in case new undefined symbols have appeared. */ files = file_chain; + lang_statement_iteration++; open_input_bfds (statement_list.head, OPEN_BFD_RESCAN); lang_list_remove_tail (&file_chain, &files); while (files.head != NULL) |