Follow NASM after all in only turning off default RIP-rel for FS and GS,

not all segment registers.  FS and GS are the only ones which can have
a segment base != 0.

svn path=/trunk/yasm/; revision=1971
This commit is contained in:
Peter Johnson 2007-09-20 05:15:29 +00:00
parent 4db86bc131
commit 314cbfd3ef
8 changed files with 520 additions and 310 deletions

View file

@ -131,6 +131,9 @@ EXTRA_DIST += modules/arch/x86/tests/riprel1.hex
EXTRA_DIST += modules/arch/x86/tests/riprel2.asm
EXTRA_DIST += modules/arch/x86/tests/riprel2.errwarn
EXTRA_DIST += modules/arch/x86/tests/riprel2.hex
EXTRA_DIST += modules/arch/x86/tests/ripseg.asm
EXTRA_DIST += modules/arch/x86/tests/ripseg.errwarn
EXTRA_DIST += modules/arch/x86/tests/ripseg.hex
EXTRA_DIST += modules/arch/x86/tests/segmov.asm
EXTRA_DIST += modules/arch/x86/tests/segmov.hex
EXTRA_DIST += modules/arch/x86/tests/shift.asm

View file

@ -69,7 +69,7 @@
mov rax,[abs dword foo]
mov rax,[abs qword foo]
; all of these are abs due to es:, except for explicit rel
; all of these are default rel, except for 64-bit displacements
mov rax,[es:foo]
mov rax,[qword es:123456789abcdef0h]
mov rbx,[es:foo]

View file

@ -2,7 +2,7 @@
8b
04
25
c4
c0
02
00
00
@ -20,7 +20,7 @@ bc
8b
1c
25
c4
c0
02
00
00
@ -28,7 +28,7 @@ c4
8b
04
25
c4
c0
02
00
00
@ -36,13 +36,13 @@ c4
8b
1c
25
c4
c0
02
00
00
48
a1
c4
c0
02
00
00
@ -53,21 +53,21 @@ c4
48
8b
05
89
85
02
00
00
48
8b
1d
82
7e
02
00
00
48
8b
05
7b
77
02
00
00
@ -75,7 +75,7 @@ c4
8b
04
25
c4
c0
02
00
00
@ -83,7 +83,7 @@ c4
8b
1c
25
c4
c0
02
00
00
@ -91,13 +91,13 @@ c4
8b
04
25
c4
c0
02
00
00
48
a1
c4
c0
02
00
00
@ -110,7 +110,7 @@ c4
8b
04
25
c4
c0
02
00
00
@ -130,7 +130,7 @@ bc
8b
1c
25
c4
c0
02
00
00
@ -139,7 +139,7 @@ c4
8b
04
25
c4
c0
02
00
00
@ -148,14 +148,14 @@ c4
8b
1c
25
c4
c0
02
00
00
26
48
a1
c4
c0
02
00
00
@ -167,259 +167,259 @@ c4
48
8b
05
13
02
00
00
26
48
8b
1d
0b
02
00
00
26
48
8b
05
03
02
00
00
26
48
8b
04
25
c0
02
00
00
26
48
8b
1c
25
c0
02
00
00
26
48
8b
04
25
c0
02
00
00
26
48
a1
c0
02
00
00
00
00
00
00
64
48
8b
04
25
c0
02
00
00
64
48
a1
f0
de
bc
9a
78
56
34
12
64
48
8b
1c
25
c0
02
00
00
64
48
8b
04
25
c0
02
00
00
64
48
8b
1c
25
c0
02
00
00
64
48
a1
c0
02
00
00
00
00
00
00
64
48
8b
05
9b
01
00
00
64
48
8b
1d
93
01
00
00
64
48
8b
05
8b
01
00
00
64
48
8b
04
25
c0
02
00
00
64
48
8b
1c
25
c0
02
00
00
64
48
8b
04
25
c0
02
00
00
64
48
a1
c0
02
00
00
00
00
00
00
48
8b
03
48
8b
03
48
8b
03
48
8b
05
55
01
00
00
48
a1
f0
de
bc
9a
78
56
34
12
48
8b
1d
44
01
00
00
48
8b
05
3d
01
00
00
48
8b
1d
36
01
00
00
48
a1
c0
02
00
00
00
00
00
00
48
8b
05
25
01
00
00
48
8b
1d
1e
01
00
00
48
8b
05
17
02
00
00
26
48
8b
1d
0f
02
00
00
26
48
8b
05
07
02
00
00
26
48
8b
04
25
c4
02
00
00
26
48
8b
1c
25
c4
02
00
00
26
48
8b
04
25
c4
02
00
00
26
48
a1
c4
02
00
00
00
00
00
00
64
48
8b
04
25
c4
02
00
00
64
48
a1
f0
de
bc
9a
78
56
34
12
64
48
8b
1c
25
c4
02
00
00
64
48
8b
04
25
c4
02
00
00
64
48
8b
1c
25
c4
02
00
00
64
48
a1
c4
02
00
00
00
00
00
00
64
48
8b
05
9f
01
00
00
64
48
8b
1d
97
01
00
00
64
48
8b
05
8f
01
00
00
64
48
8b
04
25
c4
02
00
00
64
48
8b
1c
25
c4
02
00
00
64
48
8b
04
25
c4
02
00
00
64
48
a1
c4
02
00
00
00
00
00
00
48
8b
03
48
8b
03
48
8b
03
48
8b
05
59
01
00
00
48
a1
f0
de
bc
9a
78
56
34
12
48
8b
1d
48
01
00
00
48
8b
05
41
01
00
00
48
8b
1d
3a
01
00
00
48
a1
c4
02
00
00
00
00
00
00
48
8b
05
29
01
00
00
48
8b
1d
22
01
00
00
48
8b
05
1b
01
00
00
@ -427,7 +427,7 @@ c4
8b
04
25
c4
c0
02
00
00
@ -435,7 +435,7 @@ c4
8b
1c
25
c4
c0
02
00
00
@ -443,13 +443,13 @@ c4
8b
04
25
c4
c0
02
00
00
48
a1
c4
c0
02
00
00
@ -460,10 +460,9 @@ c4
26
48
8b
04
25
c4
02
05
ed
00
00
00
26
@ -480,34 +479,31 @@ bc
26
48
8b
1c
25
c4
02
1d
da
00
00
00
26
48
8b
04
25
c4
02
05
d2
00
00
00
26
48
8b
1c
25
c4
02
1d
ca
00
00
00
26
48
a1
c4
c0
02
00
00
@ -544,7 +540,7 @@ a7
8b
04
25
c4
c0
02
00
00
@ -553,7 +549,7 @@ c4
8b
1c
25
c4
c0
02
00
00
@ -562,14 +558,14 @@ c4
8b
04
25
c4
c0
02
00
00
26
48
a1
c4
c0
02
00
00
@ -582,7 +578,7 @@ c4
8b
04
25
c4
c0
02
00
00
@ -602,7 +598,7 @@ bc
8b
1c
25
c4
c0
02
00
00
@ -611,7 +607,7 @@ c4
8b
04
25
c4
c0
02
00
00
@ -620,14 +616,14 @@ c4
8b
1c
25
c4
c0
02
00
00
64
48
a1
c4
c0
02
00
00
@ -664,7 +660,7 @@ c4
8b
04
25
c4
c0
02
00
00
@ -673,7 +669,7 @@ c4
8b
1c
25
c4
c0
02
00
00
@ -682,14 +678,14 @@ c4
8b
04
25
c4
c0
02
00
00
64
48
a1
c4
c0
02
00
00

