|
@@ -295,8 +295,8 @@ implementation
|
|
end;
|
|
end;
|
|
telf64reloc=packed record
|
|
telf64reloc=packed record
|
|
address : qword;
|
|
address : qword;
|
|
- info : qword; { bit 0-7: type, 8-31: symbol }
|
|
|
|
- addend : qword;
|
|
|
|
|
|
+ info : qword; { bit 0-31: type, 32-63: symbol }
|
|
|
|
+ addend : int64; { signed! }
|
|
end;
|
|
end;
|
|
telf64symbol=packed record
|
|
telf64symbol=packed record
|
|
st_name : longint;
|
|
st_name : longint;
|
|
@@ -768,12 +768,8 @@ implementation
|
|
inc(data,symaddr-len-CurrObjSec.Size)
|
|
inc(data,symaddr-len-CurrObjSec.Size)
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
-{$ifndef x86_64}
|
|
|
|
CurrObjSec.addsectionreloc(CurrObjSec.Size,p.objsection,reltype);
|
|
CurrObjSec.addsectionreloc(CurrObjSec.Size,p.objsection,reltype);
|
|
inc(data,symaddr);
|
|
inc(data,symaddr);
|
|
-{$else x86_64}
|
|
|
|
- CurrObjSec.addsymreloc(CurrObjSec.Size,p,reltype);
|
|
|
|
-{$endif}
|
|
|
|
end;
|
|
end;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
@@ -814,6 +810,8 @@ implementation
|
|
relsym,
|
|
relsym,
|
|
reltyp : longint;
|
|
reltyp : longint;
|
|
relocsect : TObjSection;
|
|
relocsect : TObjSection;
|
|
|
|
+ tmp: aint;
|
|
|
|
+ asize: longint;
|
|
begin
|
|
begin
|
|
with elf32data do
|
|
with elf32data do
|
|
begin
|
|
begin
|
|
@@ -865,7 +863,7 @@ implementation
|
|
begin
|
|
begin
|
|
reltyp:=R_X86_64_PC32;
|
|
reltyp:=R_X86_64_PC32;
|
|
{ length of the relocated location is handled here }
|
|
{ length of the relocated location is handled here }
|
|
- rel.addend:=qword(-4);
|
|
|
|
|
|
+ rel.addend:=-4;
|
|
end;
|
|
end;
|
|
RELOC_ABSOLUTE :
|
|
RELOC_ABSOLUTE :
|
|
reltyp:=R_X86_64_64;
|
|
reltyp:=R_X86_64_64;
|
|
@@ -875,39 +873,51 @@ implementation
|
|
begin
|
|
begin
|
|
reltyp:=R_X86_64_GOTPCREL;
|
|
reltyp:=R_X86_64_GOTPCREL;
|
|
{ length of the relocated location is handled here }
|
|
{ length of the relocated location is handled here }
|
|
- rel.addend:=qword(-4);
|
|
|
|
|
|
+ rel.addend:=-4;
|
|
end;
|
|
end;
|
|
RELOC_PLT32 :
|
|
RELOC_PLT32 :
|
|
begin
|
|
begin
|
|
reltyp:=R_X86_64_PLT32;
|
|
reltyp:=R_X86_64_PLT32;
|
|
{ length of the relocated location is handled here }
|
|
{ length of the relocated location is handled here }
|
|
- rel.addend:=qword(-4);
|
|
|
|
|
|
+ rel.addend:=-4;
|
|
end;
|
|
end;
|
|
{$endif x86_64}
|
|
{$endif x86_64}
|
|
else
|
|
else
|
|
internalerror(200602261);
|
|
internalerror(200602261);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+{ This handles ELF 'rela'-styled relocations, which are currently used only for x86_64,
|
|
|
|
+ but can be used other targets, too. }
|
|
|
|
+{$ifdef x86_64}
|
|
|
|
+ s.Data.Seek(objreloc.dataoffset);
|
|
|
|
+ if objreloc.typ=RELOC_ABSOLUTE then
|
|
|
|
+ begin
|
|
|
|
+ asize:=8;
|
|
|
|
+ s.Data.Read(tmp,8);
|
|
|
|
+ rel.addend:=rel.addend+tmp;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ asize:=4;
|
|
|
|
+ s.Data.Read(tmp,4);
|
|
|
|
+ rel.addend:=rel.addend+longint(tmp);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ { and zero the data member out }
|
|
|
|
+ tmp:=0;
|
|
|
|
+ s.Data.Seek(objreloc.dataoffset);
|
|
|
|
+ s.Data.Write(tmp,asize);
|
|
|
|
+{$endif}
|
|
|
|
+
|
|
{ Symbol }
|
|
{ Symbol }
|
|
if assigned(objreloc.symbol) then
|
|
if assigned(objreloc.symbol) then
|
|
begin
|
|
begin
|
|
-{$ifdef x86_64}
|
|
|
|
- if (objreloc.symbol.bind=AB_LOCAL) and
|
|
|
|
- (objreloc.typ in [RELOC_RELATIVE,RELOC_ABSOLUTE,RELOC_ABSOLUTE32]) then
|
|
|
|
- begin
|
|
|
|
- inc(rel.addend,objreloc.symbol.address);
|
|
|
|
- relsym:=objreloc.symbol.objsection.secsymidx;
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
-{$endif}
|
|
|
|
|
|
+ if objreloc.symbol.symidx=-1 then
|
|
begin
|
|
begin
|
|
- if objreloc.symbol.symidx=-1 then
|
|
|
|
- begin
|
|
|
|
- writeln(objreloc.symbol.Name);
|
|
|
|
- internalerror(200603012);
|
|
|
|
- end;
|
|
|
|
- relsym:=objreloc.symbol.symidx;
|
|
|
|
- end
|
|
|
|
|
|
+ writeln(objreloc.symbol.Name);
|
|
|
|
+ internalerror(200603012);
|
|
|
|
+ end;
|
|
|
|
+ relsym:=objreloc.symbol.symidx;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|