mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-29 10:00:31 +02:00
* test/opt/tretopt.pp, test/tasmread.pp: fixed GOT calculation
* test/tcg1.pp: rewrote without PIC, was having the same issue (GOT off by 1), additionally Intel syntax part won't compile anyway. This test is about push/pop encoding, not about PIC. git-svn-id: trunk@21811 -
This commit is contained in:
parent
025f840dd5
commit
34fc366d64
@ -294,7 +294,7 @@ begin
|
||||
{$ifdef darwin}
|
||||
movl %eax,p3-.Lpic(%ecx)
|
||||
{$else darwin}
|
||||
addl $_GLOBAL_OFFSET_TABLE_,%ecx
|
||||
addl $_GLOBAL_OFFSET_TABLE_+1,%ecx
|
||||
movl %eax,p3@GOT(%ecx)
|
||||
{$endif darwin}
|
||||
{$endif FPC_PIC}
|
||||
@ -349,7 +349,7 @@ begin
|
||||
{$ifdef darwin}
|
||||
movl %eax,p3-.Lpic(%ecx)
|
||||
{$else darwin}
|
||||
addl $_GLOBAL_OFFSET_TABLE_,%ecx
|
||||
addl $_GLOBAL_OFFSET_TABLE_+1,%ecx
|
||||
movl %eax,p3@GOT(%ecx)
|
||||
{$endif darwin}
|
||||
{$endif FPC_PIC}
|
||||
|
@ -20,7 +20,7 @@ begin
|
||||
{$ifdef darwin}
|
||||
mov [test.l-@@LPIC+ecx],5
|
||||
{$else darwin}
|
||||
add ecx, _GLOBAL_OFFSET_TABLE_
|
||||
add ecx, _GLOBAL_OFFSET_TABLE_+1
|
||||
mov [test.l + ecx],5
|
||||
{$endif darwin}
|
||||
{$endif FPC_PIC}
|
||||
|
@ -2,71 +2,32 @@
|
||||
{$R-}
|
||||
program test_register_pushing;
|
||||
|
||||
var
|
||||
before, after : longint;
|
||||
wpush,lpush : longint;
|
||||
const
|
||||
haserror : boolean = false;
|
||||
|
||||
|
||||
procedure dotest;
|
||||
var
|
||||
wpush,lpush: longint;
|
||||
begin
|
||||
{$ifdef CPUI386}
|
||||
{$asmmode att}
|
||||
asm
|
||||
{$ifndef FPC_PIC}
|
||||
movl %esp,before
|
||||
movl %esp,wpush
|
||||
pushw %es
|
||||
movl %esp,after
|
||||
subl %esp,wpush
|
||||
popw %es
|
||||
{$else not FPC_PIC}
|
||||
call .LPIC
|
||||
.LPIC:
|
||||
popl %ecx
|
||||
{$ifdef darwin}
|
||||
movl %esp,before-.LPIC(%ecx)
|
||||
pushw %es
|
||||
movl %esp,after-.LPIC(%ecx)
|
||||
popw %es
|
||||
{$else darwin}
|
||||
addl $_GLOBAL_OFFSET_TABLE_,%ecx
|
||||
movl %esp,before@GOT(%ecx)
|
||||
pushw %es
|
||||
movl %esp,after@GOT(%ecx)
|
||||
popw %es
|
||||
{$endif darwin}
|
||||
{$endif not FPC_PIC}
|
||||
end;
|
||||
wpush:=before-after;
|
||||
if wpush<>2 then
|
||||
begin
|
||||
Writeln('Compiler does not push "pushw %es" into 2 bytes');
|
||||
haserror:=true;
|
||||
end;
|
||||
|
||||
asm
|
||||
{$ifndef FPC_PIC}
|
||||
movl %esp,before
|
||||
movl %esp,lpush
|
||||
pushl %es
|
||||
movl %esp,after
|
||||
subl %esp,lpush
|
||||
popl %es
|
||||
{$else not FPC_PIC}
|
||||
call .LPIC
|
||||
.LPIC:
|
||||
popl %ecx
|
||||
{$ifdef darwin}
|
||||
movl %esp,before-.LPIC(%ecx)
|
||||
pushl %es
|
||||
movl %esp,after-.LPIC(%ecx)
|
||||
popl %es
|
||||
{$else darwin}
|
||||
addl $_GLOBAL_OFFSET_TABLE_,%ecx
|
||||
movl %esp,before@GOT(%ecx)
|
||||
pushl %es
|
||||
movl %esp,after@GOT(%ecx)
|
||||
popl %es
|
||||
{$endif darwin}
|
||||
{$endif not FPC_PIC}
|
||||
end;
|
||||
lpush:=before-after;
|
||||
|
||||
if lpush<>4 then
|
||||
begin
|
||||
Writeln('Compiler does not push "pushl %es" into 4 bytes');
|
||||
@ -74,61 +35,22 @@ begin
|
||||
end;
|
||||
|
||||
asm
|
||||
{$ifndef FPC_PIC}
|
||||
movl %esp,before
|
||||
movl %esp,wpush
|
||||
pushw %gs
|
||||
movl %esp,after
|
||||
subl %esp,wpush
|
||||
popw %gs
|
||||
{$else not FPC_PIC}
|
||||
call .LPIC
|
||||
.LPIC:
|
||||
popl %ecx
|
||||
{$ifdef darwin}
|
||||
movl %esp,before-.LPIC(%ecx)
|
||||
pushw %gs
|
||||
movl %esp,after-.LPIC(%ecx)
|
||||
popw %gs
|
||||
{$else darwin}
|
||||
addl $_GLOBAL_OFFSET_TABLE_,%ecx
|
||||
movl %esp,before@GOT(%ecx)
|
||||
pushw %gs
|
||||
movl %esp,after@GOT(%ecx)
|
||||
popw %gs
|
||||
{$endif darwin}
|
||||
{$endif not FPC_PIC}
|
||||
end;
|
||||
wpush:=before-after;
|
||||
if wpush<>2 then
|
||||
begin
|
||||
Writeln('Compiler does not push "pushw %gs" into 2 bytes');
|
||||
haserror:=true;
|
||||
end;
|
||||
asm
|
||||
{$ifndef FPC_PIC}
|
||||
movl %esp,before
|
||||
movl %esp,lpush
|
||||
pushl %gs
|
||||
movl %esp,after
|
||||
subl %esp,lpush
|
||||
popl %gs
|
||||
{$else not FPC_PIC}
|
||||
call .LPIC
|
||||
.LPIC:
|
||||
popl %ecx
|
||||
{$ifdef darwin}
|
||||
movl %esp,before-.LPIC(%ecx)
|
||||
pushl %gs
|
||||
movl %esp,after-.LPIC(%ecx)
|
||||
popl %gs
|
||||
{$else darwin}
|
||||
addl $_GLOBAL_OFFSET_TABLE_,%ecx
|
||||
movl %esp,before@GOT(%ecx)
|
||||
pushl %gs
|
||||
movl %esp,after@GOT(%ecx)
|
||||
popl %gs
|
||||
{$endif darwin}
|
||||
{$endif not FPC_PIC}
|
||||
end;
|
||||
lpush:=before-after;
|
||||
|
||||
if lpush<>4 then
|
||||
begin
|
||||
Writeln('Compiler does not push "pushl %gs" into 4 bytes');
|
||||
@ -136,31 +58,16 @@ begin
|
||||
end;
|
||||
{$asmmode intel}
|
||||
asm
|
||||
{$ifndef FPC_PIC}
|
||||
mov before,esp
|
||||
mov lpush,esp
|
||||
push es
|
||||
mov after,esp
|
||||
sub lpush,esp
|
||||
pop es
|
||||
{$else not FPC_PIC}
|
||||
call @@LPIC
|
||||
@@LPIC:
|
||||
pop ecx
|
||||
{$ifdef darwin}
|
||||
mov [before-@@LPIC+ecx],esp
|
||||
push es
|
||||
mov [after-@@LPIC+ecx],esp
|
||||
pop es
|
||||
{$else darwin}
|
||||
add ecx,@_GLOBAL_OFFSET_TABLE_
|
||||
mov [ecx].OFFSET before,esp
|
||||
push es
|
||||
mov [ecx].OFFSET after,esp
|
||||
pop es
|
||||
{$endif darwin}
|
||||
{$endif not FPC_PIC}
|
||||
end;
|
||||
Writeln('Intel "push es" uses ',before-after,' bytes');
|
||||
{$endif CPUI386}
|
||||
Writeln('Intel "push es" uses ',lpush,' bytes');
|
||||
if haserror then
|
||||
Halt(1);
|
||||
end;
|
||||
|
||||
begin
|
||||
dotest;
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user