|
@@ -74,6 +74,8 @@ interface
|
|
|
|
|
|
TElfObjData = class(TObjData)
|
|
TElfObjData = class(TObjData)
|
|
public
|
|
public
|
|
|
|
+ ident: TElfIdent;
|
|
|
|
+ flags: longword;
|
|
constructor create(const n:string);override;
|
|
constructor create(const n:string);override;
|
|
function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
|
|
function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
|
|
procedure CreateDebugSections;override;
|
|
procedure CreateDebugSections;override;
|
|
@@ -119,7 +121,6 @@ interface
|
|
FLoaded: PBoolean;
|
|
FLoaded: PBoolean;
|
|
shdrs: TElfsecheaderarray;
|
|
shdrs: TElfsecheaderarray;
|
|
nsects: longword;
|
|
nsects: longword;
|
|
- shentsize: longword;
|
|
|
|
shoffset: aword;
|
|
shoffset: aword;
|
|
shstrndx: longword;
|
|
shstrndx: longword;
|
|
symtabndx: longword;
|
|
symtabndx: longword;
|
|
@@ -133,7 +134,7 @@ interface
|
|
symversions: PWord;
|
|
symversions: PWord;
|
|
dynobj: boolean;
|
|
dynobj: boolean;
|
|
verdefs: TFPHashObjectList;
|
|
verdefs: TFPHashObjectList;
|
|
- function LoadHeader:word;
|
|
|
|
|
|
+ function LoadHeader(out objdata:TObjData):boolean;
|
|
procedure LoadSection(const shdr:TElfsechdr;index:longint;objdata:TObjData);
|
|
procedure LoadSection(const shdr:TElfsechdr;index:longint;objdata:TObjData);
|
|
procedure LoadRelocations(const secrec:TSectionRec);
|
|
procedure LoadRelocations(const secrec:TSectionRec);
|
|
procedure LoadSymbols(objdata:TObjData;count,locals:longword);
|
|
procedure LoadSymbols(objdata:TObjData;count,locals:longword);
|
|
@@ -1567,11 +1568,11 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- function TElfObjInput.LoadHeader:word;
|
|
|
|
|
|
+ function TElfObjInput.LoadHeader(out objdata:TObjData):boolean;
|
|
var
|
|
var
|
|
header:TElfHeader;
|
|
header:TElfHeader;
|
|
begin
|
|
begin
|
|
- result:=ET_NONE;
|
|
|
|
|
|
+ result:=false;
|
|
if not FReader.read(header,sizeof(header)) then
|
|
if not FReader.read(header,sizeof(header)) then
|
|
begin
|
|
begin
|
|
InputError('Can''t read ELF header');
|
|
InputError('Can''t read ELF header');
|
|
@@ -1609,12 +1610,30 @@ implementation
|
|
InputError('ELF file is for different CPU');
|
|
InputError('ELF file is for different CPU');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
+ if (header.e_type<>ET_REL) and (header.e_type<>ET_DYN) then
|
|
|
|
+ begin
|
|
|
|
+ InputError('Not a relocatable or dynamic ELF file');
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ if header.e_shentsize<>sizeof(TElfsechdr) then
|
|
|
|
+ InternalError(2012062701);
|
|
|
|
|
|
nsects:=header.e_shnum;
|
|
nsects:=header.e_shnum;
|
|
- shentsize:=header.e_shentsize;
|
|
|
|
|
|
+ dynobj:=(header.e_type=ET_DYN);
|
|
shoffset:=header.e_shoff;
|
|
shoffset:=header.e_shoff;
|
|
shstrndx:=header.e_shstrndx;
|
|
shstrndx:=header.e_shstrndx;
|
|
- result:=header.e_type;
|
|
|
|
|
|
+
|
|
|
|
+ if dynobj then
|
|
|
|
+ begin
|
|
|
|
+ objdata:=TElfDynamicObjData.Create(InputFilename);
|
|
|
|
+ verdefs:=TElfDynamicObjData(objdata).versiondefs;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ objdata:=CObjData.Create(InputFilename);
|
|
|
|
+
|
|
|
|
+ TElfObjData(objdata).ident:=header.e_ident;
|
|
|
|
+ TElfObjData(objdata).flags:=header.e_flags;
|
|
|
|
+ result:=true;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1659,26 +1678,8 @@ implementation
|
|
InputFileName:=AReader.FileName;
|
|
InputFileName:=AReader.FileName;
|
|
result:=false;
|
|
result:=false;
|
|
|
|
|
|
- i:=LoadHeader;
|
|
|
|
- if (i=ET_NONE) then { error message already given in this case }
|
|
|
|
|
|
+ if not LoadHeader(objData) then
|
|
exit;
|
|
exit;
|
|
- if (i<>ET_REL) and (i<>ET_DYN) then
|
|
|
|
- begin
|
|
|
|
- InputError('Not a relocatable or dynamic ELF file');
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
- dynobj:=(i=ET_DYN);
|
|
|
|
-
|
|
|
|
- if shentsize<>sizeof(TElfsechdr) then
|
|
|
|
- InternalError(2012062701);
|
|
|
|
-
|
|
|
|
- if dynobj then
|
|
|
|
- begin
|
|
|
|
- objdata:=TElfDynamicObjData.Create(InputFilename);
|
|
|
|
- verdefs:=TElfDynamicObjData(objdata).versiondefs;
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- objdata:=CObjData.Create(InputFilename);
|
|
|
|
|
|
|
|
FSecTbl:=AllocMem(nsects*sizeof(TSectionRec));
|
|
FSecTbl:=AllocMem(nsects*sizeof(TSectionRec));
|
|
FLoaded:=AllocMem(nsects*sizeof(boolean));
|
|
FLoaded:=AllocMem(nsects*sizeof(boolean));
|