Merged revision(s) 32491-32492 from branches/svenbarth/packages:

Adjust non-Windows resources to work with indirect main information as well.

rtl/inc/systemh.inc, TEntryInformation:
  + new cross platform field ResLocation which stores the pointer to the resources
rtl/inc/intres.inc:
  * change the type of ResHeader from PResHdr to PPResHdr (and adjust code that uses it accordingly; Note: the first dereferencing is assumed to be always valid!)
  * adjust declaration of ResHeader depending on whether indirect main information is used or not
rtl/darwin/sysinit.pas & rtl/linux/si_impl.inc:
  * pass the location of the resources through SysInitEntryInformation
rtl/bsd/system.pp & rtl/linux/system.pp:
  + new public variable FPCResLocation which is setup by SysEntry
rtl/win32/sysinit.inc:
  * initialize ResLocation of SysInitEntryInformation as Nil
rtl/win32/system.pp:
  * initialize ResLocation of EntryInformation as Nil
........
For systems that support both internal and external resources (in this case only Darwin ones) we need to generate the FPC_RESLOCATION symbol always, because the SysInit unit is resource type agnostic.

ngenutil.pas, tnodeutils:
  * InsertResourceInfo: generate FPC_RESLOCATION symbol pointing to 0 in case the program is compiled on Darwin with resources set to external ones (-We)

git-svn-id: trunk@33952 -
This commit is contained in:
svenbarth 2016-06-12 09:08:17 +00:00
parent 3f45860cf9
commit ca07a4f86f
3 changed files with 20 additions and 9 deletions

View File

@ -1272,11 +1272,14 @@ implementation
var var
tcb: ttai_typedconstbuilder; tcb: ttai_typedconstbuilder;
begin begin
if (target_res.id in [res_elf,res_macho,res_xcoff]) then if (target_res.id in [res_elf,res_macho,res_xcoff]) or
{ generate the FPC_RESLOCATION symbol even when using external resources,
because in SysInit we can only reference it unconditionally }
((target_res.id=res_ext) and (target_info.system in systems_darwin)) then
begin begin
tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_make_dead_strippable]); tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_make_dead_strippable]);
if ResourcesUsed then if ResourcesUsed and (target_res.id<>res_ext) then
tcb.emit_tai(Tai_const.Createname('FPC_RESSYMBOL',0),voidpointertype) tcb.emit_tai(Tai_const.Createname('FPC_RESSYMBOL',0),voidpointertype)
else else
{ Nil pointer to resource information } { Nil pointer to resource information }

View File

@ -30,6 +30,7 @@ var
{$ifdef FPC_HAS_RESSTRINITS} {$ifdef FPC_HAS_RESSTRINITS}
ResStrInitTables : record end; external name 'FPC_RESSTRINITTABLES'; ResStrInitTables : record end; external name 'FPC_RESSTRINITTABLES';
{$endif} {$endif}
ResLocation: record end; external name 'FPC_RESLOCATION';
ResourceStringTables : record end; external name 'FPC_RESOURCESTRINGTABLES'; ResourceStringTables : record end; external name 'FPC_RESOURCESTRINGTABLES';
StkLen: SizeUInt; external name '__stklen'; StkLen: SizeUInt; external name '__stklen';
@ -46,7 +47,7 @@ const
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING} {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
WideInitTables : @WideInitTables; WideInitTables : @WideInitTables;
{$endif} {$endif}
ResLocation : nil; ResLocation : @ResLocation;
PascalMain : @PascalMain; PascalMain : @PascalMain;
valgrind_used : false; valgrind_used : false;
OS: ( OS: (

View File

@ -28,14 +28,21 @@ type
handles : PPtrUint; //pointer to handles handles : PPtrUint; //pointer to handles
end; end;
PResHdr = ^TResHdr; PResHdr = ^TResHdr;
PPResHdr = ^PResHdr;
TLibGetResHdr=function():PResHdr; TLibGetResHdr=function():PResHdr;
var var
{$ifdef FPC_HAS_WINLIKERESOURCES} {$ifdef FPC_HAS_WINLIKERESOURCES}
ResHeader : PResHdr; external name 'FPC_RESLOCATION'; {$ifdef FPC_HAS_INDIRECT_ENTRY_INFORMATION}
ResHeader : PPResHdr; external name '_FPC_ResLocation';
{$else} {$else}
ResHeader : PResHdr= nil; ResHeaderVar : PResHdr; external name 'FPC_RESLOCATION';
ResHeader : PPResHdr = @ResHeaderVar;
{$endif}
{$else}
ResHeaderVar : PResHdr = nil;
ResHeader : PPResHdr= @ResHeaderVar;
{$endif} {$endif}
(***************************************************************************** (*****************************************************************************
@ -49,7 +56,7 @@ var
begin begin
ExtGetResHdr:=nil; ExtGetResHdr:=nil;
if ModuleHandle=0 then if ModuleHandle=0 then
ExtGetResHdr:=ResHeader // internal ExtGetResHdr:=ResHeader^ // internal
else else
begin begin
// 1-st way to get resource location // 1-st way to get resource location
@ -351,18 +358,18 @@ end;
Function IntLockResource(ResData: TFPResourceHGLOBAL): Pointer; Function IntLockResource(ResData: TFPResourceHGLOBAL): Pointer;
begin begin
IntLockResource:=Nil; IntLockResource:=Nil;
if ResHeader=nil then exit; if ResHeader^=nil then exit;
IntLockResource:=Pointer(ResData); IntLockResource:=Pointer(ResData);
end; end;
Function IntUnlockResource(ResData: TFPResourceHGLOBAL): LongBool; Function IntUnlockResource(ResData: TFPResourceHGLOBAL): LongBool;
begin begin
IntUnlockResource:=(ResHeader<>nil); IntUnlockResource:=(ResHeader^<>nil);
end; end;
Function IntFreeResource(ResData: TFPResourceHGLOBAL): LongBool; Function IntFreeResource(ResData: TFPResourceHGLOBAL): LongBool;
begin begin
IntFreeResource:=(ResHeader<>nil); IntFreeResource:=(ResHeader^<>nil);
end; end;
const const