This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: m68hc11 - bug found with MOVW oprx16_xysp, oprx16_xysp1


Hi James,

I applied the patch to my local repository and it all checks out. I believe the patch to file tc-m68hc11.c should be back-ported since it is a bug fix. Can someone advise on that?

Thanks,
Sean

On 11/07/2012 07:13 AM, James Murray wrote:
On Wed, 2012-11-07 at 08:44 +0100, Stephane Carrez wrote:
Yes, there is a problem here. frag_more(2) must be called before fix_new().
OK,
how does this look as a fix and testcase ?

--------------------------------------------------------
gas/Changelog
2012-11-07  James Murray <jsm@jsm-net.demon.co.uk>

* config/tc-m68hc11.c: Fix R_M68HC12_16B relocation for movb/w

diff -Nuar a/src/gas/config/tc-m68hc11.c b/src/gas/config/tc-m68hc11.c
--- a/src/gas/config/tc-m68hc11.c 2012-11-06 00:49:37.000000000 +0000
+++ b/src/gas/config/tc-m68hc11.c 2012-11-07 13:48:10.000000000 +0000
@@ -2219,9 +2219,9 @@
byte <<= 3;
byte |= 0xe2;
number_to_chars_bigendian (f, byte, 1);
+ f = frag_more (2);
fix_new (frag_now, f - frag_now->fr_literal, 2,
sym, off, 0, BFD_RELOC_M68HC12_16B);
- f = frag_more (2);
return 1;
}
else
@@ -4459,8 +4459,8 @@
if (value < 0)
value += 65536;
- where[1] = (value >> 8);
- where[2] = (value & 0xff);
+ where[0] = (value >> 8);
+ where[1] = (value & 0xff);
break;
case BFD_RELOC_M68HC11_RL_JUMP:
diff -Nuar a/src/ld/testsuite/ld-m68hc11/movw.d
b/src/ld/testsuite/ld-m68hc11/movw.d
--- a/src/ld/testsuite/ld-m68hc11/movw.d 1970-01-01 01:00:00.000000000
+0100
+++ b/src/ld/testsuite/ld-m68hc11/movw.d 2012-11-07 13:47:07.000000000
+0000
@@ -0,0 +1,18 @@
+#source: movw.s
+#as: -m m9s12x
+#ld: -mm68hc12elf --relax -defsym gp_max_on=0x1234 -defsym
gp_clk=0x5432 -defsym small_off=0x5
+#objdump: -m m9s12x -d --prefix-addresses -r
+
+tmpdir/dump: file format elf32-m68hc12
+
+
+Disassembly of section .text:
+00008000 <_start> movw 0x1234,X, 0x5432,X
+00008008 <_start\+0x8> movw 0x22,SP, 0x5432,Y
+0000800f <_start\+0xf> movw 0x5432,X, 0x12,SP
+00008016 <_start\+0x16> movw 0x1001,X, 0x2002,Y
+0000801e <_start\+0x1e> movw 0x5,SP, 0x1234,Y
+00008026 <_start\+0x26> tfr X,Y
+00008028 <_start\+0x28> rts
+00008029 <_etext> nop
+
diff -Nuar a/src/ld/testsuite/ld-m68hc11/movw.s
b/src/ld/testsuite/ld-m68hc11/movw.s
--- a/src/ld/testsuite/ld-m68hc11/movw.s 1970-01-01 01:00:00.000000000
+0100
+++ b/src/ld/testsuite/ld-m68hc11/movw.s 2012-11-07 13:47:05.000000000
+0000
@@ -0,0 +1,13 @@
+;;; Bug. movw used R_M68HC12_16B which was 1 byte misaligned.
+ .sect .text
+ .globl _start
+_start:
+start:
+ movw gp_max_on,x, gp_clk,x
+ movw 0x22,sp, gp_clk,y
+ movw gp_clk,x, 0x12,sp
+ movw 0x1001,x, 0x2002,y
+ movw small_off,sp, gp_max_on,y
+ tfr x,y
+ rts
+
--------------------------------------------------------


Notes
1 - all tests pass here and compiled application code is unchanged.
2 - as a future improvement the linker should use the 9bit and 5bit
indexed forms if the value (e.g. small_off) turns out to be small enough
at link time. Presently the longer 16bit version is used.
3 - I'm not sure where _etext is coming from in the testcase.

regards

James Murray


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]