diff options
author | Andrew Jenner <andrew@codesourcery.com> | 2018-07-30 12:24:14 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2018-07-30 12:24:14 +0100 |
commit | b8891f8d622a31306062065813fc278d8a94fe21 (patch) | |
tree | 4476440b69e1ce90b7e2b5a90d08f42563b43a7a /ld/testsuite/ld-csky | |
parent | 7d8a31665739412395f6dd370d2279acd322e78e (diff) | |
download | gdb-b8891f8d622a31306062065813fc278d8a94fe21.zip gdb-b8891f8d622a31306062065813fc278d8a94fe21.tar.gz gdb-b8891f8d622a31306062065813fc278d8a94fe21.tar.bz2 |
Add support for the C_SKY series of processors.
This patch series is a new binutils port for C-SKY processors, including support for both the V1 and V2 processor variants. V1 is derived from the MCore architecture while V2 is substantially different, with mixed 16- and 32-bit instructions, a larger register set, a different (but overlapping) ABI, etc. There is support for bare-metal ELF targets and Linux with both glibc and uClibc.
This code is being contributed jointly by C-SKY Microsystems and Mentor Graphics. C-SKY is responsible for the technical content and has proposed Lifang Xia and Yunhai Shang as port maintainers. (Note that C-SKY does have a corporate copyright assignment on file with the FSF.) Mentor Graphics' role has been cleaning up the code, adding documentation and additional test cases, etc, to address issues we anticipated reviewers would complain about.
bfd * Makefile.am (ALL_MACHINES, ALL_MACHINES_CFILES): Add C-SKY.
(BFD32_BACKENDS, BFD_BACKENDS_CFILES): Likewise.
* Makefile.in: Regenerated.
* archures.c (enum bfd_architecture): Add bfd_arch_csky and
related bfd_mach defines.
(bfd_csky_arch): Declare.
(bfd_archures_list): Add C-SKY.
* bfd-in.h (elf32_csky_build_stubs): Declare.
(elf32_csky_size_stubs): Declare.
(elf32_csky_next_input_section: Declare.
(elf32_csky_setup_section_lists): Declare.
* bfd-in2.h: Regenerated.
* config.bfd: Add C-SKY.
* configure.ac: Likewise.
* configure: Regenerated.
* cpu-csky.c: New file.
* elf-bfd.h (enum elf_target_id): Add C-SKY.
* elf32-csky.c: New file.
* libbfd.h: Regenerated.
* reloc.c: Add C-SKY relocations.
* targets.c (csky_elf32_be_vec, csky_elf32_le_vec): Declare.
(_bfd_target_vector): Add C-SKY target vector entries.
binutils* readelf.c: Include elf/csky.h.
(guess_is_rela): Handle EM_CSKY.
(dump_relocations): Likewise.
(get_machine_name): Likewise.
(is_32bit_abs_reloc): Likewise.
include * dis-asm.h (csky_symbol_is_valid): Declare.
* opcode/csky.h: New file.
opcodes * Makefile.am (TARGET_LIBOPCODES_CFILES): Add csky-dis.c.
* Makefile.in: Regenerated.
* configure.ac: Add C-SKY.
* configure: Regenerated.
* csky-dis.c: New file.
* csky-opc.h: New file.
* disassemble.c (ARCH_csky): Define.
(disassembler, disassemble_init_for_target): Add case for ARCH_csky.
* disassemble.h (print_insn_csky, csky_get_disassembler): Declare.
gas * Makefile.am (TARGET_CPU_CFILES): Add entry for C-SKY.
(TARGET_CPU_HFILES, TARGET_ENV_HFILES): Likewise.
* Makefile.in: Regenerated.
* config/tc-csky.c: New file.
* config/tc-csky.h: New file.
* config/te-csky_abiv1.h: New file.
* config/te-csky_abiv1_linux.h: New file.
* config/te-csky_abiv2.h: New file.
* config/te-csky_abiv2_linux.h: New file.
* configure.tgt: Add C-SKY.
* doc/Makefile.am (CPU_DOCS): Add entry for C-SKY.
* doc/Makefile.in: Regenerated.
* doc/all.texi: Set CSKY feature.
* doc/as.texi (Overview): Add C-SKY options.
(Machine Dependencies): Likewise.
* doc/c-csky.texi: New file.
* testsuite/gas/csky/*: New test cases.
ld * Makefile.am (ALL_EMULATION_SOURCES): Add C-SKY emulations.
(ecskyelf.c, ecskyelf_linux.c): New rules.
* Makefile.in: Regenerated.
* configure.tgt: Add C-SKY.
* emulparams/cskyelf.sh: New file.
* emulparams/cskyelf_linux.sh: New file.
* emultempl/cskyelf.em: New file.
* gen-doc.texi: Add C-SKY.
* ld.texi: Likewise.
(Options specific to C-SKY targets): New section.
* testsuite/ld-csky/*: New tests.
Diffstat (limited to 'ld/testsuite/ld-csky')
29 files changed, 628 insertions, 0 deletions
diff --git a/ld/testsuite/ld-csky/csky.exp b/ld/testsuite/ld-csky/csky.exp new file mode 100644 index 0000000..94a769f --- /dev/null +++ b/ld/testsuite/ld-csky/csky.exp @@ -0,0 +1,15 @@ +if { ! [istarget csky-*-*] } { + return +} + +set linux_gnu [expr [istarget csky*-*-linux*]] + +foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.d]] { + + if { ! $linux_gnu && ([string match "$srcdir/$subdir/tls-*.d" $test] + || [string match "$srcdir/$subdir/got*.d" $test]) } { + continue + } + + run_dump_test [file rootname $test] +} diff --git a/ld/testsuite/ld-csky/data.d b/ld/testsuite/ld-csky/data.d new file mode 100644 index 0000000..21b2f27 --- /dev/null +++ b/ld/testsuite/ld-csky/data.d @@ -0,0 +1,18 @@ +#name: GB(r28) relative .data section references +#source: data.s +#source: data_section.s +#ld: -e __start +#objdump: -dr + +.*: file format .* + + +Disassembly of section .text: + +[0-9a-f]+ <__start>: + [0-9a-f]+: cd400004 lrs.b r10, \[0x4\] // the offset is based on .data + [0-9a-f]+: cd440002 lrs.h r10, \[0x2\] // the offset is based on .data + [0-9a-f]+: cd480001 lrs.w r10, \[0x1\] // the offset is based on .data + [0-9a-f]+: cd700004 srs.b r11, \[0x4\] // the offset is based on .data + [0-9a-f]+: cd740002 srs.h r11, \[0x2\] // the offset is based on .data + [0-9a-f]+: cd780001 srs.w r11, \[0x1\] // the offset is based on .data diff --git a/ld/testsuite/ld-csky/data.s b/ld/testsuite/ld-csky/data.s new file mode 100644 index 0000000..b5af989 --- /dev/null +++ b/ld/testsuite/ld-csky/data.s @@ -0,0 +1,10 @@ + .text + .global __start +__start: + lrs.b r10, [word1] + lrs.h r10, [word1] + lrs.w r10, [word1] + + srs.b r11, [word1] + srs.h r11, [word1] + srs.w r11, [word1] diff --git a/ld/testsuite/ld-csky/data_section.s b/ld/testsuite/ld-csky/data_section.s new file mode 100644 index 0000000..886561c --- /dev/null +++ b/ld/testsuite/ld-csky/data_section.s @@ -0,0 +1,7 @@ + .global word0, word1 + .data + .align 4 +word0: + .word 0xabcd1234 +word1: + .word 0xdeadbeef diff --git a/ld/testsuite/ld-csky/emit-relocs-1.d b/ld/testsuite/ld-csky/emit-relocs-1.d new file mode 100644 index 0000000..3cc05ac --- /dev/null +++ b/ld/testsuite/ld-csky/emit-relocs-1.d @@ -0,0 +1,37 @@ +#name: Emit relocs 1 +#source: emit-relocs-1a.s +#source: emit-relocs-1b.s +#ld: -q -T emit-relocs-1.ld +#objdump: -sr + +.*: file format .* + +RELOCATION RECORDS FOR \[\.data\]: +OFFSET TYPE VALUE * +00000000 R_CKCORE_ADDR32 \.data +00000004 R_CKCORE_ADDR32 \.data\+0x00001000 +00000008 R_CKCORE_ADDR32 \.merge1\+0x00000002 +0000000c R_CKCORE_ADDR32 \.merge2 +00000010 R_CKCORE_ADDR32 \.merge3 +00000014 R_CKCORE_ADDR32 \.merge3\+0x00000004 +00000020 R_CKCORE_ADDR32 \.data\+0x00000020 +00000024 R_CKCORE_ADDR32 \.data\+0x00001020 +00000028 R_CKCORE_ADDR32 \.merge1 +0000002c R_CKCORE_ADDR32 \.merge2\+0x00000002 +00000030 R_CKCORE_ADDR32 \.merge3\+0x00000008 +00000034 R_CKCORE_ADDR32 \.merge3\+0x00000004 + + +Contents of section \.text: + 80000 036c .* +Contents of section \.merge1: + 80400 666c7574 74657200 flutter.* +Contents of section \.merge2: + 80800 74617374 696e6700 tasting.* +Contents of section \.merge3: + 80c00 00010000 00020000 00030000 .* +Contents of section \.data: + 81000 00100800 00200800 02040800 00080800 .* + 81010 000c0800 040c0800 00000000 00000000 .* + 81020 20100800 20200800 00040800 02080800 .* + 81030 080c0800 040c0800 .* diff --git a/ld/testsuite/ld-csky/emit-relocs-1.ld b/ld/testsuite/ld-csky/emit-relocs-1.ld new file mode 100644 index 0000000..574030b --- /dev/null +++ b/ld/testsuite/ld-csky/emit-relocs-1.ld @@ -0,0 +1,20 @@ +ENTRY(__start) +SECTIONS +{ + . = 0x80000; + .text : { *(.text) } + + . = ALIGN (0x400); + .merge1 : { *(.merge1) } + + . = ALIGN (0x400); + .merge2 : { *(.merge2) } + + . = ALIGN (0x400); + .merge3 : { *(.merge3) } + + . = ALIGN (0x400); + .data : { *(.data) } + + /DISCARD/ : { *(*) } +} diff --git a/ld/testsuite/ld-csky/emit-relocs-1a.s b/ld/testsuite/ld-csky/emit-relocs-1a.s new file mode 100644 index 0000000..89bbf99 --- /dev/null +++ b/ld/testsuite/ld-csky/emit-relocs-1a.s @@ -0,0 +1,24 @@ + .text + .align 4 + .globl __start +__start: + nop + + .section .merge1,"aMS",@progbits,1 +A: .string "utter" + + .section .merge2,"aMS",@progbits,1 +B: .string "tasting" + + .section .merge3,"aM",@progbits,4 +C: .4byte 0x100 +D: .4byte 0x200 + + .data + .align 4 +E: .4byte E + .4byte E + 0x1000 + .4byte A + .4byte B + .4byte C + .4byte D diff --git a/ld/testsuite/ld-csky/emit-relocs-1b.s b/ld/testsuite/ld-csky/emit-relocs-1b.s new file mode 100644 index 0000000..82229c1 --- /dev/null +++ b/ld/testsuite/ld-csky/emit-relocs-1b.s @@ -0,0 +1,18 @@ + .section .merge1,"aMS",@progbits,1 +A: .string "flutter" + + .section .merge2,"aMS",@progbits,1 +B: .string "sting" + + .section .merge3,"aM",@progbits,4 +C: .4byte 0x300 +D: .4byte 0x200 + + .data + .align 4 +E: .4byte E + .4byte E + 0x1000 + .4byte A + .4byte B + .4byte C + .4byte D diff --git a/ld/testsuite/ld-csky/got.d b/ld/testsuite/ld-csky/got.d new file mode 100644 index 0000000..ac997c4 --- /dev/null +++ b/ld/testsuite/ld-csky/got.d @@ -0,0 +1,29 @@ +#name: GOT/PLT Link test +#source: got.s +#ld: -shared --hash-style=sysv +#readelf: -d -r + +Dynamic section at offset 0x[0-9a-f]+ contains 13 entries: + Tag Type Name/Value + 0x00000004 \(HASH\) .* + 0x00000005 \(STRTAB\) .* + 0x00000006 \(SYMTAB\) .* + 0x0000000a \(STRSZ\) .* \(bytes\) + 0x0000000b \(SYMENT\) .* \(bytes\) + 0x00000003 \(PLTGOT\) 0x[0-9a-f]+ + 0x00000002 \(PLTRELSZ\) 12 \(bytes\) + 0x00000014 \(PLTREL\) RELA + 0x00000017 \(JMPREL\) 0x[0-9a-f]+ + 0x00000007 \(RELA\) 0x[0-9a-f]+ + 0x00000008 \(RELASZ\) 24 \(bytes\) + 0x00000009 \(RELAENT\) 12 \(bytes\) + 0x00000000 \(NULL\) 0x0 + +Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ [0-9a-f]+ R_CKCORE_GLOB_DAT 00000000 var1 \+ 0 +[0-9a-f]+ [0-9a-f]+ R_CKCORE_GLOB_DAT 00000000 var2 \+ 0 + +Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entry: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ [0-9a-f]+ R_CKCORE_JUMP_SLO 00000000 bar \+ .* diff --git a/ld/testsuite/ld-csky/got.s b/ld/testsuite/ld-csky/got.s new file mode 100644 index 0000000..d5f3b72 --- /dev/null +++ b/ld/testsuite/ld-csky/got.s @@ -0,0 +1,19 @@ + .text + .align 2 + .global foo + .type foo, @function +foo: + push l0, lr, gb + lrw t1, .L2@GOTPC + grs gb, .L2 +.L2: + addu gb, gb, t1 + lrs.w a3, [var1@GOT] + ld.w l0, (a3, 0) + lrs.w a3, [var2@GOT] + ld.w a3, (a3, 0) + lrs.w a0, [bar@PLT] + addu l0, l0, a3 + jsr a0 + addu a0, l0, a0 + pop l0, lr, gb diff --git a/ld/testsuite/ld-csky/hilo16.d b/ld/testsuite/ld-csky/hilo16.d new file mode 100644 index 0000000..f2435c0 --- /dev/null +++ b/ld/testsuite/ld-csky/hilo16.d @@ -0,0 +1,14 @@ +#name: address hi16/lo16 relocations +#source: hilo16.s +#source: hilo16_symbol.s +#ld: -e __start +#objdump: -dr + +.*: file format .* + + +Disassembly of section .text: + +[0-9a-f]+ <__start>: + [0-9a-f]+: ea21dead movih r1, 57005 + [0-9a-f]+: ec21beef ori r1, r1, 48879 diff --git a/ld/testsuite/ld-csky/hilo16.s b/ld/testsuite/ld-csky/hilo16.s new file mode 100644 index 0000000..601fbc6 --- /dev/null +++ b/ld/testsuite/ld-csky/hilo16.s @@ -0,0 +1,7 @@ +# Test the hi16/lo16 relocations + +.text +.global __start +__start: + movih r1, (long_symbol) >> 16 + ori r1, r1, (long_symbol) & 0xffff diff --git a/ld/testsuite/ld-csky/hilo16_symbol.s b/ld/testsuite/ld-csky/hilo16_symbol.s new file mode 100644 index 0000000..e8fad0f --- /dev/null +++ b/ld/testsuite/ld-csky/hilo16_symbol.s @@ -0,0 +1,2 @@ +.global long_symbol +.set long_symbol, 0xDEADBEEF diff --git a/ld/testsuite/ld-csky/tls-gd-v1.d b/ld/testsuite/ld-csky/tls-gd-v1.d new file mode 100644 index 0000000..c2c8766 --- /dev/null +++ b/ld/testsuite/ld-csky/tls-gd-v1.d @@ -0,0 +1,30 @@ +#name: TLS Global Dynamic link test (C-SKY V1) +#source: tls-gd-v1.s +#as: -mcpu=ck610 +#ld: -shared --hash-style=sysv +#readelf: -d -r + +Dynamic section at offset 0x[0-9a-f]+ contains 13 entries: + Tag Type Name/Value + 0x00000004 \(HASH\) .* + 0x00000005 \(STRTAB\) .* + 0x00000006 \(SYMTAB\) .* + 0x0000000a \(STRSZ\) .* \(bytes\) + 0x0000000b \(SYMENT\) .* \(bytes\) + 0x00000003 \(PLTGOT\) 0x[0-9a-f]+ + 0x00000002 \(PLTRELSZ\) 12 \(bytes\) + 0x00000014 \(PLTREL\) RELA + 0x00000017 \(JMPREL\) 0x[0-9a-f]+ + 0x00000007 \(RELA\) 0x[0-9a-f]+ + 0x00000008 \(RELASZ\) 24 \(bytes\) + 0x00000009 \(RELAENT\) 12 \(bytes\) + 0x00000000 \(NULL\) 0x0 + +Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ [0-9a-f]+ R_CKCORE_TLS_DTPM 00000000 var \+ 0 +[0-9a-f]+ [0-9a-f]+ R_CKCORE_TLS_DTPO 00000000 var \+ 0 + +Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entry: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ 0000040c R_CKCORE_JUMP_SLO 00000000 __tls_get_addr \+ .* diff --git a/ld/testsuite/ld-csky/tls-gd-v1.s b/ld/testsuite/ld-csky/tls-gd-v1.s new file mode 100644 index 0000000..617aac0 --- /dev/null +++ b/ld/testsuite/ld-csky/tls-gd-v1.s @@ -0,0 +1,26 @@ + .global __tls_get_addr + .text + .align 2 + .global foo + .type foo, @function +foo: + subi sp, sp, 8 + st.w gb, (sp) + st.w r15, (sp, 4) + bsr .L2 +.L2: + lrw gb, .L2@GOTPC + addu gb, gb, r15 + lrw r7, __tls_get_addr@PLT + addu r7, r7, gb + ld.w r7, (r7) + bsr .LTLS0 +.LTLS0: + lrw r2, var@TLSGD32 + addu r2, r15 + jsr r7 + ld.w r2, (r2) + ld.w r15, (sp, 4) + ld.w gb, (sp) + addi sp, sp, 8 + jmp r15 diff --git a/ld/testsuite/ld-csky/tls-gd.d b/ld/testsuite/ld-csky/tls-gd.d new file mode 100644 index 0000000..2d5e1fc --- /dev/null +++ b/ld/testsuite/ld-csky/tls-gd.d @@ -0,0 +1,29 @@ +#name: TLS Global Dynamic link test +#source: tls-gd.s +#ld: -shared --hash-style=sysv +#readelf: -d -r + +Dynamic section at offset 0x[0-9a-f]+ contains 13 entries: + Tag Type Name/Value + 0x00000004 \(HASH\) .* + 0x00000005 \(STRTAB\) .* + 0x00000006 \(SYMTAB\) .* + 0x0000000a \(STRSZ\) .* \(bytes\) + 0x0000000b \(SYMENT\) .* \(bytes\) + 0x00000003 \(PLTGOT\) 0x[0-9a-f]+ + 0x00000002 \(PLTRELSZ\) 12 \(bytes\) + 0x00000014 \(PLTREL\) RELA + 0x00000017 \(JMPREL\) 0x[0-9a-f]+ + 0x00000007 \(RELA\) 0x[0-9a-f]+ + 0x00000008 \(RELASZ\) 24 \(bytes\) + 0x00000009 \(RELAENT\) 12 \(bytes\) + 0x00000000 \(NULL\) 0x0 + +Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ [0-9a-f]+ R_CKCORE_TLS_DTPM 00000000 var \+ 0 +[0-9a-f]+ [0-9a-f]+ R_CKCORE_TLS_DTPO 00000000 var \+ 0 + +Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entry: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ 0000040c R_CKCORE_JUMP_SLO 00000000 __tls_get_addr \+ .* diff --git a/ld/testsuite/ld-csky/tls-gd.s b/ld/testsuite/ld-csky/tls-gd.s new file mode 100644 index 0000000..8fe0e37 --- /dev/null +++ b/ld/testsuite/ld-csky/tls-gd.s @@ -0,0 +1,20 @@ + .text + .global __tls_get_addr + .align 2 + .global foo + .type foo, @function +foo: + push lr, gb + lrw t1, .L2@GOTPC + grs gb, .L2 +.L2: + addu gb, gb, t1 + grs a2, .LTLS0 + lrw a3, __tls_get_addr@PLT +.LTLS0: + lrw a0, var@TLSGD32 + ldr.w a3, (gb, a3 << 0) + addu a0, a0, a2 + jsr a3 + ld.w a0, (a0, 0) + pop lr, gb diff --git a/ld/testsuite/ld-csky/tls-ie-v1.d b/ld/testsuite/ld-csky/tls-ie-v1.d new file mode 100644 index 0000000..1f5f446 --- /dev/null +++ b/ld/testsuite/ld-csky/tls-ie-v1.d @@ -0,0 +1,25 @@ +#name: TLS Initial Exec link test (C-SKY v1) +#source: tls-ie-v1.s +#as: -mcpu=ck610 +#ld: -shared --hash-style=sysv +#readelf: -d -r + +Dynamic section at offset 0x[0-9a-f]+ contains 13 entries: + Tag Type Name/Value + 0x00000004 \(HASH\) .* + 0x00000005 \(STRTAB\) .* + 0x00000006 \(SYMTAB\) .* + 0x0000000a \(STRSZ\) .* \(bytes\) + 0x0000000b \(SYMENT\) .* \(bytes\) + 0x00000003 \(PLTGOT\) 0x[0-9a-f]+ + 0x00000002 \(PLTRELSZ\) 0 \(bytes\) + 0x00000014 \(PLTREL\) RELA + 0x00000017 \(JMPREL\) 0x[0-9a-f]+ + 0x00000007 \(RELA\) 0x[0-9a-f]+ + 0x00000008 \(RELASZ\) 12 \(bytes\) + 0x00000009 \(RELAENT\) 12 \(bytes\) + 0x00000000 \(NULL\) 0x0 + +Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ 0000003a R_CKCORE_TLS_TPOF 0 diff --git a/ld/testsuite/ld-csky/tls-ie-v1.s b/ld/testsuite/ld-csky/tls-ie-v1.s new file mode 100644 index 0000000..7c72362 --- /dev/null +++ b/ld/testsuite/ld-csky/tls-ie-v1.s @@ -0,0 +1,29 @@ + .text + .section .tbss,"awT",@nobits + .align 2 + .type var, @object + .size var, 4 +var: + .word 0 + + .text + .align 2 + .global _start + .type _start, @function +_start: + subi sp, sp, 8 + st.w r15, (sp) + bsr .LTLS0 +.LTLS0: + lrw r7, var@GOTTPOFF + addu r7, r15 + ld.w r7, (r7) + bsr __read_tp + addu r7, r7, r2 + ld.w r2, (r7) + ld.w r15, (sp) + addi sp, sp, 8 + jmp r15 +__read_tp: + movi r2, 0 + jmp r15 diff --git a/ld/testsuite/ld-csky/tls-ie.d b/ld/testsuite/ld-csky/tls-ie.d new file mode 100644 index 0000000..45a8a11 --- /dev/null +++ b/ld/testsuite/ld-csky/tls-ie.d @@ -0,0 +1,24 @@ +#name: TLS Initial Exec link test +#source: tls-ie.s +#ld: -shared --hash-style=sysv +#readelf: -d -r + +Dynamic section at offset 0x[0-9a-f]+ contains 13 entries: + Tag Type Name/Value + 0x00000004 \(HASH\) .* + 0x00000005 \(STRTAB\) .* + 0x00000006 \(SYMTAB\) .* + 0x0000000a \(STRSZ\) .* \(bytes\) + 0x0000000b \(SYMENT\) .* \(bytes\) + 0x00000003 \(PLTGOT\) 0x[0-9a-f]+ + 0x00000002 \(PLTRELSZ\) 0 \(bytes\) + 0x00000014 \(PLTREL\) RELA + 0x00000017 \(JMPREL\) 0x[0-9a-f]+ + 0x00000007 \(RELA\) 0x[0-9a-f]+ + 0x00000008 \(RELASZ\) 12 \(bytes\) + 0x00000009 \(RELAENT\) 12 \(bytes\) + 0x00000000 \(NULL\) 0x0 + +Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ 0000003a R_CKCORE_TLS_TPOF 0 diff --git a/ld/testsuite/ld-csky/tls-ie.s b/ld/testsuite/ld-csky/tls-ie.s new file mode 100644 index 0000000..36def90 --- /dev/null +++ b/ld/testsuite/ld-csky/tls-ie.s @@ -0,0 +1,27 @@ + .text + .section .tbss,"awT",@nobits + .align 2 + .type var, @object + .size var, 4 +var: + .word 0 + + .text + .align 2 + .global _start + .type _start, @function +_start: + subi sp, sp, 4 + st.w l4, (sp, 0) + mov l4, sp +.LTLS0: + lrw a3, var@GOTTPOFF + grs a2, .LTLS0 + addu a3, a3, a2 + ld.w a3, (a3, 0) + ldr.w a3, (r31, a3 << 0) + mov a0, a3 + mov sp, l4 + ld.w l4, (sp, 0) + addi sp, sp, 4 + rts diff --git a/ld/testsuite/ld-csky/tls-ld-v1.d b/ld/testsuite/ld-csky/tls-ld-v1.d new file mode 100644 index 0000000..3aaa351 --- /dev/null +++ b/ld/testsuite/ld-csky/tls-ld-v1.d @@ -0,0 +1,29 @@ +#name: TLS Local Dynamic link test (C-SKY v1) +#source: tls-ld-v1.s +#as: -mcpu=ck610 +#ld: -shared --hash-style=sysv +#readelf: -d -r + +Dynamic section at offset 0x[0-9a-f]+ contains 13 entries: + Tag Type Name/Value + 0x00000004 \(HASH\) .* + 0x00000005 \(STRTAB\) .* + 0x00000006 \(SYMTAB\) .* + 0x0000000a \(STRSZ\) .* \(bytes\) + 0x0000000b \(SYMENT\) .* \(bytes\) + 0x00000003 \(PLTGOT\) 0x[0-9a-f]+ + 0x00000002 \(PLTRELSZ\) 12 \(bytes\) + 0x00000014 \(PLTREL\) RELA + 0x00000017 \(JMPREL\) 0x[0-9a-f]+ + 0x00000007 \(RELA\) 0x[0-9a-f]+ + 0x00000008 \(RELASZ\) 12 \(bytes\) + 0x00000009 \(RELAENT\) 12 \(bytes\) + 0x00000000 \(NULL\) 0x0 + +Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ 00000038 R_CKCORE_TLS_DTPM 0 + +Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entry: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ 0000050c R_CKCORE_JUMP_SLO 00000000 __tls_get_addr \+ .* diff --git a/ld/testsuite/ld-csky/tls-ld-v1.s b/ld/testsuite/ld-csky/tls-ld-v1.s new file mode 100644 index 0000000..e0a8e76 --- /dev/null +++ b/ld/testsuite/ld-csky/tls-ld-v1.s @@ -0,0 +1,34 @@ + .global __tls_get_addr + .text + .align 2 + .global foo + .type foo, @function +foo: + subi sp, sp, 8 + st.w gb, (sp) + st.w r15, (sp, 4) + bsr .L2 +.L2: + lrw gb, .L2@GOTPC + addu gb, gb, r15 + lrw r7, __tls_get_addr@PLT + addu r7, r7, gb + ld.w r7, (r7) + bsr .LTLS0 +.LTLS0: + lrw r2, var@TLSLDM32 + addu r2, r15 + jsr r7 + lrw r7, var@TLSLDO32 + addu r2, r2, r7 + ld.w r15, (sp, 4) + ld.w gb, (sp) + addi sp, sp, 8 + jmp r15 + .size foo, .-foo + .section .tbss,"awT",@nobits + .align 2 + .type var, @object + .size var, 4 +var: + .fill 4, 1 diff --git a/ld/testsuite/ld-csky/tls-ld.d b/ld/testsuite/ld-csky/tls-ld.d new file mode 100644 index 0000000..3922152 --- /dev/null +++ b/ld/testsuite/ld-csky/tls-ld.d @@ -0,0 +1,28 @@ +#name: TLS Local Dynamic link test +#source: tls-ld.s +#ld: -shared --hash-style=sysv +#readelf: -d -r + +Dynamic section at offset 0x[0-9a-f]+ contains 13 entries: + Tag Type Name/Value + 0x00000004 \(HASH\) .* + 0x00000005 \(STRTAB\) .* + 0x00000006 \(SYMTAB\) .* + 0x0000000a \(STRSZ\) .* \(bytes\) + 0x0000000b \(SYMENT\) .* \(bytes\) + 0x00000003 \(PLTGOT\) 0x[0-9a-f]+ + 0x00000002 \(PLTRELSZ\) 12 \(bytes\) + 0x00000014 \(PLTREL\) RELA + 0x00000017 \(JMPREL\) 0x[0-9a-f]+ + 0x00000007 \(RELA\) 0x[0-9a-f]+ + 0x00000008 \(RELASZ\) 12 \(bytes\) + 0x00000009 \(RELAENT\) 12 \(bytes\) + 0x00000000 \(NULL\) 0x0 + +Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ 00000038 R_CKCORE_TLS_DTPM 0 + +Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entry: + Offset Info Type Sym.Value Sym. Name \+ Addend +[0-9a-f]+ 0000050c R_CKCORE_JUMP_SLO 00000000 __tls_get_addr \+ .* diff --git a/ld/testsuite/ld-csky/tls-ld.s b/ld/testsuite/ld-csky/tls-ld.s new file mode 100644 index 0000000..3ad06ce --- /dev/null +++ b/ld/testsuite/ld-csky/tls-ld.s @@ -0,0 +1,28 @@ + .text + .global __tls_get_addr + .align 2 + .global foo + .type foo, @function +foo: + push lr, gb + lrw t1, .L2@GOTPC + grs gb, .L2 +.L2: + addu gb, gb, t1 + grs a3, .LTLS0 +.LTLS0: + lrw a0, .LANCHOR0@TLSLDM32 + addu a0, a0, a3 + lrs.w a3, [__tls_get_addr@PLT] + jsr a3 + lrw a3, .LANCHOR0@TLSLDO32 + addu a0, a0, a3 + pop lr, gb + .size foo, .-foo + .section .tbss,"awT",@nobits + .align 2 + .set .LANCHOR0,. + 0 + .type var, @object + .size var, 4 +var: + .fill 4, 1 diff --git a/ld/testsuite/ld-csky/tls-le-v1.d b/ld/testsuite/ld-csky/tls-le-v1.d new file mode 100644 index 0000000..034d5d9 --- /dev/null +++ b/ld/testsuite/ld-csky/tls-le-v1.d @@ -0,0 +1,14 @@ +#name: TLS Local Exec link test (C-SKY v1) +#source: tls-le-v1.s +#as: -mcpu=ck610 +#ld: +#objdump: -h + +.*: file format .* + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text .* + .* + 1 .tbss .* + .* diff --git a/ld/testsuite/ld-csky/tls-le-v1.s b/ld/testsuite/ld-csky/tls-le-v1.s new file mode 100644 index 0000000..b93521e --- /dev/null +++ b/ld/testsuite/ld-csky/tls-le-v1.s @@ -0,0 +1,29 @@ + .section .tbss,"awT",@nobits + .align 2 + .type var, @object + .size var, 4 +var: + .fill 4, 1 + .text + .align 2 + .global _start + .type _start, @function +_start: + subi sp, sp, 8 + st.w r15, (sp) + st.w r8, (sp, 4) + mov r8, sp + bsr __read_tp + mov r6, r2 + lrw r7, var@TPOFF + addu r7, r7, r6 + ld.w r7, (r7) + mov r2, r7 + mov sp, r8 + ld.w r15, (sp) + ld.w r8, (sp, 4) + addi sp, sp, 8 + jmp r15 +__read_tp: + movi r2, 0 + jmp r15 diff --git a/ld/testsuite/ld-csky/tls-le.d b/ld/testsuite/ld-csky/tls-le.d new file mode 100644 index 0000000..8a0d90f --- /dev/null +++ b/ld/testsuite/ld-csky/tls-le.d @@ -0,0 +1,13 @@ +#name: TLS Local Exec link test +#source: tls-le.s +#ld: +#objdump: -h + +.*: file format .* + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text .* + .* + 1 .tbss .* + .* diff --git a/ld/testsuite/ld-csky/tls-le.s b/ld/testsuite/ld-csky/tls-le.s new file mode 100644 index 0000000..240a59d --- /dev/null +++ b/ld/testsuite/ld-csky/tls-le.s @@ -0,0 +1,23 @@ + .text + .section .tbss,"awT",@nobits + .align 2 + .type var, @object + .size var, 4 +var: + .word 0 + + .text + .align 2 + .global _start + .type _start, @function +_start: + subi sp, sp, 4 + st.w l4, (sp, 0) + mov l4, sp + lrw a3, var@TPOFF + ldr.w a3, (r31, a3 << 0) + mov a0, a3 + mov sp, l4 + ld.w l4, (sp, 0) + addi sp, sp, 4 + rts |