mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 18:09:30 +02:00
* If subtrahend symbol belongs to current section, generate a RELATIVE relocation instead of PIC_PAIR. Now the corresponding relative expressions in assembler operands compile correctly on all i386 targets (and x86_64 too, although such feature is less important there).
+ Test. git-svn-id: trunk@21864 -
This commit is contained in:
parent
57b67dfa30
commit
21524c56c6
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -10333,6 +10333,7 @@ tests/test/tasm3.pp svneol=native#text/plain
|
||||
tests/test/tasm4.pp svneol=native#text/plain
|
||||
tests/test/tasm5.pp svneol=native#text/plain
|
||||
tests/test/tasm6.pp svneol=native#text/plain
|
||||
tests/test/tasm7.pp svneol=native#text/plain
|
||||
tests/test/tasmread.pp svneol=native#text/plain
|
||||
tests/test/tasout.pp svneol=native#text/plain
|
||||
tests/test/tassignmentoperator1.pp svneol=native#text/pascal
|
||||
|
@ -2425,8 +2425,16 @@ implementation
|
||||
(Assigned(oper[opidx]^.ref^.relsymbol)) then
|
||||
begin
|
||||
relsym:=objdata.symbolref(oper[opidx]^.ref^.relsymbol);
|
||||
currabsreloc:=RELOC_PIC_PAIR;
|
||||
currval:=relsym.offset;
|
||||
if relsym.objsection=objdata.CurrObjSec then
|
||||
begin
|
||||
currval:=objdata.CurrObjSec.size+ea_data.bytes-relsym.offset+currval;
|
||||
currabsreloc:=RELOC_RELATIVE;
|
||||
end
|
||||
else
|
||||
begin
|
||||
currabsreloc:=RELOC_PIC_PAIR;
|
||||
currval:=relsym.offset;
|
||||
end;
|
||||
end;
|
||||
objdata_writereloc(currval,ea_data.bytes,currsym,currabsreloc);
|
||||
inc(s,ea_data.bytes);
|
||||
|
24
tests/test/tasm7.pp
Normal file
24
tests/test/tasm7.pp
Normal file
@ -0,0 +1,24 @@
|
||||
{ %CPU=i386 }
|
||||
|
||||
{$asmmode att}
|
||||
var
|
||||
test: array[0..2] of longint;
|
||||
|
||||
function proc: longint; assembler;
|
||||
asm
|
||||
call .L1
|
||||
.L1:
|
||||
pop %eax
|
||||
movl test-.L1(%eax),%eax
|
||||
// This should also work (but it doesn't due to bugs in asmreader):
|
||||
// movl test-.L1+8(%eax),%eax
|
||||
end;
|
||||
|
||||
begin
|
||||
test[0]:=5555;
|
||||
test[1]:=6666;
|
||||
test[2]:=7777;
|
||||
if proc<>5555 then
|
||||
Halt(1);
|
||||
Halt(0);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user