View file

@ -0,0 +1,35 @@
bits 64
foo:
default abs
mov rbx, [foo]
mov rbx, [es:foo]
mov rbx, [fs:foo]
mov rbx, [gs:foo]
mov rbx, [rel es:foo]
mov rbx, [rel fs:foo]
mov rbx, [rel gs:foo]
mov rbx, [abs es:foo]
mov rbx, [abs fs:foo]
mov rbx, [abs gs:foo]
;mov rbx, [es:rel foo]
;mov rbx, [fs:rel foo]
;mov rbx, [es:abs foo]
;mov rbx, [fs:abs foo]
default rel
mov rbx, [foo]
mov rbx, [es:foo]
mov rbx, [fs:foo]
mov rbx, [gs:foo]
mov rbx, [rel es:foo]
mov rbx, [rel fs:foo]
mov rbx, [rel gs:foo]
mov rbx, [abs es:foo]
mov rbx, [abs fs:foo]
mov rbx, [abs gs:foo]
;mov rbx, [es:rel foo]
;mov rbx, [fs:rel foo]
;mov rbx, [es:abs foo]
;mov rbx, [fs:abs foo]

View file

@ -0,0 +1,6 @@
-:6: warning: `es' segment register ignored in 64-bit mode
-:9: warning: `es' segment register ignored in 64-bit mode
-:12: warning: `es' segment register ignored in 64-bit mode
-:22: warning: `es' segment register ignored in 64-bit mode
-:25: warning: `es' segment register ignored in 64-bit mode
-:28: warning: `es' segment register ignored in 64-bit mode

View file

@ -0,0 +1,170 @@
48
8b
1c
25
00
00
00
00
26
48
8b
1c
25
00
00
00
00
64
48
8b
1c
25
00
00
00
00
65
48
8b
1c
25
00
00
00
00
26
48
8b
1d
d5
ff
ff
ff
64
48
8b
1d
cd
ff
ff
ff
65
48
8b
1d
c5
ff
ff
ff
26
48
8b
1c
25
00
00
00
00
64
48
8b
1c
25
00
00
00
00
65
48
8b
1c
25
00
00
00
00
48
8b
1d
a3
ff
ff
ff
26
48
8b
1d
9b
ff
ff
ff
64
48
8b
1c
25
00
00
00
00
65
48
8b
1c
25
00
00
00
00
26
48
8b
1d
81
ff
ff
ff
64
48
8b
1d
79
ff
ff
ff
65
48
8b
1d
71
ff
ff
ff
26
48
8b
1c
25
00
00
00
00
64
48
8b
1c
25
00
00
00
00
65
48
8b
1c
25
00
00
00
00

View file

@ -1178,10 +1178,13 @@ x86_id_insn_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc)
yasm_x86__ea_set_disponly(insn->x86_ea);
else if (id_insn->default_rel &&
!op->data.ea->not_pc_rel &&
op->data.ea->segreg == 0 &&
op->data.ea->segreg != 0x6404 &&
op->data.ea->segreg != 0x6505 &&
!yasm_expr__contains(
op->data.ea->disp.abs, YASM_EXPR_REG))
/* Enable default PC-rel if no regs/segregs */
/* Enable default PC-rel if no regs and segreg
* is not FS or GS.
*/
insn->x86_ea->ea.pc_rel = 1;
break;
case YASM_INSN__OPERAND_IMM:

View file

@ -755,11 +755,8 @@ parse_memaddr(yasm_parser_nasm *parser_nasm)
}
get_next_token();
ea = parse_memaddr(parser_nasm);
if (ea) {
if (ea)
yasm_ea_set_segreg(ea, segreg);
ea->pc_rel = 0;
ea->not_pc_rel = 1;
}
return ea;
}
case SIZE_OVERRIDE: