This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ARM] PR ld/21402, only override the symbol dynamic decision on undefined weak symbol


Hi Jiong,

I missed the conversation about this.

I double checked the conditions to call elf_backend_finish_dynamic_symbol function.
Indeed, The expected case the code want to caught is won't trigger the backend function at all.

I run the glibc test with the new linker.
I use the a native gcc armhf tool-chain together with its libstdc++.so and libc.so to compile the test case.

There is no BFD internal errors mentioned
here: https://sourceware.org/ml/binutils/2017-06/msg00412.html


But I agree that, the check is redundant. And I removed the check in the patch.

Additionally, there are other GOT related relocates that are not included when generating the R_ARM_RELATIVE relocations for local symbols in GOT. They are:
R_ARM_GOTPC
R_ARM_GOTOFF32

But it seems the related symbols are not put into the GOT table. So that should be fine.

The relocations:
R_ARM_GOT32
R_ARM_GOT_PREL
are properly handled to create R_ARM_RELATIVE relocations for this case.


Regards,
Renlin



bfd/ChangeLog:

2017-09-21  Renlin Li  <renlin.li@arm.com>

     PR ld/21402
    (allocate_dynrelocs_for_symbol): Only make undefined weak symbols into
    dynamic.

ld/ChangeLog:

2017-09-21  Renlin Li  <renlin.li@arm.com>

    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.

On 20/09/17 15:29, Jiong Wang wrote:
         (elf32_arm_finish_dynamic_symbol): Add sanity check.

Have you verified ARM port is immune from
https://sourceware.org/ml/binutils/2017-06/msg00412.html ?

The sanity check proven to be unnecessary and it does not contribute
to the correctness. The explanation is at:
   https://sourceware.org/ml/binutils/2017-07/msg00018.html

Regards,
Jiong


diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index bad8540..deeaf60 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -15443,8 +15450,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 +15538,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 +15762,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/testsuite/ld-arm/tls-app.d b/ld/testsuite/ld-arm/tls-app.d
index de0cbab..454adcd 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 <foo>:
-    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]+ <foo>:
+    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 b156d52..518c18c 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 21cd959..529da37 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.+


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]