diff options
author | Sandra Loosemore <sandra@codesourcery.com> | 2013-02-06 23:22:26 +0000 |
---|---|---|
committer | Sandra Loosemore <sandra@codesourcery.com> | 2013-02-06 23:22:26 +0000 |
commit | 36591ba149edf6c6608d931a6d53bb99849fdc99 (patch) | |
tree | 9ca2405118dd7414b90a8fffb09eb1d5023dfd96 /ld/testsuite/ld-nios2 | |
parent | 574b0b3165dfa8ce1bdc2a41ae73148b6d8ea6be (diff) | |
download | fsf-binutils-gdb-36591ba149edf6c6608d931a6d53bb99849fdc99.zip fsf-binutils-gdb-36591ba149edf6c6608d931a6d53bb99849fdc99.tar.gz fsf-binutils-gdb-36591ba149edf6c6608d931a6d53bb99849fdc99.tar.bz2 |
2013-02-06 Sandra Loosemore <sandra@codesourcery.com>
Andrew Jenner <andrew@codesourcery.com>
Based on patches from Altera Corporation.
bfd/
* Makefile.am (ALL_MACHINES): Add cpu-nios2.lo.
(ALL_MACHINES_CFILES): Add cpu-nios2.c.
(BFD_BACKENDS): Add elf32-nios2.lo.
(BFD32_BACKENDS_CFILES): Add elf32-nios2.c.
* Makefile.in: Regenerated.
* configure.in: Add entries for bfd_elf32_bignios2_vec and
bfd_elf32_littlenios2_vec.
* configure: Regenerated.
* config.bfd: Add cases for nios2.
* archures.c (enum bfd_architecture): Add bfd_arch_nios2.
(bfd_mach_nios2): Define.
(bfd_nios2_arch): Declare.
(bfd_archures_list): Add bfd_nios2_arch.
* targets.c (bfd_elf32_bignios2_vec): Declare.
(bfd_elf32_littlenios2_vec): Declare.
(_bfd_target_vector): Add entries for bfd_elf32_bignios2_vec and
bfd_elf32_littlenios2_vec.
* elf-bfd.h (enum elf_target_id): Add NIOS2_ELF_DATA.
* reloc.c (enum bfd_reloc_code_real): Add Nios II relocations.
* bfd-in2.h: Regenerated.
* libbfd.h: Regenerated.
* cpu-nios2.c: New file.
* elf32-nios2.c: New file.
opcodes/
* Makefile.am (TARGET_LIBOPCODES_CFILES): Add nios2-dis.c and
nios2-opc.c.
* Makefile.in: Regenerated.
* configure.in: Add case for bfd_nios2_arch.
* configure: Regenerated.
* disassemble.c (ARCH_nios2): Define.
(disassembler): Add case for bfd_arch_nios2.
* nios2-dis.c: New file.
* nios2-opc.c: New file.
include/
* dis-asm.h (print_insn_big_nios2): Declare.
(print_insn_little_nios2): Declare.
include/elf
* nios2.h: New file.
include/opcode/
* nios2.h: New file.
gas/
* Makefile.am (TARGET_CPU_CFILES): Add config/tc-nios2.c.
(TARGET_CPU_HFILES): Add config/tc-nios2.h.
* Makefile.in: Regenerated.
* configure.tgt: Add case for nios2*-linux*.
* config/obj-elf.c: Conditionally include elf/nios2.h.
* config/tc-nios2.c: New file.
* config/tc-nios2.h: New file.
* doc/Makefile.am (CPU_DOCS): Add c-nios2.texi.
* doc/Makefile.in: Regenerated.
* doc/all.texi: Set NIOSII.
* doc/as.texinfo (Overview): Add Nios II options.
(Machine Dependencies): Include c-nios2.texi.
* doc/c-nios2.texi: New file.
* NEWS: Note Altera Nios II support.
gas/testsuite/
* gas/nios2/add.d: New.
* gas/nios2/add.s: New.
* gas/nios2/align_fill.d: New.
* gas/nios2/align_fill.s: New.
* gas/nios2/align_text.d: New.
* gas/nios2/align_text.s: New.
* gas/nios2/and.d: New.
* gas/nios2/and.s: New.
* gas/nios2/branch.d: New.
* gas/nios2/branch.s: New.
* gas/nios2/break.d: New.
* gas/nios2/break.s: New.
* gas/nios2/bret.d: New.
* gas/nios2/bret.s: New.
* gas/nios2/cache.d: New.
* gas/nios2/cache.s: New.
* gas/nios2/call26.d: New.
* gas/nios2/call26.s: New.
* gas/nios2/call.d: New.
* gas/nios2/call.s: New.
* gas/nios2/cmp.d: New.
* gas/nios2/cmp.s: New.
* gas/nios2/comments.d: New.
* gas/nios2/comments.s: New.
* gas/nios2/complex.d: New.
* gas/nios2/complex.s: New.
* gas/nios2/ctl.d: New.
* gas/nios2/ctl.s: New.
* gas/nios2/custom.d: New.
* gas/nios2/custom.s: New.
* gas/nios2/etbt.d: New.
* gas/nios2/etbt.s: New.
* gas/nios2/flushda.d: New.
* gas/nios2/flushda.s: New.
* gas/nios2/illegal.l: New.
* gas/nios2/illegal.s: New.
* gas/nios2/jmp.d: New.
* gas/nios2/jmp.s: New.
* gas/nios2/ldb.d: New.
* gas/nios2/ldb.s: New.
* gas/nios2/ldh.d: New.
* gas/nios2/ldh.s: New.
* gas/nios2/ldw.d: New.
* gas/nios2/ldw.s: New.
* gas/nios2/lineseparator.d: New.
* gas/nios2/lineseparator.s: New.
* gas/nios2/mov.d: New.
* gas/nios2/movia.d: New.
* gas/nios2/movia.s: New.
* gas/nios2/movi.d: New.
* gas/nios2/movi.s: New.
* gas/nios2/mov.s: New.
* gas/nios2/mul.d: New.
* gas/nios2/mul.s: New.
* gas/nios2/nios2.exp: New.
* gas/nios2/nor.d: New.
* gas/nios2/nor.s: New.
* gas/nios2/or.d: New.
* gas/nios2/or.s: New.
* gas/nios2/ret.d: New.
* gas/nios2/ret.s: New.
* gas/nios2/rol.d: New.
* gas/nios2/rol.s: New.
* gas/nios2/rotate.d: New.
* gas/nios2/rotate.s: New.
* gas/nios2/stb.d: New.
* gas/nios2/stb.s: New.
* gas/nios2/sth.d: New.
* gas/nios2/sth.s: New.
* gas/nios2/stw.d: New.
* gas/nios2/stw.s: New.
* gas/nios2/sub.d: New.
* gas/nios2/sub.s: New.
* gas/nios2/sync.d: New.
* gas/nios2/sync.s: New.
* gas/nios2/trap.d: New.
* gas/nios2/trap.s: New.
* gas/nios2/tret.d: New.
* gas/nios2/tret.s: New.
* gas/nios2/warn_noat.l: New.
* gas/nios2/warn_noat.s: New.
* gas/nios2/warn_nobreak.l: New.
* gas/nios2/warn_nobreak.s: New.
* gas/nios2/xor.d: New.
* gas/nios2/xor.s: New.
ld/
* Makefile.am (enios2elf.c): New rule.
* Makefile.in: Regenerated.
* configure.tgt: Add case for nios2*-*-*.
* emulparams/nios2elf.sh: New file.
* NEWS: Note Altera Nios II support.
ld/testsuite/
* ld-nios2/emit-relocs-1a.s: New.
* ld-nios2/emit-relocs-1b.s: New.
* ld-nios2/emit-relocs-1.d: New.
* ld-nios2/emit-relocs-1.ld: New.
* ld-nios2/gprel.d: New.
* ld-nios2/gprel.s: New.
* ld-nios2/hilo16.d: New.
* ld-nios2/hilo16.s: New.
* ld-nios2/hilo16_symbol.s: New.
* ld-nios2/imm5.d: New.
* ld-nios2/imm5.s: New.
* ld-nios2/imm5_symbol.s: New.
* ld-nios2/nios2.exp: New.
* ld-nios2/pcrel16.d: New.
* ld-nios2/pcrel16_label.s: New.
* ld-nios2/pcrel16.s: New.
* ld-nios2/relax_callr.d: New.
* ld-nios2/relax_callr.ld: New.
* ld-nios2/relax_callr.s: New.
* ld-nios2/relax_cjmp.d: New.
* ld-nios2/relax_cjmp.s: New.
* ld-nios2/relax_jmp.ld: New.
* ld-nios2/relax_section.d: New.
* ld-nios2/relax_section.s: New.
* ld-nios2/relax_ujmp.d: New.
* ld-nios2/relax_ujmp.s: New.
* ld-nios2/reloc.d: New.
* ld-nios2/reloc.s: New.
* ld-nios2/reloc_symbol.s: New.
* ld-nios2/s16.d: New.
* ld-nios2/s16.s: New.
* ld-nios2/s16_symbol.s: New.
* ld-nios2/u16.d: New.
* ld-nios2/u16.s: New.
* ld-nios2/u16_symbol.s: New.
* ld-elf/indirect.exp: Skip on targets that don't support
-shared -fPIC.
* ld-elfcomm/elfcomm.exp: Build with -G0 for nios2.
* ld-plugin/lto.exp: Skip shared library tests on targets that
don't support them. Skip execution tests on non-native targets.
binutils/
* readelf.c: Include elf/nios2.h.
(dump_relocations): Add case for EM_ALTERA_NIOS2.
(get_nios2_dynamic_type): New.
(get_dynamic_type): Add case for EM_ALTERA_NIOS2.
(is_32bit_abs_reloc): Fix EM_ALTERA_NIOS2 case.
(is_16bit_abs_reloc): Likewise.
(is_none_reloc): Add EM_ALTERA_NIOS2 and EM_NIOS32 cases.
* NEWS: Note Altera Nios II support.
* MAINTAINERS: Add Nios II maintainers.
Diffstat (limited to 'ld/testsuite/ld-nios2')
35 files changed, 610 insertions, 0 deletions
diff --git a/ld/testsuite/ld-nios2/emit-relocs-1.d b/ld/testsuite/ld-nios2/emit-relocs-1.d new file mode 100644 index 0000000..aba0a53 --- /dev/null +++ b/ld/testsuite/ld-nios2/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_NIOS2_BFD_RELOC32 \.data +00000004 R_NIOS2_BFD_RELOC32 \.data\+0x00001000 +00000008 R_NIOS2_BFD_RELOC32 \.merge1\+0x00000002 +0000000c R_NIOS2_BFD_RELOC32 \.merge2 +00000010 R_NIOS2_BFD_RELOC32 \.merge3 +00000014 R_NIOS2_BFD_RELOC32 \.merge3\+0x00000004 +00000020 R_NIOS2_BFD_RELOC32 \.data\+0x00000020 +00000024 R_NIOS2_BFD_RELOC32 \.data\+0x00001020 +00000028 R_NIOS2_BFD_RELOC32 \.merge1 +0000002c R_NIOS2_BFD_RELOC32 \.merge2\+0x00000002 +00000030 R_NIOS2_BFD_RELOC32 \.merge3\+0x00000008 +00000034 R_NIOS2_BFD_RELOC32 \.merge3\+0x00000004 + + +Contents of section \.text: + 80000 3a880100 00000000 00000000 00000000 .* +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-nios2/emit-relocs-1.ld b/ld/testsuite/ld-nios2/emit-relocs-1.ld new file mode 100644 index 0000000..1879ef4 --- /dev/null +++ b/ld/testsuite/ld-nios2/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-nios2/emit-relocs-1a.s b/ld/testsuite/ld-nios2/emit-relocs-1a.s new file mode 100644 index 0000000..bf0a8a1 --- /dev/null +++ b/ld/testsuite/ld-nios2/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-nios2/emit-relocs-1b.s b/ld/testsuite/ld-nios2/emit-relocs-1b.s new file mode 100644 index 0000000..82229c1 --- /dev/null +++ b/ld/testsuite/ld-nios2/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-nios2/gprel.d b/ld/testsuite/ld-nios2/gprel.d new file mode 100644 index 0000000..202aece --- /dev/null +++ b/ld/testsuite/ld-nios2/gprel.d @@ -0,0 +1,17 @@ +#name: NIOS2 gp-relative relocations +#source: gprel.s +#ld: +#objdump: -dr --prefix-addresses + +# Test the %gprel macro. + +.*: +file format elf32-littlenios2 + +Disassembly of section .text: +[0-9a-f]+ <[^>]*> movui gp,[0-9]+ +[0-9a-f]+ <[^>]*> ldw at,-[0-9]+\(gp\) +[0-9a-f]+ <[^>]*> ldw r2,-[0-9]+\(gp\) +[0-9a-f]+ <[^>]*> ldb r3,-[0-9]+\(gp\) +[0-9a-f]+ <[^>]*> ldw at,-[0-9]+\(gp\) +[0-9a-f]+ <[^>]*> ldw r2,-[0-9]+\(gp\) +[0-9a-f]+ <[^>]*> ldb r3,-[0-9]+\(gp\) diff --git a/ld/testsuite/ld-nios2/gprel.s b/ld/testsuite/ld-nios2/gprel.s new file mode 100644 index 0000000..2414722 --- /dev/null +++ b/ld/testsuite/ld-nios2/gprel.s @@ -0,0 +1,29 @@ +.set noat + +.sdata + +sym1: +.long 0xdead +sym2: +.long 0xbeef +sym3: +.byte 0x7f + +.section .sbss, "w" +sym4: +.long 0 +sym5: +.long 0 +sym6: +.byte 0 + +.text +.global _start +_start: + movui gp, _gp + ldw r1, %gprel(sym1)(gp) + ldw r2, %gprel(sym2)(gp) + ldb r3, %gprel(sym3)(gp) + ldw r1, %gprel(sym4)(gp) + ldw r2, %gprel(sym5)(gp) + ldb r3, %gprel(sym6)(gp) diff --git a/ld/testsuite/ld-nios2/hilo16.d b/ld/testsuite/ld-nios2/hilo16.d new file mode 100644 index 0000000..c703413 --- /dev/null +++ b/ld/testsuite/ld-nios2/hilo16.d @@ -0,0 +1,13 @@ +#name: NIOS2 R_NIOS2_HI16,LO16,HIADJ16 +#source: hilo16.s +#source: hilo16_symbol.s +#ld: +#objdump: -dr --prefix-addresses + +# Test the %hi, %lo and %hiadi relocations +.*: +file format elf32-littlenios2 + +Disassembly of section .text: +[0-9a-f]+ <[^>]*> addi at,at,-8531 +[0-9a-f]+ <[^>]*> addi at,at,-16657 +[0-9a-f]+ <[^>]*> addi at,at,-8530 diff --git a/ld/testsuite/ld-nios2/hilo16.s b/ld/testsuite/ld-nios2/hilo16.s new file mode 100644 index 0000000..47b404f1 --- /dev/null +++ b/ld/testsuite/ld-nios2/hilo16.s @@ -0,0 +1,10 @@ +# Test the %hi, lo and %hiadj relocations + +.set noat + +.text +.global _start +_start: + addi r1, r1, %hi(long_symbol) + addi r1, r1, %lo(long_symbol) + addi r1, r1, %hiadj(long_symbol) diff --git a/ld/testsuite/ld-nios2/hilo16_symbol.s b/ld/testsuite/ld-nios2/hilo16_symbol.s new file mode 100644 index 0000000..88fdddc --- /dev/null +++ b/ld/testsuite/ld-nios2/hilo16_symbol.s @@ -0,0 +1,3 @@ +.global long_symbol +.set long_symbol, 0xDEADBEEF + diff --git a/ld/testsuite/ld-nios2/imm5.d b/ld/testsuite/ld-nios2/imm5.d new file mode 100644 index 0000000..2640c9c --- /dev/null +++ b/ld/testsuite/ld-nios2/imm5.d @@ -0,0 +1,13 @@ +#name: NIOS2 R_NIOS2_IMM5 +#source: imm5.s +#source: imm5_symbol.s +#ld: +#objdump: -dr --prefix-addresses + +# Test the branch instructions. +.*: +file format elf32-littlenios2 + +Disassembly of section .text: +[0-9a-f]+ <[^>]*> roli at,at,31 +[0-9a-f]+ <.[^>]*> Address 0x[0-9a-f]+ is out of bounds. + diff --git a/ld/testsuite/ld-nios2/imm5.s b/ld/testsuite/ld-nios2/imm5.s new file mode 100644 index 0000000..21bbfc3 --- /dev/null +++ b/ld/testsuite/ld-nios2/imm5.s @@ -0,0 +1,9 @@ +# Test the imm5 relocation + +.set noat +.text +.global _start +_start: + roli r1, r1, imm5 + + diff --git a/ld/testsuite/ld-nios2/imm5_symbol.s b/ld/testsuite/ld-nios2/imm5_symbol.s new file mode 100644 index 0000000..d988951 --- /dev/null +++ b/ld/testsuite/ld-nios2/imm5_symbol.s @@ -0,0 +1,4 @@ +.global imm5 +.text +.byte imm5 +.set imm5, 31 diff --git a/ld/testsuite/ld-nios2/nios2.exp b/ld/testsuite/ld-nios2/nios2.exp new file mode 100644 index 0000000..22080b4 --- /dev/null +++ b/ld/testsuite/ld-nios2/nios2.exp @@ -0,0 +1,7 @@ +if { ! [istarget nios2-*-*] } { + return +} + +foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.d]] { + run_dump_test [file rootname $test] +} diff --git a/ld/testsuite/ld-nios2/pcrel16.d b/ld/testsuite/ld-nios2/pcrel16.d new file mode 100644 index 0000000..d4dda2e --- /dev/null +++ b/ld/testsuite/ld-nios2/pcrel16.d @@ -0,0 +1,15 @@ +#name: NIOS2 R_NIOS2_PCREL16 +#source: pcrel16.s +#source: pcrel16_label.s +#ld: +#objdump: -dr --prefix-addresses + +# Test the relative branch relocations. +.*: +file format elf32-littlenios2 + +Disassembly of section .text: + +[0-9a-f]+ <[^>]*> br [0-9a-f]+ <ext_label> +[0-9a-f]+ <[^>]*> br [0-9a-f]+ <ext_label\+0x10> +[0-9a-f]+ <[^>]*> nop +[0-9a-f]+ <[^>]*> nop diff --git a/ld/testsuite/ld-nios2/pcrel16.s b/ld/testsuite/ld-nios2/pcrel16.s new file mode 100644 index 0000000..61c1c7e --- /dev/null +++ b/ld/testsuite/ld-nios2/pcrel16.s @@ -0,0 +1,8 @@ +# Test for pc-relative relocations +.set norelax +.text +.global _start +_start: + br ext_label + br ext_label + 16 + diff --git a/ld/testsuite/ld-nios2/pcrel16_label.s b/ld/testsuite/ld-nios2/pcrel16_label.s new file mode 100644 index 0000000..3a76612 --- /dev/null +++ b/ld/testsuite/ld-nios2/pcrel16_label.s @@ -0,0 +1,5 @@ +.text +ext_label: + nop + nop +.global ext_label diff --git a/ld/testsuite/ld-nios2/relax_callr.d b/ld/testsuite/ld-nios2/relax_callr.d new file mode 100644 index 0000000..7d40fe4 --- /dev/null +++ b/ld/testsuite/ld-nios2/relax_callr.d @@ -0,0 +1,24 @@ +#name: NIOS2 relax_callr +#as: -relax-all +#ld: --relax -Trelax_callr.ld +#source: relax_callr.s +#objdump: -dr --prefix-addresses +# Test relaxation of callr + +.*: +file format elf32-littlenios2 + +Disassembly of section text1: +00000000 <[^>]*> movhi at,2048 +00000004 <[^>]*> ori at,at,0 +00000008 <[^>]*> callr at +0000000c <[^>]*> movhi at,2048 +00000010 <[^>]*> ori at,at,20 +00000014 <[^>]*> callr at + +Disassembly of section text2: +08000000 <func> nop +08000004 <[^>]*> br 08000014 <func1> +08000008 <[^>]*> nop +0800000c <[^>]*> nop +08000010 <[^>]*> nop +08000014 <func1> nop diff --git a/ld/testsuite/ld-nios2/relax_callr.ld b/ld/testsuite/ld-nios2/relax_callr.ld new file mode 100644 index 0000000..bc02d40 --- /dev/null +++ b/ld/testsuite/ld-nios2/relax_callr.ld @@ -0,0 +1,11 @@ +/* Simple script for testing relaxation */ + +OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2") +OUTPUT_ARCH(nios2) +ENTRY(_start) +SECTIONS +{ + _start = .; + text1 0 : { *(text1) } + text2 0x08000000 : { *(text2) } +} diff --git a/ld/testsuite/ld-nios2/relax_callr.s b/ld/testsuite/ld-nios2/relax_callr.s new file mode 100644 index 0000000..b4cc2c4 --- /dev/null +++ b/ld/testsuite/ld-nios2/relax_callr.s @@ -0,0 +1,17 @@ +# relaxation test for callr + +.globl text1 +.section text1, "ax", @progbits + + call func + call func1 + +.section text2, "ax", @progbits +func: + nop + br func1 + nop + nop + nop +func1: + nop diff --git a/ld/testsuite/ld-nios2/relax_cjmp.d b/ld/testsuite/ld-nios2/relax_cjmp.d new file mode 100644 index 0000000..535c59d --- /dev/null +++ b/ld/testsuite/ld-nios2/relax_cjmp.d @@ -0,0 +1,38 @@ +#name: NIOS2 relax_cjmp +#as: -relax-all +#ld: --relax -Trelax_jmp.ld +#source: relax_cjmp.s +#objdump: -dr --prefix-addresses + +# Test relaxation of conditional jumps + +.*: +file format elf32-littlenios2 + +Disassembly of section text2: +00000000 <[^>]*> bge r2,r3,00008000 <[^>]*> +00000004 <[^>]*> bge r2,r3,00000014 <[^>]*> +00000008 <[^>]*> movhi at,1 +0000000c <[^>]*> ori at,at,24 +00000010 <[^>]*> jmp at +00000014 <[^>]*> bge r3,r2,00000020 <sym> +00000018 <[^>]*> nop +0000001c <[^>]*> nop +00000020 <sym> nop + +Disassembly of section text1: +00008000 <[^>]*> beq r2,r3,00010000 <on_border> +00008004 <[^>]*> bne r2,r3,00008014 <[^>]*> +00008008 <[^>]*> movhi at,1 +0000800c <[^>]*> ori at,at,24 +00008010 <[^>]*> jmp at +00008014 <[^>]*> nop +00008018 <[^>]*> nop +#... +00010000 <on_border> bne r2,r3,00010018 <in_range> +00010004 <[^>]*> nop +00010008 <[^>]*> nop +0001000c <[^>]*> nop +00010010 <[^>]*> nop +00010014 <[^>]*> nop +00010018 <in_range> nop +#pass diff --git a/ld/testsuite/ld-nios2/relax_cjmp.s b/ld/testsuite/ld-nios2/relax_cjmp.s new file mode 100644 index 0000000..af00a1e --- /dev/null +++ b/ld/testsuite/ld-nios2/relax_cjmp.s @@ -0,0 +1,32 @@ +# relaxing conditional jumps -- absolute + +.globl text1 +.section text1, "ax", @progbits + beq r2, r3, on_border + beq r2, r3, out_of_range + nop + nop + +.align 15 +on_border: + bne r2, r3, in_range + nop + nop + nop + nop + nop +out_of_range: +in_range: + nop + +.globl text2 +.section text2, "ax", @progbits + + bge r2, r3, text1 + blt r2, r3, out_of_range + ble r2, r3, sym + nop + nop +sym: + nop + diff --git a/ld/testsuite/ld-nios2/relax_jmp.ld b/ld/testsuite/ld-nios2/relax_jmp.ld new file mode 100644 index 0000000..df6c220 --- /dev/null +++ b/ld/testsuite/ld-nios2/relax_jmp.ld @@ -0,0 +1,11 @@ +/* Simple script for testing relaxation */ + +OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2") +OUTPUT_ARCH(nios2) +ENTRY(_start) +SECTIONS +{ + _start = .; + text2 0 : { *(text2) } + text1 0x8000 : { *(text1) } +} diff --git a/ld/testsuite/ld-nios2/relax_section.d b/ld/testsuite/ld-nios2/relax_section.d new file mode 100644 index 0000000..93980cd --- /dev/null +++ b/ld/testsuite/ld-nios2/relax_section.d @@ -0,0 +1,35 @@ +#name: NIOS2 relax_section +#as: -relax-section +#ld: --relax -Trelax_jmp.ld +#source: relax_section.s +#objdump: -dr --prefix-addresses + +# Test relaxation of section + +.*: +file format elf32-littlenios2 + +Disassembly of section text1: +00008000 <[^>]*> bne r2,r3,00008010 <[^>]*> +00008004 <[^>]*> nextpc at +00008008 <[^>]*> addi at,at,32764 +0000800c <[^>]*> jmp at +00008010 <[^>]*> bge r2,r3,00008024 <[^>]*> +00008014 <[^>]*> nextpc at +00008018 <[^>]*> addi at,at,32767 +0000801c <[^>]*> addi at,at,9 +00008020 <[^>]*> jmp at +00008024 <[^>]*> bne r2,r3,00008030 <in_range> +00008028 <[^>]*> nop +0000802c <[^>]*> nop +00008030 <in_range> nop +#... +00010000 <[^>]*> br 00008030 <in_range> +00010004 <just_out_of_range> nop +00010008 <[^>]*> nop +0001000c <[^>]*> nop +00010010 <[^>]*> nop +00010014 <[^>]*> nop +00010018 <[^>]*> nop +0001001c <[^>]*> nop +00010020 <farther_out_of_range> nop +#pass diff --git a/ld/testsuite/ld-nios2/relax_section.s b/ld/testsuite/ld-nios2/relax_section.s new file mode 100644 index 0000000..0e803d1 --- /dev/null +++ b/ld/testsuite/ld-nios2/relax_section.s @@ -0,0 +1,23 @@ +# relaxing conditional and unconditional jumps -- pc-relative + +.globl text1 +.section text1, "ax", @progbits + beq r2, r3, just_out_of_range + blt r2, r3, farther_out_of_range + bne r2, r3, in_range + nop + nop +in_range: + nop +.align 15 + br in_range +just_out_of_range: + nop + nop + nop + nop + nop + nop + nop +farther_out_of_range: + nop diff --git a/ld/testsuite/ld-nios2/relax_ujmp.d b/ld/testsuite/ld-nios2/relax_ujmp.d new file mode 100644 index 0000000..68313c1 --- /dev/null +++ b/ld/testsuite/ld-nios2/relax_ujmp.d @@ -0,0 +1,32 @@ +#name: NIOS2 relax_ujmp +#as: -relax-all +#ld: --relax -Trelax_jmp.ld +#source: relax_ujmp.s +#objdump: -dr --prefix-addresses + +# Test relaxation of unconditional jumps + +.*: +file format elf32-littlenios2 + +Disassembly of section text2: +00000000 <[^>]*> br 00008000 <[^>]*> +00000004 <[^>]*> movhi at,1 +00000008 <[^>]*> ori at,at,16 +0000000c <[^>]*> jmp at +00000010 <[^>]*> br 0000001c <sym> +00000014 <[^>]*> nop +00000018 <[^>]*> nop +0000001c <sym> nop + +Disassembly of section text1: +00008000 <[^>]*> br 00010000 <on_border> +00008004 <[^>]*> movhi at,1 +00008008 <[^>]*> ori at,at,16 +0000800c <[^>]*> jmp at +#... +00010000 <on_border> br 00010010 <in_range> +00010004 <[^>]*> nop +00010008 <[^>]*> nop +0001000c <[^>]*> nop +00010010 <in_range> nop +#pass diff --git a/ld/testsuite/ld-nios2/relax_ujmp.s b/ld/testsuite/ld-nios2/relax_ujmp.s new file mode 100644 index 0000000..8982d73 --- /dev/null +++ b/ld/testsuite/ld-nios2/relax_ujmp.s @@ -0,0 +1,37 @@ +# relaxing unconditional jumps + +.globl text1 +.section text1, "ax", @progbits + + br on_border + br out_of_range + nop + nop + + +.align 15 +# nop +# nop +on_border: + br in_range + nop + nop + nop +out_of_range: +in_range: + nop + +.globl text2 +.section text2, "ax", @progbits + + br text1 + br out_of_range + br sym + nop + nop +sym: + nop + + + + diff --git a/ld/testsuite/ld-nios2/reloc.d b/ld/testsuite/ld-nios2/reloc.d new file mode 100644 index 0000000..cb2959d --- /dev/null +++ b/ld/testsuite/ld-nios2/reloc.d @@ -0,0 +1,10 @@ +#name: NIOS2 R_NIOS2_BFD_RELOC_XX +#source: reloc.s +#source: reloc_symbol.s +#ld: +#objdump: -s + +.*: +file format elf32-littlenios2 + +Contents of section .text: + [0-9a-f]+ fa00cefa efbeadde facefaef beadde00 ................ diff --git a/ld/testsuite/ld-nios2/reloc.s b/ld/testsuite/ld-nios2/reloc.s new file mode 100644 index 0000000..2d555c3 --- /dev/null +++ b/ld/testsuite/ld-nios2/reloc.s @@ -0,0 +1,9 @@ +# Test for Nios II 32-bit, 16 and 8-bit relocations + +.global byte_sym +.global short_sym +.global long_sym + +.set byte_sym, 0xFA +.set short_sym, 0xFACE +.set long_sym, 0xDEADBEEF diff --git a/ld/testsuite/ld-nios2/reloc_symbol.s b/ld/testsuite/ld-nios2/reloc_symbol.s new file mode 100644 index 0000000..fa7ac95 --- /dev/null +++ b/ld/testsuite/ld-nios2/reloc_symbol.s @@ -0,0 +1,24 @@ +.text +.global _start +_start: + +# byte aligned +.align 0 +.byte byte_sym + +# short aligned +.align 1 +.short short_sym + +# word aligned +.align 2 +.long long_sym + +# now lets try some unaligned words and halfwords +.byte byte_sym +.2byte short_sym +.4byte long_sym + +#.align 2 +#nop + diff --git a/ld/testsuite/ld-nios2/s16.d b/ld/testsuite/ld-nios2/s16.d new file mode 100644 index 0000000..6257e18 --- /dev/null +++ b/ld/testsuite/ld-nios2/s16.d @@ -0,0 +1,12 @@ +#name: NIOS2 R_NIOS2_S16 +#source: s16.s +#source: s16_symbol.s +#ld: +#objdump: -s + +# Test the signed 16-bit relocations. +.*: +file format elf32-littlenios2 + +Contents of section .text: + [0-9a-f]+ 04004408 04006008 c4ff5f08 44004808 ..D...`..._.D.H. + [0-9a-f]+ 44004008 D.@. diff --git a/ld/testsuite/ld-nios2/s16.s b/ld/testsuite/ld-nios2/s16.s new file mode 100644 index 0000000..df13efa --- /dev/null +++ b/ld/testsuite/ld-nios2/s16.s @@ -0,0 +1,16 @@ +# Test for Nios II 32-bit, 16 and 8-bit relocations + +.set noat +.set some_other_sym, 0x1000 +.text +.global _start +_start: +# signed 16-bit relocation + addi r1, r1, some_sym + addi r1, r1, min + addi r1, r1, max + addi r1, r1, some_sym + some_other_sym + 1 + addi r1, r1, some_sym - some_other_sym + 1 + + + diff --git a/ld/testsuite/ld-nios2/s16_symbol.s b/ld/testsuite/ld-nios2/s16_symbol.s new file mode 100644 index 0000000..3902177 --- /dev/null +++ b/ld/testsuite/ld-nios2/s16_symbol.s @@ -0,0 +1,10 @@ +.global some_sym +.global some_other_sym +.global min +.global max + +.set max, 0x7fff +.set min, -0x8000 +.set some_sym, 0x1000 + + diff --git a/ld/testsuite/ld-nios2/u16.d b/ld/testsuite/ld-nios2/u16.d new file mode 100644 index 0000000..7d1df05 --- /dev/null +++ b/ld/testsuite/ld-nios2/u16.d @@ -0,0 +1,12 @@ +#name: NIOS2 R_NIOS2_U16 +#source: u16.s +#source: u16_symbol.s +#ld: +#objdump: -s + +# Test the unsigned 16-bit relocations. +.*: +file format elf32-littlenios2 + +Contents of section .text: + [0-9a-f]+ 0c004408 0c004008 ccff7f08 4c004808 ..D...@.....L.H. + [0-9a-f]+ 4c004008 L.@. diff --git a/ld/testsuite/ld-nios2/u16.s b/ld/testsuite/ld-nios2/u16.s new file mode 100644 index 0000000..b890682 --- /dev/null +++ b/ld/testsuite/ld-nios2/u16.s @@ -0,0 +1,16 @@ +# Test for Nios II 32-bit, 16 and 8-bit relocations + +.set noat +.set some_other_sym, 0x1000 +.text +.global _start +_start: +# unsigned 16-bit relocation + andi r1, r1, some_sym + andi r1, r1, min + andi r1, r1, max + andi r1, r1, some_sym + some_other_sym + 1 + andi r1, r1, some_sym - some_other_sym + 1 + + + diff --git a/ld/testsuite/ld-nios2/u16_symbol.s b/ld/testsuite/ld-nios2/u16_symbol.s new file mode 100644 index 0000000..518b4de --- /dev/null +++ b/ld/testsuite/ld-nios2/u16_symbol.s @@ -0,0 +1,9 @@ +.global some_sym +.global min +.global max + +.set max, 0xffff +.set min, 0 +.set some_sym, 0x1000 + + |