From 32348c581bf104d46c3fb42a7ff5cefe8ef65f7f Mon Sep 17 00:00:00 2001 From: Claudiu Zissulescu Date: Wed, 7 Sep 2016 09:47:34 +0200 Subject: [ARC] Fix parsing dtpoff relocation expression. 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 * 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 * 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. --- ld/ChangeLog | 8 ++++++++ ld/testsuite/ld-arc/arc.exp | 5 +++++ ld/testsuite/ld-arc/tls-dtpoff.dd | 11 +++++++++++ ld/testsuite/ld-arc/tls-dtpoff.rd | 4 ++++ ld/testsuite/ld-arc/tls-dtpoff.s | 12 ++++++++++++ ld/testsuite/ld-arc/tls-relocs.ld | 20 ++++++++++++++++++++ 6 files changed, 60 insertions(+) create mode 100644 ld/testsuite/ld-arc/tls-dtpoff.dd create mode 100644 ld/testsuite/ld-arc/tls-dtpoff.rd create mode 100644 ld/testsuite/ld-arc/tls-dtpoff.s create mode 100644 ld/testsuite/ld-arc/tls-relocs.ld (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index 58c888d..2a3db2c 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +2016-09-14 Claudiu Zissulescu + + * 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 PR ld/20537 diff --git a/ld/testsuite/ld-arc/arc.exp b/ld/testsuite/ld-arc/arc.exp index 700edff..fed4d2a 100644 --- a/ld/testsuite/ld-arc/arc.exp +++ b/ld/testsuite/ld-arc/arc.exp @@ -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 index 0000000..d27475a --- /dev/null +++ b/ld/testsuite/ld-arc/tls-dtpoff.dd @@ -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 index 0000000..533beea --- /dev/null +++ b/ld/testsuite/ld-arc/tls-dtpoff.rd @@ -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 index 0000000..d544366 --- /dev/null +++ b/ld/testsuite/ld-arc/tls-dtpoff.s @@ -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 index 0000000..314b0dd --- /dev/null +++ b/ld/testsuite/ld-arc/tls-relocs.ld @@ -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) } +} -- cgit v1.1