From b86372ccecd1fb48eaab657698397c32777f2f8c Mon Sep 17 00:00:00 2001 From: sergei Date: Sat, 13 Apr 2013 18:52:50 +0000 Subject: [PATCH] + Internal linker: process unreferenced .pdata sections on x86_64-win64, restores the possibility to use GAS on win64 (which got broken by introducing SEH). git-svn-id: trunk@24235 - --- compiler/ogbase.pas | 12 +++++++++--- compiler/ogcoff.pas | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index d565c104ca..c964236a11 100644 --- a/compiler/ogbase.pas +++ b/compiler/ogbase.pas @@ -3160,9 +3160,15 @@ implementation ProcessWorkList; { Handle stuff like .pdata, i.e. sections that are not referenced - but must be included if sections they reference are included. } - MarkTargetSpecificSections(ObjSectionWorkList); - ProcessWorkList; + but must be included if sections they reference are included. + Loop is necessary because .pdata can reference (via .xdata) + more text sections, VMTs of exception classes, etc. } + repeat + MarkTargetSpecificSections(ObjSectionWorkList); + if (ObjSectionWorkList.Count=0) then + break; + ProcessWorkList; + until False; ObjSectionWorkList.Free; ObjSectionWorkList:=nil; diff --git a/compiler/ogcoff.pas b/compiler/ogcoff.pas index 2b4f02534e..ab232f5454 100644 --- a/compiler/ogcoff.pas +++ b/compiler/ogcoff.pas @@ -232,6 +232,7 @@ interface procedure GenerateRelocs; public constructor create;override; + procedure MarkTargetSpecificSections(WorkList:TFPObjectList);override; procedure AfterUnusedSectionRemoval;override; procedure GenerateLibraryImports(ImportLibraryList:TFPHashObjectList);override; procedure MemPos_Start;override; @@ -2472,6 +2473,50 @@ const pemagic : array[0..3] of byte = ( end; + procedure TPECoffexeoutput.MarkTargetSpecificSections(WorkList:TFPObjectList); + var + exesec:TExeSection; + objsec,textsec:TObjSection; + objsym:TObjSymbol; + objreloc:TObjRelocation; + i,j:longint; + begin + if target_info.system<>system_x86_64_win64 then + exit; + exesec:=FindExeSection('.pdata'); + if exesec=nil then + exit; + for i:=0 to exesec.ObjSectionList.Count-1 do + begin + objsec:=TObjSection(exesec.ObjSectionList[i]); + if objsec.Used then + continue; + j:=0; + while j