public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Fix RIP handling for Intel mode
@ 2007-09-16 17:17 H.J. Lu
  2007-09-17  9:49 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2007-09-16 17:17 UTC (permalink / raw)
  To: binutils

intel_e04 may be called recursively. We may see the end of input inside
the loop. I am checking in this patch to fix it.


H.J.
----
gas/

2007-09-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR gas/5034
	* config/tc-i386.c (intel_e04): Return 1 if cur_token.code is
	T_NIL.

gas/testsuite/

2007-09-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR gas/5034
	* gas/i386/x86-64-rip.s: Add Intel mode testcases.
	* gas/i386/x86-64-rip-intel.d: Updated.
	* gas/i386/x86-64-rip.d: Likewise.

--- gas/config/tc-i386.c.rip	2007-09-14 18:58:16.000000000 -0700
+++ gas/config/tc-i386.c	2007-09-15 14:24:28.000000000 -0700
@@ -7913,6 +7913,9 @@ intel_e04 (void)
       if (!intel_e05())
 	return 0;
 
+      if (cur_token.code == T_NIL)
+	return 1;
+
       if (nregs >= 0 && NUM_ADDRESS_REGS > nregs)
 	i.base_reg = i386_regtab + REGNAM_AL; /* al is invalid as base */
 
--- gas/testsuite/gas/i386/x86-64-rip-intel.d.rip	2007-04-26 11:15:47.000000000 -0700
+++ gas/testsuite/gas/i386/x86-64-rip-intel.d	2007-09-15 14:50:59.000000000 -0700
@@ -7,9 +7,13 @@
 
 Disassembly of section .text:
 
