diff options
author | sergei <sergei@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2012-07-25 11:08:54 +0000 |
---|---|---|
committer | sergei <sergei@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2012-07-25 11:08:54 +0000 |
commit | ef08632630b25cd0c1578b43d1786a20b5483334 (patch) | |
tree | 95ed478e690f2bde8f7e1e7ba5ac7f7b95d35e2b /compiler | |
parent | a69fe0e7894a46b7c5d9f23f3d63ce324789a17c (diff) | |
download | fpc-ef08632630b25cd0c1578b43d1786a20b5483334.tar.gz |
+ Basic executable stack support in TExeOutput.
+ Two stubs (TExeOutput.Load_DynamicObject and TObjInput.CanReadObjData) to override in ELF linker.
+ Stop linking if errors were detected while loading object files.
* Changed TStaticLibrary to TObject. It is never looked up by name, so hashing is redundant; moreover its name has been changed to TCmdStr, which may be trimmed by TFPHashList.
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@21968 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/link.pas | 10 | ||||
-rw-r--r-- | compiler/ogbase.pas | 29 |
2 files changed, 29 insertions, 10 deletions
diff --git a/compiler/link.pas b/compiler/link.pas index f45302de04..0ae610ccdd 100644 --- a/compiler/link.pas +++ b/compiler/link.pas @@ -93,7 +93,7 @@ interface FCExeOutput : TExeOutputClass; FCObjInput : TObjInputClass; { Libraries } - FStaticLibraryList : TFPHashObjectList; + FStaticLibraryList : TFPObjectList; FImportLibraryList : TFPHashObjectList; procedure Load_ReadObject(const para:TCmdStr); procedure Load_ReadStaticLibrary(const para:TCmdStr); @@ -112,7 +112,7 @@ interface IsHandled : PBooleanArray; property CObjInput:TObjInputClass read FCObjInput write FCObjInput; property CExeOutput:TExeOutputClass read FCExeOutput write FCExeOutput; - property StaticLibraryList:TFPHashObjectList read FStaticLibraryList; + property StaticLibraryList:TFPObjectList read FStaticLibraryList; property ImportLibraryList:TFPHashObjectList read FImportLibraryList; procedure DefaultLinkScript;virtual;abstract; procedure ScriptAddGenericSections(secnames:string); @@ -848,7 +848,7 @@ Implementation begin inherited Create; linkscript:=TCmdStrList.Create; - FStaticLibraryList:=TFPHashObjectList.Create(true); + FStaticLibraryList:=TFPObjectList.Create(true); FImportLibraryList:=TFPHashObjectList.Create(true); exemap:=nil; exeoutput:=nil; @@ -960,7 +960,7 @@ Implementation exit; Comment(V_Tried,'Opening library '+para); objreader:=TArObjectreader.create(para); - TStaticLibrary.Create(StaticLibraryList,para,objreader,CObjInput); + StaticLibraryList.Add(TStaticLibrary.Create(para,objreader,CObjInput)); end; @@ -1276,6 +1276,8 @@ Implementation ParseScript_Handle; { Load .o files and resolve symbols } ParseScript_Load; + if ErrorCount>0 then + goto myexit; exeoutput.ResolveSymbols(StaticLibraryList); { Generate symbols and code to do the importing } exeoutput.GenerateLibraryImports(ImportLibraryList); diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index 6db26c343a..dee5da250d 100644 --- a/compiler/ogbase.pas +++ b/compiler/ogbase.pas @@ -240,6 +240,7 @@ interface property CObjSection:TObjSectionClass read FCObjSection write FCObjSection; public CurrPass : byte; + ExecStack : boolean; constructor create(const n:string);virtual; destructor destroy;override; { Sections } @@ -312,6 +313,7 @@ interface destructor destroy;override; function newObjData(const n:string):TObjData; function ReadObjData(AReader:TObjectreader;Data:TObjData):boolean;virtual;abstract; + class function CanReadObjData(AReader:TObjectreader):boolean;virtual; procedure inputerror(const s : string); end; TObjInputClass=class of TObjInput; @@ -368,12 +370,13 @@ interface end; TExeSectionClass=class of TExeSection; - TStaticLibrary = class(TFPHashObject) + TStaticLibrary = class(TObject) private + FName : TCmdStr; FArReader : TObjectReader; FObjInputClass : TObjInputClass; public - constructor create(AList:TFPHashObjectList;const AName:string;AReader:TObjectReader;AObjInputClass:TObjInputClass); + constructor create(const AName:TCmdStr;AReader:TObjectReader;AObjInputClass:TObjInputClass); destructor destroy;override; property ArReader:TObjectReader read FArReader; property ObjInputClass:TObjInputClass read FObjInputClass; @@ -444,6 +447,7 @@ interface CurrDataPos : aword; MaxMemPos : qword; IsSharedLibrary : boolean; + ExecStack : boolean; constructor create;virtual; destructor destroy;override; function FindExeSection(const aname:string):TExeSection; @@ -454,6 +458,7 @@ interface procedure Load_ProvideSymbol(const aname:string);virtual; procedure Load_IsSharedLibrary; procedure Load_ImageBase(const avalue:string); + procedure Load_DynamicObject(ObjData:TObjData);virtual; procedure Order_Start;virtual; procedure Order_End;virtual; procedure Order_ExeSection(const aname:string);virtual; @@ -477,7 +482,7 @@ interface procedure DataPos_Symbols;virtual; procedure BuildVTableTree(VTInheritList,VTEntryList:TFPObjectList); procedure PackUnresolvedExeSymbols(const s:string); - procedure ResolveSymbols(StaticLibraryList:TFPHashObjectList); + procedure ResolveSymbols(StaticLibraryList:TFPObjectList); procedure PrintMemoryMap; procedure FixupSymbols; procedure FixupRelocations; @@ -1456,9 +1461,9 @@ implementation TStaticLibrary ****************************************************************************} - constructor TStaticLibrary.create(AList:TFPHashObjectList;const AName:string;AReader:TObjectReader;AObjInputClass:TObjInputClass); + constructor TStaticLibrary.create(const AName:TCmdStr;AReader:TObjectReader;AObjInputClass:TObjInputClass); begin - inherited create(AList,AName); + FName:=AName; FArReader:=AReader; FObjInputClass:=AObjInputClass; end; @@ -1595,6 +1600,7 @@ implementation if ObjData.classtype<>FCObjData then Comment(V_Error,'Invalid input object format for '+ObjData.name+' got '+ObjData.classname+' expected '+FCObjData.classname); ObjDataList.Add(ObjData); + ExecStack:=ExecStack or ObjData.ExecStack; end; @@ -1660,6 +1666,11 @@ implementation end; + procedure TExeOutput.Load_DynamicObject(ObjData:TObjData); + begin + end; + + procedure TExeOutput.Order_Start; begin end; @@ -2079,7 +2090,7 @@ implementation end; - procedure TExeOutput.ResolveSymbols(StaticLibraryList:TFPHashObjectList); + procedure TExeOutput.ResolveSymbols(StaticLibraryList:TFPObjectList); var ObjData : TObjData; exesym : TExeSymbol; @@ -2987,6 +2998,12 @@ implementation end; + class function TObjInput.CanReadObjData(AReader:TObjectReader):boolean; + begin + result:=false; + end; + + procedure TObjInput.ReadSectionContent(Data:TObjData); var i: longint; |