aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2013-03-21 16:08:07 +0000
committerNick Clifton <nickc@redhat.com>2013-03-21 16:08:07 +0000
commit81f5558e3d93654ed79b6ea28850a4798ea1404f (patch)
tree09a020b2f58cf3b34739e07297561af0184b61ba /ld
parentb2f83c08372136fe9fe7d1df2feb5566c8b883fb (diff)
downloadgdb-81f5558e3d93654ed79b6ea28850a4798ea1404f.zip
gdb-81f5558e3d93654ed79b6ea28850a4798ea1404f.tar.gz
gdb-81f5558e3d93654ed79b6ea28850a4798ea1404f.tar.bz2
* elf32-h8300 (h8_relax_section): Add new relaxation of mov
@(disp:32,ERx) to mov @(disp:16,ERx). (R_H8_DISP32A16): New reloc. Comments added and corrected. * reloc.c (BFD_RELOC_H8_DISP32A16): New reloc. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * ld.texinfo (H8/300): Add description of relaxation of mov @(disp:32,ERx) to mov @(disp:16,ERx). * ld-h8300/h8300.exp: Add new relax-7 test on ELF. * ld-h8300/relax-2.s: Add other direction and .w/.l variants of mov insns. * ld-h8300/relax-2.d: Update expected disassembly. * ld-h8300/relax-7a.s: New: tests for mov @(disp:32,ERx) -> mov @(disp:16,ERx). * ld-h8300/relax-7b.s: New: Likewise. * ld-h8300/relax-7.d: New: expected disassembly. * config/tc-h8300.c (do_a_fix_imm): Add relaxation of mov @(disp:32,ERx) to mov @(disp:16,ERx) insns by new reloc R_H8_DISP32A16. * config/tc-h8300.h: Remove duplicated defines.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog5
-rw-r--r--ld/ld.texinfo10
-rw-r--r--ld/testsuite/ChangeLog11
-rw-r--r--ld/testsuite/ld-h8300/h8300.exp3
-rw-r--r--ld/testsuite/ld-h8300/relax-2.d14
-rw-r--r--ld/testsuite/ld-h8300/relax-2.s16
-rw-r--r--ld/testsuite/ld-h8300/relax-7.d81
-rw-r--r--ld/testsuite/ld-h8300/relax-7a.s66
-rw-r--r--ld/testsuite/ld-h8300/relax-7b.s19
9 files changed, 219 insertions, 6 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index e733147..93a52dc 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-21 Michael Schewe <michael.schewe@gmx.net>
+
+ * ld.texinfo (H8/300): Add description of relaxation of
+ mov @(disp:32,ERx) to mov @(disp:16,ERx).
+
2013-03-21 Kai Tietz <ktietz@redhat.com>
* pe-dll.c (process_def_file_and_drectve): Don't handle VC
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index 1f8e34d..7fae2c2 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -6078,7 +6078,7 @@ respectively.
@cindex synthesizing on H8/300
@item synthesizing instructions
-@c FIXME: specifically mov.b, or any mov instructions really?
+@c FIXME: specifically mov.b, or any mov instructions really? -> mov.b only, at least on H8, H8H, H8S
@command{ld} finds all @code{mov.b} instructions which use the
sixteen-bit absolute address form, but refer to the top
page of memory, and changes them to use the eight-bit address form.
@@ -6086,6 +6086,14 @@ page of memory, and changes them to use the eight-bit address form.
@samp{mov.b @code{@@}@var{aa}:8} whenever the address @var{aa} is in the
top page of memory).
+@command{ld} finds all @code{mov} instructions which use the register
+indirect with 32-bit displacement addressing mode, but use a small
+displacement inside 16-bit displacement range, and changes them to use
+the 16-bit displacement form. (That is: the linker turns @samp{mov.b
+@code{@@}@var{d}:32,ERx} into @samp{mov.b @code{@@}@var{d}:16,ERx}
+whenever the displacement @var{d} is in the 16 bit signed integer
+range. Only implemented in ELF-format ld).
+
@item bit manipulation instructions
@command{ld} finds all bit manipulation instructions like @code{band, bclr,
biand, bild, bior, bist, bixor, bld, bnot, bor, bset, bst, btst, bxor}
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index c30e3cd..4c1cac7 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2013-02-02 Michael Schewe <michael.schewe@gmx.net>
+
+ * ld-h8300/h8300.exp: Add new relax-7 test on ELF.
+ * ld-h8300/relax-2.s: Add other direction and .w/.l variants of
+ mov insns.
+ * ld-h8300/relax-2.d: Update expected disassembly.
+ * ld-h8300/relax-7a.s: New: tests for mov @(disp:32,ERx) -> mov
+ @(disp:16,ERx).
+ * ld-h8300/relax-7b.s: New: Likewise.
+ * ld-h8300/relax-7.d: New: expected disassembly.
+
2013-03-20 Venkataramanan Kumar <venkataramanan.kumar@linaro.org>
* ld-elf/group8a.d (notarget): Remove aarch64*-*-*.
diff --git a/ld/testsuite/ld-h8300/h8300.exp b/ld/testsuite/ld-h8300/h8300.exp
index 3604dfa..240c7c3 100644
--- a/ld/testsuite/ld-h8300/h8300.exp
+++ b/ld/testsuite/ld-h8300/h8300.exp
@@ -1,5 +1,5 @@
# Expect script for ld-h8300 tests
-# Copyright 2002, 2003, 2004, 2005, 2007, 2010 Free Software Foundation, Inc.
+# Copyright 2002-2013 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
@@ -35,6 +35,7 @@ if [is_elf_format] {
run_dump_test relax-4
run_dump_test relax-5
run_dump_test relax-6
+ run_dump_test relax-7
run_dump_test gcsection
} else {
run_dump_test relax-3-coff
diff --git a/ld/testsuite/ld-h8300/relax-2.d b/ld/testsuite/ld-h8300/relax-2.d
index 963139d..b79f5c2 100644
--- a/ld/testsuite/ld-h8300/relax-2.d
+++ b/ld/testsuite/ld-h8300/relax-2.d
@@ -7,5 +7,15 @@
Disassembly of section .text:
00000100 <_start>:
- *100: mov.b @0x67:8,r0l
- *102: mov.b @0x4321:16,r0l
+ 100: mov.b @0x64:8,r0l
+ 102: mov.b r0l,@0x64:8
+ 104: mov.b @0x4320:16,r0l
+ 108: mov.b r0l,@0x4320:16
+ 10c: mov.w @0xff64:16,r0
+ 110: mov.w r0,@0xff64:16
+ 114: mov.w @0x4320:16,r0
+ 118: mov.w r0,@0x4320:16
+ 11c: mov.l @0xff64:16,er0
+ 122: mov.l er0,@0xff64:16
+ 128: mov.l @0x4320:16,er0
+ 12e: mov.l er0,@0x4320:16
diff --git a/ld/testsuite/ld-h8300/relax-2.s b/ld/testsuite/ld-h8300/relax-2.s
index aa82dba..8e096b8 100644
--- a/ld/testsuite/ld-h8300/relax-2.s
+++ b/ld/testsuite/ld-h8300/relax-2.s
@@ -2,7 +2,19 @@
.globl _start
_start:
mov.b @foo:16,r0l
+ mov.b r0l,@foo:16
mov.b @bar:32,r0l
+ mov.b r0l,@bar:32
- .equ foo,0xffff67
- .equ bar,0x4321
+ mov.w @foo:16,r0
+ mov.w r0,@foo:16
+ mov.w @bar:32,r0
+ mov.w r0,@bar:32
+
+ mov.l @foo:16,er0
+ mov.l er0,@foo:16
+ mov.l @bar:32,er0
+ mov.l er0,@bar:32
+
+ .equ foo,0xffff64
+ .equ bar,0x4320
diff --git a/ld/testsuite/ld-h8300/relax-7.d b/ld/testsuite/ld-h8300/relax-7.d
new file mode 100644
index 0000000..ecf1a10
--- /dev/null
+++ b/ld/testsuite/ld-h8300/relax-7.d
@@ -0,0 +1,81 @@
+# name: H8300 Relaxation Test 7
+# source: relax-7?.s
+# ld: --relax -m h8300self
+# objdump: -d -s --no-show-raw-insn
+
+.*: file format .*-h8300
+
+Contents of section .text:
+ 0100 1a801aa2 7a01ffff 80000100 6f2201d0 [^\000]*
+ 0110 59206e0a ff016e8a ff016e1a 00016e9a [^\000]*
+ 0120 00015470 6f02fff2 6f82fff2 6f120002 [^\000]*
+ 0130 6f920002 54700100 6f028004 01006f82 [^\000]*
+ 0140 80040100 6f120004 01006f92 00045470 [^\000]*
+ 0150 7a000100 78006b01 fff25470 78006a2a [^\000]*
+ 0160 ffff7ff1 78006aaa ffff7ff1 78106a2a [^\000]*
+ 0170 00008000 78106aaa 00008000 54707800 [^\000]*
+ 0180 6b22ffff 7ffa7800 6ba2ffff 7ffa7810 [^\000]*
+ 0190 6b220000 80007810 6ba20000 80005470 [^\000]*
+ 01a0 01007800 6b2200ff ff040100 78806ba2 [^\000]*
+ 01b0 00ffff04 01007810 6b220000 80000100 [^\000]*
+ 01c0 78906ba2 00008000 5470 [^\000]*
+Contents of section .rodata:
+ 01cc 00000112 00000124 00000136 0000015c [^\000]*
+ 01dc 0000017e 000001a0 00000150 01007800 [^\000]*
+ 01ec 6b200000 01e80000 [^\000]*
+
+Disassembly of section .text:
+
+00000100 <_start>:
+ 100: sub.l er0,er0
+ 102: sub.l er2,er2
+ 104: mov.l #0xffff8000,er1
+ 10a: mov.l @\(0x1d0:16,er2\),er2
+ 110: jmp @er2
+
+00000112 <.L20>:
+ 112: mov.b @\(0xff01:16,er0\),r2l
+ 116: mov.b r2l,@\(0xff01:16,er0\)
+ 11a: mov.b @\(0x1:16,er1\),r2l
+ 11e: mov.b r2l,@\(0x1:16,er1\)
+ 122: rts[\t]*
+
+00000124 <.L21>:
+ 124: mov.w @\(0xfff2:16,er0\),r2
+ 128: mov.w r2,@\(0xfff2:16,er0\)
+ 12c: mov.w @\(0x2:16,er1\),r2
+ 130: mov.w r2,@\(0x2:16,er1\)
+ 134: rts[\t]*
+
+00000136 <.L22>:
+ 136: mov.l @\(0x8004:16,er0\),er2
+ 13c: mov.l er2,@\(0x8004:16,er0\)
+ 142: mov.l @\(0x4:16,er1\),er2
+ 148: mov.l er2,@\(0x4:16,er1\)
+ 14e: rts[\t]*
+
+00000150 <.L100Relax>:
+ 150: mov.l #0x1007800,er0
+ 156: mov.w @0xfff2:16,r1
+ 15a: rts[\t]*
+
+0000015c <.L30noRelax>:
+ 15c: mov.b @\(0xffff7ff1:32,er0\),r2l
+ 164: mov.b r2l,@\(0xffff7ff1:32,er0\)
+ 16c: mov.b @\(0x8000:32,er1\),r2l
+ 174: mov.b r2l,@\(0x8000:32,er1\)
+ 17c: rts[\t]*
+
+0000017e <.L31noRelax>:
+ 17e: mov.w @\(0xffff7ffa:32,er0\),r2
+ 186: mov.w r2,@\(0xffff7ffa:32,er0\)
+ 18e: mov.w @\(0x8000:32,er1\),r2
+ 196: mov.w r2,@\(0x8000:32,er1\)
+ 19e: rts[\t]*
+
+000001a0 <.L32noRelax>:
+ 1a0: mov.l @\(0xffff04:32,er0\),er2
+ 1aa: mov.l er2,@\(0xffff04:32,er0\)
+ 1b4: mov.l @\(0x8000:32,er1\),er2
+ 1be: mov.l er2,@\(0x8000:32,er1\)
+ 1c8: rts[\t]*
diff --git a/ld/testsuite/ld-h8300/relax-7a.s b/ld/testsuite/ld-h8300/relax-7a.s
new file mode 100644
index 0000000..915fb79
--- /dev/null
+++ b/ld/testsuite/ld-h8300/relax-7a.s
@@ -0,0 +1,66 @@
+ .h8300s
+# relax expected
+ .global _start
+ .section .text.func1,"ax",@progbits
+ .align 1
+_start:
+ sub.l er0,er0
+ sub.l er2,er2
+ mov.l #var3,er1
+ mov.l @(table+4:32,er2),er2
+ jmp @er2
+ .section .rodata.tab,"a",@progbits
+ .align 2
+table:
+ .long .L20
+ .long .L21
+ .long .L22
+ .long .L30noRelax
+ .long .L31noRelax
+ .long .L32noRelax
+ .long .L100Relax
+ .section .text.func1
+.L20:
+ mov.b @(var1+1:32,er0), r2l
+ mov.b r2l,@(var1+1:32,er0)
+ mov.b @(1:32,er1), r2l
+ mov.b r2l,@(1:32,er1)
+ rts
+.L21:
+ mov.w @(var2+2:32,er0), r2
+ mov.w r2,@(var2+2:32,er0)
+ mov.w @(2:32,er1), r2
+ mov.w r2,@(2:32,er1)
+ rts
+.L22:
+ mov.l @(var3+4:32,er0), er2
+ mov.l er2,@(var3+4:32,er0)
+ mov.l @(4:32,er1), er2
+ mov.l er2,@(4:32,er1)
+ rts
+
+.L100Relax:
+ mov.l #0x01007800,er0
+# part of MOV.L @(d:24,ERs),ERd opcode
+ mov.w @var2+2:32,r1
+ rts
+
+# no relax allowed:
+.L30noRelax:
+ mov.b @(var4+1:32,er0), r2l
+ mov.b r2l,@(var4+1:32,er0)
+ mov.b @(0x8000:32,er1), r2l
+ mov.b r2l,@(0x8000:32,er1)
+ rts
+.L31noRelax:
+ mov.w @(var5+2:32,er0), r2
+ mov.w r2,@(var5+2:32,er0)
+ mov.w @(0x8000:32,er1), r2
+ mov.w r2,@(0x8000:32,er1)
+ rts
+.L32noRelax:
+ mov.l @(var6+4:32,er0), er2
+ mov.l er2,@(var6+4:32,er0)
+ mov.l @(0x8000:32,er1), er2
+ mov.l er2,@(0x8000:32,er1)
+ rts
diff --git a/ld/testsuite/ld-h8300/relax-7b.s b/ld/testsuite/ld-h8300/relax-7b.s
new file mode 100644
index 0000000..eea9cfd
--- /dev/null
+++ b/ld/testsuite/ld-h8300/relax-7b.s
@@ -0,0 +1,19 @@
+ .h8300s
+ .global var1,var2,var3,var4,var5,var6
+
+ .equ var1,0xffffff00
+ .equ var2,0xfffffff0
+ .equ var3,0xffff8000
+
+ .equ var4,0xffff7ff0
+ .equ var5,0xffff7ff8
+ .equ var6,0x00ffff00
+
+ .section .rodata.tab2,"a",@progbits
+ .align 2
+table2: # no relax in sections other than text expected:
+ .short 0x0100
+ # MOV.L @(d:24,ERs),ERd opcodes
+ .short 0x7800
+ .short 0x6b20
+ .long table2