Committed: test-cases for some old SH bugs

Hans-Peter Nilsson hp@bitrange.com
Sun Oct 14 08:21:00 GMT 2001


Last time I did some SH hacking, I wrote some test-cases for the bugs
handled then and some previous problems I read about in the mailing lists
and which I couldn't find were obviously fixed.  Please don't think I'm
arguing that obvious fixes shouldn't have test-cases; all fixes should.

	* ld-sh/rd-sh.exp: New framework file.
	* ld-sh/ld-r-1.d, ld-sh/ldr1.s, ld-sh/ldr2.s, ld-sh/shared-1.d,
	ld-sh/weak1.s, ld-sh/weak1.d, ld-sh/sub2l.s, ld-sh/sub2l-1.d: New
	test files.

*** /dev/null	Tue Jan  1 05:00:00 1980
--- rd-sh.exp	Sat Sep 15 19:16:34 2001
***************
*** 0 ****
--- 1,36 ----
+ # Expect script for run_dump_test based ld-sh tests.
+ #   Copyright 2001 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 Hans-Peter Nilsson (hp@bitrange.com)
+ #
+
+ # This file is kept separate from sh.exp, because having it separate
+ # simplifies selective testing, like in "make check-ld
+ # RUNTESTFLAGS=rd-sh.exp=shared-1".  It is assumed that sh.exp is a place
+ # for constructs where the name of the test is harder to extract and
+ # select than here.
+
+ if ![istarget sh*-*-*] {
+     return
+ }
+
+ set rd_test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+ foreach shtest $rd_test_list {
+     # We need to strip the ".d", but can leave the dirname.
+     verbose [file rootname $shtest]
+     run_dump_test [file rootname $shtest]
+ }
*** /dev/null	Tue Jan  1 05:00:00 1980
--- ld-r-1.d	Sun Oct 14 16:51:18 2001
***************
*** 0 ****
--- 1,22 ----
+ #source: ldr1.s
+ #source: ldr2.s
+ #as: -little
+ #ld: -r -EL
+ #readelf: -r -x1 -x2
+ #target: sh*-*-elf sh*-*-linux*
+
+ # Make sure relocations against global and local symbols with relative and
+ # absolute 32-bit relocs don't come out wrong after ld -r.  Remember that
+ # SH uses partial_inplace (sort-of REL within RELA) with its confusion
+ # where and which addends to use and how.  A file linked -r must have the
+ # same layout as a plain assembly file: the addend is in the data only.
+
+ Relocation section '\.rela\.text' at offset 0x1b8 contains 1 entries:
+  Offset     Info    Type            Symbol's Value  Symbol's Name          Addend
+ 00000008  00000101 R_SH_DIR32            00000000  \.text                     \+ 0
+
+ Hex dump of section '\.text':
+   0x00000000          0000000c 00090009 00090009 .*
+
+ Hex dump of section '\.rela\.text':
+   0x00000000          00000000 00000101 00000008 .*
*** /dev/null	Tue Jan  1 05:00:00 1980
--- ldr1.s	Sat Sep 15 18:57:13 2001
***************
*** 0 ****
--- 1,5 ----
+  .text
+  nop
+  nop
+  nop
+  nop
*** /dev/null	Tue Jan  1 05:00:00 1980
--- ldr2.s	Sat Sep 15 18:57:55 2001
***************
*** 0 ****
--- 1,3 ----
+  .text
+  .long bar
+ bar:
*** /dev/null	Tue Jan  1 05:00:00 1980
--- shared-1.d	Mon Sep 17 07:21:08 2001
***************
*** 0 ****
--- 1,22 ----
+ #source: ldr1.s
+ #source: ldr2.s
+ #as: -little
+ #ld: -shared -EL
+ #readelf: -r -x4 -x5
+ #target: sh*-*-elf sh*-*-linux*
+
+ # Make sure relocations against global and local symbols with relative and
+ # absolute 32-bit relocs don't come out wrong after ld -r.  Remember that
+ # SH uses partial_inplace (sort-of REL within RELA) with related confusion
+ # about how, when, where and which addends to use.  A DSO must have the
+ # same value in the addend as in the data, so either can be used.
+
+ Relocation section '\.rela\.text' at offset 0x32c contains 1 entries:
+  Offset     Info    Type            Symbol's Value  Symbol's Name          Addend
+ 00000340  000000a5 R_SH_RELATIVE                                          00000344
+
+ Hex dump of section '\.rela\.text':
+   0x0000032c          00000344 000000a5 00000340 .*
+
+ Hex dump of section '\.text':
+   0x00000338          00000344 00090009 00090009 .*
*** /dev/null	Tue Jan  1 05:00:00 1980
--- weak1.s	Sat Sep 15 20:23:40 2001
***************
*** 0 ****
--- 1,19 ----
+  .data
+  .align 2
+ d0:
+  .long 1
+  .global w0
+ w0:
+  .long 0
+  .weak w0
+  .text
+  .align 5
+ f:
+  mov.l .L3,r1
+  mov.l @r1,r0
+  rts
+  nop
+  .align 2
+ .L3:
+  .long w0
+
*** /dev/null	Tue Jan  1 05:00:00 1980
--- weak1.d	Mon Sep 17 03:13:34 2001
***************
*** 0 ****
--- 1,20 ----
+ #source: weak1.s
+ #as: -little
+ #ld: -e 0x1000 -EL
+ #objdump: -ts
+
+ .*:     file format elf32-shl
+
+ SYMBOL TABLE:
+ #...
+ 0+10a0 l       .data	0+ d0
+ 0+1000 l       .text	0+ f
+ 0+10a4  w      .data	0+ w0
+ #...
+
+ Contents of section .text:
+  1000 01d11260 0b000900 a4100000 09000900  .*
+  1010 09000900 09000900 09000900 09000900  .*
+ Contents of section .data:
+  10a0 01000000 00000000                    .*
+ #pass
*** /dev/null	Tue Jan  1 05:00:00 1980
--- sub2l.s	Sun Sep 16 22:47:42 2001
***************
*** 0 ****
--- 1,26 ----
+ ! "The subtraction of two symbols".
+  .little
+  .text
+  .align 5
+ f:
+  rts
+ f2:
+  nop
+
+  .section .text.foo,"ax",@progbits
+  .align 5
+  .global ff
+ ff:
+  nop
+  nop
+  nop
+  nop
+ L:
+  rts
+  nop
+  .align 2
+  .long f-L
+  .long f2-L
+  .long f2
+  .long L
+  .long ff+4
*** /dev/null	Tue Jan  1 05:00:00 1980
--- sub2l-1.d	Mon Sep 17 03:07:34 2001
***************
*** 0 ****
--- 1,23 ----
+ #source: sub2l.s
+ #as: -little
+ #ld: -EL -e 0x1000
+ #objdump: -st
+
+
+ .*/dump:     file format elf32-shl
+
+ SYMBOL TABLE:
+ #...
+ 0+1000 l       .text	00000000 f
+ 0+1002 l       .text	00000000 f2
+ 0+1028 l       .text	00000000 L
+ 0+1020 g       .text	00000000 ff
+ #...
+
+ Contents of section \.text:
+  1000 0b000900 09000900 09000900 09000900  .*
+  1010 09000900 09000900 09000900 09000900  .*
+  1020 09000900 09000900 0b000900 d8ffffff  .*
+  1030 daffffff 02100000 28100000 24100000  .*
+ Contents of section \.data:
+ #pass

brgds, H-P




More information about the Binutils mailing list