mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-28 04:59:26 +02:00
- Removed tcoffexeoutput.FCoffSyms, it is never used (symbols are written directly to the output)
* Improved TCoffObjOutput.ReadObjData to use one Seek less, also improved error messages. git-svn-id: trunk@21440 -
This commit is contained in:
parent
2f92336b94
commit
1c271251f8
@ -220,7 +220,6 @@ interface
|
|||||||
|
|
||||||
TCoffexeoutput = class(texeoutput)
|
TCoffexeoutput = class(texeoutput)
|
||||||
private
|
private
|
||||||
FCoffsyms,
|
|
||||||
FCoffStrs : tdynamicarray;
|
FCoffStrs : tdynamicarray;
|
||||||
win32 : boolean;
|
win32 : boolean;
|
||||||
nsects : word;
|
nsects : word;
|
||||||
@ -1593,10 +1592,8 @@ const pemagic : array[0..3] of byte = (
|
|||||||
|
|
||||||
destructor TCoffObjInput.destroy;
|
destructor TCoffObjInput.destroy;
|
||||||
begin
|
begin
|
||||||
if assigned(FCoffSyms) then
|
FCoffSyms.free;
|
||||||
FCoffSyms.free;
|
FCoffStrs.free;
|
||||||
if assigned(FCoffStrs) then
|
|
||||||
FCoffStrs.free;
|
|
||||||
if assigned(FSymTbl) then
|
if assigned(FSymTbl) then
|
||||||
freemem(FSymTbl);
|
freemem(FSymTbl);
|
||||||
if assigned(FSecTbl) then
|
if assigned(FSecTbl) then
|
||||||
@ -1723,8 +1720,7 @@ const pemagic : array[0..3] of byte = (
|
|||||||
begin
|
begin
|
||||||
nsyms:=FCoffSyms.Size div sizeof(CoffSymbol);
|
nsyms:=FCoffSyms.Size div sizeof(CoffSymbol);
|
||||||
{ Allocate memory for symidx -> TObjSymbol table }
|
{ Allocate memory for symidx -> TObjSymbol table }
|
||||||
GetMem(FSymTbl,nsyms*sizeof(TObjSymbolrec));
|
FSymTbl:=AllocMem(nsyms*sizeof(TObjSymbolrec));
|
||||||
FillChar(FSymTbl^,nsyms*sizeof(TObjSymbolrec),0);
|
|
||||||
{ Load the Symbols }
|
{ Load the Symbols }
|
||||||
FCoffSyms.Seek(0);
|
FCoffSyms.Seek(0);
|
||||||
symidx:=0;
|
symidx:=0;
|
||||||
@ -1907,23 +1903,28 @@ const pemagic : array[0..3] of byte = (
|
|||||||
{$ifdef arm}
|
{$ifdef arm}
|
||||||
eVCobj:=header.flag=$100;
|
eVCobj:=header.flag=$100;
|
||||||
{$endif arm}
|
{$endif arm}
|
||||||
|
{ ObjSymbols }
|
||||||
|
AReader.Seek(header.sympos);
|
||||||
|
if not AReader.ReadArray(FCoffSyms,header.syms*sizeof(CoffSymbol)) then
|
||||||
|
begin
|
||||||
|
InputError('Error reading coff symbol table');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
{ Strings }
|
{ Strings }
|
||||||
AReader.Seek(header.sympos+header.syms*sizeof(CoffSymbol));
|
|
||||||
if not AReader.Read(strsize,4) then
|
if not AReader.Read(strsize,4) then
|
||||||
begin
|
begin
|
||||||
InputError('Error reading COFF Symtable');
|
InputError('Error reading COFF string table');
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if (strsize>4) and not AReader.ReadArray(FCoffStrs,Strsize-4) then
|
if (strsize>4) and not AReader.ReadArray(FCoffStrs,Strsize-4) then
|
||||||
begin
|
begin
|
||||||
InputError('Error reading COFF Symtable');
|
InputError('Error reading COFF string table');
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
{ Section headers }
|
{ Section headers }
|
||||||
{ Allocate SecIdx -> TObjSection table, secidx is 1-based }
|
{ Allocate SecIdx -> TObjSection table, secidx is 1-based }
|
||||||
FSecCount:=header.nsects;
|
FSecCount:=header.nsects;
|
||||||
GetMem(FSecTbl,(header.nsects+1)*sizeof(TObjSection));
|
FSecTbl:=AllocMem((header.nsects+1)*sizeof(TObjSection));
|
||||||
FillChar(FSecTbl^,(header.nsects+1)*sizeof(TObjSection),0);
|
|
||||||
AReader.Seek(sizeof(tcoffheader)+header.opthdr);
|
AReader.Seek(sizeof(tcoffheader)+header.opthdr);
|
||||||
for i:=1 to header.nsects do
|
for i:=1 to header.nsects do
|
||||||
begin
|
begin
|
||||||
@ -1979,13 +1980,6 @@ const pemagic : array[0..3] of byte = (
|
|||||||
objsec.datapos:=sechdr.datapos;
|
objsec.datapos:=sechdr.datapos;
|
||||||
objsec.Size:=sechdr.dataSize;
|
objsec.Size:=sechdr.dataSize;
|
||||||
end;
|
end;
|
||||||
{ ObjSymbols }
|
|
||||||
AReader.Seek(header.sympos);
|
|
||||||
if not AReader.ReadArray(FCoffSyms,header.syms*sizeof(CoffSymbol)) then
|
|
||||||
begin
|
|
||||||
Comment(V_Error,'Error reading coff file');
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
{ Insert all ObjSymbols }
|
{ Insert all ObjSymbols }
|
||||||
read_symbols(objdata);
|
read_symbols(objdata);
|
||||||
{ Section Data }
|
{ Section Data }
|
||||||
@ -2380,7 +2374,6 @@ const pemagic : array[0..3] of byte = (
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
result:=false;
|
result:=false;
|
||||||
FCoffSyms:=TDynamicArray.Create(SymbolMaxGrow);
|
|
||||||
FCoffStrs:=TDynamicArray.Create(StrsMaxGrow);
|
FCoffStrs:=TDynamicArray.Create(StrsMaxGrow);
|
||||||
textExeSec:=FindExeSection('.text');
|
textExeSec:=FindExeSection('.text');
|
||||||
dataExeSec:=FindExeSection('.data');
|
dataExeSec:=FindExeSection('.data');
|
||||||
@ -2546,7 +2539,6 @@ const pemagic : array[0..3] of byte = (
|
|||||||
end;
|
end;
|
||||||
{ Release }
|
{ Release }
|
||||||
FCoffStrs.Free;
|
FCoffStrs.Free;
|
||||||
FCoffSyms.Free;
|
|
||||||
result:=true;
|
result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user