mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 07:49:24 +02:00
* i386 _GLOBAL_OFFSET_TABLE_ label special treatment moved to taicpu.pass2
git-svn-id: trunk@16100 -
This commit is contained in:
parent
6a9a991dca
commit
d2939bce3d
@ -768,20 +768,6 @@ implementation
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
{$ifdef i386}
|
|
||||||
{ Hack for _GLOBAL_OFFSET_TABLE_ which needs a special
|
|
||||||
relocation type R_386_GOTPC, found by trial/error PM }
|
|
||||||
if p.name='_GLOBAL_OFFSET_TABLE_' then
|
|
||||||
begin
|
|
||||||
reltype:=RELOC_GOTPC;
|
|
||||||
{ This value comes from the offset of the relocation
|
|
||||||
of _GLOBAL_OFFSET_TABLE symbol within the instruction
|
|
||||||
movl $_GLOBAL_OFFSET_TABLE_,%ebx
|
|
||||||
It might be wrong if the symbol is used
|
|
||||||
in some other instruction having a bigger offset }
|
|
||||||
inc(data,2);
|
|
||||||
end;
|
|
||||||
{$endif i386}
|
|
||||||
CurrObjSec.addsymreloc(CurrObjSec.Size,p,reltype);
|
CurrObjSec.addsymreloc(CurrObjSec.Size,p,reltype);
|
||||||
{$ifndef x86_64}
|
{$ifndef x86_64}
|
||||||
if (reltype=RELOC_RELATIVE) or (reltype=RELOC_PLT32) then
|
if (reltype=RELOC_RELATIVE) or (reltype=RELOC_PLT32) then
|
||||||
|
@ -1972,6 +1972,29 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$endif x86_64}
|
{$endif x86_64}
|
||||||
|
procedure objdata_writereloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);
|
||||||
|
begin
|
||||||
|
{$ifdef i386}
|
||||||
|
{ Special case of '_GLOBAL_OFFSET_TABLE_'
|
||||||
|
which needs a special relocation type R_386_GOTPC }
|
||||||
|
if assigned (p) and
|
||||||
|
(p.name='_GLOBAL_OFFSET_TABLE_') and
|
||||||
|
(tf_pic_uses_got in target_info.flags) then
|
||||||
|
begin
|
||||||
|
{ nothing else than a 4 byte relocation should occur
|
||||||
|
for GOT }
|
||||||
|
if len<>4 then
|
||||||
|
Message1(asmw_e_invalid_opcode_and_operands,GetString);
|
||||||
|
Reloctype:=RELOC_GOTPC;
|
||||||
|
{ We need to add the offset of the relocation
|
||||||
|
of _GLOBAL_OFFSET_TABLE symbol within
|
||||||
|
the current instruction }
|
||||||
|
inc(data,objdata.currobjsec.size-insoffset);
|
||||||
|
end;
|
||||||
|
{$endif i386}
|
||||||
|
objdata.writereloc(data,len,p,Reloctype);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
CondVal:array[TAsmCond] of byte=($0,
|
CondVal:array[TAsmCond] of byte=($0,
|
||||||
@ -2070,7 +2093,7 @@ implementation
|
|||||||
if (currval<-128) or (currval>127) then
|
if (currval<-128) or (currval>127) then
|
||||||
Message2(asmw_e_value_exceeds_bounds,'signed byte',tostr(currval));
|
Message2(asmw_e_value_exceeds_bounds,'signed byte',tostr(currval));
|
||||||
if assigned(currsym) then
|
if assigned(currsym) then
|
||||||
objdata.writereloc(currval,1,currsym,currabsreloc)
|
objdata_writereloc(currval,1,currsym,currabsreloc)
|
||||||
else
|
else
|
||||||
objdata.writebytes(currval,1);
|
objdata.writebytes(currval,1);
|
||||||
end;
|
end;
|
||||||
@ -2080,7 +2103,7 @@ implementation
|
|||||||
if (currval<-256) or (currval>255) then
|
if (currval<-256) or (currval>255) then
|
||||||
Message2(asmw_e_value_exceeds_bounds,'byte',tostr(currval));
|
Message2(asmw_e_value_exceeds_bounds,'byte',tostr(currval));
|
||||||
if assigned(currsym) then
|
if assigned(currsym) then
|
||||||
objdata.writereloc(currval,1,currsym,currabsreloc)
|
objdata_writereloc(currval,1,currsym,currabsreloc)
|
||||||
else
|
else
|
||||||
objdata.writebytes(currval,1);
|
objdata.writebytes(currval,1);
|
||||||
end;
|
end;
|
||||||
@ -2090,7 +2113,7 @@ implementation
|
|||||||
if (currval<0) or (currval>255) then
|
if (currval<0) or (currval>255) then
|
||||||
Message2(asmw_e_value_exceeds_bounds,'unsigned byte',tostr(currval));
|
Message2(asmw_e_value_exceeds_bounds,'unsigned byte',tostr(currval));
|
||||||
if assigned(currsym) then
|
if assigned(currsym) then
|
||||||
objdata.writereloc(currval,1,currsym,currabsreloc)
|
objdata_writereloc(currval,1,currsym,currabsreloc)
|
||||||
else
|
else
|
||||||
objdata.writebytes(currval,1);
|
objdata.writebytes(currval,1);
|
||||||
end;
|
end;
|
||||||
@ -2100,7 +2123,7 @@ implementation
|
|||||||
if (currval<-65536) or (currval>65535) then
|
if (currval<-65536) or (currval>65535) then
|
||||||
Message2(asmw_e_value_exceeds_bounds,'word',tostr(currval));
|
Message2(asmw_e_value_exceeds_bounds,'word',tostr(currval));
|
||||||
if assigned(currsym) then
|
if assigned(currsym) then
|
||||||
objdata.writereloc(currval,2,currsym,currabsreloc)
|
objdata_writereloc(currval,2,currsym,currabsreloc)
|
||||||
else
|
else
|
||||||
objdata.writebytes(currval,2);
|
objdata.writebytes(currval,2);
|
||||||
end;
|
end;
|
||||||
@ -2110,14 +2133,14 @@ implementation
|
|||||||
if opsize=S_Q then
|
if opsize=S_Q then
|
||||||
begin
|
begin
|
||||||
if assigned(currsym) then
|
if assigned(currsym) then
|
||||||
objdata.writereloc(currval,8,currsym,currabsreloc)
|
objdata_writereloc(currval,8,currsym,currabsreloc)
|
||||||
else
|
else
|
||||||
objdata.writebytes(currval,8);
|
objdata.writebytes(currval,8);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if assigned(currsym) then
|
if assigned(currsym) then
|
||||||
objdata.writereloc(currval,4,currsym,currabsreloc32)
|
objdata_writereloc(currval,4,currsym,currabsreloc32)
|
||||||
else
|
else
|
||||||
objdata.writebytes(currval,4);
|
objdata.writebytes(currval,4);
|
||||||
end
|
end
|
||||||
@ -2126,7 +2149,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
getvalsym(c-32);
|
getvalsym(c-32);
|
||||||
if assigned(currsym) then
|
if assigned(currsym) then
|
||||||
objdata.writereloc(currval,4,currsym,currabsreloc32)
|
objdata_writereloc(currval,4,currsym,currabsreloc32)
|
||||||
else
|
else
|
||||||
objdata.writebytes(currval,4);
|
objdata.writebytes(currval,4);
|
||||||
end;
|
end;
|
||||||
@ -2144,17 +2167,17 @@ implementation
|
|||||||
begin
|
begin
|
||||||
getvalsym(c-52);
|
getvalsym(c-52);
|
||||||
if assigned(currsym) then
|
if assigned(currsym) then
|
||||||
objdata.writereloc(currval,4,currsym,currrelreloc)
|
objdata_writereloc(currval,4,currsym,currrelreloc)
|
||||||
else
|
else
|
||||||
objdata.writereloc(currval-insend,4,nil,currabsreloc32)
|
objdata_writereloc(currval-insend,4,nil,currabsreloc32)
|
||||||
end;
|
end;
|
||||||
56,57,58 :
|
56,57,58 :
|
||||||
begin
|
begin
|
||||||
getvalsym(c-56);
|
getvalsym(c-56);
|
||||||
if assigned(currsym) then
|
if assigned(currsym) then
|
||||||
objdata.writereloc(currval,4,currsym,currrelreloc)
|
objdata_writereloc(currval,4,currsym,currrelreloc)
|
||||||
else
|
else
|
||||||
objdata.writereloc(currval-insend,4,nil,currabsreloc32)
|
objdata_writereloc(currval-insend,4,nil,currabsreloc32)
|
||||||
end;
|
end;
|
||||||
192,193,194 :
|
192,193,194 :
|
||||||
begin
|
begin
|
||||||
@ -2294,7 +2317,7 @@ implementation
|
|||||||
else
|
else
|
||||||
{$endif x86_64}
|
{$endif x86_64}
|
||||||
currabsreloc:=RELOC_ABSOLUTE;
|
currabsreloc:=RELOC_ABSOLUTE;
|
||||||
objdata.writereloc(oper[opidx]^.ref^.offset,1,currsym,currabsreloc);
|
objdata_writereloc(oper[opidx]^.ref^.offset,1,currsym,currabsreloc);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -2341,7 +2364,7 @@ implementation
|
|||||||
currabsreloc:=RELOC_PIC_PAIR;
|
currabsreloc:=RELOC_PIC_PAIR;
|
||||||
currval:=relsym.offset;
|
currval:=relsym.offset;
|
||||||
end;
|
end;
|
||||||
objdata.writereloc(currval,ea_data.bytes,currsym,currabsreloc);
|
objdata_writereloc(currval,ea_data.bytes,currsym,currabsreloc);
|
||||||
inc(s,ea_data.bytes);
|
inc(s,ea_data.bytes);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user