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: [PATCH 5/5] Dynamic TLS GOT entries would not be relocated.


Hi,

Indeed description should have been more verbose/existent.
Please find a new patch with new description and testcase.

Cheers,
Cupertino

On 08/19/2016 09:54 AM, Nick Clifton wrote:
> Hi Cupertino,
>
>> bfd/ChangeLog:
>>
>> Cupertino Miranda  <cmiranda@synopsys.com>
>>
>> 	elf32-arc.c (elf_arc_relocate_section): Changed.
> Why ?
>
>
> Cheers
>   Nick
>
>

From 1e84cd9dedf83b5771ca38257740226add64b011 Mon Sep 17 00:00:00 2001
From: Cupertino Miranda <cmiranda@synopsys.com>
Date: Thu, 21 Jul 2016 15:32:35 +0200
Subject: [PATCH 5/5] Dynamic TLS GOT entries would not be relocated.

Forgot to set should_relocate to TRUE in case of GOT and TLS relocations of
undefined symbols for shared libraries.
In dynamic libraries if symbol is not known the instruction relocation would
not be resolved to point to the respective .got entry.
A test was created to detect similar future mistakes.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	elf32-arc.c (elf_arc_relocate_section): Changed. Set should_relocate to
						TRUE for GOT and TLS relocs.

ld/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	ld/testsuite/ld-arc/tls_gd-01.s: Added a testcase for this patch.
	ld/testsuite/ld-arc/tls_gd-01.d: Likewise.
---
 bfd/elf32-arc.c                 |  2 ++
 ld/testsuite/ld-arc/tls_gd-01.d | 13 +++++++++++++
 ld/testsuite/ld-arc/tls_gd-01.s |  7 +++++++
 3 files changed, 22 insertions(+)
 create mode 100644 ld/testsuite/ld-arc/tls_gd-01.d
 create mode 100644 ld/testsuite/ld-arc/tls_gd-01.s

diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index e4b2d09..6ebe5bf 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1374,6 +1374,8 @@ elf_arc_relocate_section (bfd *		          output_bfd,
       if ((is_reloc_for_GOT (howto)
 	   || is_reloc_for_TLS (howto)))
 	{
+	  reloc_data.should_relocate = TRUE;
+
 	  struct got_entry **list
 	    = get_got_entry_list_for_symbol (output_bfd, r_symndx, h);
 
diff --git a/ld/testsuite/ld-arc/tls_gd-01.d b/ld/testsuite/ld-arc/tls_gd-01.d
new file mode 100644
index 0000000..f7027af
--- /dev/null
+++ b/ld/testsuite/ld-arc/tls_gd-01.d
@@ -0,0 +1,13 @@
+#source: tls_gd-01.s
+#as: -mcpu=arc700
+#ld: -shared
+#objdump: -d
+
+[^:]+:     file format elf32-littlearc
+
+
+Disassembly of section \.text:
+
+[0-9a-f]+ <__start>:
+ [0-9a-f]+:	2700 7f80 0000 2080 	add	r0,pcl,0x2080
+ [0-9a-f]+:	2700 7f80 0000 2080 	add	r0,pcl,0x2080
diff --git a/ld/testsuite/ld-arc/tls_gd-01.s b/ld/testsuite/ld-arc/tls_gd-01.s
new file mode 100644
index 0000000..a217a13
--- /dev/null
+++ b/ld/testsuite/ld-arc/tls_gd-01.s
@@ -0,0 +1,7 @@
+	.text
+	.align 4
+
+        .global __start
+__start:
+	add r0, pcl, @baz@tlsgd      
+	add r0, pcl, @bar@tlsgd      
-- 
2.9.0


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