* Function RelocName made a member of TElfTarget, so it can be used outside of TElfExeOutput class.

* Methods ReportNonDSOReloc and ReportRelocOverflow moved to TElfExeOutput, they are applicable to all target-specific descendants.

git-svn-id: trunk@23094 -
This commit is contained in:
sergei 2012-12-02 13:05:53 +00:00
parent 5adb28a935
commit c4d8396158
4 changed files with 36 additions and 22 deletions

View File

@ -122,6 +122,11 @@ implementation
end;
function elf_i386_relocname(reltyp:byte):string;
begin
result:='TODO';
end;
{****************************************************************************
TElfExeOutput386
****************************************************************************}
@ -464,6 +469,7 @@ implementation
exe_image_base: $8048000;
machine_code: EM_386;
relocs_use_addend: false;
relocname: @elf_i386_relocName;
encodereloc: @elf_i386_encodeReloc;
loadreloc: @elf_i386_loadReloc;
loadsection: nil;

View File

@ -144,6 +144,7 @@ interface
class function CanReadObjData(AReader:TObjectreader):boolean;override;
end;
TRelocNameProc=function(reltyp:byte):string;
TEncodeRelocProc=function(objrel:TObjRelocation):byte;
TLoadRelocProc=procedure(objrel:TObjRelocation);
TLoadSectionProc=function(objinput:TElfObjInput;objdata:TObjData;const shdr:TElfsechdr;shindex:longint):boolean;
@ -153,6 +154,7 @@ interface
exe_image_base: longword;
machine_code: word;
relocs_use_addend: boolean;
relocname: TRelocNameProc;
encodereloc: TEncodeRelocProc;
loadreloc: TLoadRelocProc;
loadsection: TLoadSectionProc;
@ -246,6 +248,8 @@ interface
procedure WritePLTEntry(exesym:TExeSymbol);virtual;
procedure WriteIndirectPLTEntry(exesym:TExeSymbol);virtual;
procedure GOTRelocPass1(objsec:TObjSection;var idx:longint);virtual;abstract;
procedure ReportNonDSOReloc(reltyp:byte;objsec:TObjSection;ObjReloc:TObjRelocation);
procedure ReportRelocOverflow(reltyp:byte;objsec:TObjSection;ObjReloc:TObjRelocation);
public
constructor Create;override;
destructor Destroy;override;
@ -2814,6 +2818,20 @@ implementation
end;
procedure TElfExeOutput.ReportNonDSOReloc(reltyp:byte;objsec:TObjSection;ObjReloc:TObjRelocation);
begin
{ TODO: include objsec properties into message }
Comment(v_error,'Relocation '+ElfTarget.RelocName(reltyp)+' against '''+objreloc.TargetName+''' cannot be used when linking a shared object; recompile with -Cg');
end;
procedure TElfExeOutput.ReportRelocOverflow(reltyp:byte;objsec:TObjSection;ObjReloc:TObjRelocation);
begin
{ TODO: include objsec properties into message }
Comment(v_error,'Relocation truncated to fit: '+ElfTarget.RelocName(reltyp)+' against '''+objreloc.TargetName+'''');
end;
{****************************************************************************
TElfExeSection
****************************************************************************}

View File

@ -80,6 +80,12 @@ implementation
end;
function elf_sparc_relocname(reltyp:byte):string;
begin
result:='TODO';
end;
procedure elf_sparc.loadreloc(objrel:TObjRelocation);
begin
end;
@ -97,6 +103,7 @@ implementation
exe_image_base: $8000; // fixme
machine_code: EM_SPARC;
relocs_use_addend: false;
relocname: @elf_sparc_relocName;
encodereloc: @elf_sparc_encodeReloc;
loadreloc: @elf_sparc_loadReloc;
loadsection: nil;

View File

@ -35,10 +35,7 @@ implementation
type
TElfExeOutputx86_64=class(TElfExeOutput)
private
function RelocName(reltyp:byte):string;
procedure MaybeWriteGOTEntry(reltyp:byte;relocval:aint;objsym:TObjSymbol);
procedure ReportNonDSOReloc(reltyp:byte;objsec:TObjSection;ObjReloc:TObjRelocation);
procedure ReportRelocOverflow(reltyp:byte;objsec:TObjSection;ObjReloc:TObjRelocation);
protected
procedure WriteFirstPLTEntry;override;
procedure WritePLTEntry(exesym:TExeSymbol);override;
@ -185,11 +182,7 @@ implementation
end;
{****************************************************************************
TELFExeOutputx86_64
****************************************************************************}
function TElfExeOutputx86_64.RelocName(reltyp:byte):string;
function elf_x86_64_relocname(reltyp:byte):string;
begin
if reltyp<=high(relocprops) then
result:=relocprops[reltyp].name
@ -197,20 +190,9 @@ implementation
result:='unknown ('+tostr(reltyp)+')';
end;
procedure TElfExeOutputx86_64.ReportNonDSOReloc(reltyp:byte;objsec:TObjSection;ObjReloc:TObjRelocation);
begin
{ TODO: include objsec properties into message }
Comment(v_error,'Relocation '+RelocName(reltyp)+' against '''+objreloc.TargetName+''' cannot be used when linking a shared object; recompile with -Cg');
end;
procedure TElfExeOutputx86_64.ReportRelocOverflow(reltyp:byte;objsec:TObjSection;ObjReloc:TObjRelocation);
begin
{ TODO: include objsec properties into message }
Comment(v_error,'Relocation truncated to fit: '+RelocName(reltyp)+' against '''+objreloc.TargetName+'''');
end;
{****************************************************************************
TELFExeOutputx86_64
****************************************************************************}
procedure TElfExeOutputx86_64.GOTRelocPass1(objsec:TObjSection;var idx:longint);
var
@ -595,6 +577,7 @@ implementation
exe_image_base: $400000;
machine_code: EM_X86_64;
relocs_use_addend: true;
relocname: @elf_x86_64_relocName;
encodereloc: @elf_x86_64_encodeReloc;
loadreloc: @elf_x86_64_loadReloc;
loadsection: nil;