From 165f707ac88916aedecc96fa518be8879704d6da Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 27 Nov 2017 13:40:43 +1030 Subject: 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 ): Return a result for first phase. Test ldscript_def. (fold_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. --- ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d') diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d index 011df6c..17e42d0 100644 --- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d +++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d @@ -5,7 +5,7 @@ Disassembly of section .text: .* <__start>: .*: 3c1c0fc0 lui gp,0xfc0 - .*: 279c7c30 addiu gp,gp,31792 + .*: 279c7b80 addiu gp,gp,31616 .*: 0399e021 addu gp,gp,t9 .*: 27bdfff0 addiu sp,sp,-16 .*: afbe0008 sw s8,8\(sp\) @@ -55,7 +55,7 @@ Disassembly of section .text: .* : .*: 3c1c0fc0 lui gp,0xfc0 - .*: 279c7b70 addiu gp,gp,31600 + .*: 279c7ac0 addiu gp,gp,31424 .*: 0399e021 addu gp,gp,t9 .*: 27bdfff0 addiu sp,sp,-16 .*: afbe0008 sw s8,8\(sp\) -- cgit v1.1