patch, ld ELF segfault, gas i370-elf, d10v
trix@redhat.com
trix@redhat.com
Mon Jun 10 10:52:00 GMT 2002
The important part of this patch fixes a segfaulting problem ld and -z
combreloc.
Some targets, such as d10v, use elf32.em but have some script other than
elf.sh. This causes genscripts.sh to generate this code
; else if (link_info.combreloc) return <<< BAD empty script >>>
; else return
"/* Default linker script, for normal executables */\n\
Because -z combreloc is a default arg, trivial ld use segfaults.
This patch adds logic to check if GENERATE_COMBRELOC_SCRIPT is defined
before emitting this code for elf emulations.
Here are some of targets and check test results
Fix Orig
x86-linux-elf 135/13 135/13
d30v-elf 15/3/13 15/3/13
dlx-elf 13/5/13 13/5/13
sparc-elf 18/0/13 18/0/13
sparc-linux-gnu ""
sh-linux 21/0/16 ""
vax-dec-bsd -broken-
i370-elf 17/1/13 16/2/13
xstormy16-elf 18/13 17/1/13
i386-chaos-elf 19/13 ""
hppa-elf 13/3/12/13 12/4/2/13
m68hc11-elf 7/0/13 7/0/13
d10v-elf 37/0/13 17/1/13
Mainline ELF's did not show any regressions.
Non mainline ELF's i370, stormy16, hppa, d10v have 1 fix. (a sections
test in d10v).
This patch also fixes a build problem with i370-elf. In gas,
tc_comment_chars is not defined.
This patch adds a simple, no dumping, linker test. run_link_test.
OK to commit these changes?
For d10v:
Fix a pc relative relocations.
Fix default linker layout.
Add ld/testsuite/ld-d10v and a number of d10v specific linker tests.
These changes will be committed once the problem with ld segfaulting is
resolved.
Tom
--
Tom Rix
GCC Engineer
trix@redhat.com
-------------- next part --------------
ld:
2002-06-10 Tom Rix <trix@redhat.com>
* emultempl/elf32.em: gld*_get_script: Check for
GENERATE_COMBRELOC_SCRIPT.
* scripttempl/elfd10v.sc : Fix STACK and INSN.
* emulparams/d10velf.sh : Fix TEXT_START_ADDR.
ld/testsuite:
2002-06-10 Tom Rix <trix@redhat.com>
* lib/ld-lib.exp (run_link_test): New function for simple linking.
* ld-d10v/d10v.exp: New driver for d10v.
* ld-d10v/default_layout.d : New test.
* ld-d10v/regression-001.lt: New test for a linker regression.
* ld-d10v/linktest-002.lt: New test for run_link_test.
* ld-d10v/reloc-001.d - reloc-016.d: New tests.
bfd:
2002-06-10 Tom Rix <trix@redhat.com>
* elf32-d10v.c (elf_d10v_howto_table): Change R_D10V_10_PCREL_R,
R_D10V_10_PCREL_L and R_D10V_18_PCREL to use
complain_overflow_bitfield.
gas:
2002-06-10 Tom Rix <trix@redhat.com>
* config/tc-i370.h (tc_comment_chars): Define for i370-elf.
diff -N -rup -x *.gmo -x *~ src-old/bfd/elf32-d10v.c src/bfd/elf32-d10v.c
--- src-old/bfd/elf32-d10v.c Sun Jun 9 13:32:46 2002
+++ src/bfd/elf32-d10v.c Mon Jun 10 11:52:28 2002
@@ -1,5 +1,5 @@
/* D10V-specific support for 32-bit ELF
- Copyright 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright 1996, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Martin Hunt (hunt@cygnus.com).
This file is part of BFD, the Binary File Descriptor library.
@@ -67,10 +67,10 @@ static reloc_howto_type elf_d10v_howto_t
HOWTO (R_D10V_10_PCREL_R, /* type */
2, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
+ 7, /* bitsize */
true, /* pc_relative */
0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
+ complain_overflow_bitfield, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_D10V_10_PCREL_R", /* name */
false, /* partial_inplace */
@@ -83,10 +83,10 @@ static reloc_howto_type elf_d10v_howto_t
HOWTO (R_D10V_10_PCREL_L, /* type */
2, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
+ 7, /* bitsize */
true, /* pc_relative */
15, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
+ complain_overflow_bitfield, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_D10V_10_PCREL_L", /* name */
false, /* partial_inplace */
@@ -128,10 +128,10 @@ static reloc_howto_type elf_d10v_howto_t
HOWTO (R_D10V_18_PCREL, /* type */
2, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
+ 15, /* bitsize */
true, /* pc_relative */
0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
+ complain_overflow_bitfield, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_D10V_18_PCREL", /* name */
false, /* partial_inplace */
diff -N -rup -x *.gmo -x *~ src-old/gas/config/tc-i370.h src/gas/config/tc-i370.h
--- src-old/gas/config/tc-i370.h Sun Jun 9 13:32:51 2002
+++ src/gas/config/tc-i370.h Mon Jun 10 10:21:51 2002
@@ -65,3 +65,6 @@ extern int target_big_endian;
extern long md_pcrel_from_section PARAMS ((struct fix *, segT));
#define md_operand(x)
+
+#define tc_comment_chars i370_comment_chars
+extern const char *i370_comment_chars;
diff -N -rup -x *.gmo -x *~ src-old/ld/emulparams/d10velf.sh src/ld/emulparams/d10velf.sh
--- src-old/ld/emulparams/d10velf.sh Sun Jun 9 13:33:01 2002
+++ src/ld/emulparams/d10velf.sh Mon Jun 10 06:02:02 2002
@@ -1,7 +1,7 @@
MACHINE=
SCRIPT_NAME=elfd10v
OUTPUT_FORMAT="elf32-d10v"
-TEXT_START_ADDR=0x01000000
+TEXT_START_ADDR=0x01014000
READONLY_START_ADDR=0x02000004
ARCH=d10v
MAXPAGESIZE=32
diff -N -rup -x *.gmo -x *~ src-old/ld/emultempl/elf32.em src/ld/emultempl/elf32.em
--- src-old/ld/emultempl/elf32.em Sun Jun 9 13:33:02 2002
+++ src/ld/emultempl/elf32.em Mon Jun 10 11:54:09 2002
@@ -1376,13 +1376,17 @@ echo ' ; else if (!config.magic_demand_
sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
fi
if test -n "$GENERATE_SHLIB_SCRIPT" ; then
+if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
echo ' ; else if (link_info.shared && link_info.combreloc) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xsc >> e${EMULATION_NAME}.c
+fi
echo ' ; else if (link_info.shared) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xs >> e${EMULATION_NAME}.c
fi
+if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
echo ' ; else if (link_info.combreloc) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xc >> e${EMULATION_NAME}.c
+fi
echo ' ; else return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
echo '; }' >> e${EMULATION_NAME}.c
diff -N -rup -x *.gmo -x *~ src-old/ld/scripttempl/elfd10v.sc src/ld/scripttempl/elfd10v.sc
--- src-old/ld/scripttempl/elfd10v.sc Sun Jun 9 13:33:02 2002
+++ src/ld/scripttempl/elfd10v.sc Mon Jun 10 06:01:03 2002
@@ -66,14 +66,14 @@ ${RELOCATING+${EXECUTABLE_SYMBOLS}}
MEMORY
{
UNIFIED : org = 0, len = 0x1000000
- INSN : org = 0x1000000, len = 0x40000
+ INSN : org = 0x1014000, len = 0x40000
DATA : org = 0x2000004, len = 0x7FFC
- STACK : org = 0x2007FFE, len = 4
+ STACK : org = 0x200BFFE, len = 4
}
SECTIONS
{
- .text :
+ .text ${RELOCATING+${TEXT_START_ADDR}} :
{
${RELOCATING+${TEXT_START_SYMBOLS}}
KEEP (*(.init))
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/d10v.exp src/ld/testsuite/ld-d10v/d10v.exp
--- src-old/ld/testsuite/ld-d10v/d10v.exp Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/d10v.exp Mon Jun 10 11:33:35 2002
@@ -0,0 +1,39 @@
+# Expect script for ld-d10v tests
+# Copyright 2002 Free Software Foundation, Inc.
+#
+# This file 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Written by Tom Rix, trix@redhat.com
+#
+
+# Test d10v
+
+if ![istarget d10v-*-*] {
+ return
+}
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+foreach test $test_list {
+ # We need to strip the ".d", but can leave the dirname.
+ verbose [file rootname $test]
+ run_dump_test [file rootname $test]
+}
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.lt]]
+foreach test $test_list {
+ # We need to strip the ".lt", but can leave the dirname.
+ verbose [file rootname $test]
+ run_link_test [file rootname $test]
+}
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/default_layout.d src/ld/testsuite/ld-d10v/default_layout.d
--- src-old/ld/testsuite/ld-d10v/default_layout.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/default_layout.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,16 @@
+#source: simple.s
+#ld:
+#objdump: -h
+
+.*: file format elf32-d10v
+
+Sections:
+Idx Name Size VMA LMA File off Algn
+ 0 \.text 00000004 01014000 01014000 00001000 2\*\*0
+ CONTENTS, ALLOC, LOAD, READONLY, CODE
+ 1 \.data 00000000 02000004 02000004 00001004 2\*\*0
+ CONTENTS, ALLOC, LOAD, DATA
+ 2 \.bss 00000000 02000004 02000004 00001004 2\*\*0
+ ALLOC
+ 3 .stack 00000000 0200bffe 0200bffe 00001004 2\*\*0
+ CONTENTS
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/linktest-001.s src/ld/testsuite/ld-d10v/linktest-001.s
--- src-old/ld/testsuite/ld-d10v/linktest-001.s Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/linktest-001.s Mon Jun 10 06:24:45 2002
@@ -0,0 +1,4 @@
+ .section .data
+ .global bar
+bar:
+ .space 64
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/linktest-002.lt src/ld/testsuite/ld-d10v/linktest-002.lt
--- src-old/ld/testsuite/ld-d10v/linktest-002.lt Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/linktest-002.lt Mon Jun 10 06:24:45 2002
@@ -0,0 +1,2 @@
+#source: linktest-001.s
+#source: linktest-002.s
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/linktest-002.s src/ld/testsuite/ld-d10v/linktest-002.s
--- src-old/ld/testsuite/ld-d10v/linktest-002.s Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/linktest-002.s Mon Jun 10 06:24:45 2002
@@ -0,0 +1,4 @@
+ .section .text
+ .global _start
+_start:
+ ldi r0,bar
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/regression-001.lt src/ld/testsuite/ld-d10v/regression-001.lt
--- src-old/ld/testsuite/ld-d10v/regression-001.lt Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/regression-001.lt Mon Jun 10 06:24:45 2002
@@ -0,0 +1,3 @@
+#source: regression-001.s
+#as: -W
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/regression-001.s src/ld/testsuite/ld-d10v/regression-001.s
--- src-old/ld/testsuite/ld-d10v/regression-001.s Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/regression-001.s Mon Jun 10 06:24:45 2002
@@ -0,0 +1,14 @@
+ .section .data
+ ;;
+ ;; The next line caused an earlier ld to core dump.
+ .global .data
+foo:
+ .space 0x0064
+
+ .section .text
+ .global _test
+ .global _start
+_test:
+ ldi r0,foo
+_start:
+ nop
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-001.d src/ld/testsuite/ld-d10v/reloc-001.d
--- src-old/ld/testsuite/ld-d10v/reloc-001.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-001.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,14 @@
+#source: reloc-001.s
+#ld: -T $srcdir/$subdir/reloc-001.ld
+#objdump: -D
+
+# Test 10 bit pc rel reloc normal case
+
+.*: file format elf32-d10v
+
+Disassembly of section .text:
+
+01014000 <_start>:
+ 1014000: 65 20 cc 1a brf0f.s 1014104 <foo> -> jmp r13
+Disassembly of section .data:
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-001.ld src/ld/testsuite/ld-d10v/reloc-001.ld
--- src-old/ld/testsuite/ld-d10v/reloc-001.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-001.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,10 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ *(.text)
+ foo = (. + 0x100);
+ }
+}
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-001.s src/ld/testsuite/ld-d10v/reloc-001.s
--- src-old/ld/testsuite/ld-d10v/reloc-001.s Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-001.s Mon Jun 10 06:24:45 2002
@@ -0,0 +1,11 @@
+ ;; Test pc relative relocation
+
+ .text
+ .global _start
+_start:
+ brf0f.s foo
+ jmp r13
+
+
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-002.d src/ld/testsuite/ld-d10v/reloc-002.d
--- src-old/ld/testsuite/ld-d10v/reloc-002.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-002.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,13 @@
+#source: reloc-001.s
+#ld: -T $srcdir/$subdir/reloc-002.ld
+#objdump: -D
+
+# Test 10 bit pc rel reloc good boundary.
+
+.*: file format elf32-d10v
+
+Disassembly of section .text:
+
+01014000 <_start>:
+ 1014000: 65 3f cc 1a brf0f.s 10141fc <foo> -> jmp r13
+Disassembly of section .data:
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-002.ld src/ld/testsuite/ld-d10v/reloc-002.ld
--- src-old/ld/testsuite/ld-d10v/reloc-002.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-002.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,10 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ *(.text)
+ foo = (. + 0x1F8);
+ }
+}
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-003.d src/ld/testsuite/ld-d10v/reloc-003.d
--- src-old/ld/testsuite/ld-d10v/reloc-003.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-003.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,5 @@
+#source: reloc-001.s
+#ld: -T $srcdir/$subdir/reloc-003.ld
+#error: relocation truncated to fit: R_D10V_10_PCREL_L foo$
+
+# Test 10 bit pc rel reloc bad boundary.
\ No newline at end of file
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-003.ld src/ld/testsuite/ld-d10v/reloc-003.ld
--- src-old/ld/testsuite/ld-d10v/reloc-003.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-003.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,10 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ *(.text)
+ foo = (. + 0x1FC);
+ }
+}
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-004.d src/ld/testsuite/ld-d10v/reloc-004.d
--- src-old/ld/testsuite/ld-d10v/reloc-004.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-004.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,5 @@
+#source: reloc-001.s
+#ld: -T $srcdir/$subdir/reloc-004.ld
+#error: relocation truncated to fit: R_D10V_10_PCREL_L foo$
+
+# Test 10 bit pc rel reloc normal bad.
\ No newline at end of file
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-004.ld src/ld/testsuite/ld-d10v/reloc-004.ld
--- src-old/ld/testsuite/ld-d10v/reloc-004.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-004.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,10 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ foo = .;
+ . = (. + 0x400);
+ }
+}
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-005.d src/ld/testsuite/ld-d10v/reloc-005.d
--- src-old/ld/testsuite/ld-d10v/reloc-005.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-005.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,14 @@
+#source: reloc-005.s
+#ld: -T $srcdir/$subdir/reloc-005.ld
+#objdump: -D
+
+# Test 18 bit pc rel reloc normal case
+
+.*: file format elf32-d10v
+
+Disassembly of section .text:
+
+01014000 <_start>:
+ 1014000: e4 00 10 02 bra.l 1018008 <foo>
+ 1014004: 26 0d 5e 00 jmp r13 || nop
+Disassembly of section .data:
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-005.ld src/ld/testsuite/ld-d10v/reloc-005.ld
--- src-old/ld/testsuite/ld-d10v/reloc-005.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-005.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,10 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ *(.text)
+ foo = (. + 0x4000);
+ }
+}
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-005.s src/ld/testsuite/ld-d10v/reloc-005.s
--- src-old/ld/testsuite/ld-d10v/reloc-005.s Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-005.s Mon Jun 10 06:24:45 2002
@@ -0,0 +1,11 @@
+ ;; Test 18 bit pc rel relocation
+
+ .text
+ .global _start
+_start:
+ bra.l foo
+ jmp r13
+
+
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-006.d src/ld/testsuite/ld-d10v/reloc-006.d
--- src-old/ld/testsuite/ld-d10v/reloc-006.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-006.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,14 @@
+#source: reloc-005.s
+#ld: -T $srcdir/$subdir/reloc-006.ld
+#objdump: -D
+
+# Test 18 bit pc rel reloc good boundary
+
+.*: file format elf32-d10v
+
+Disassembly of section .text:
+
+01014000 <_start>:
+ 1014000: e4 00 7f ff bra.l 1033ffc <foo>
+ 1014004: 26 0d 5e 00 jmp r13 || nop
+Disassembly of section .data:
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-006.ld src/ld/testsuite/ld-d10v/reloc-006.ld
--- src-old/ld/testsuite/ld-d10v/reloc-006.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-006.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,8 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ *(.text)
+ foo = (. + 0x1fff4);
+ }
+}
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-007.d src/ld/testsuite/ld-d10v/reloc-007.d
--- src-old/ld/testsuite/ld-d10v/reloc-007.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-007.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,7 @@
+#source: reloc-005.s
+#ld: -T $srcdir/$subdir/reloc-007.ld
+#objdump: -D
+#error: relocation truncated to fit: R_D10V_18_PCREL foo$
+
+# Test 18 bit pc rel reloc bad boundary
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-007.ld src/ld/testsuite/ld-d10v/reloc-007.ld
--- src-old/ld/testsuite/ld-d10v/reloc-007.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-007.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,8 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ *(.text)
+ foo = (. + 0x1fff8);
+ }
+}
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-008.d src/ld/testsuite/ld-d10v/reloc-008.d
--- src-old/ld/testsuite/ld-d10v/reloc-008.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-008.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,7 @@
+#source: reloc-005.s
+#ld: -T $srcdir/$subdir/reloc-008.ld
+#objdump: -D
+#error: relocation truncated to fit: R_D10V_18_PCREL foo$
+
+# Test 18 bit pc rel reloc normal bad
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-008.ld src/ld/testsuite/ld-d10v/reloc-008.ld
--- src-old/ld/testsuite/ld-d10v/reloc-008.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-008.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,8 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ *(.text)
+ foo = (. + 0x41fff8);
+ }
+}
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-009.d src/ld/testsuite/ld-d10v/reloc-009.d
--- src-old/ld/testsuite/ld-d10v/reloc-009.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-009.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,16 @@
+#source: reloc-009.s
+#ld: -T $srcdir/$subdir/reloc-009.ld
+#objdump: -D
+
+# Test 10 bit pc rel reloc negative normal case
+
+.*: file format elf32-d10v
+Disassembly of section .text:
+
+01014000 <foo>:
+ ...
+
+01014100 <_start>:
+ 1014100: 6f 00 4a c0 nop -> brf0f.s 1014000 <foo>
+ 1014104: 26 0d 5e 00 jmp r13 || nop
+Disassembly of section .data:
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-009.ld src/ld/testsuite/ld-d10v/reloc-009.ld
--- src-old/ld/testsuite/ld-d10v/reloc-009.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-009.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,11 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ foo = .;
+ . = (. + 0x100);
+ *(.text)
+ }
+}
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-009.s src/ld/testsuite/ld-d10v/reloc-009.s
--- src-old/ld/testsuite/ld-d10v/reloc-009.s Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-009.s Mon Jun 10 06:24:45 2002
@@ -0,0 +1,12 @@
+ ;; Test pc relative relocation
+
+ .text
+ .global _start
+_start:
+ nop
+ brf0f.s foo
+ jmp r13
+
+
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-010.d src/ld/testsuite/ld-d10v/reloc-010.d
--- src-old/ld/testsuite/ld-d10v/reloc-010.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-010.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,17 @@
+#source: reloc-009.s
+#ld: -T $srcdir/$subdir/reloc-010.ld
+#objdump: -D
+
+# Test 10 bit pc rel reloc negative good boundary case
+
+.*: file format elf32-d10v
+
+Disassembly of section .text:
+
+01014000 <foo>:
+ ...
+
+01014200 <_start>:
+ 1014200: 6f 00 4a 80 nop -> brf0f.s 1014000 <foo>
+ 1014204: 26 0d 5e 00 jmp r13 || nop
+Disassembly of section .data:
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-010.ld src/ld/testsuite/ld-d10v/reloc-010.ld
--- src-old/ld/testsuite/ld-d10v/reloc-010.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-010.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,11 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ foo = .;
+ . = (. + 0x200);
+ *(.text)
+ }
+}
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-011.d src/ld/testsuite/ld-d10v/reloc-011.d
--- src-old/ld/testsuite/ld-d10v/reloc-011.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-011.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,6 @@
+#source: reloc-009.s
+#ld: -T $srcdir/$subdir/reloc-011.ld
+#error: relocation truncated to fit: R_D10V_10_PCREL_R foo$
+
+# Test 10 bit pc rel reloc negative bad boundary.
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-011.ld src/ld/testsuite/ld-d10v/reloc-011.ld
--- src-old/ld/testsuite/ld-d10v/reloc-011.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-011.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,11 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ foo = .;
+ . = (. + 0x204);
+ *(.text)
+ }
+}
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-012.d src/ld/testsuite/ld-d10v/reloc-012.d
--- src-old/ld/testsuite/ld-d10v/reloc-012.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-012.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,6 @@
+#source: reloc-009.s
+#ld: -T $srcdir/$subdir/reloc-012.ld
+#error: relocation truncated to fit: R_D10V_10_PCREL_R foo$
+
+# Test 10 bit pc rel reloc negative normal bad.
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-012.ld src/ld/testsuite/ld-d10v/reloc-012.ld
--- src-old/ld/testsuite/ld-d10v/reloc-012.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-012.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,11 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ foo = .;
+ . = (. + 0x80004);
+ *(.text)
+ }
+}
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-013.d src/ld/testsuite/ld-d10v/reloc-013.d
--- src-old/ld/testsuite/ld-d10v/reloc-013.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-013.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,17 @@
+#source: reloc-005.s
+#ld: -T $srcdir/$subdir/reloc-013.ld
+#objdump: -D
+
+# Test 18 bit pc rel reloc negative normal case
+
+.*: file format elf32-d10v
+
+Disassembly of section .text:
+
+01014000 <foo>:
+ ...
+
+01014400 <_start>:
+ 1014400: e4 00 ff 00 bra.l 1014000 <foo>
+ 1014404: 26 0d 5e 00 jmp r13 || nop
+Disassembly of section .data:
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-013.ld src/ld/testsuite/ld-d10v/reloc-013.ld
--- src-old/ld/testsuite/ld-d10v/reloc-013.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-013.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,12 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ foo = .;
+ . = (. + 0x400);
+ *(.text)
+ }
+}
+
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-014.d src/ld/testsuite/ld-d10v/reloc-014.d
--- src-old/ld/testsuite/ld-d10v/reloc-014.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-014.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,17 @@
+#source: reloc-005.s
+#ld: -T $srcdir/$subdir/reloc-014.ld
+#objdump: -D
+
+# Test 18 bit pc rel reloc negative good boundary case
+
+.*: file format elf32-d10v
+
+Disassembly of section .text:
+
+01014000 <foo>:
+ ...
+
+01034000 <_start>:
+ 1034000: e4 00 80 00 bra.l 1014000 <foo>
+ 1034004: 26 0d 5e 00 jmp r13 || nop
+Disassembly of section .data:
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-014.ld src/ld/testsuite/ld-d10v/reloc-014.ld
--- src-old/ld/testsuite/ld-d10v/reloc-014.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-014.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,12 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ foo = .;
+ . = (. + 0x20000);
+ *(.text)
+ }
+}
+
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-015.d src/ld/testsuite/ld-d10v/reloc-015.d
--- src-old/ld/testsuite/ld-d10v/reloc-015.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-015.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,7 @@
+#source: reloc-005.s
+#ld: -T $srcdir/$subdir/reloc-015.ld
+#objdump: -D
+#error: relocation truncated to fit: R_D10V_18_PCREL foo$
+
+# Test 18 bit pc rel negative reloc bad boundary
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-015.ld src/ld/testsuite/ld-d10v/reloc-015.ld
--- src-old/ld/testsuite/ld-d10v/reloc-015.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-015.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,12 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ foo = .;
+ . = (. + 0x20004);
+ *(.text)
+ }
+}
+
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-016.d src/ld/testsuite/ld-d10v/reloc-016.d
--- src-old/ld/testsuite/ld-d10v/reloc-016.d Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-016.d Mon Jun 10 06:24:45 2002
@@ -0,0 +1,7 @@
+#source: reloc-005.s
+#ld: -T $srcdir/$subdir/reloc-016.ld
+#objdump: -D
+#error: relocation truncated to fit: R_D10V_18_PCREL foo$
+
+# Test 18 bit pc rel negative reloc normal bad
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/reloc-016.ld src/ld/testsuite/ld-d10v/reloc-016.ld
--- src-old/ld/testsuite/ld-d10v/reloc-016.ld Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/reloc-016.ld Mon Jun 10 06:24:45 2002
@@ -0,0 +1,12 @@
+SECTIONS
+{
+ .text 0x01014000 :
+ {
+ foo = .;
+ . = (. + 0x800004);
+ *(.text)
+ }
+}
+
+
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/ld-d10v/simple.s src/ld/testsuite/ld-d10v/simple.s
--- src-old/ld/testsuite/ld-d10v/simple.s Wed Dec 31 18:00:00 1969
+++ src/ld/testsuite/ld-d10v/simple.s Mon Jun 10 06:24:45 2002
@@ -0,0 +1,5 @@
+ .text
+ .global _start
+_start:
+ jmp r13
+
diff -N -rup -x *.gmo -x *~ src-old/ld/testsuite/lib/ld-lib.exp src/ld/testsuite/lib/ld-lib.exp
--- src-old/ld/testsuite/lib/ld-lib.exp Sun Jun 9 13:33:04 2002
+++ src/ld/testsuite/lib/ld-lib.exp Mon Jun 10 06:29:20 2002
@@ -810,6 +810,217 @@ proc run_dump_test { name } {
pass $testname
}
+# run_link_test FILE
+# Copied from run_dump_test, with the dumping part removed.
+#
+# Assemble a .s file, then run some utility on it and check the output.
+#
+# There should be an assembly language file named FILE.s in the test
+# suite directory. `run_link_test' will assemble and link FILE.s
+#
+# The FILE.lt file begins with zero or more option lines, which specify
+# flags to pass to the assembler, the program to run to dump the
+# assembler's output, and the options it wants. The option lines have
+# the syntax:
+#
+# # OPTION: VALUE
+#
+# OPTION is the name of some option, like "name" or "ld", and
+# VALUE is OPTION's value. The valid options are described below.
+# Whitespace is ignored everywhere, except within VALUE. The option
+# list ends with the first line that doesn't match the above syntax
+# (hmm, not great for error detection).
+#
+# The interesting options are:
+#
+# name: TEST-NAME
+# The name of this test, passed to DejaGNU's `pass' and `fail'
+# commands. If omitted, this defaults to FILE, the root of the
+# .s and .d files' names.
+#
+# as: FLAGS
+# When assembling, pass FLAGS to the assembler.
+# If assembling several files, you can pass different assembler
+# options in the "source" directives. See below.
+#
+# ld: FLAGS
+# Link assembled files using FLAGS, in the order of the "source"
+# directives, when using multiple files.
+#
+# source: SOURCE [FLAGS]
+# Assemble the file SOURCE.s using the flags in the "as" directive
+# and the (optional) FLAGS. If omitted, the source defaults to
+# FILE.s.
+# This is useful if several .x files want to share a .s file.
+# More than one "source" directive can be given, which is useful
+# when testing linking.
+#
+# xfail: TARGET
+# The test is expected to fail on TARGET. This may occur more than
+# once.
+#
+# target: TARGET
+# Only run the test for TARGET. This may occur more than once; the
+# target being tested must match at least one.
+#
+# notarget: TARGET
+# Do not run the test for TARGET. This may occur more than once;
+# the target being tested must not match any of them.
+#
+# Each option may occur at most once unless otherwise mentioned.
+#
+
+proc run_link_test { name } {
+ global subdir srcdir
+ global AS LD
+ global ASFLAGS LDFLAGS
+ global host_triplet runtests
+
+ if [string match "*/*" $name] {
+ set file $name
+ set name [file tail $name]
+ } else {
+ set file "$srcdir/$subdir/$name"
+ }
+
+ if ![runtest_file_p $runtests $name] then {
+ return
+ }
+
+ set opt_array [slurp_options "${file}.lt"]
+ if { $opt_array == -1 } {
+ perror "error reading options from $file.lt"
+ unresolved $subdir/$name
+ return
+ }
+ set dumpfile tmpdir/dump.out
+ set run_ld 0
+ set opts(as) {}
+ set opts(ld) {}
+ set opts(xfail) {}
+ set opts(target) {}
+ set opts(notarget) {}
+ set opts(name) {}
+ set opts(source) {}
+ set asflags(${file}.s) {}
+
+ foreach i $opt_array {
+ set opt_name [lindex $i 0]
+ set opt_val [lindex $i 1]
+ if ![info exists opts($opt_name)] {
+ perror "unknown option $opt_name in file $file.lt"
+ unresolved $subdir/$name
+ return
+ }
+
+ switch -- $opt_name {
+ xfail {}
+ target {}
+ notarget {}
+ source {
+ # Move any source-specific as-flags to a separate array to
+ # simplify processing.
+ if { [llength $opt_val] > 1 } {
+ set asflags([lindex $opt_val 0]) [lrange $opt_val 1 end]
+ set opt_val [lindex $opt_val 0]
+ } else {
+ set asflags($opt_val) {}
+ }
+ }
+ default {
+ if [string length $opts($opt_name)] {
+ perror "option $opt_name multiply set in $file.lt"
+ unresolved $subdir/$name
+ return
+ }
+ }
+ }
+ set opts($opt_name) [concat $opts($opt_name) $opt_val]
+ }
+
+ # Decide early whether we should run the test for this target.
+ if { [llength $opts(target)] > 0 } {
+ set targmatch 0
+ foreach targ $opts(target) {
+ if [istarget $targ] {
+ set targmatch 1
+ break
+ }
+ }
+ if { $targmatch == 0 } {
+ return
+ }
+ }
+ foreach targ $opts(notarget) {
+ if [istarget $targ] {
+ return
+ }
+ }
+
+ if { $opts(name) == "" } {
+ set testname "$subdir/$name"
+ } else {
+ set testname $opts(name)
+ }
+
+ if { $opts(source) == "" } {
+ set sourcefiles [list ${file}.s]
+ } else {
+ set sourcefiles {}
+ foreach sf $opts(source) {
+ lappend sourcefiles "$srcdir/$subdir/$sf"
+ # Must have asflags indexed on source name.
+ set asflags($srcdir/$subdir/$sf) $asflags($sf)
+ }
+ }
+
+ # Time to setup xfailures.
+ foreach targ $opts(xfail) {
+ setup_xfail $targ
+ }
+
+ # Assemble each file.
+ set objfiles {}
+ for { set i 0 } { $i < [llength $sourcefiles] } { incr i } {
+ set sourcefile [lindex $sourcefiles $i]
+
+ set objfile "tmpdir/dump$i.o"
+ lappend objfiles $objfile
+ set cmd "$AS $ASFLAGS $opts(as) $asflags($sourcefile) -o $objfile $sourcefile"
+
+ send_log "$cmd\n"
+ set cmdret [catch "exec $cmd" comp_output]
+ set comp_output [prune_warnings $comp_output]
+
+ # We accept errors at assembly stage too, unless we're supposed to
+ # link something.
+ if { $cmdret != 0 || ![string match "" $comp_output] } then {
+ send_log "$comp_output\n"
+ verbose "$comp_output" 3
+ fail $testname
+ return
+ }
+ }
+
+ # Link the file(s).
+ set objfile "tmpdir/dump"
+ set cmd "$LD $LDFLAGS $opts(ld) -o $objfile $objfiles"
+
+ send_log "$cmd\n"
+ set cmdret [catch "exec $cmd" comp_output]
+ set comp_output [prune_warnings $comp_output]
+
+ if { $cmdret != 0 || ![string match "" $comp_output] } then {
+
+ send_log "$comp_output\n"
+ verbose "$comp_output" 3
+ fail $testname
+ return
+ }
+
+ pass $testname
+}
+
proc slurp_options { file } {
if [catch { set f [open $file r] } x] {
#perror "couldn't open `$file': $x"
More information about the Binutils
mailing list