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] x86: fix handling of %eip/%rip


Along with allowing (the admittedly somewhat odd, but possible) %eip-
relative addressing to be encoded just like other 32-bit addressing
modes, this also fixes the problem of the identifier 'rip' not having
been available for programmer use in Intel-syntax 32-bit code.

Built and tested on x86_64-unknown-linux-gnu.

gas/
2007-09-25  Jan Beulich  <jbeulich@novell.com>

	* config/tc-i386.c (build_modrm_byte): Also check for RegEip
	when considering IP-relative addressing.

gas/testsuite/
2007-09-25  Jan Beulich  <jbeulich@novell.com>

	* gas/i386/reloc64.s: Adjust for %eip-relative addressing no
	longer generating errors.
	* gas/i386/reloc64.d, gas/i386/reloc64.l: Update.
	* gas/i386/x86-64-addr32.s: Remove explicit addr32 prefix
	for %eip-realtive addressing case.

opcodes/
2007-09-25  Jan Beulich  <jbeulich@novell.com>

	* i386-opc.h (RegEip): Define.
	(RegEiz): Adjust.
	* i386-reg.tbl: Add eip. Mark rip and eip with RegRex64.
	* i386-tbl.h: Re-generate.

--- 2007-09-25/gas/config/tc-i386.c	2007-09-25 16:27:43.000000000 +0200
+++ 2007-09-25/gas/config/tc-i386.c	2007-09-25 17:30:50.000000000 +0200
@@ -4548,7 +4548,8 @@ build_modrm_byte (void)
 		}
 	    }
 	  /* RIP addressing for 64bit mode.  */
