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] Unbreak Arm blx relocations


My previous patch to implement Arm bl->blx conversion accidentally removed the 
gas code for resolving relocations on blx instructions.

http://sourceware.org/ml/binutils/2005-10/msg00430.html

The symptoms are that a BLX instruction to a label in the same section gets 
resolved by the assembler, but the H offset bit is not set correctly.

The patch below fixes this.
Testes on arm-none-eabi.
Ok?

Paul

2006-03-14  Paul Brook  <paul@codesourcery.com>

gas/
	* config/tc-arm.c (md_apply_fix): Set H bit on blx instruction.
gas/testsuite/
	* gas/arm/blx-local.d: New test.
	* gas/arm/blx-local.d: New test.
Index: gas/config/tc-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/gas/config/tc-arm.c,v
retrieving revision 1.246
diff -u -p -r1.246 tc-arm.c
--- gas/config/tc-arm.c	10 Mar 2006 17:20:30 -0000	1.246
+++ gas/config/tc-arm.c	14 Mar 2006 19:27:33 -0000
@@ -11864,6 +11864,14 @@ md_apply_fix (fixS *	fixP,
 	{
 	  newval = md_chars_to_number (buf, INSN_SIZE);
 	  newval |= (value >> 2) & 0x00ffffff;
+	  /* Set the H bit on BLX instructions.  */
+	  if (temp == 1)
+	    {
+	      if (value & 2)
+		newval |= 0x01000000;
+	      else
+		newval &= ~0x01000000;
+	    }
 	  md_number_to_chars (buf, newval, INSN_SIZE);
 	}
       break;
Index: gas/testsuite/gas/arm/blx-local.d
===================================================================
RCS file: gas/testsuite/gas/arm/blx-local.d
diff -N gas/testsuite/gas/arm/blx-local.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/blx-local.d	14 Mar 2006 19:37:05 -0000
@@ -0,0 +1,14 @@
+#name: Local BLX instructions
+#objdump: -dr --prefix-addresses --show-raw-insn
+#as:
+
+# Test assembler resolution of blx instructions.
+
+.*: +file format .*arm.*
+
+Disassembly of section .text:
+
+0+00 <[^>]*> fa000000 	blx	00+8 <foo>
+0+04 <[^>]*> fbffffff 	blx	00+a <foo2>
+0+08 <[^>]*> 46c0      	nop			\(mov r8, r8\)
+0+0a <[^>]*> 46c0      	nop			\(mov r8, r8\)
Index: gas/testsuite/gas/arm/blx-local.s
===================================================================
RCS file: gas/testsuite/gas/arm/blx-local.s
diff -N gas/testsuite/gas/arm/blx-local.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/blx-local.s	14 Mar 2006 19:30:59 -0000
@@ -0,0 +1,16 @@
+        .text
+	.arch armv5t
+        .arm
+one:
+        blx     foo
+        blx     foo2
+
+        .thumb
+        .type foo, %function
+        .thumb_func
+foo:
+        nop
+        .type foo2, %function
+        .thumb_func
+foo2:
+        nop

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