From 2431b6e63b48716a774672f714b9d54359839c25 Mon Sep 17 00:00:00 2001 From: nickysn Date: Mon, 24 Aug 2015 20:18:44 +0000 Subject: [PATCH] * i8086-msdos internal linker: use a different approach for finding the stack segment - either its class name must be 'STACK' (wlink compatible) or its combine type must be scStack (tlink compatible) git-svn-id: trunk@31398 - --- compiler/ogomf.pas | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/compiler/ogomf.pas b/compiler/ogomf.pas index d48c37591e..9046939045 100644 --- a/compiler/ogomf.pas +++ b/compiler/ogomf.pas @@ -233,6 +233,7 @@ interface Size, MemPos, MemBasePos: qword; + IsStack: Boolean; constructor create(HashObjectList:TFPHashObjectList;const s:TSymStr); destructor destroy;override; procedure AddObjSection(ObjSec: TOmfObjSection); @@ -274,6 +275,7 @@ interface procedure CalcSegments_MemBasePos; procedure WriteMap_SegmentsAndGroups; procedure WriteMap_HeaderData; + function FindStackSegment: TMZExeUnifiedLogicalSegment; procedure FillLoadableImageSize; procedure FillStartAddress; procedure FillStackAddress; @@ -1933,6 +1935,9 @@ implementation FSegName:=Name; FSegClass:=''; end; + { wlink recognizes the stack segment by the class name 'STACK' } + { let's be compatible with wlink } + IsStack:=FSegClass='STACK'; end; destructor TMZExeUnifiedLogicalSegment.destroy; @@ -1945,6 +1950,11 @@ implementation begin ObjSectionList.Add(ObjSec); ObjSec.MZExeUnifiedLogicalSegment:=self; + { tlink (and ms link?) use the scStack segment combination to recognize + the stack segment. + let's be compatible with tlink as well } + if ObjSec.Combination=scStack then + IsStack:=True; end; procedure TMZExeUnifiedLogicalSegment.CalcMemPos; @@ -2157,6 +2167,24 @@ implementation exemap.Add('Entry point address: '+HexStr(Header.InitialCS,4)+':'+HexStr(Header.InitialIP,4)); end; + function TMZExeOutput.FindStackSegment: TMZExeUnifiedLogicalSegment; + var + i: Integer; + stackseg_wannabe: TMZExeUnifiedLogicalSegment; + begin + Result:=nil; + for i:=0 to ExeUnifiedLogicalSegments.Count-1 do + begin + stackseg_wannabe:=TMZExeUnifiedLogicalSegment(ExeUnifiedLogicalSegments[i]); + { if there are multiple stack segments, choose the largest one. + In theory, we're probably supposed to combine them all and put + them in a contiguous location in memory, but we don't care } + if stackseg_wannabe.IsStack and + (not assigned(result) or (Result.Size