From: Peter Johnson Date: Sat, 12 Jul 2003 22:55:22 +0000 (-0000) Subject: Fix RIP-relative effective addresses. They always have a 32-bit X-Git-Tag: v0.3.0~6^2~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba5a46bd974e45e30ac8665cefc619f74d34aa0d;p=yasm Fix RIP-relative effective addresses. They always have a 32-bit displacement. Noticed by: Ben Skeggs svn path=/trunk/yasm/; revision=1006 --- diff --git a/modules/arch/x86/tests/mem64.asm b/modules/arch/x86/tests/mem64.asm index fd773318..a9e1c35c 100644 --- a/modules/arch/x86/tests/mem64.asm +++ b/modules/arch/x86/tests/mem64.asm @@ -11,12 +11,12 @@ a32 mov rbx, [0] ; 67 48 8B 1C 25 00 00 00 00 mov ebx, [rcx] ; 8B 19 mov r8, [r9] ; 4D 8B 01 mov ecx, [ebx] ; 67 8B 0B -mov edx, [rip] ; 8B 15 -a32 mov rcx, [rip+5] ; 67 48 8B 4D 05 +mov edx, [rip] ; 8B 15 00 00 00 00 +a32 mov rcx, [rip+5] ; 67 48 8B 0D 05 00 00 00 mov rbx, [rax+rbx*4] ; 48 8B 1C 98 mov rdx, [rsp] ; 48 8B 14 24 mov rax, [r12] ; 49 8B 04 24 mov rcx, [rbp] ; 48 8B 4D 00 mov rbx, [r13] ; 49 8B 5D 00 -mov ah, [rip] ; 8A 25 +mov ah, [rip] ; 8A 25 00 00 00 00 mov bh, [rcx] ; 8A 39 diff --git a/modules/arch/x86/tests/mem64.hex b/modules/arch/x86/tests/mem64.hex index 691cffdf..ae433679 100644 --- a/modules/arch/x86/tests/mem64.hex +++ b/modules/arch/x86/tests/mem64.hex @@ -80,11 +80,18 @@ a1 0b 8b 15 +00 +00 +00 +00 67 48 8b -4d +0d 05 +00 +00 +00 48 8b 1c @@ -107,5 +114,9 @@ a1 00 8a 25 +00 +00 +00 +00 8a 39 diff --git a/modules/arch/x86/x86expr.c b/modules/arch/x86/x86expr.c index e5288344..77c2b83e 100644 --- a/modules/arch/x86/x86expr.c +++ b/modules/arch/x86/x86expr.c @@ -25,7 +25,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -/*@unused@*/ RCSID("$IdPath: yasm/modules/arch/x86/x86expr.c,v 1.54 2003/03/26 05:07:55 peter Exp $"); +/*@unused@*/ RCSID("$IdPath$"); #define YASM_LIB_INTERNAL #define YASM_EXPR_INTERNAL @@ -736,6 +736,10 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize, *sib = 0; *v_sib = 0; *n_sib = 0; + /* RIP always requires a 32-bit displacement */ + *v_modrm = 1; + *displen = 4; + return 1; } else if (indexreg == REG3264_NONE) { /* basereg only */ /* Don't need to go to the full effort of determining what type