m68k-palmos: internal sysinit, and patch target support so it works prc-tools-remix on a modern system

git-svn-id: trunk@37230 -
This commit is contained in:
Károly Balogh 2017-09-16 21:34:55 +00:00
parent 8c8a026fa6
commit fd00920006
3 changed files with 41 additions and 19 deletions

View File

@ -330,8 +330,10 @@ interface
{ all systems for which weak linking has been tested/is supported } { all systems for which weak linking has been tested/is supported }
systems_weak_linking = systems_darwin + systems_solaris + systems_linux + systems_android; systems_weak_linking = systems_darwin + systems_solaris + systems_linux + systems_android;
systems_internal_sysinit = [system_i386_linux,system_i386_win32,system_x86_64_win64, systems_internal_sysinit = [system_i386_win32,system_x86_64_win64,
system_powerpc64_linux,system_m68k_atari,system_sparc64_linux]+systems_darwin+systems_amigalike; system_i386_linux,system_powerpc64_linux,system_sparc64_linux,
system_m68k_atari,system_m68k_palmos
]+systems_darwin+systems_amigalike;
{ all systems that use garbage collection for reference-counted types } { all systems that use garbage collection for reference-counted types }
systems_garbage_collected_managed_types = [ systems_garbage_collected_managed_types = [

View File

@ -34,7 +34,7 @@ unit i_palmos;
system : system_m68k_PalmOS; system : system_m68k_PalmOS;
name : 'PalmOS'; name : 'PalmOS';
shortname : 'PalmOS'; shortname : 'PalmOS';
flags : [tf_under_development,tf_code_small,tf_static_reg_based,tf_smartlink_sections]; flags : [tf_under_development,tf_code_small,tf_static_reg_based,tf_smartlink_library,tf_requires_proper_alignment];
cpu : cpu_m68k; cpu : cpu_m68k;
unit_env : 'PALMUNITS'; unit_env : 'PALMUNITS';
extradefines : ''; extradefines : '';
@ -61,8 +61,8 @@ unit i_palmos;
Cprefix : '_'; Cprefix : '_';
newline : #10; newline : #10;
dirsep : '/'; dirsep : '/';
assem : as_gas; assem : as_m68k_as_aout;
assemextern : as_gas; assemextern : as_m68k_as_aout;
link : ld_none; link : ld_none;
linkextern : ld_palmos; linkextern : ld_palmos;
ar : ar_gnu_ar; ar : ar_gnu_ar;

View File

@ -34,9 +34,10 @@ interface
private private
Function WriteResponseFile : Boolean; Function WriteResponseFile : Boolean;
public public
constructor Create;override; constructor Create; override;
procedure SetDefaultInfo;override; procedure SetDefaultInfo; override;
function MakeExecutable:boolean;override; procedure InitSysInitUnitName; override;
function MakeExecutable:boolean; override;
end; end;
@ -65,12 +66,23 @@ procedure TLinkerPalmOS.SetDefaultInfo;
begin begin
with Info do with Info do
begin begin
ExeCmd[1]:='ldpalm $OPT $STRIP -N -dy -T $SCRIPT -o $EXE @$RES'; //ExeCmd[1]:='ldpalm $OPT $STRIP -N -dy -T $SCRIPT -o $EXE @$RES';
ExeCmd[2]:='build-prc $EXE.prc "$APPNAME" $APPID $EXE *.bin';
{ This is based on my successful experiment with prc-tools remix.
Anyone who has more insight into this Palm magic, feel free to fix. (KB) }
ExeCmd[1]:='ld $OPT $STRIP --no-check-sections -N -dy -o $EXE $RES';
ExeCmd[2]:='obj-res $EXE';
ExeCmd[3]:='build-prc $EXE.prc "$APPNAME" $APPID $EXE *.$EXE.grc';
end; end;
end; end;
procedure TLinkerPalmOS.InitSysInitUnitName;
begin
sysinitunit:='si_prc';
end;
Function TLinkerPalmOS.WriteResponseFile : Boolean; Function TLinkerPalmOS.WriteResponseFile : Boolean;
Var Var
linkres : TLinkRes; linkres : TLinkRes;
@ -94,13 +106,18 @@ begin
HPath:=TCmdStrListItem(LibrarySearchPath.First); HPath:=TCmdStrListItem(LibrarySearchPath.First);
while assigned(HPath) do while assigned(HPath) do
begin begin
LinkRes.Add('-L'+HPath.Str); LinkRes.Add('SEARCH_DIR('+HPath.Str+')');
HPath:=TCmdStrListItem(HPath.Next); HPath:=TCmdStrListItem(HPath.Next);
end; end;
{ add objectfiles, start with crt0 always } LinkRes.Add('INPUT (');
{ using crt0, we should stick C compatible } { add objectfiles, start with prt0 always }
LinkRes.AddFileName(FindObjectFile('crt0','',false)); if not (target_info.system in systems_internal_sysinit) then
begin
{ add objectfiles, start with crt0 always }
{ using crt0, we should stick C compatible }
LinkRes.AddFileName(FindObjectFile('crt0','',false));
end;
{ main objectfiles } { main objectfiles }
while not ObjectFiles.Empty do while not ObjectFiles.Empty do
@ -109,21 +126,22 @@ begin
if s<>'' then if s<>'' then
LinkRes.AddFileName(s); LinkRes.AddFileName(s);
end; end;
LinkRes.Add(')');
{ Write staticlibraries } { Write staticlibraries }
if not StaticLibFiles.Empty then if not StaticLibFiles.Empty then
begin begin
LinkRes.Add('-('); LinkRes.Add('GROUP(');
While not StaticLibFiles.Empty do While not StaticLibFiles.Empty do
begin begin
S:=StaticLibFiles.GetFirst; S:=StaticLibFiles.GetFirst;
LinkRes.AddFileName(s) LinkRes.AddFileName(s)
end; end;
LinkRes.Add('-)'); LinkRes.Add(')');
end; end;
{ currently the PalmOS target must be linked always against the C lib } { currently the PalmOS target must be linked always against the C lib }
LinkRes.Add('-lcrt'); {LinkRes.Add('-lcrt');}
{ Write sharedlibraries like -l<lib>, also add the needed dynamic linker { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
here to be sure that it gets linked this is needed for glibc2 systems (PFV) } here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
@ -180,16 +198,18 @@ begin
for i:=1 to 2 do for i:=1 to 2 do
begin begin
SplitBinCmd(Info.ExeCmd[i],binstr,cmdstr); SplitBinCmd(Info.ExeCmd[i],binstr,cmdstr);
binstr:=FindUtil(utilsprefix+BinStr);
if binstr<>'' then if binstr<>'' then
begin begin
Replace(cmdstr,'$EXE',MaybeQuoted(current_module.exefilename)); Replace(cmdstr,'$EXE',MaybeQuoted(current_module.exefilename));
Replace(cmdstr,'$OPT',Info.ExtraOptions); Replace(cmdstr,'$OPT',Info.ExtraOptions);
Replace(cmdstr,'$RES',MaybeQuoted(outputexedir+Info.ResName)); Replace(cmdstr,'$RES',MaybeQuoted(outputexedir+Info.ResName));
Replace(cmdstr,'$STRIP',StripStr); Replace(cmdstr,'$STRIP',StripStr);
Replace(cmdstr,'$SCRIPT',FindUtil('palm.ld')); // Replace(cmdstr,'$SCRIPT',FindUtil('palm.ld'));
Replace(cmdstr,'$APPNAME',palmos_applicationname); Replace(cmdstr,'$APPNAME',palmos_applicationname);
Replace(cmdstr,'$APPID',palmos_applicationid); Replace(cmdstr,'$APPID',palmos_applicationid);
success:=DoExec(FindUtil(binstr),cmdstr,(i=1),false);
success:=DoExec(binstr,cmdstr,(i=1),false);
if not success then if not success then
break; break;
end; end;