From ed2c4879565a32432f6cbbf7569e0922835475b0 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 26 Jul 2014 23:44:37 +0530 Subject: [PATCH] opcodes: blackfin: do not force align the PC If the user gives us an unaligned PC, then dump an error as such. Otherwise if you try to disassemble at an odd address, the output will look weird (it'll read one byte earlier). This can be seen in one of the gas tests where data is in the middle of .text, so move the data to .data like it should be in the first place. Signed-off-by: Mike Frysinger --- gas/testsuite/ChangeLog | 5 +++++ gas/testsuite/gas/bfin/load.d | 11 ++--------- gas/testsuite/gas/bfin/load.s | 1 + opcodes/ChangeLog | 5 +++++ opcodes/bfin-dis.c | 10 +++++++++- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 8bf212127c8..13dd20da6e2 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-08-13 Mike Frysinger + + * gas/bfin/load.d: Update output. + * gas/bfin/load.s: Add .data section. + 2014-08-12 H.J. Lu * gas/i386/omit-lock.s: Remove type directive. diff --git a/gas/testsuite/gas/bfin/load.d b/gas/testsuite/gas/bfin/load.d index 5d03d8cd0b7..299312837dd 100644 --- a/gas/testsuite/gas/bfin/load.d +++ b/gas/testsuite/gas/bfin/load.d @@ -31,7 +31,7 @@ Disassembly of section .text: 54: 36 e1 ff 7f M2 = 0x7fff \(X\);.* 58: 81 60 R1 = 0x10 \(X\);.* 5a: 3c e1 00 00 L0 = 0x0 \(X\);.* - 5e: 27 e1 f3 00 R7 = 0xf3 \(X\);.* + 5e: 27 e1 01 00 R7 = 0x1 \(X\);.* 62: 00 e1 03 00 R0.L = 0x3;.* 66: 01 e1 0f 00 R1.L = 0xf;.* @@ -106,11 +106,4 @@ Disassembly of section .text: e8: fb 98 R3 = B\[FP--\] \(X\); ea: b7 e5 00 00 R7 = B\[SP \+ 0x0\] \(X\); ee: be e5 01 80 R6 = B\[FP \+ -0x7fff\] \(X\); - -000000f2 : - ... - -000000f3 : - f3: 10 00 IF !CC JUMP 0xf3 ; - f5: 00 00 NOP; - ... + \.\.\. diff --git a/gas/testsuite/gas/bfin/load.s b/gas/testsuite/gas/bfin/load.s index 96ae1faad19..0b785259827 100644 --- a/gas/testsuite/gas/bfin/load.s +++ b/gas/testsuite/gas/bfin/load.s @@ -129,6 +129,7 @@ load_byte_sign_extend: r7 = B [ sp+0] (x); r6 = b [fp-0x7fff] (X); + .data .global load_data load_data1: .byte 0 load_data2: .word 16 diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index fc1b494e074..48db533f71b 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,8 @@ +2014-08-13 Mike Frysinger + + * bfin-dis.c (ifetch): Do not align pc to 2 bytes. + (_print_insn_bfin): Add check for unaligned pc. + 2014-08-13 Mike Frysinger * bfin-dis.c (ifetch): New function. diff --git a/opcodes/bfin-dis.c b/opcodes/bfin-dis.c index 69919154c5a..8cc4604af82 100644 --- a/opcodes/bfin-dis.c +++ b/opcodes/bfin-dis.c @@ -4645,7 +4645,7 @@ ifetch (bfd_vma pc, disassemble_info *outf, TIword *iw) bfd_byte buf[2]; int status; - status = (*outf->read_memory_func) (pc & ~0x01, buf, 2, outf); + status = (*outf->read_memory_func) (pc, buf, 2, outf); if (status != 0) { (*outf->memory_error_func) (status, pc, outf); @@ -4663,6 +4663,14 @@ _print_insn_bfin (bfd_vma pc, disassemble_info *outf) TIword iw1; int rv = 0; + /* The PC must be 16-bit aligned. */ + if (pc & 1) + { + OUTS (outf, "ILLEGAL (UNALIGNED)"); + /* For people dumping data, just re-align the return value. */ + return 1; + } + if (ifetch (pc, outf, &iw0)) return -1; -- 2.30.2