浏览代码

amiga: section smartlinking support for amiga. needs vlink nightly

git-svn-id: trunk@35243 -
Károly Balogh 8 年之前
父节点
当前提交
48744d0abd
共有 2 个文件被更改,包括 34 次插入14 次删除
  1. 1 1
      compiler/systems/i_amiga.pas
  2. 33 13
      compiler/systems/t_amiga.pas

+ 1 - 1
compiler/systems/i_amiga.pas

@@ -97,7 +97,7 @@ unit i_amiga;
             system       : system_powerpc_Amiga;
             system       : system_powerpc_Amiga;
             name         : 'AmigaOS for PowerPC';
             name         : 'AmigaOS for PowerPC';
             shortname    : 'amiga';
             shortname    : 'amiga';
-            flags        : [tf_files_case_aware,tf_requires_proper_alignment,tf_has_winlike_resources];
+            flags        : [tf_files_case_aware,tf_requires_proper_alignment,tf_has_winlike_resources,tf_smartlink_sections];
             cpu          : cpu_powerpc;
             cpu          : cpu_powerpc;
             unit_env     : 'AMIGAUNITS';
             unit_env     : 'AMIGAUNITS';
             extradefines : 'PPC603;HASAMIGA;AMIGAOS4';
             extradefines : 'PPC603;HASAMIGA;AMIGAOS4';

+ 33 - 13
compiler/systems/t_amiga.pas

@@ -52,7 +52,7 @@ implementation
 
 
     uses
     uses
        SysUtils,
        SysUtils,
-       cutils,cfileutl,cclasses,
+       cutils,cfileutl,cclasses,aasmbase,
        globtype,globals,systems,verbose,script,fmodule,i_amiga;
        globtype,globals,systems,verbose,script,fmodule,i_amiga;
 
 
 
 
@@ -82,7 +82,7 @@ begin
      end
      end
     else
     else
      begin
      begin
-      ExeCmd[1]:='vlink -b amigahunk $OPT $STRIP -o $EXE -T $RES';
+      ExeCmd[1]:='vlink -b amigahunk $GCSECTIONS $OPT $STRIP -o $EXE -T $RES';
      end;
      end;
    end;
    end;
 end;
 end;
@@ -97,7 +97,7 @@ begin
      end
      end
     else
     else
      begin
      begin
-      ExeCmd[1]:='vlink -q -n -b elf32amigaos -P_start -P__amigaos4__ -nostdlib $OPT $STRIP -o $EXE -T $RES';
+      ExeCmd[1]:='vlink -q -n -b elf32amigaos -P_start -P__amigaos4__ -nostdlib $GCSECTIONS $OPT $STRIP -o $EXE -T $RES';
      end;
      end;
   end;
   end;
 end;
 end;
@@ -346,9 +346,21 @@ var
   CmdStr  : TCmdStr;
   CmdStr  : TCmdStr;
   StripStr: string[40];
   StripStr: string[40];
   DynLinkStr : string;
   DynLinkStr : string;
+  GCSectionsStr : string;
 begin
 begin
   StripStr:='';
   StripStr:='';
-  if (cs_link_strip in current_settings.globalswitches) then StripStr:='-s';
+  GCSectionsStr:='';
+  DynLinkStr:='';
+
+  if (cs_link_strip in current_settings.globalswitches) then
+    StripStr:='-s';
+  if rlinkpath<>'' Then
+    DynLinkStr:='--rpath-link '+rlinkpath;
+  if UseVLink then
+    begin
+      if create_smartlink_sections then
+        GCSectionsStr:='-gc-all -sc -sd';
+    end;
 
 
   { Call linker }
   { Call linker }
   SplitBinCmd(Info.ExeCmd[1],BinStr,CmdStr);
   SplitBinCmd(Info.ExeCmd[1],BinStr,CmdStr);
@@ -357,11 +369,9 @@ begin
   Replace(cmdstr,'$EXE',Unix2AmigaPath(maybequoted(ScriptFixFileName(current_module.exefilename))));
   Replace(cmdstr,'$EXE',Unix2AmigaPath(maybequoted(ScriptFixFileName(current_module.exefilename))));
   Replace(cmdstr,'$RES',Unix2AmigaPath(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
   Replace(cmdstr,'$RES',Unix2AmigaPath(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$STRIP',StripStr);
-  if rlinkpath<>'' Then
-    DynLinkStr:='--rpath-link '+rlinkpath
-  else
-    DynLinkStr:='';
+  Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
+
   MakeAmiga68kExe:=DoExec(BinStr,CmdStr,true,false);
   MakeAmiga68kExe:=DoExec(BinStr,CmdStr,true,false);
 end;
 end;
 
 
@@ -372,9 +382,21 @@ var
   CmdStr  : TCmdStr;
   CmdStr  : TCmdStr;
   StripStr: string[40];
   StripStr: string[40];
   DynLinkStr : string;
   DynLinkStr : string;
+  GCSectionsStr : string;
 begin
 begin
   StripStr:='';
   StripStr:='';
-  if (cs_link_strip in current_settings.globalswitches) then StripStr:='-s';
+  GCSectionsStr:='';
+  DynLinkStr:='';
+
+  if (cs_link_strip in current_settings.globalswitches) then
+    StripStr:='-s';
+  if rlinkpath<>'' Then
+    DynLinkStr:='--rpath-link '+rlinkpath;
+  if UseVLink then
+    begin
+      if create_smartlink_sections then
+        GCSectionsStr:='-gc-all -sc -sd';
+    end;
 
 
   { Call linker }
   { Call linker }
   SplitBinCmd(Info.ExeCmd[1],BinStr,CmdStr);
   SplitBinCmd(Info.ExeCmd[1],BinStr,CmdStr);
@@ -383,11 +405,9 @@ begin
   Replace(cmdstr,'$EXE',Unix2AmigaPath(maybequoted(ScriptFixFileName(current_module.exefilename))));
   Replace(cmdstr,'$EXE',Unix2AmigaPath(maybequoted(ScriptFixFileName(current_module.exefilename))));
   Replace(cmdstr,'$RES',Unix2AmigaPath(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
   Replace(cmdstr,'$RES',Unix2AmigaPath(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$STRIP',StripStr);
-  if rlinkpath<>'' Then
-    DynLinkStr:='--rpath-link '+rlinkpath
-  else
-    DynLinkStr:='';
+  Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
+
   MakeAmigaPPCExe:=DoExec(BinStr,CmdStr,true,false);
   MakeAmigaPPCExe:=DoExec(BinStr,CmdStr,true,false);
 end;
 end;