From: Dimitar Dimitrov Date: Fri, 30 Dec 2016 10:39:49 +0000 (+0200) Subject: PRU LD Port X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0220170b4d87ce940d40ac98387ff2d7fbed3ab2;p=binutils-gdb.git PRU LD Port * NEWS: Mention new PRU target. * Makefile.am: Add PRU target. * configure.tgt: Ditto. * emulparams/pruelf.sh: New file. * emultempl/pruelf.em: New file. * scripttempl/pru.sc: New file. * Makefile.in: Regenerate. * testsuite/ld-pru/emit-relocs-1.d: New PRU testcase file. * testsuite/ld-pru/emit-relocs-1.ld: Ditto. * testsuite/ld-pru/emit-relocs-1a.s: Ditto. * testsuite/ld-pru/emit-relocs-1b.s * testsuite/ld-pru/ldi32.d: Ditto. * testsuite/ld-pru/ldi32.s: Ditto. * testsuite/ld-pru/ldi32_symbol.s: Ditto. * testsuite/ld-pru/norelax_ldi32-data.d: Ditto. * testsuite/ld-pru/norelax_ldi32-dis.d: Ditto. * testsuite/ld-pru/pcrel_s10.d: Ditto. * testsuite/ld-pru/pcrel_s10.s: Ditto. * testsuite/ld-pru/pcrel_s10_label.s: Ditto. * testsuite/ld-pru/pcrel_u8-illegal.d: Ditto. * testsuite/ld-pru/pcrel_u8-illegal.s: Ditto. * testsuite/ld-pru/pcrel_u8-illegal2.d: Ditto. * testsuite/ld-pru/pcrel_u8-illegal2.s: Ditto. * testsuite/ld-pru/pcrel_u8-illegal3.d: Ditto. * testsuite/ld-pru/pcrel_u8-illegal3.s: Ditto. * testsuite/ld-pru/pcrel_u8.d: Ditto. * testsuite/ld-pru/pcrel_u8.s: Ditto. * testsuite/ld-pru/pcrel_u8_label.s: Ditto. * testsuite/ld-pru/pmem.d: Ditto. * testsuite/ld-pru/pmem.s: Ditto. * testsuite/ld-pru/pmem_symbol.s: Ditto. * testsuite/ld-pru/pru.exp: Ditto. * testsuite/ld-pru/relax_ldi32-data.d: Ditto. * testsuite/ld-pru/relax_ldi32-dis.d: Ditto. * testsuite/ld-pru/relax_ldi32.s: Ditto. * testsuite/ld-pru/relax_ldi32_symbol.s: Ditto. * testsuite/ld-pru/reloc.d: Ditto. * testsuite/ld-pru/reloc.s: Ditto. * testsuite/ld-pru/reloc_symbol.s: Ditto. * testsuite/ld-pru/u16.d: Ditto. * testsuite/ld-pru/u16.s: Ditto. * testsuite/ld-pru/u16_symbol.s: Ditto. PRU does not export __end symbol because it is ambiguous for it. Users are expected to use instead the section markers __text_end, __data_end, __bss_end or __noinit_end. * testsuite/lib/ld-lib.exp (check_shared_lib_support): No shared libraries are supported for PRU. (check_gc_sections_available): Mark PRU as not supported. * testsuite/ld-elf/eh-frame-hdr.d: Disable for PRU. * testsuite/ld-elf/endsym.d: Likewise. * testsuite/ld-elf/group8a.d: Likewise. * testsuite/ld-elf/group8b.d: Likewise. * testsuite/ld-elf/group9a.d: Likewise. * testsuite/ld-elf/group9b.d: Likewise. * testsuite/ld-elf/merge.d: Likewise. * testsuite/ld-elf/pr12851.d: Likewise. * testsuite/ld-elf/pr14926.d: Likewise. * testsuite/ld-elf/sec-to-seg.exp: Likewise. * testsuite/ld-elf/sec64k.exp: Mark sec64k case as too big for PRU. * testsuite/ld-srec/srec.exp (run_srec_test): Add setup for PRU. Signed-off-by: Dimitar Dimitrov --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 144672e68f5..f55272cafe3 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,63 @@ +2016-12-31 Dimitar Dimitrov + + * NEWS: Mention new PRU target. + * Makefile.am: Add PRU target. + * configure.tgt: Ditto. + * emulparams/pruelf.sh: New file. + * emultempl/pruelf.em: New file. + * scripttempl/pru.sc: New file. + * Makefile.in: Regenerate. + * testsuite/ld-pru/emit-relocs-1.d: New PRU testcase file. + * testsuite/ld-pru/emit-relocs-1.ld: Ditto. + * testsuite/ld-pru/emit-relocs-1a.s: Ditto. + * testsuite/ld-pru/emit-relocs-1b.s + * testsuite/ld-pru/ldi32.d: Ditto. + * testsuite/ld-pru/ldi32.s: Ditto. + * testsuite/ld-pru/ldi32_symbol.s: Ditto. + * testsuite/ld-pru/norelax_ldi32-data.d: Ditto. + * testsuite/ld-pru/norelax_ldi32-dis.d: Ditto. + * testsuite/ld-pru/pcrel_s10.d: Ditto. + * testsuite/ld-pru/pcrel_s10.s: Ditto. + * testsuite/ld-pru/pcrel_s10_label.s: Ditto. + * testsuite/ld-pru/pcrel_u8-illegal.d: Ditto. + * testsuite/ld-pru/pcrel_u8-illegal.s: Ditto. + * testsuite/ld-pru/pcrel_u8-illegal2.d: Ditto. + * testsuite/ld-pru/pcrel_u8-illegal2.s: Ditto. + * testsuite/ld-pru/pcrel_u8-illegal3.d: Ditto. + * testsuite/ld-pru/pcrel_u8-illegal3.s: Ditto. + * testsuite/ld-pru/pcrel_u8.d: Ditto. + * testsuite/ld-pru/pcrel_u8.s: Ditto. + * testsuite/ld-pru/pcrel_u8_label.s: Ditto. + * testsuite/ld-pru/pmem.d: Ditto. + * testsuite/ld-pru/pmem.s: Ditto. + * testsuite/ld-pru/pmem_symbol.s: Ditto. + * testsuite/ld-pru/pru.exp: Ditto. + * testsuite/ld-pru/relax_ldi32-data.d: Ditto. + * testsuite/ld-pru/relax_ldi32-dis.d: Ditto. + * testsuite/ld-pru/relax_ldi32.s: Ditto. + * testsuite/ld-pru/relax_ldi32_symbol.s: Ditto. + * testsuite/ld-pru/reloc.d: Ditto. + * testsuite/ld-pru/reloc.s: Ditto. + * testsuite/ld-pru/reloc_symbol.s: Ditto. + * testsuite/ld-pru/u16.d: Ditto. + * testsuite/ld-pru/u16.s: Ditto. + * testsuite/ld-pru/u16_symbol.s: Ditto. + * testsuite/lib/ld-lib.exp (check_shared_lib_support): No shared + libraries are supported for PRU. + (check_gc_sections_available): Mark PRU as not supported. + * testsuite/ld-elf/eh-frame-hdr.d: Disable for PRU. + * testsuite/ld-elf/endsym.d: Likewise. + * testsuite/ld-elf/group8a.d: Likewise. + * testsuite/ld-elf/group8b.d: Likewise. + * testsuite/ld-elf/group9a.d: Likewise. + * testsuite/ld-elf/group9b.d: Likewise. + * testsuite/ld-elf/merge.d: Likewise. + * testsuite/ld-elf/pr12851.d: Likewise. + * testsuite/ld-elf/pr14926.d: Likewise. + * testsuite/ld-elf/sec-to-seg.exp: Likewise. + * testsuite/ld-elf/sec64k.exp: Mark sec64k case as too big for PRU. + * testsuite/ld-srec/srec.exp (run_srec_test): Add setup for PRU. + 2016-12-31 Dimitar Dimitrov * testsuite/lib/ld-lib.exp (run_dump_test): Pass -- to send_log. diff --git a/ld/Makefile.am b/ld/Makefile.am index ac908bce859..524be3e0979 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -1714,6 +1714,12 @@ eppcnw.c: $(srcdir)/emulparams/ppcnw.sh \ eppcpe.c: $(srcdir)/emulparams/ppcpe.sh \ $(srcdir)/emultempl/pe.em $(srcdir)/scripttempl/ppcpe.sc ${GEN_DEPENDS} +epruelf.c: $(srcdir)/emulparams/pruelf.sh \ + $(srcdir)/emultempl/elf32.em \ + $(ELF_DEPS) $(srcdir)/scripttempl/pru.sc \ + $(srcdir)/emultempl/pruelf.em ${GEN_DEPENDS} + ${GENSCRIPTS} pruelf "$(tdir_pruelf)" + eriscix.c: $(srcdir)/emulparams/riscix.sh \ $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} diff --git a/ld/Makefile.in b/ld/Makefile.in index 46c0302df18..b545eb71e2d 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -3307,6 +3307,12 @@ eppcnw.c: $(srcdir)/emulparams/ppcnw.sh \ eppcpe.c: $(srcdir)/emulparams/ppcpe.sh \ $(srcdir)/emultempl/pe.em $(srcdir)/scripttempl/ppcpe.sc ${GEN_DEPENDS} +epruelf.c: $(srcdir)/emulparams/pruelf.sh \ + $(srcdir)/emultempl/elf32.em \ + $(ELF_DEPS) $(srcdir)/scripttempl/pru.sc \ + $(srcdir)/emultempl/pruelf.em ${GEN_DEPENDS} + ${GENSCRIPTS} pruelf "$(tdir_pruelf)" + eriscix.c: $(srcdir)/emulparams/riscix.sh \ $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} diff --git a/ld/NEWS b/ld/NEWS index 583d50a3b2d..0a455505d19 100644 --- a/ld/NEWS +++ b/ld/NEWS @@ -1,5 +1,7 @@ -*- text -*- +* Add support for the Texas Instruments PRU processor. + Changes in 2.28: * The EXCLUDE_FILE linker script construct can now be applied outside of the diff --git a/ld/configure.tgt b/ld/configure.tgt index b9f4782b4d1..5e0447e6b16 100644 --- a/ld/configure.tgt +++ b/ld/configure.tgt @@ -684,6 +684,7 @@ powerpc-*-aix*) targ_emul=aixppc ;; powerpc-*-beos*) targ_emul=aixppc ;; powerpc-*-windiss*) targ_emul=elf32ppcwindiss ;; powerpc-*-lynxos*) targ_emul=ppclynx ;; +pru*-*-*) targ_emul=pruelf ;; riscv32*-*-*) targ_emul=elf32lriscv targ_extra_emuls="elf64lriscv" targ_extra_libpath=$targ_extra_emuls ;; diff --git a/ld/emulparams/pruelf.sh b/ld/emulparams/pruelf.sh new file mode 100644 index 00000000000..02debba764f --- /dev/null +++ b/ld/emulparams/pruelf.sh @@ -0,0 +1,19 @@ +SCRIPT_NAME=elf +TEMPLATE_NAME=elf32 +OUTPUT_FORMAT="elf32-pru" +LITTLE_OUTPUT_FORMAT="elf32-pru" +SCRIPT_NAME=pru + +ARCH=pru +MACHINE= +MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" +COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" +EMBEDDED=yes + +TEXT_ORIGIN=0x20000000 +TEXT_LENGTH=8K +DATA_ORIGIN=0x0 +DATA_LENGTH=8K + +ENTRY=_start +EXTRA_EM_FILE=pruelf diff --git a/ld/emultempl/pruelf.em b/ld/emultempl/pruelf.em new file mode 100644 index 00000000000..dd3ec7669fd --- /dev/null +++ b/ld/emultempl/pruelf.em @@ -0,0 +1,50 @@ +# This shell script emits a C file. -*- C -*- +# Copyright (C) 2016 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# This file is sourced from elf32.em, and defines extra pru-elf +# specific routines. +# +fragment < imem} + + .data ${RELOCATING-0} : + { + /* Optional variable that user is prepared to have NULL address. */ + ${RELOCATING+ *(.data.atzero*)} + + /* CRT is prepared for constructor/destructor table to have + a "valid" NULL address. */ + ${CONSTRUCTING+ _ctors_start = . ; } + ${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.ctors.*)))} + ${CONSTRUCTING+ KEEP (*(.ctors))} + ${CONSTRUCTING+ _ctors_end = . ; } + ${CONSTRUCTING+ _dtors_start = . ; } + ${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.dtors.*)))} + ${CONSTRUCTING+ KEEP (*(.dtors))} + ${CONSTRUCTING+ _dtors_end = . ; } + + /* DATA memory starts at address 0. So to avoid placing a valid static + variable at the invalid NULL address, we introduce the .data.atzero + section. If CRT can make some use of it - great. Otherwise skip a + word. In all cases .data/.bss sections must start at non-zero. */ + . += (. == 0 ? 4 : 0); + + ${RELOCATING+ PROVIDE (_data_start = .) ; } + *(.data) + ${RELOCATING+ *(.data*)} + ${RELOCATING+ *(.rodata) /* We need to include .rodata here if gcc is used. */} + ${RELOCATING+ *(.rodata.*) /* with -fdata-sections. */} + ${RELOCATING+*(.gnu.linkonce.d*)} + ${RELOCATING+*(.gnu.linkonce.r*)} + ${RELOCATING+. = ALIGN(4);} + ${RELOCATING+ PROVIDE (_data_end = .) ; } + } ${RELOCATING+ > dmem } + + .resource_table ${RELOCATING-0} : + { + *(.resource_table) + KEEP (*(.resource_table)) + } > dmem + + .bss ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (_bss_start = .) ; } + *(.bss) + ${RELOCATING+ *(.bss.*)} + ${RELOCATING+*(.gnu.linkonce.b*)} + *(COMMON) + ${RELOCATING+ PROVIDE (_bss_end = .) ; } + } ${RELOCATING+ > dmem} + + /* Global data not cleared after reset. */ + .noinit ${RELOCATING-0}: + { + ${RELOCATING+ PROVIDE (_noinit_start = .) ; } + *(.noinit) + ${RELOCATING+ PROVIDE (_noinit_end = .) ; } + ${RELOCATING+ PROVIDE (_heap_start = .) ; } + ${RELOCATING+ . += __HEAP_SIZE ; } + /* Stack is not here really. It will be put at the end of DMEM. + But we take into account its size here, in order to allow + for MEMORY overflow checking during link time. */ + ${RELOCATING+ . += __STACK_SIZE ; } + } ${RELOCATING+ > dmem} + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .note.gnu.build-id : { *(.note.gnu.build-id) } +EOF + +. $srcdir/scripttempl/DWARF.sc + +cat <]*> ldi r16, 48879 +[0-9a-f]+ <[^>]*> ldi r16.w2, 57005 diff --git a/ld/testsuite/ld-pru/ldi32.s b/ld/testsuite/ld-pru/ldi32.s new file mode 100644 index 00000000000..1165fe60f70 --- /dev/null +++ b/ld/testsuite/ld-pru/ldi32.s @@ -0,0 +1,6 @@ +# Test the ldi32 relocation + + .text + .global _start +_start: + ldi32 r16, long_symbol diff --git a/ld/testsuite/ld-pru/ldi32_symbol.s b/ld/testsuite/ld-pru/ldi32_symbol.s new file mode 100644 index 00000000000..2e160667d4e --- /dev/null +++ b/ld/testsuite/ld-pru/ldi32_symbol.s @@ -0,0 +1,2 @@ + .global long_symbol + .set long_symbol, 0xDEADBEEF diff --git a/ld/testsuite/ld-pru/norelax_ldi32-data.d b/ld/testsuite/ld-pru/norelax_ldi32-data.d new file mode 100644 index 00000000000..47fc2c12f4e --- /dev/null +++ b/ld/testsuite/ld-pru/norelax_ldi32-data.d @@ -0,0 +1,20 @@ +#name: PRU LDI32 disabled-relaxation data +#source: relax_ldi32.s +#source: relax_ldi32_symbol.s +#as: --mlink-relax +#ld: --no-relax +#objdump: -s + +# Note: default linker script should put a guard at DRAM address 0 + +.*: +file format elf32-pru + +Contents of section .text: + [0-9a-f]+ f0efbe24 d0adde24 0f00f630 f0efbe24 .* + [0-9a-f]+ d0adde24 f0cace24 d0000024 e0cace24 .* + [0-9a-f]+ f0cace24 d0010024 f0efbe24 d0acde24 .* + [0-9a-f]+ f0785624 d0341224 f0785624 d0000024 .* + [0-9a-f]+ f0120024 f100007e .* +Contents of section .data: + 0000 00000000 48000020 40000000 12004000 .* + 0010 10000000 f0ffffff 100040aa .* diff --git a/ld/testsuite/ld-pru/norelax_ldi32-dis.d b/ld/testsuite/ld-pru/norelax_ldi32-dis.d new file mode 100644 index 00000000000..072de5fbd49 --- /dev/null +++ b/ld/testsuite/ld-pru/norelax_ldi32-dis.d @@ -0,0 +1,29 @@ +#name: PRU LDI32 disabled-relaxation +#source: relax_ldi32.s +#source: relax_ldi32_symbol.s +#as: --mlink-relax +#ld: --no-relax +#objdump: -dr --prefix-addresses + +# Test the LDI32 relaxation +.*: +file format elf32-pru + +Disassembly of section .text: +..000000 <[^>]*> ldi r16, 48879 +..000004 <[^>]*> ldi r16.w2, 57005 +..000008 <[^>]*> loop ..000044 <__end_loop>, r22 +..00000c <[^>]*> ldi r16, 48879 +..000010 <[^>]*> ldi r16.w2, 57005 +..000014 <[^>]*> ldi r16, 52938 +..000018 <[^>]*> ldi r16.w2, 0 +..00001c <[^>]*> ldi r0, 52938 +..000020 <[^>]*> ldi r16, 52938 +..000024 <[^>]*> ldi r16.w2, 1 +..000028 <[^>]*> ldi r16, 48879 +..00002c <[^>]*> ldi r16.w2, 57004 +..000030 <[^>]*> ldi r16, 22136 +..000034 <[^>]*> ldi r16.w2, 4660 +..000038 <[^>]*> ldi r16, 22136 +..00003c <[^>]*> ldi r16.w2, 0 +..000040 <[^>]*> ldi r16, 18 +..000044 <[^>]*> qba ..000008 <__intermediate> diff --git a/ld/testsuite/ld-pru/pcrel_s10.d b/ld/testsuite/ld-pru/pcrel_s10.d new file mode 100644 index 00000000000..95602c586bc --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_s10.d @@ -0,0 +1,18 @@ +#name: PRU R_PRU_S10_PCREL +#source: pcrel_s10.s +#source: pcrel_s10_label.s +#ld: +#objdump: -dr --prefix-addresses + +# Test the relative quick branch relocations. +.*: +file format elf32-pru + +Disassembly of section .text: +[0-9a-f]+ <[^>]*> qba [0-9a-f]+ +[0-9a-f]+ <[^>]*> qba [0-9a-f]+ +[0-9a-f]+ <[^>]*> nop +[0-9a-f]+ <[^>]*> nop +[0-9a-f]+ <[^>]*> nop +[0-9a-f]+ <[^>]*> nop +[0-9a-f]+ <[^>]*> nop +[0-9a-f]+ <[^>]*> nop diff --git a/ld/testsuite/ld-pru/pcrel_s10.s b/ld/testsuite/ld-pru/pcrel_s10.s new file mode 100644 index 00000000000..2a55773c4a9 --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_s10.s @@ -0,0 +1,7 @@ +# Test for pc-relative relocations + .text + .section .init0, "x" + .global _start +_start: + qba ext_label + qba ext_label + 16 diff --git a/ld/testsuite/ld-pru/pcrel_s10_label.s b/ld/testsuite/ld-pru/pcrel_s10_label.s new file mode 100644 index 00000000000..2dc424c5469 --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_s10_label.s @@ -0,0 +1,9 @@ + .text +ext_label: + nop + nop + nop + nop + nop + nop + .global ext_label diff --git a/ld/testsuite/ld-pru/pcrel_u8-illegal.d b/ld/testsuite/ld-pru/pcrel_u8-illegal.d new file mode 100644 index 00000000000..a88523747fc --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_u8-illegal.d @@ -0,0 +1,7 @@ +#name: PRU R_PRU_U8_PCREL illegal +#source: pcrel_u8-illegal.s +#source: pcrel_u8_label.s +#ld: +#error: [^\n]*: relocation truncated to fit: R_PRU_U8_PCREL against `.init0' + +# Check that LOOP cannot reference "prior" labels. diff --git a/ld/testsuite/ld-pru/pcrel_u8-illegal.s b/ld/testsuite/ld-pru/pcrel_u8-illegal.s new file mode 100644 index 00000000000..e33bd800e1f --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_u8-illegal.s @@ -0,0 +1,9 @@ +# Test for illegal pc-relative relocations + .text + .section .init0, "x" + .global _start +_start: +foo: +# Negative loop termination point + nop + loop foo, r20 diff --git a/ld/testsuite/ld-pru/pcrel_u8-illegal2.d b/ld/testsuite/ld-pru/pcrel_u8-illegal2.d new file mode 100644 index 00000000000..604ea9838d9 --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_u8-illegal2.d @@ -0,0 +1,7 @@ +#name: PRU R_PRU_U8_PCREL illegal offset 0 +#source: pcrel_u8-illegal2.s +#source: pcrel_u8_label.s +#ld: +#error: [^\n]*: relocation out of range + +# Check that LOOP cannot reference "prior" labels. diff --git a/ld/testsuite/ld-pru/pcrel_u8-illegal2.s b/ld/testsuite/ld-pru/pcrel_u8-illegal2.s new file mode 100644 index 00000000000..a4bcf9747ed --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_u8-illegal2.s @@ -0,0 +1,7 @@ +# Test for illegal pc-relative relocations + .text + .section .init0, "x" + .global _start +_start: +L0: + loop L0, r0 diff --git a/ld/testsuite/ld-pru/pcrel_u8-illegal3.d b/ld/testsuite/ld-pru/pcrel_u8-illegal3.d new file mode 100644 index 00000000000..604ea9838d9 --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_u8-illegal3.d @@ -0,0 +1,7 @@ +#name: PRU R_PRU_U8_PCREL illegal offset 0 +#source: pcrel_u8-illegal2.s +#source: pcrel_u8_label.s +#ld: +#error: [^\n]*: relocation out of range + +# Check that LOOP cannot reference "prior" labels. diff --git a/ld/testsuite/ld-pru/pcrel_u8-illegal3.s b/ld/testsuite/ld-pru/pcrel_u8-illegal3.s new file mode 100644 index 00000000000..8eb71f56a30 --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_u8-illegal3.s @@ -0,0 +1,7 @@ +# Test for illegal pc-relative relocations + .text + .section .init0, "x" + .global _start +_start: + loop L1, r0 +L1: diff --git a/ld/testsuite/ld-pru/pcrel_u8.d b/ld/testsuite/ld-pru/pcrel_u8.d new file mode 100644 index 00000000000..60ff05883cc --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_u8.d @@ -0,0 +1,15 @@ +#name: PRU R_PRU_U8_PCREL +#source: pcrel_u8.s +#source: pcrel_u8_label.s +#ld: +#objdump: -dr --prefix-addresses + +# Test the relative quick branch relocations. +.*: +file format elf32-pru + +Disassembly of section .text: +[0-9a-f]+ <[^>]*> loop [0-9a-f]+ , 5 +[0-9a-f]+ <[^>]*> nop +[0-9a-f]+ <[^>]*> nop +[0-9a-f]+ <[^>]*> nop +[0-9a-f]+ <[^>]*> nop diff --git a/ld/testsuite/ld-pru/pcrel_u8.s b/ld/testsuite/ld-pru/pcrel_u8.s new file mode 100644 index 00000000000..948e5a5d6e9 --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_u8.s @@ -0,0 +1,9 @@ +# Test for pc-relative relocations + .text + .section .init0, "x" + .global _start +_start: + loop end_loop, 5 + nop + nop + nop diff --git a/ld/testsuite/ld-pru/pcrel_u8_label.s b/ld/testsuite/ld-pru/pcrel_u8_label.s new file mode 100644 index 00000000000..e4652fa1f02 --- /dev/null +++ b/ld/testsuite/ld-pru/pcrel_u8_label.s @@ -0,0 +1,4 @@ + .text +end_loop: + nop + .global end_loop diff --git a/ld/testsuite/ld-pru/pmem.d b/ld/testsuite/ld-pru/pmem.d new file mode 100644 index 00000000000..b5747ded4f3 --- /dev/null +++ b/ld/testsuite/ld-pru/pmem.d @@ -0,0 +1,15 @@ +#name: PRU R_PRU_BFD_*_PMEM +#source: pmem.s +#source: pmem_symbol.s +#ld: +#objdump: -s + +# Note: default linker script should put a guard at DRAM address 0 + +.*: +file format elf32-pru + +Contents of section .text: + [0-9a-f]+ e0050024 e0070024 05000000 05000600 .* + [0-9a-f]+ e0e0e012 e0e0e012 .* +Contents of section .data: + 0000 00000000 .* diff --git a/ld/testsuite/ld-pru/pmem.s b/ld/testsuite/ld-pru/pmem.s new file mode 100644 index 00000000000..4c67ae328ac --- /dev/null +++ b/ld/testsuite/ld-pru/pmem.s @@ -0,0 +1,15 @@ +# Test for PRU pmem relocations + + .global byte_sym + .global short_sym + .global long_sym + + .set byte_sym, 0xFA + .set short_sym, 0xFACE + .set long_sym, 0xDEADBEEF + + .text + .global _text_label + nop +_text_label: + nop diff --git a/ld/testsuite/ld-pru/pmem_symbol.s b/ld/testsuite/ld-pru/pmem_symbol.s new file mode 100644 index 00000000000..d3eb386b18a --- /dev/null +++ b/ld/testsuite/ld-pru/pmem_symbol.s @@ -0,0 +1,13 @@ + .text + .section .init0, "x" + .global _start +_start: + + # U16_PMEMIMM + ldi r0, %pmem(_text_label) + ldi r0, %pmem(_text_label + 8) + +# Try 32/16_PMEM + .4byte %pmem(_text_label) + .2byte %pmem(_text_label) + .2byte %pmem(_text_label + 4) diff --git a/ld/testsuite/ld-pru/pru.exp b/ld/testsuite/ld-pru/pru.exp new file mode 100644 index 00000000000..ac01a3cf559 --- /dev/null +++ b/ld/testsuite/ld-pru/pru.exp @@ -0,0 +1,8 @@ +if { ! [istarget pru-*-*] } { + return +} + +foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.d]] { + verbose [file rootname $test] + run_dump_test [file rootname $test] +} diff --git a/ld/testsuite/ld-pru/relax_ldi32-data.d b/ld/testsuite/ld-pru/relax_ldi32-data.d new file mode 100644 index 00000000000..2c24fe422e4 --- /dev/null +++ b/ld/testsuite/ld-pru/relax_ldi32-data.d @@ -0,0 +1,19 @@ +#name: PRU LDI32 relaxation data +#source: relax_ldi32.s +#source: relax_ldi32_symbol.s +#as: --mlink-relax +#ld: --relax +#objdump: -s + +# Note: default linker script should put a guard at DRAM address 0 + +.*: +file format elf32-pru + +Contents of section .text: + [0-9a-f]+ f0efbe24 d0adde24 0d00f630 f0efbe24 .* + [0-9a-f]+ d0adde24 f0cace24 e0cace24 f0cace24 .* + [0-9a-f]+ d0010024 f0efbe24 d0acde24 f0785624 .* + [0-9a-f]+ d0341224 f0785624 f0100024 f300007e .* +Contents of section .data: + 0000 00000000 40000020 38000000 10003800 .* + 0010 0e000000 f2ffffff 0e0038aa .* diff --git a/ld/testsuite/ld-pru/relax_ldi32-dis.d b/ld/testsuite/ld-pru/relax_ldi32-dis.d new file mode 100644 index 00000000000..1371f1c6448 --- /dev/null +++ b/ld/testsuite/ld-pru/relax_ldi32-dis.d @@ -0,0 +1,27 @@ +#name: PRU LDI32 relaxation +#source: relax_ldi32.s +#source: relax_ldi32_symbol.s +#as: --mlink-relax +#ld: --relax +#objdump: -dr --prefix-addresses + +# Test the LDI32 relaxation +.*: +file format elf32-pru + +Disassembly of section .text: +..000000 <[^>]*> ldi r16, 48879 +..000004 <[^>]*> ldi r16.w2, 57005 +..000008 <[^>]*> loop ..00003c <__end_loop>, r22 +..00000c <[^>]*> ldi r16, 48879 +..000010 <[^>]*> ldi r16.w2, 57005 +..000014 <[^>]*> ldi r16, 52938 +..000018 <[^>]*> ldi r0, 52938 +..00001c <[^>]*> ldi r16, 52938 +..000020 <[^>]*> ldi r16.w2, 1 +..000024 <[^>]*> ldi r16, 48879 +..000028 <[^>]*> ldi r16.w2, 57004 +..00002c <[^>]*> ldi r16, 22136 +..000030 <[^>]*> ldi r16.w2, 4660 +..000034 <[^>]*> ldi r16, 22136 +..000038 <[^>]*> ldi r16, 16 +..00003c <[^>]*> qba ..000008 <__intermediate> diff --git a/ld/testsuite/ld-pru/relax_ldi32.s b/ld/testsuite/ld-pru/relax_ldi32.s new file mode 100644 index 00000000000..18fb57fdbe5 --- /dev/null +++ b/ld/testsuite/ld-pru/relax_ldi32.s @@ -0,0 +1,30 @@ +# Test LDI32 relaxation + + .text + .global _start +_start: + ldi32 r16, long_symbol +__intermediate: + loop __end_loop, r22 + ldi32 r16, long_symbol + ldi32 r16, short_symbol + ldi r0, short_symbol + ldi32 r16, short_symbol + 0x10000 + ldi32 r16, long_symbol - 0x10000 + ldi32 r16, 0x12345678 + ldi32 r16, 0x5678 + ldi r16, %pmem(__end) +__end_loop: + qba __intermediate +__end: + + .data + .4byte __end + .4byte (__end - __intermediate) + .2byte %pmem(__end) + .2byte (__end - __intermediate) + .4byte %pmem(__end - __intermediate) + .4byte %pmem(__intermediate - __end) + .2byte %pmem(__end - __intermediate) + .byte (__end - __intermediate) + .byte 0xaa diff --git a/ld/testsuite/ld-pru/relax_ldi32_symbol.s b/ld/testsuite/ld-pru/relax_ldi32_symbol.s new file mode 100644 index 00000000000..c2cf554b1e7 --- /dev/null +++ b/ld/testsuite/ld-pru/relax_ldi32_symbol.s @@ -0,0 +1,5 @@ + .global long_symbol + .global short_symbol + + .set long_symbol, 0xDEADBEEF + .set short_symbol, 0xceca diff --git a/ld/testsuite/ld-pru/reloc.d b/ld/testsuite/ld-pru/reloc.d new file mode 100644 index 00000000000..8bd1ceca59f --- /dev/null +++ b/ld/testsuite/ld-pru/reloc.d @@ -0,0 +1,14 @@ +#name: PRU R_PRU_BFD_RELOC_XX +#source: reloc.s +#source: reloc_symbol.s +#ld: +#objdump: -s + +# Note: default linker script should put a guard at DRAM address 0 + +.*: +file format elf32-pru + +Contents of section .text: + [0-9a-f]+ fa00cefa efbeadde facefaef beadde00 .* +Contents of section .data: + 0000 00000000 .* diff --git a/ld/testsuite/ld-pru/reloc.s b/ld/testsuite/ld-pru/reloc.s new file mode 100644 index 00000000000..3d40c2ecc37 --- /dev/null +++ b/ld/testsuite/ld-pru/reloc.s @@ -0,0 +1,9 @@ +# Test for PRU 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-pru/reloc_symbol.s b/ld/testsuite/ld-pru/reloc_symbol.s new file mode 100644 index 00000000000..160a824b3e4 --- /dev/null +++ b/ld/testsuite/ld-pru/reloc_symbol.s @@ -0,0 +1,24 @@ + .text + .section .init0, "x" + .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-pru/u16.d b/ld/testsuite/ld-pru/u16.d new file mode 100644 index 00000000000..9cc6482f9ae --- /dev/null +++ b/ld/testsuite/ld-pru/u16.d @@ -0,0 +1,11 @@ +#name: PRU R_PRU_U16 +#source: u16.s +#source: u16_symbol.s +#ld: +#objdump: -dr --prefix-addresses + +# Test the regulard LDI relocation +.*: +file format elf32-pru + +Disassembly of section .text: +[0-9a-f]+ <[^>]*> ldi r16, 54321 diff --git a/ld/testsuite/ld-pru/u16.s b/ld/testsuite/ld-pru/u16.s new file mode 100644 index 00000000000..4527b8fd312 --- /dev/null +++ b/ld/testsuite/ld-pru/u16.s @@ -0,0 +1,4 @@ + .text + .global _start +_start: + ldi r16, short_symbol diff --git a/ld/testsuite/ld-pru/u16_symbol.s b/ld/testsuite/ld-pru/u16_symbol.s new file mode 100644 index 00000000000..5e4e79d3925 --- /dev/null +++ b/ld/testsuite/ld-pru/u16_symbol.s @@ -0,0 +1,2 @@ + .global short_symbol + .set short_symbol, 54321 diff --git a/ld/testsuite/ld-srec/srec.exp b/ld/testsuite/ld-srec/srec.exp index 9fcf07ac581..10b0a513479 100644 --- a/ld/testsuite/ld-srec/srec.exp +++ b/ld/testsuite/ld-srec/srec.exp @@ -300,6 +300,11 @@ proc run_srec_test { test objs } { set flags "$flags -no-relax" } + # PRU ELF target relaxes by default; S-Record linker does not + if [istarget pru*-*-*] { + set flags "$flags -no-relax" + } + if { ![ld_simple_link $ld tmpdir/sr1 "$flags $objs"] \ || ![ld_simple_link $ld tmpdir/sr2.sr "$flags --oformat srec $objs"] } { fail $test diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index de0848a3668..5049b129037 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -1705,6 +1705,7 @@ proc check_gc_sections_available { } { || [istarget dlx-*-*] || [istarget i960-*-*] || [istarget pj*-*-*] + || [istarget pru*-*-*] || [istarget alpha-*-*] || [istarget hppa*64-*-*] || [istarget i370-*-*] @@ -1777,6 +1778,7 @@ proc check_shared_lib_support { } { && ![istarget nds32*-*-*] && ![istarget or1k*-*-*] && ![istarget pj-*-*] + && ![istarget pru-*-*] && ![istarget rl78-*-*] && ![istarget rx-*-*] && ![istarget spu-*-*]