From 6c699715f68be7d8c468e965fbefce997f7ed937 Mon Sep 17 00:00:00 2001 From: Renlin Li Date: Mon, 25 Sep 2017 11:41:54 +0100 Subject: [PATCH] [ARM] PR ld/21402, only override the symbol dynamic decision on undefined weak symbol. Similar as aarch64 backend, arm backend only overrides the decision on undefined weak symbols. arm backend part already emits necessary relative relocation for this case. bfd/ PR ld/21402 * elf32-arm.c (allocate_dynrelocs_for_symbol): Only make undefined weak symbols into dynamic. ld/ PR ld/21402 * testsuite/ld-arm/tls-app.d: Update address. * testsuite/ld-arm/tls-app.r: Remove relocations. * testsuite/ld-arm/unresolved-1-dyn.d: Update. --- bfd/ChangeLog | 6 ++++++ bfd/elf32-arm.c | 12 ++++++------ ld/ChangeLog | 7 +++++++ ld/testsuite/ld-arm/tls-app.d | 22 +++++++++++----------- ld/testsuite/ld-arm/tls-app.r | 3 --- ld/testsuite/ld-arm/unresolved-1-dyn.d | 2 +- 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f98881266eb..bf400a93512 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2017-10-10 Renlin Li + + PR ld/21402 + * elf32-arm.c (allocate_dynrelocs_for_symbol): Only make undefined weak + symbols into dynamic. + 2017-10-09 H.J. Lu PR ld/22274 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index bad8540c6fd..f841da70803 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -15443,8 +15443,8 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) { /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ - if (h->dynindx == -1 - && !h->forced_local) + if (h->dynindx == -1 && !h->forced_local + && h->root.type == bfd_link_hash_undefweak) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; @@ -15531,8 +15531,8 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ - if (h->dynindx == -1 - && !h->forced_local) + if (h->dynindx == -1 && !h->forced_local + && h->root.type == bfd_link_hash_undefweak) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; @@ -15755,8 +15755,8 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) { /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ - if (h->dynindx == -1 - && !h->forced_local) + if (h->dynindx == -1 && !h->forced_local + && h->root.type == bfd_link_hash_undefweak) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; diff --git a/ld/ChangeLog b/ld/ChangeLog index 58f64204acc..2a7f7bcc7ed 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2017-10-10 Renlin Li + + PR ld/21402 + * testsuite/ld-arm/tls-app.d: Update address. + * testsuite/ld-arm/tls-app.r: Remove relocations. + * testsuite/ld-arm/unresolved-1-dyn.d: Update. + 2017-10-10 Alan Modra * Makefile.am (earmelfb_fuchsia.c): Rename rule from earmelf_fuchsia.c. diff --git a/ld/testsuite/ld-arm/tls-app.d b/ld/testsuite/ld-arm/tls-app.d index de0cbab9616..454adcd066c 100644 --- a/ld/testsuite/ld-arm/tls-app.d +++ b/ld/testsuite/ld-arm/tls-app.d @@ -2,17 +2,17 @@ .*: file format elf32-.*arm.* architecture: arm.*, flags 0x00000112: EXEC_P, HAS_SYMS, D_PAGED -start address 0x000081c8 +start address 0x00008[0-9a-f]+ Disassembly of section .text: -000081c8 : - 81c8: e1a00000 nop ; \(mov r0, r0\) - 81cc: e1a00000 nop ; \(mov r0, r0\) - 81d0: e1a0f00e mov pc, lr - 81d4: 000080bc .word 0x000080bc - 81d8: 000080b4 .word 0x000080b4 - 81dc: 000080ac .word 0x000080ac - 81e0: 00000004 .word 0x00000004 - 81e4: 000080c4 .word 0x000080c4 - 81e8: 00000014 .word 0x00000014 +00008[0-9a-f]+ : + 8[0-9a-f]+: e1a00000 nop ; \(mov r0, r0\) + 8[0-9a-f]+: e1a00000 nop ; \(mov r0, r0\) + 8[0-9a-f]+: e1a0f00e mov pc, lr + 8[0-9a-f]+: 000080bc .word 0x000080bc + 8[0-9a-f]+: 000080b4 .word 0x000080b4 + 8[0-9a-f]+: 000080ac .word 0x000080ac + 8[0-9a-f]+: 00000004 .word 0x00000004 + 8[0-9a-f]+: 000080c4 .word 0x000080c4 + 8[0-9a-f]+: 00000014 .word 0x00000014 diff --git a/ld/testsuite/ld-arm/tls-app.r b/ld/testsuite/ld-arm/tls-app.r index b156d523686..518c18cd58b 100644 --- a/ld/testsuite/ld-arm/tls-app.r +++ b/ld/testsuite/ld-arm/tls-app.r @@ -3,8 +3,5 @@ DYNAMIC RELOCATION RECORDS OFFSET TYPE VALUE -[0-9a-f]+ R_ARM_TLS_DTPMOD32 app_gd -[0-9a-f]+ R_ARM_TLS_DTPOFF32 app_gd [0-9a-f]+ R_ARM_TLS_DTPMOD32 lib_gd [0-9a-f]+ R_ARM_TLS_DTPOFF32 lib_gd -[0-9a-f]+ R_ARM_TLS_TPOFF32 app_ie diff --git a/ld/testsuite/ld-arm/unresolved-1-dyn.d b/ld/testsuite/ld-arm/unresolved-1-dyn.d index 21cd9599c68..529da373461 100644 --- a/ld/testsuite/ld-arm/unresolved-1-dyn.d +++ b/ld/testsuite/ld-arm/unresolved-1-dyn.d @@ -5,4 +5,4 @@ Relocation section '\.rel\.dyn' .* Offset .* -.* R_ARM_GLOB_DAT +00000000 +foo +^.* 00000000 R_ARM_NONE.+ -- 2.30.2