This is the mail archive of the binutils-cvs@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]

[binutils-gdb] Fix ARC TLS support.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b125bd17270aca2af4d945ce8477f981dbc27e7e

commit b125bd17270aca2af4d945ce8477f981dbc27e7e
Author: Claudiu Zissulescu <claziss@synopsys.com>
Date:   Mon Feb 1 17:03:56 2016 +0000

    Fix ARC TLS support.
    
           * config/tc-arc.c (md_apply_fix): Allow addendum.
            (arc_reloc_op): Allow complex expressions for tpoff.
            (md_apply_fix): Handle resolved TLS local symbol.
    
    	* gas/arc/tls-relocs1.d: New file.
    	* gas/arc/tls-relocs1.s: Likewise.

Diff:
---
 gas/ChangeLog                       |  9 +++++++++
 gas/config/tc-arc.c                 | 11 +++++++++--
 gas/testsuite/gas/arc/tls-relocs1.d | 12 ++++++++++++
 gas/testsuite/gas/arc/tls-relocs1.s | 24 ++++++++++++++++++++++++
 4 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 6e7319d..d219d42 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,12 @@
+2016-01-26  Claudiu Zissulescu  <claziss@synopsys.com>
+
+        * config/tc-arc.c (md_apply_fix): Allow addendum.
+        (arc_reloc_op): Allow complex expressions for tpoff.
+        (md_apply_fix): Handle resolved TLS local symbol.
+
+	* testsuite/gas/arc/tls-relocs1.d: New file.
+	* testsuite/gas/arc/tls-relocs1.s: Likewise.
+
 2016-02-01  Loria  <Loria@phantasia.org>
 
 	PR target/19311
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index 40ba0ad..20a48f7 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -363,7 +363,7 @@ static const struct arc_reloc_op_tag
   DEF (tlsgd,   BFD_RELOC_ARC_TLS_GD_GOT,	0),
   DEF (tlsie,   BFD_RELOC_ARC_TLS_IE_GOT,	0),
   DEF (tpoff9,  BFD_RELOC_ARC_TLS_LE_S9,	0),
-  DEF (tpoff,   BFD_RELOC_ARC_TLS_LE_32,	0),
+  DEF (tpoff,   BFD_RELOC_ARC_TLS_LE_32,	1),
   DEF (dtpoff9, BFD_RELOC_ARC_TLS_DTPOFF_S9,	0),
   DEF (dtpoff,  BFD_RELOC_ARC_TLS_DTPOFF,	0),
 };
@@ -1301,7 +1301,8 @@ md_apply_fix (fixS *fixP,
     {
     case BFD_RELOC_ARC_TLS_DTPOFF:
     case BFD_RELOC_ARC_TLS_LE_32:
-      fixP->fx_offset = 0;
+      if (fixP->fx_done)
+	break;
       /* Fall through.  */
     case BFD_RELOC_ARC_TLS_GD_GOT:
     case BFD_RELOC_ARC_TLS_IE_GOT:
@@ -1363,6 +1364,12 @@ md_apply_fix (fixS *fixP,
 	 from ld rx,[pcl,@sym@gotpc] to add rx,pcl,@sym@gotpc.  */
       as_bad (_("Unsupported operation on reloc"));
       return;
+
+    case BFD_RELOC_ARC_TLS_DTPOFF:
+    case BFD_RELOC_ARC_TLS_LE_32:
+      gas_assert (!fixP->fx_addsy);
+      gas_assert (!fixP->fx_subsy);
+
     case BFD_RELOC_ARC_GOTOFF:
     case BFD_RELOC_ARC_32_ME:
     case BFD_RELOC_ARC_PC32:
diff --git a/gas/testsuite/gas/arc/tls-relocs1.d b/gas/testsuite/gas/arc/tls-relocs1.d
new file mode 100644
index 0000000..3944874
--- /dev/null
+++ b/gas/testsuite/gas/arc/tls-relocs1.d
@@ -0,0 +1,12 @@
+#as: -mcpu=archs
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <foo>:
+   0:	2100 3f82 0000 0000 	add	r2,r25,0
+			4: R_ARC_TLS_LE_32	a\+0x30
+   8:	2000 0f80 0000 003c 	add	r0,r0,0x3c
diff --git a/gas/testsuite/gas/arc/tls-relocs1.s b/gas/testsuite/gas/arc/tls-relocs1.s
new file mode 100644
index 0000000..fc71e66
--- /dev/null
+++ b/gas/testsuite/gas/arc/tls-relocs1.s
@@ -0,0 +1,24 @@
+;;; TLS tests: check tpoff addendum and resolving local TLS symbols.
+
+	.cpu HS
+	.global		a
+	.section	.tbss,"awT",@nobits
+	.align		4
+	.type		a, @object
+	.size		a, 60
+a:
+	.zero		 60
+
+	.type		local_tls_var, @object
+	.size		local_tls_var, 4
+local_tls_var:
+	.zero		4
+
+
+	.section	.text
+	.align 4
+foo:
+;;; Test if the tpoff addendum is correctly generated.
+	add r2,r25,@a@tpoff+48
+;;; Test if local TLS symbol is correctly resolved.
+	add r0,r0,@local_tls_var@dtpoff@.tbss


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