* x86_64: warn only on negative offsets if rsp is involed, second part of #40113

+ tests
This commit is contained in:
florian 2023-01-17 23:09:09 +01:00
parent b5763eb412
commit 5598ffc210
3 changed files with 35 additions and 1 deletions

View File

@ -854,7 +854,7 @@ begin
;
end;
if memoffset < 0 then
if ((operands[i].opr.ref.base=NR_ESP) or (operands[i].opr.ref.index=NR_ESP)) and (memoffset < 0) then
begin
Message2(asmr_w_check_mem_operand_negative_offset,
//std_op2str[opcode],

17
tests/webtbf/tw40113c.pp Normal file
View File

@ -0,0 +1,17 @@
{ %cpu=x86_64 }
{ %opt=-Sew }
{ %fail }
{$asmmode intel}
begin
asm
movss xmm0, dword ptr [rsp-8] // (2)
lea rax, @table[rip]
lea rsp, [rsp+32]
jmp @next
db 0, 1, 2, 3, 4, 5, 6, 7
@table:
db 8, 9, 10
@next:
end ['rax', 'xmm0'];
end.

17
tests/webtbs/tw40113d.pp Normal file
View File

@ -0,0 +1,17 @@
{ %cpu=x86_64 }
{ %opt=-Sew }
{ %norun }
{$asmmode intel}
begin
asm
movss xmm0, dword ptr [rax-8] // (2)
lea rax, @table[rip]
lea rsp, [rsp+32]
jmp @next
db 0, 1, 2, 3, 4, 5, 6, 7
@table:
db 8, 9, 10
@next:
end ['rax', 'xmm0'];
end.