[ARC] Fix parsing dtpoff relocation expression.
authorClaudiu Zissulescu <claziss@synopsys.com>
Wed, 7 Sep 2016 07:47:34 +0000 (09:47 +0200)
committerClaudiu Zissulescu <claziss@synopsys.com>
Wed, 14 Sep 2016 12:04:34 +0000 (14:04 +0200)
The assembler accepts dtpoff complex relocation expression like
identifier@dtpoff + const. However, it doesn't accept an expression such
as identifier@dtpoff@base + const. This patch solves this issue, and adds
a number of tests.

ld/
2016-09-14  Claudiu Zissulescu  <claziss@synopsys.com>

* testsuite/ld-arc/tls-dtpoff.dd: New file.
* testsuite/ld-arc/tls-dtpoff.rd: Likewise.
* testsuite/ld-arc/tls-dtpoff.s: Likewise.
* testsuite/ld-arc/tls-relocs.ld: Likewise.
* testsuite/ld-arc/arc.exp: Add new tdpoff test.

gas/
2016-09-14  Claudiu Zissulescu  <claziss@synopsys.com>

* testsuite/gas/arc/tls-relocs2.d: New file.
* testsuite/gas/arc/tls-relocs2.s: Likewise.
* config/tc-arc.c (tokenize_arguments): Accept offsets when base
is used.

gas/ChangeLog
gas/config/tc-arc.c
gas/testsuite/gas/arc/tls-relocs2.d [new file with mode: 0644]
gas/testsuite/gas/arc/tls-relocs2.s [new file with mode: 0644]
ld/ChangeLog
ld/testsuite/ld-arc/arc.exp
ld/testsuite/ld-arc/tls-dtpoff.dd [new file with mode: 0644]
ld/testsuite/ld-arc/tls-dtpoff.rd [new file with mode: 0644]
ld/testsuite/ld-arc/tls-dtpoff.s [new file with mode: 0644]
ld/testsuite/ld-arc/tls-relocs.ld [new file with mode: 0644]

index 6544175eb6f4da0d9279e332eea19d3d7b120a7e..12fd86187ee70d3f74f5f27cc9aba3abf85f9b4b 100644 (file)
@@ -1,3 +1,10 @@
+2016-09-14  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * testsuite/gas/arc/tls-relocs2.d: New file.
+       * testsuite/gas/arc/tls-relocs2.s: Likewise.
+       * config/tc-arc.c (tokenize_arguments): Accept offsets when base
+       is used.
+
 2016-09-12  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        * config/tc-s390.c (s390_parse_cpu): Support alternate arch
index 4e4dcb37df60006c08b5ea92cd1bc937479087cd..58adf0b341caf2dce4889c4597d6743dbde94208 100644 (file)
@@ -1157,7 +1157,7 @@ tokenize_arguments (char *str,
              restore_line_pointer (c);
              tmpE.X_add_number = 0;
            }
-         else if ((*input_line_pointer != '+')
+         if ((*input_line_pointer != '+')
                   && (*input_line_pointer != '-'))
            {
              tmpE.X_add_number = 0;
diff --git a/gas/testsuite/gas/arc/tls-relocs2.d b/gas/testsuite/gas/arc/tls-relocs2.d
new file mode 100644 (file)
index 0000000..e52318f
--- /dev/null
@@ -0,0 +1,10 @@
+#as: -mcpu=archs
+#objdump: -dr
+
+.*: +file format .*arc.*
+
+
+Disassembly of section .text:
+
+00000000 <.text>:
+   0:  70c3 0000 0804          add_s   r0,r0,0x804
diff --git a/gas/testsuite/gas/arc/tls-relocs2.s b/gas/testsuite/gas/arc/tls-relocs2.s
new file mode 100644 (file)
index 0000000..1f1d045
--- /dev/null
@@ -0,0 +1,12 @@
+       .cpu HS
+;;; Test if palette is resolved by the assembler.
+       add_s r0,r0,@palette@dtpoff@.tbss+2048
+
+       .section        .tbss,"awT",@nobits
+       .align 4
+       .zero   4
+       .align 4
+       .type   palette, @object
+       .size   palette, 6144
+palette:
+       .zero   6144
index 58c888d34185f400d28621f49e3444a89ea98206..2a3db2cb63b3ec6de9dc2184b61a13bbfc8e0933 100644 (file)
@@ -1,3 +1,11 @@
+2016-09-14  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * testsuite/ld-arc/tls-dtpoff.dd: New file.
+       * testsuite/ld-arc/tls-dtpoff.rd: Likewise.
+       * testsuite/ld-arc/tls-dtpoff.s: Likewise.
+       * testsuite/ld-arc/tls-relocs.ld: Likewise.
+       * testsuite/ld-arc/arc.exp: Add new tdpoff test.
+
 2016-09-14  Nick Clifton  <nickc@redhat.com>
 
        PR ld/20537
index 700edffc35607e4ebef1587a633f07e1276533a8..fed4d2ae1f650610fe977d41f0801fcddee249a5 100644 (file)
@@ -35,6 +35,11 @@ set arccommon_tests {
         "-q -T sda-relocs.ld -A elf32-arclittle" "" "-mcpu=archs -EL" {sda-relocs.s}
         {{objdump -fdw sda-relocs.dd} {readelf --relocs sda-relocs.rd}}
         "sda-relocs.so" }
+    { "TLS reloc dtpoff"
+        "-q -T tls-relocs.ld -A elf32-arclittle" "" "-mcpu=archs -EL"
+       {tls-dtpoff.s}
+        {{objdump -fdw tls-dtpoff.dd} {readelf --relocs tls-dtpoff.rd}}
+        "sda-relocs.so" }
 }
 
 run_ld_link_tests $arccommon_tests
diff --git a/ld/testsuite/ld-arc/tls-dtpoff.dd b/ld/testsuite/ld-arc/tls-dtpoff.dd
new file mode 100644 (file)
index 0000000..d27475a
--- /dev/null
@@ -0,0 +1,11 @@
+
+.*:     file format .*arc.*
+architecture: ARCv2, flags 0x00000113:
+HAS_RELOC, EXEC_P, HAS_SYMS, D_PAGED
+start address 0x00010000
+
+
+Disassembly of section .text:
+
+[0-9a-f]+ <.text>:
+   [0-9a-f]+:  70c3 0000 0804          add_s   r0,r0,0x804
diff --git a/ld/testsuite/ld-arc/tls-dtpoff.rd b/ld/testsuite/ld-arc/tls-dtpoff.rd
new file mode 100644 (file)
index 0000000..533beea
--- /dev/null
@@ -0,0 +1,4 @@
+
+Relocation section '\.rela\.text' .*:
+ Offset +Info +Type +Sym.Value +Sym. Name \+ Addend
+[0-9a-f]+  [0-9a-f]+ R_ARC_TLS_DTPOFF  [0-9a-f]+   palette \+ 800
diff --git a/ld/testsuite/ld-arc/tls-dtpoff.s b/ld/testsuite/ld-arc/tls-dtpoff.s
new file mode 100644 (file)
index 0000000..d544366
--- /dev/null
@@ -0,0 +1,12 @@
+       .cpu HS
+;;; Test if palette is resolved by the linker.
+       add_s r0,r0,@palette@dtpoff+2048
+
+       .section        .tbss,"awT",@nobits
+       .align 4
+       .zero   4
+       .align 4
+       .type   palette, @object
+       .size   palette, 6144
+palette:
+       .zero   6144
diff --git a/ld/testsuite/ld-arc/tls-relocs.ld b/ld/testsuite/ld-arc/tls-relocs.ld
new file mode 100644 (file)
index 0000000..314b0dd
--- /dev/null
@@ -0,0 +1,20 @@
+/* Default linker script, for normal executables.  */
+OUTPUT_FORMAT("elf32-littlearc", "elf32-bigarc",
+              "elf32-littlearc")
+
+OUTPUT_ARCH(arc)
+ENTRY(__start)
+
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  PROVIDE (__start = 0x10000);
+  . = 0x10000 + SIZEOF_HEADERS;
+
+  .text           : {*(.text .stub .text.*)} =0
+  .tdata          : {.tdata = .; *(.tdata .tdata.* .gnu.linkonce.td.*) }
+  .tbss           : {.tbss = .; *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
+
+  /DISCARD/ : { *(.__arc_profile_*) }
+  /DISCARD/ : { *(.note.GNU-stack) }
+}
This page took 0.033468 seconds and 4 git commands to generate.