-	  else if (i.base_reg->reg_num == RegRip)
+	  else if (i.base_reg->reg_num == RegRip ||
+		   i.base_reg->reg_num == RegEip)
 	    {
 	      i.rm.regmem = NO_BASE_REGISTER;
 	      i.types[op].bitfield.disp8 = 0;
@@ -5980,7 +5981,8 @@ i386_index_check (const char *operand_st
 	       || (i.prefix[ADDR_PREFIX]
 		   && !i.base_reg->reg_type.bitfield.reg32))
 	   && (i.index_reg
-	       || i.base_reg->reg_num != RegRip))
+	       || i.base_reg->reg_num !=
+		  (i.prefix[ADDR_PREFIX] == 0 ? RegRip : RegEip)))
 	  || (i.index_reg
 	      && (!i.index_reg->reg_type.bitfield.baseindex
 		  || (i.prefix[ADDR_PREFIX] == 0
--- 2007-09-25/gas/testsuite/gas/i386/reloc64.d	2007-06-18 09:23:34.000000000 +0200
+++ 2007-09-25/gas/testsuite/gas/i386/reloc64.d	2007-09-24 15:55:06.000000000 +0200
@@ -18,6 +18,7 @@ Disassembly of section \.text:
 .*[ 	]+R_X86_64_PC8[ 	]+xtrn\+0x0*1
 .*[ 	]+R_X86_64_PC32[ 	]+xtrn\+0xf+c
 .*[ 	]+R_X86_64_PC32[ 	]+xtrn\+0xf+c
+.*[ 	]+R_X86_64_PC32[ 	]+xtrn\+0xf+c
 .*[ 	]+R_X86_64_PC8[ 	]+xtrn\+0xf+f
 .*[ 	]+R_X86_64_GOT64[ 	]+xtrn
 .*[ 	]+R_X86_64_GOT32[ 	]+xtrn
@@ -28,6 +29,7 @@ Disassembly of section \.text:
 .*[ 	]+R_X86_64_GOTPCREL[ 	]+xtrn\+0xf+c
 .*[ 	]+R_X86_64_GOTPC32[ 	]+_GLOBAL_OFFSET_TABLE_\+0x0*2
 .*[ 	]+R_X86_64_GOTPC32[ 	]+_GLOBAL_OFFSET_TABLE_\+0xf+c
+.*[ 	]+R_X86_64_GOTPC32[ 	]+_GLOBAL_OFFSET_TABLE_\+0xf+c
 .*[ 	]+R_X86_64_GOTPC32[ 	]+_GLOBAL_OFFSET_TABLE_\+0x0*2
 .*[ 	]+R_X86_64_PLT32[ 	]+xtrn
 .*[ 	]+R_X86_64_PLT32[ 	]+xtrn
--- 2007-09-25/gas/testsuite/gas/i386/reloc64.l	2006-04-21 10:25:37.000000000 +0200
+++ 2007-09-25/gas/testsuite/gas/i386/reloc64.l	2007-09-24 15:54:24.000000000 +0200
@@ -1,5 +1,4 @@
 .*: Assembler messages:
-.*:29: Error: .*
 .*:35: Error: .*
 .*:36: Error: .*
 .*:37: Error: .*
@@ -17,7 +16,6 @@
 .*:54: Error: .*
 .*:55: Error: .*
 .*:57: Error: .*
-.*:66: Error: .*
 .*:73: Error: .*
 .*:75: Error: .*
 .*:76: Error: .*
--- 2007-09-25/gas/testsuite/gas/i386/reloc64.s	2007-06-18 09:23:35.000000000 +0200
+++ 2007-09-25/gas/testsuite/gas/i386/reloc64.s	2007-09-24 15:53:56.000000000 +0200
@@ -26,7 +26,7 @@ ill	mov	$(xtrn - .), %eax
 	mov	$(xtrn - .), %ax
 	mov	$(xtrn - .), %al
 	mov	xtrn(%rip), %eax
-bad	mov	xtrn(%eip), %eax
+	mov	xtrn(%eip), %eax
 	call	xtrn
 	jrcxz	xtrn
 
@@ -62,8 +62,8 @@ ill	movabs	$_GLOBAL_OFFSET_TABLE_, %rax
 ill	add	$_GLOBAL_OFFSET_TABLE_, %eax
 ill	add	$_GLOBAL_OFFSET_TABLE_, %ax
 ill	add	$_GLOBAL_OFFSET_TABLE_, %al
-	lea	_GLOBAL_OFFSET_TABLE_(%rip), %rax #???
-bad	lea	_GLOBAL_OFFSET_TABLE_(%eip), %rax
+	lea	_GLOBAL_OFFSET_TABLE_(%rip), %rax
+	lea	_GLOBAL_OFFSET_TABLE_(%eip), %rax
 ill	movabs	$(_GLOBAL_OFFSET_TABLE_ - .), %rax
 	add	$(_GLOBAL_OFFSET_TABLE_ - .), %rax
 ill	add	$(_GLOBAL_OFFSET_TABLE_ - .), %eax
--- 2007-09-25/gas/testsuite/gas/i386/x86-64-addr32.s	2006-11-13 15:22:00.000000000 +0100
+++ 2007-09-25/gas/testsuite/gas/i386/x86-64-addr32.s	2007-09-24 16:04:05.000000000 +0200
@@ -1,7 +1,7 @@
 .text
 	lea		symbol(%eax), %rax
 	lea		symbol(%r8d), %rax
-	addr32 lea	symbol(%rip), %rax
+	lea		symbol(%eip), %rax
 	addr32 lea	symbol, %rax
 	addr32 mov	0x600898,%al
 	addr32 mov	0x600898,%ax
--- 2007-09-25/opcodes/i386-opc.h	2007-09-25 16:27:55.000000000 +0200
+++ 2007-09-25/opcodes/i386-opc.h	2007-09-25 17:22:31.000000000 +0200
@@ -444,8 +444,9 @@ typedef struct
 #define RegRex64    0x2  /* Extended 8 bit register.  */
   unsigned int reg_num;
 #define RegRip	((unsigned int ) ~0)
+#define RegEip	(RegRip - 1)
 /* EIZ and RIZ are fake index registers.  */
-#define RegEiz	(RegRip - 1)
+#define RegEiz	(RegEip - 1)
 #define RegRiz	(RegEiz - 1)
 }
 reg_entry;
--- 2007-09-25/opcodes/i386-reg.tbl	2007-09-25 16:27:55.000000000 +0200
+++ 2007-09-25/opcodes/i386-reg.tbl	2007-09-25 17:19:30.000000000 +0200
@@ -187,9 +187,10 @@ xmm12, RegXMM, RegRex, 4
 xmm13, RegXMM, RegRex, 5
 xmm14, RegXMM, RegRex, 6
 xmm15, RegXMM, RegRex, 7
-// No type will make this register rejected for all purposes except
-// for addressing.  This saves creating one extra type for RIP.
-rip, BaseIndex, 0, RegRip
+// No type will make these registers rejected for all purposes except
+// for addressing.  This saves creating one extra type for RIP/EIP.
+rip, BaseIndex, RegRex64, RegRip
+eip, BaseIndex, RegRex64, RegEip
 // No type will make these registers rejected for all purposes except
 // for addressing.
 eiz, BaseIndex, 0, RegEiz
--- 2007-09-25/opcodes/i386-tbl.h	2007-09-25 16:27:56.000000000 +0200
+++ 2007-09-25/opcodes/i386-tbl.h	2007-09-25 17:38:45.000000000 +0200
@@ -13278,7 +13278,11 @@ const reg_entry i386_regtab[] =
   { "rip",
     { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
-    0, RegRip },
+    RegRex64, RegRip },
+  { "eip",
+    { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
+    RegRex64, RegEip },
   { "eiz",
     { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },



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