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]

[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 <vapier@gentoo.org>
---
 gas/testsuite/gas/bfin/load.d | 11 ++---------
 gas/testsuite/gas/bfin/load.s |  1 +
 opcodes/bfin-dis.c            | 10 +++++++++-
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/gas/testsuite/gas/bfin/load.d b/gas/testsuite/gas/bfin/load.d
index 5d03d8c..2993128 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 <load_data1>:
-	...
-
-000000f3 <load_data2>:
-  f3:	10 00       	IF !CC JUMP 0xf3 <load_data2>;
-  f5:	00 00       	NOP;
-	...
+	\.\.\.
diff --git a/gas/testsuite/gas/bfin/load.s b/gas/testsuite/gas/bfin/load.s
index 96ae1fa..0b78525 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/bfin-dis.c b/opcodes/bfin-dis.c
index 6991915..8cc4604 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.0.0


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