From 180ca03b42ba20ef4969e7ecb4c5056e56ad489a Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Wed, 6 Feb 2013 23:22:06 +0000 Subject: 2013-02-06 Sandra Loosemore Andrew Jenner 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. --- ld/testsuite/ld-nios2/emit-relocs-1.d | 37 +++++++++++++++++++++++++++++++++ ld/testsuite/ld-nios2/emit-relocs-1.ld | 20 ++++++++++++++++++ ld/testsuite/ld-nios2/emit-relocs-1a.s | 24 +++++++++++++++++++++ ld/testsuite/ld-nios2/emit-relocs-1b.s | 18 ++++++++++++++++ ld/testsuite/ld-nios2/gprel.d | 17 +++++++++++++++ ld/testsuite/ld-nios2/gprel.s | 29 ++++++++++++++++++++++++++ ld/testsuite/ld-nios2/hilo16.d | 13 ++++++++++++ ld/testsuite/ld-nios2/hilo16.s | 10 +++++++++ ld/testsuite/ld-nios2/hilo16_symbol.s | 3 +++ ld/testsuite/ld-nios2/imm5.d | 13 ++++++++++++ ld/testsuite/ld-nios2/imm5.s | 9 ++++++++ ld/testsuite/ld-nios2/imm5_symbol.s | 4 ++++ ld/testsuite/ld-nios2/nios2.exp | 7 +++++++ ld/testsuite/ld-nios2/pcrel16.d | 15 ++++++++++++++ ld/testsuite/ld-nios2/pcrel16.s | 8 +++++++ ld/testsuite/ld-nios2/pcrel16_label.s | 5 +++++ ld/testsuite/ld-nios2/relax_callr.d | 24 +++++++++++++++++++++ ld/testsuite/ld-nios2/relax_callr.ld | 11 ++++++++++ ld/testsuite/ld-nios2/relax_callr.s | 17 +++++++++++++++ ld/testsuite/ld-nios2/relax_cjmp.d | 38 ++++++++++++++++++++++++++++++++++ ld/testsuite/ld-nios2/relax_cjmp.s | 32 ++++++++++++++++++++++++++++ ld/testsuite/ld-nios2/relax_jmp.ld | 11 ++++++++++ ld/testsuite/ld-nios2/relax_section.d | 35 +++++++++++++++++++++++++++++++ ld/testsuite/ld-nios2/relax_section.s | 23 ++++++++++++++++++++ ld/testsuite/ld-nios2/relax_ujmp.d | 32 ++++++++++++++++++++++++++++ ld/testsuite/ld-nios2/relax_ujmp.s | 37 +++++++++++++++++++++++++++++++++ ld/testsuite/ld-nios2/reloc.d | 10 +++++++++ ld/testsuite/ld-nios2/reloc.s | 9 ++++++++ ld/testsuite/ld-nios2/reloc_symbol.s | 24 +++++++++++++++++++++ ld/testsuite/ld-nios2/s16.d | 12 +++++++++++ ld/testsuite/ld-nios2/s16.s | 16 ++++++++++++++ ld/testsuite/ld-nios2/s16_symbol.s | 10 +++++++++ ld/testsuite/ld-nios2/u16.d | 12 +++++++++++ ld/testsuite/ld-nios2/u16.s | 16 ++++++++++++++ ld/testsuite/ld-nios2/u16_symbol.s | 9 ++++++++ 35 files changed, 610 insertions(+) create mode 100644 ld/testsuite/ld-nios2/emit-relocs-1.d create mode 100644 ld/testsuite/ld-nios2/emit-relocs-1.ld create mode 100644 ld/testsuite/ld-nios2/emit-relocs-1a.s create mode 100644 ld/testsuite/ld-nios2/emit-relocs-1b.s create mode 100644 ld/testsuite/ld-nios2/gprel.d create mode 100644 ld/testsuite/ld-nios2/gprel.s create mode 100644 ld/testsuite/ld-nios2/hilo16.d create mode 100644 ld/testsuite/ld-nios2/hilo16.s create mode 100644 ld/testsuite/ld-nios2/hilo16_symbol.s create mode 100644 ld/testsuite/ld-nios2/imm5.d create mode 100644 ld/testsuite/ld-nios2/imm5.s create mode 100644 ld/testsuite/ld-nios2/imm5_symbol.s create mode 100644 ld/testsuite/ld-nios2/nios2.exp create mode 100644 ld/testsuite/ld-nios2/pcrel16.d create mode 100644 ld/testsuite/ld-nios2/pcrel16.s create mode 100644 ld/testsuite/ld-nios2/pcrel16_label.s create mode 100644 ld/testsuite/ld-nios2/relax_callr.d create mode 100644 ld/testsuite/ld-nios2/relax_callr.ld create mode 100644 ld/testsuite/ld-nios2/relax_callr.s create mode 100644 ld/testsuite/ld-nios2/relax_cjmp.d create mode 100644 ld/testsuite/ld-nios2/relax_cjmp.s create mode 100644 ld/testsuite/ld-nios2/relax_jmp.ld create mode 100644 ld/testsuite/ld-nios2/relax_section.d create mode 100644 ld/testsuite/ld-nios2/relax_section.s create mode 100644 ld/testsuite/ld-nios2/relax_ujmp.d create mode 100644 ld/testsuite/ld-nios2/relax_ujmp.s create mode 100644 ld/testsuite/ld-nios2/reloc.d create mode 100644 ld/testsuite/ld-nios2/reloc.s create mode 100644 ld/testsuite/ld-nios2/reloc_symbol.s create mode 100644 ld/testsuite/ld-nios2/s16.d create mode 100644 ld/testsuite/ld-nios2/s16.s create mode 100644 ld/testsuite/ld-nios2/s16_symbol.s create mode 100644 ld/testsuite/ld-nios2/u16.d create mode 100644 ld/testsuite/ld-nios2/u16.s create mode 100644 ld/testsuite/ld-nios2/u16_symbol.s (limited to 'ld/testsuite/ld-nios2') 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 0000000000..aba0a535d9 --- /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 0000000000..1879ef4cbe --- /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 0000000000..bf0a8a1689 --- /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 0000000000..82229c1495 --- /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 0000000000..202aece4dc --- /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 0000000000..2414722919 --- /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 0000000000..c703413392 --- /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 0000000000..47b404f177 --- /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 0000000000..88fdddccae --- /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 0000000000..2640c9c623 --- /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 0000000000..21bbfc3c45 --- /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 0000000000..d988951401 --- /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 0000000000..22080b49d7 --- /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 0000000000..d4dda2e9e8 --- /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]+ +[0-9a-f]+ <[^>]*> br [0-9a-f]+ +[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 0000000000..61c1c7e51d --- /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 0000000000..3a76612692 --- /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 0000000000..7d40fe4005 --- /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 nop +08000004 <[^>]*> br 08000014 +08000008 <[^>]*> nop +0800000c <[^>]*> nop +08000010 <[^>]*> nop +08000014 nop diff --git a/ld/testsuite/ld-nios2/relax_callr.ld b/ld/testsuite/ld-nios2/relax_callr.ld new file mode 100644 index 0000000000..bc02d40aa8 --- /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 0000000000..b4cc2c473f --- /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 0000000000..535c59d5b2 --- /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 +00000018 <[^>]*> nop +0000001c <[^>]*> nop +00000020 nop + +Disassembly of section text1: +00008000 <[^>]*> beq r2,r3,00010000 +00008004 <[^>]*> bne r2,r3,00008014 <[^>]*> +00008008 <[^>]*> movhi at,1 +0000800c <[^>]*> ori at,at,24 +00008010 <[^>]*> jmp at +00008014 <[^>]*> nop +00008018 <[^>]*> nop +#... +00010000 bne r2,r3,00010018 +00010004 <[^>]*> nop +00010008 <[^>]*> nop +0001000c <[^>]*> nop +00010010 <[^>]*> nop +00010014 <[^>]*> nop +00010018 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 0000000000..af00a1e381 --- /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 0000000000..df6c2208e8 --- /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 0000000000..93980cdcd0 --- /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 +00008028 <[^>]*> nop +0000802c <[^>]*> nop +00008030 nop +#... +00010000 <[^>]*> br 00008030 +00010004 nop +00010008 <[^>]*> nop +0001000c <[^>]*> nop +00010010 <[^>]*> nop +00010014 <[^>]*> nop +00010018 <[^>]*> nop +0001001c <[^>]*> nop +00010020 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 0000000000..0e803d115a --- /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 0000000000..68313c123b --- /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 +00000014 <[^>]*> nop +00000018 <[^>]*> nop +0000001c nop + +Disassembly of section text1: +00008000 <[^>]*> br 00010000 +00008004 <[^>]*> movhi at,1 +00008008 <[^>]*> ori at,at,16 +0000800c <[^>]*> jmp at +#... +00010000 br 00010010 +00010004 <[^>]*> nop +00010008 <[^>]*> nop +0001000c <[^>]*> nop +00010010 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 0000000000..8982d73979 --- /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 0000000000..cb2959d23d --- /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 0000000000..2d555c3547 --- /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 0000000000..fa7ac95545 --- /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 0000000000..6257e18078 --- /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 0000000000..df13efa006 --- /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 0000000000..3902177fd9 --- /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 0000000000..7d1df05711 --- /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 0000000000..b890682391 --- /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 0000000000..518b4def8e --- /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 + + -- cgit v1.2.1