mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-04 08:07:22 +01:00
* enabled internal linker for winx64
* more descriptive error messages for the coff reader * fixed coff magic for x64 git-svn-id: trunk@3104 -
This commit is contained in:
parent
e93081c0d0
commit
1d46c65496
@ -249,6 +249,7 @@ interface
|
||||
function newObjData(const n:string):TObjData;
|
||||
function readobjectfile(const fn:string;Data:TObjData):boolean;virtual;
|
||||
property Reader:TObjectReader read FReader;
|
||||
procedure inputerror(const s : string);
|
||||
end;
|
||||
TObjInputClass=class of TObjInput;
|
||||
|
||||
@ -1902,5 +1903,9 @@ implementation
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TObjInput.inputerror(const s : string);
|
||||
begin
|
||||
Comment(V_Error,s+' while reading '+reader.filename);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@ -223,15 +223,15 @@ implementation
|
||||
|
||||
const
|
||||
{$ifdef i386}
|
||||
COFF_MAGIC = $14c;
|
||||
COFF_MAGIC = $14c;
|
||||
COFF_OPT_MAGIC = $10b;
|
||||
{$endif i386}
|
||||
{$ifdef arm}
|
||||
COFF_MAGIC = $1c0;
|
||||
COFF_MAGIC = $1c0;
|
||||
COFF_OPT_MAGIC = $10b;
|
||||
{$endif arm}
|
||||
{$ifdef x86_64}
|
||||
COFF_MAGIC = $14c;
|
||||
COFF_MAGIC = $8664;
|
||||
COFF_OPT_MAGIC = $20b;
|
||||
{$endif x86_64}
|
||||
|
||||
@ -1360,7 +1360,7 @@ const win32stub : array[0..131] of byte=(
|
||||
result:=nil;
|
||||
if (secidx<1) or (secidx>FSecCount) then
|
||||
begin
|
||||
Comment(V_Error,'Error reading coff file, invalid section index');
|
||||
InputError('Failed reading coff file, invalid section index');
|
||||
exit;
|
||||
end;
|
||||
result:=FSecTbl^[secidx];
|
||||
@ -1394,7 +1394,7 @@ const win32stub : array[0..131] of byte=(
|
||||
$07 : rel_type:=RELOC_RVA;
|
||||
else
|
||||
begin
|
||||
Comment(V_Error,'Error reading coff file');
|
||||
InputError('Failed reading coff file, illegal reloctype $'+system.hexstr(rel.reloctype,4));
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
@ -1408,7 +1408,7 @@ const win32stub : array[0..131] of byte=(
|
||||
end
|
||||
else
|
||||
begin
|
||||
Comment(V_Error,'Error reading coff file');
|
||||
InputError('Failed reading coff file, can''t resolve symbol of relocation');
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
@ -1507,7 +1507,7 @@ const win32stub : array[0..131] of byte=(
|
||||
COFF_SYM_SECTION :
|
||||
begin
|
||||
if sym.section=0 then
|
||||
Comment(V_Error,'Error reading coff file');
|
||||
InputError('Failed reading coff file, illegal section');
|
||||
objsec:=GetSection(sym.section);
|
||||
if sym.value>=objsec.mempos then
|
||||
address:=sym.value-objsec.mempos;
|
||||
@ -1552,7 +1552,7 @@ const win32stub : array[0..131] of byte=(
|
||||
Reader.Seek(datapos);
|
||||
if not Reader.ReadArray(data,Size) then
|
||||
begin
|
||||
Comment(V_Error,'Error reading coff file');
|
||||
Comment(V_Error,'Error reading coff file, can''t read object data');
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
@ -1600,12 +1600,12 @@ const win32stub : array[0..131] of byte=(
|
||||
{ Read COFF header }
|
||||
if not reader.read(header,sizeof(coffheader)) then
|
||||
begin
|
||||
Comment(V_Error,'Error reading coff file');
|
||||
Comment(V_Error,'Error reading coff file, can''t read header: '+reader.filename);
|
||||
exit;
|
||||
end;
|
||||
if header.mach<>COFF_MAGIC then
|
||||
begin
|
||||
Comment(V_Error,'Not a coff file');
|
||||
Comment(V_Error,'Not a coff file, illegal magic: '+reader.filename);
|
||||
exit;
|
||||
end;
|
||||
{ Strings }
|
||||
@ -1622,7 +1622,7 @@ const win32stub : array[0..131] of byte=(
|
||||
end;
|
||||
if not Reader.ReadArray(FCoffStrs,Strsize-4) then
|
||||
begin
|
||||
Comment(V_Error,'Error reading coff file');
|
||||
Comment(V_Error,'Error reading coff file: '+reader.filename);
|
||||
exit;
|
||||
end;
|
||||
{ Section headers }
|
||||
@ -1635,7 +1635,7 @@ const win32stub : array[0..131] of byte=(
|
||||
begin
|
||||
if not reader.read(sechdr,sizeof(sechdr)) then
|
||||
begin
|
||||
Comment(V_Error,'Error reading coff file');
|
||||
Comment(V_Error,'Error reading coff file, can''t read section header: '+reader.filename);
|
||||
exit;
|
||||
end;
|
||||
move(sechdr.name,secnamebuf,8);
|
||||
|
||||
@ -60,6 +60,7 @@ type
|
||||
bufidx,
|
||||
bufmax : longint;
|
||||
function readbuf:boolean;
|
||||
function getfilename : string;
|
||||
public
|
||||
constructor create;
|
||||
destructor destroy;override;
|
||||
@ -68,6 +69,7 @@ type
|
||||
procedure seek(len:longint);
|
||||
function read(out b;len:longint):boolean;virtual;
|
||||
function readarray(a:TDynamicArray;len:longint):boolean;
|
||||
property filename : string read getfilename;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -339,5 +341,9 @@ begin
|
||||
readarray:=(idx=orglen);
|
||||
end;
|
||||
|
||||
function tobjectreader.getfilename : string;
|
||||
begin
|
||||
result:=f.filename;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@ -1803,6 +1803,7 @@ initialization
|
||||
{$endif i386}
|
||||
{$ifdef x86_64}
|
||||
RegisterExternalLinker(system_x64_win64_info,TLinkerWin32);
|
||||
RegisterInternalLinker(system_x64_win64_info,TPECoffLinker);
|
||||
RegisterImport(system_x86_64_win64,TImportLibWin32);
|
||||
RegisterExport(system_x86_64_win64,TExportLibWin32);
|
||||
RegisterDLLScanner(system_x86_64_win64,TDLLScannerWin32);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user