-0+000 <.text>:
-[	 ]*0:[	 ]+8d 05 00 00 00 00[	 ]+lea[	 ]+eax,\[rip\+0x0\][ 	]*(#.*)?
-[	 ]*6:[	 ]+8d 05 11 11 11 11[	 ]+lea[	 ]+eax,\[rip\+0x11111111\][ 	]*(#.*)?
-[	 ]*c:[	 ]+8d 05 01 00 00 00[	 ]+lea[	 ]+eax,\[rip\+0x1\][ 	]*(#.*)?
-[	 ]*12:[	 ]+8d 05 00 00 00 00[	 ]+lea[	 ]+eax,\[rip\+0x0\][ 	]*(#.*)?
+0+ <.text>:
+[ 	]*[a-f0-9]+:	8d 05 00 00 00 00    	lea    eax,\[rip\+0x0\][ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	symbol-0x4
+[ 	]*[a-f0-9]+:	8d 05 11 11 11 11    	lea    eax,\[rip\+0x11111111\]        # 0x1111111d
+[ 	]*[a-f0-9]+:	8d 05 01 00 00 00    	lea    eax,\[rip\+0x1\]        # 0x13
+[ 	]*[a-f0-9]+:	8d 05 00 00 00 00    	lea    eax,\[rip\+0x0\]        # 0x18
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    rax,QWORD PTR \[rip\+0x0\][ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    rax,QWORD PTR \[rip\+0x0\][ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    rax,QWORD PTR \[rip\+0x0\][ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    rax,QWORD PTR \[rip\+0x0\][ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
 #pass
--- gas/testsuite/gas/i386/x86-64-rip.d.rip	2007-04-26 22:54:10.000000000 -0700
+++ gas/testsuite/gas/i386/x86-64-rip.d	2007-09-15 14:51:12.000000000 -0700
@@ -6,9 +6,13 @@
 
 Disassembly of section .text:
 
-0+000 <.text>:
-[	 ]*0:[	 ]+8d 05 00 00 00 00[	 ]+lea[	 ]+0x0\(%rip\),%eax[ 	]*(#.*)?
-[	 ]*6:[	 ]+8d 05 11 11 11 11[	 ]+lea[	 ]+0x11111111\(%rip\),%eax[ 	]*(#.*)?
-[	 ]*c:[	 ]+8d 05 01 00 00 00[	 ]+lea[	 ]+0x1\(%rip\),%eax[ 	]*(#.*)?
-[	 ]*12:[	 ]+8d 05 00 00 00 00[	 ]+lea[	 ]+0x0\(%rip\),%eax[ 	]*(#.*)?
+0+ <.text>:
+[ 	]*[a-f0-9]+:	8d 05 00 00 00 00    	lea    0x0\(%rip\),%eax[ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	symbol-0x4
+[ 	]*[a-f0-9]+:	8d 05 11 11 11 11    	lea    0x11111111\(%rip\),%eax        # 0x1111111d
+[ 	]*[a-f0-9]+:	8d 05 01 00 00 00    	lea    0x1\(%rip\),%eax        # 0x13
+[ 	]*[a-f0-9]+:	8d 05 00 00 00 00    	lea    0x0\(%rip\),%eax        # 0x18
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    0x0\(%rip\),%rax[ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    0x0\(%rip\),%rax[ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    0x0\(%rip\),%rax[ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    0x0\(%rip\),%rax[ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
 #pass
--- gas/testsuite/gas/i386/x86-64-rip.s.rip	2004-07-21 09:09:43.000000000 -0700
+++ gas/testsuite/gas/i386/x86-64-rip.s	2007-09-15 14:26:28.000000000 -0700
@@ -3,3 +3,8 @@
 	leal	0x11111111(%rip), %eax
 	leal	1(%rip), %eax
 	leal	(%rip), %eax
+.intel_syntax noprefix
+mov     rax, QWORD PTR __CTOR_END__-8[rip]
+mov     rax, QWORD PTR __CTOR_END__+-8[rip]
+mov     rax, QWORD PTR -8+__CTOR_END__[rip]
+mov     rax, QWORD PTR __CTOR_END__[rip-8]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: Fix RIP handling for Intel mode
  2007-09-16 17:17 PATCH: Fix RIP handling for Intel mode H.J. Lu
@ 2007-09-17  9:49 ` Jan Beulich
  2007-09-17 16:11   ` H.J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2007-09-17  9:49 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

Please revert this patch if you committed it already: The syntax you're trying to
make gas accept is not being accepted by masm. In the below (32-bit) opcodes,
all those that are commented (masm-style ;) get rejected by masm 7.00, 7.10,
and 8.00 (didn't check any others).

	mov	eax,[eax]
	mov	eax,x[eax]
	mov	eax,x+[eax]
;	mov	eax,x-[eax]
	mov	eax,x+8[eax]
;	mov	eax,x-8[eax]
	mov	eax,x[-8+eax]
	mov	eax,x[eax-8]
	mov	eax,x+8[eax+edx]
;	mov	eax,x-8[eax+edx]
	mov	eax,x[-8+eax+edx]
	mov	eax,x[eax+edx-8]

Jan

>>> "H.J. Lu" <hjl@lucon.org> 16.09.07 00:04 >>>
intel_e04 may be called recursively. We may see the end of input inside
the loop. I am checking in this patch to fix it.


H.J.
----
gas/

2007-09-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR gas/5034
	* config/tc-i386.c (intel_e04): Return 1 if cur_token.code is
	T_NIL.

gas/testsuite/

2007-09-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR gas/5034
	* gas/i386/x86-64-rip.s: Add Intel mode testcases.
	* gas/i386/x86-64-rip-intel.d: Updated.
	* gas/i386/x86-64-rip.d: Likewise.

--- gas/config/tc-i386.c.rip	2007-09-14 18:58:16.000000000 -0700
+++ gas/config/tc-i386.c	2007-09-15 14:24:28.000000000 -0700
@@ -7913,6 +7913,9 @@ intel_e04 (void)
       if (!intel_e05())
 	return 0;
 
+      if (cur_token.code == T_NIL)
+	return 1;
+
       if (nregs >= 0 && NUM_ADDRESS_REGS > nregs)
 	i.base_reg = i386_regtab + REGNAM_AL; /* al is invalid as base */
 
--- gas/testsuite/gas/i386/x86-64-rip-intel.d.rip	2007-04-26 11:15:47.000000000 -0700
+++ gas/testsuite/gas/i386/x86-64-rip-intel.d	2007-09-15 14:50:59.000000000 -0700
@@ -7,9 +7,13 @@
 
 Disassembly of section .text:
 
-0+000 <.text>:
-[	 ]*0:[	 ]+8d 05 00 00 00 00[	 ]+lea[	 ]+eax,\[rip\+0x0\][ 	]*(#.*)?
-[	 ]*6:[	 ]+8d 05 11 11 11 11[	 ]+lea[	 ]+eax,\[rip\+0x11111111\][ 	]*(#.*)?
-[	 ]*c:[	 ]+8d 05 01 00 00 00[	 ]+lea[	 ]+eax,\[rip\+0x1\][ 	]*(#.*)?
-[	 ]*12:[	 ]+8d 05 00 00 00 00[	 ]+lea[	 ]+eax,\[rip\+0x0\][ 	]*(#.*)?
+0+ <.text>:
+[ 	]*[a-f0-9]+:	8d 05 00 00 00 00    	lea    eax,\[rip\+0x0\][ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	symbol-0x4
+[ 	]*[a-f0-9]+:	8d 05 11 11 11 11    	lea    eax,\[rip\+0x11111111\]        # 0x1111111d
+[ 	]*[a-f0-9]+:	8d 05 01 00 00 00    	lea    eax,\[rip\+0x1\]        # 0x13
+[ 	]*[a-f0-9]+:	8d 05 00 00 00 00    	lea    eax,\[rip\+0x0\]        # 0x18
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    rax,QWORD PTR \[rip\+0x0\][ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    rax,QWORD PTR \[rip\+0x0\][ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    rax,QWORD PTR \[rip\+0x0\][ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    rax,QWORD PTR \[rip\+0x0\][ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
 #pass
--- gas/testsuite/gas/i386/x86-64-rip.d.rip	2007-04-26 22:54:10.000000000 -0700
+++ gas/testsuite/gas/i386/x86-64-rip.d	2007-09-15 14:51:12.000000000 -0700
@@ -6,9 +6,13 @@
 
 Disassembly of section .text:
 
-0+000 <.text>:
-[	 ]*0:[	 ]+8d 05 00 00 00 00[	 ]+lea[	 ]+0x0\(%rip\),%eax[ 	]*(#.*)?
-[	 ]*6:[	 ]+8d 05 11 11 11 11[	 ]+lea[	 ]+0x11111111\(%rip\),%eax[ 	]*(#.*)?
-[	 ]*c:[	 ]+8d 05 01 00 00 00[	 ]+lea[	 ]+0x1\(%rip\),%eax[ 	]*(#.*)?
-[	 ]*12:[	 ]+8d 05 00 00 00 00[	 ]+lea[	 ]+0x0\(%rip\),%eax[ 	]*(#.*)?
+0+ <.text>:
+[ 	]*[a-f0-9]+:	8d 05 00 00 00 00    	lea    0x0\(%rip\),%eax[ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	symbol-0x4
+[ 	]*[a-f0-9]+:	8d 05 11 11 11 11    	lea    0x11111111\(%rip\),%eax        # 0x1111111d
+[ 	]*[a-f0-9]+:	8d 05 01 00 00 00    	lea    0x1\(%rip\),%eax        # 0x13
+[ 	]*[a-f0-9]+:	8d 05 00 00 00 00    	lea    0x0\(%rip\),%eax        # 0x18
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    0x0\(%rip\),%rax[ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    0x0\(%rip\),%rax[ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    0x0\(%rip\),%rax[ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
+[ 	]*[a-f0-9]+:	48 8b 05 00 00 00 00 	mov    0x0\(%rip\),%rax[ 	]*#[ 	]*0x[a-f0-9]+[ 	]+[a-f0-9]+: R_X86_64_PC32	__CTOR_END__-0xc
 #pass
--- gas/testsuite/gas/i386/x86-64-rip.s.rip	2004-07-21 09:09:43.000000000 -0700
+++ gas/testsuite/gas/i386/x86-64-rip.s	2007-09-15 14:26:28.000000000 -0700
@@ -3,3 +3,8 @@
 	leal	0x11111111(%rip), %eax
 	leal	1(%rip), %eax
 	leal	(%rip), %eax
+.intel_syntax noprefix
+mov     rax, QWORD PTR __CTOR_END__-8[rip]
+mov     rax, QWORD PTR __CTOR_END__+-8[rip]
+mov     rax, QWORD PTR -8+__CTOR_END__[rip]
+mov     rax, QWORD PTR __CTOR_END__[rip-8]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: Fix RIP handling for Intel mode
  2007-09-17  9:49 ` Jan Beulich
@ 2007-09-17 16:11   ` H.J. Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2007-09-17 16:11 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils

On Mon, Sep 17, 2007 at 10:43:54AM +0100, Jan Beulich wrote:
> Please revert this patch if you committed it already: The syntax you're trying to
> make gas accept is not being accepted by masm. In the below (32-bit) opcodes,
> all those that are commented (masm-style ;) get rejected by masm 7.00, 7.10,
> and 8.00 (didn't check any others).
> 
> 	mov	eax,[eax]
> 	mov	eax,x[eax]
> 	mov	eax,x+[eax]
> ;	mov	eax,x-[eax]
> 	mov	eax,x+8[eax]
> ;	mov	eax,x-8[eax]
> 	mov	eax,x[-8+eax]
> 	mov	eax,x[eax-8]
> 	mov	eax,x+8[eax+edx]
> ;	mov	eax,x-8[eax+edx]
> 	mov	eax,x[-8+eax+edx]
> 	mov	eax,x[eax+edx-8]
> 
> Jan
> 

Reverted.


H.J.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-09-17 14:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-16 17:17 PATCH: Fix RIP handling for Intel mode H.J. Lu
2007-09-17  9:49 ` Jan Beulich
2007-09-17 16:11   ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).