mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-16 04:30:35 +01:00
+ write mz exe section data
+ fill MaxExtraParagraphs in the MZ header with $ffff by default, to prevent DOS from loading the program at the highest possible address git-svn-id: trunk@31386 -
This commit is contained in:
parent
fdbfaacec8
commit
449506ffb7
@ -2086,6 +2086,7 @@ implementation
|
||||
|
||||
procedure TMZExeOutput.FillHeaderData;
|
||||
begin
|
||||
Header.MaxExtraParagraphs:=$FFFF;
|
||||
FillLoadableImageSize;
|
||||
FillStartAddress;
|
||||
if assigned(exemap) then
|
||||
@ -2093,10 +2094,27 @@ implementation
|
||||
end;
|
||||
|
||||
function TMZExeOutput.writeExe: boolean;
|
||||
var
|
||||
ExeSec: TMZExeSection;
|
||||
i: Integer;
|
||||
ObjSec: TOmfObjSection;
|
||||
begin
|
||||
Result:=False;
|
||||
FillHeaderData;
|
||||
Header.WriteTo(FWriter);
|
||||
|
||||
ExeSec:=MZFlatContentSection;
|
||||
ExeSec.DataPos:=FWriter.Size;
|
||||
for i:=0 to ExeSec.ObjSectionList.Count-1 do
|
||||
begin
|
||||
ObjSec:=TOmfObjSection(ExeSec.ObjSectionList[i]);
|
||||
if ObjSec.MemPos<Header.LoadableImageSize then
|
||||
begin
|
||||
FWriter.WriteZeros(max(0,ObjSec.MemPos-FWriter.Size+ExeSec.DataPos));
|
||||
if assigned(ObjSec.Data) then
|
||||
FWriter.writearray(ObjSec.Data);
|
||||
end;
|
||||
end;
|
||||
Result:=True;
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user