mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 03:46:10 +02:00
* Moved creation of GOT section into separate virtual method.
* TElfSymtab.WriteSymbol: write type of external symbols as STT_NOTYPE only in object files; external symbols in exe/so files must have type of their resolving symbol. * TElfObjData.writeReloc_internal: RELOC_RELATIVE needs adjustment by size presumably on x86 only; ARM data relocations don't need it, other CPUs aren't checked yet. * Use VER_xx and VERSYM_xx constants instead of literal values. git-svn-id: trunk@23290 -
This commit is contained in:
parent
1dd964960c
commit
35439c0e1d
@ -258,6 +258,8 @@ interface
|
|||||||
tlsseg: TElfSegment;
|
tlsseg: TElfSegment;
|
||||||
relative_reloc_count: longint;
|
relative_reloc_count: longint;
|
||||||
function AllocGOTSlot(objsym: TObjSymbol):boolean;
|
function AllocGOTSlot(objsym: TObjSymbol):boolean;
|
||||||
|
procedure CreateGOTSection;virtual;
|
||||||
|
procedure make_dynamic_if_undefweak(exesym:TExeSymbol);
|
||||||
procedure WriteDynRelocEntry(dataofs:aword;typ:byte;symidx:aword;addend:aword);
|
procedure WriteDynRelocEntry(dataofs:aword;typ:byte;symidx:aword;addend:aword);
|
||||||
procedure WriteFirstPLTEntry;virtual;abstract;
|
procedure WriteFirstPLTEntry;virtual;abstract;
|
||||||
procedure WritePLTEntry(exesym:TExeSymbol);virtual;
|
procedure WritePLTEntry(exesym:TExeSymbol);virtual;
|
||||||
@ -289,6 +291,7 @@ interface
|
|||||||
const
|
const
|
||||||
{ Bits of TObjSymbol.refs field }
|
{ Bits of TObjSymbol.refs field }
|
||||||
symref_plt = 1;
|
symref_plt = 1;
|
||||||
|
symref_from_text = 2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -673,7 +676,10 @@ implementation
|
|||||||
reloc.size:=len;
|
reloc.size:=len;
|
||||||
ObjRelocations.Add(reloc);
|
ObjRelocations.Add(reloc);
|
||||||
if reltype=RELOC_RELATIVE then
|
if reltype=RELOC_RELATIVE then
|
||||||
|
{ ARM does not require this adjustment, other CPUs must be checked }
|
||||||
|
{$if defined(i386) or defined(x86_64)}
|
||||||
dec(offset,len)
|
dec(offset,len)
|
||||||
|
{$endif i386 or x86_64}
|
||||||
else if reltype<>RELOC_ABSOLUTE then
|
else if reltype<>RELOC_ABSOLUTE then
|
||||||
InternalError(2012062401);
|
InternalError(2012062401);
|
||||||
if ElfTarget.relocs_use_addend then
|
if ElfTarget.relocs_use_addend then
|
||||||
@ -919,7 +925,8 @@ implementation
|
|||||||
else
|
else
|
||||||
InternalError(2012111801);
|
InternalError(2012111801);
|
||||||
end;
|
end;
|
||||||
if (objsym.bind<>AB_EXTERNAL) then
|
{ External symbols must be NOTYPE in relocatable files }
|
||||||
|
if (objsym.bind<>AB_EXTERNAL) or (kind<>esk_obj) then
|
||||||
begin
|
begin
|
||||||
case objsym.typ of
|
case objsym.typ of
|
||||||
AT_FUNCTION :
|
AT_FUNCTION :
|
||||||
@ -1369,10 +1376,10 @@ implementation
|
|||||||
if assigned(symversions) then
|
if assigned(symversions) then
|
||||||
begin
|
begin
|
||||||
ver:=symversions[i];
|
ver:=symversions[i];
|
||||||
if (ver=0) or (ver > $7FFF) then
|
if (ver=VER_NDX_LOCAL) or (ver>VERSYM_VERSION) then
|
||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
if (bind= AB_LOCAL) or (sym.st_shndx=SHN_UNDEF) then
|
if (bind=AB_LOCAL) or (sym.st_shndx=SHN_UNDEF) then
|
||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
{ validity of name and objsection has been checked above }
|
{ validity of name and objsection has been checked above }
|
||||||
@ -2064,6 +2071,14 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TElfExeOutput.make_dynamic_if_undefweak(exesym:TExeSymbol);
|
||||||
|
begin
|
||||||
|
if (exesym.dynindex=0) and (exesym.state=symstate_undefweak) and
|
||||||
|
not (cs_link_staticflag in current_settings.globalswitches) then
|
||||||
|
exesym.dynindex:=dynsymlist.add(exesym)+1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TElfExeOutput.AllocGOTSlot(objsym:TObjSymbol):boolean;
|
function TElfExeOutput.AllocGOTSlot(objsym:TObjSymbol):boolean;
|
||||||
var
|
var
|
||||||
exesym: TExeSymbol;
|
exesym: TExeSymbol;
|
||||||
@ -2128,11 +2143,8 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TElfExeOutput.Load_Start;
|
procedure TElfExeOutput.CreateGOTSection;
|
||||||
begin
|
begin
|
||||||
inherited Load_Start;
|
|
||||||
dynsymlist:=TFPObjectList.Create(False);
|
|
||||||
|
|
||||||
gotpltobjsec:=TElfObjSection.create_ext(internalObjData,'.got.plt',
|
gotpltobjsec:=TElfObjSection.create_ext(internalObjData,'.got.plt',
|
||||||
SHT_PROGBITS,SHF_ALLOC or SHF_WRITE,sizeof(pint),sizeof(pint));
|
SHT_PROGBITS,SHF_ALLOC or SHF_WRITE,sizeof(pint),sizeof(pint));
|
||||||
|
|
||||||
@ -2147,6 +2159,14 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TElfExeOutput.Load_Start;
|
||||||
|
begin
|
||||||
|
inherited Load_Start;
|
||||||
|
dynsymlist:=TFPObjectList.Create(False);
|
||||||
|
CreateGOTSection;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TElfExeOutput.Load_DynamicObject(objdata:TObjData;asneeded:boolean);
|
procedure TElfExeOutput.Load_DynamicObject(objdata:TObjData;asneeded:boolean);
|
||||||
var
|
var
|
||||||
i: longint;
|
i: longint;
|
||||||
|
Loading…
Reference in New Issue
Block a user