Преглед на файлове

* m68k: enabled vasm assembler support for the Sinclair QL, and added linking

git-svn-id: trunk@47312 -
Károly Balogh преди 4 години
родител
ревизия
eda7d535bd
променени са 3 файла, в които са добавени 65 реда и са изтрити 79 реда
  1. 4 2
      compiler/m68k/ag68kvasm.pas
  2. 1 1
      compiler/systems/i_sinclairql.pas
  3. 60 76
      compiler/systems/t_sinclairql.pas

+ 4 - 2
compiler/m68k/ag68kvasm.pas

@@ -99,7 +99,9 @@ unit ag68kvasm;
           { a.out doesn't support named sections }
           system_m68k_amiga: objtype:='-Felf';
           { atari never had a standard object format, a.out is limited, vasm/vlink author recommends vobj }
-          system_m68k_atari: objtype:='-Fvobj';
+          system_m68k_atari,
+          { same with the QL }
+          system_m68k_sinclairql: objtype:='-Fvobj';
         else
           internalerror(2016052601);
         end;
@@ -133,7 +135,7 @@ unit ag68kvasm;
          idtxt  : 'VASM';
          asmbin : 'vasmm68k_std';
          asmcmd:  '-quiet -elfregs -gas $OTYPE $ARCH -o $OBJ $EXTRAOPT $ASM';
-         supported_targets : [system_m68k_amiga,system_m68k_atari];
+         supported_targets : [system_m68k_amiga,system_m68k_atari,system_m68k_sinclairql];
          flags : [af_needar,af_smartlink_sections];
          labelprefix : '.L';
          labelmaxlen : -1;

+ 1 - 1
compiler/systems/i_sinclairql.pas

@@ -64,7 +64,7 @@ unit i_sinclairql;
             dirsep       : '/'; { ... the underlying tools (binutils/vlink/vasm) prefer Unix paths }
             assem        : as_m68k_as_aout;
             assemextern  : as_m68k_as_aout;
-            link         : ld_sinclairql;
+            link         : ld_none;
             linkextern   : ld_sinclairql;
             ar           : ar_gnu_ar;
             res          : res_ext;

+ 60 - 76
compiler/systems/t_sinclairql.pas

@@ -33,6 +33,7 @@ type
   PLinkerSinclairQL = ^TLinkerSinclairQL;
   TLinkerSinclairQL = class(texternallinker)
     private
+      Origin: DWord;
       UseVLink: boolean;
       function WriteResponseFile(isdll: boolean): boolean;
       procedure SetSinclairQLInfo;
@@ -52,6 +53,10 @@ implementation
        globtype,globals,systems,verbose,cscript,fmodule,i_sinclairql;
 
 
+    const
+       DefaultOrigin = $20000;
+
+
 constructor TLinkerSinclairQL.Create;
 begin
   UseVLink:=(cs_link_vlink in current_settings.globalswitches);
@@ -65,6 +70,11 @@ end;
 
 procedure TLinkerSinclairQL.SetSinclairQLInfo;
 begin
+  if ImageBaseSetExplicity then
+    Origin:=ImageBase
+  else
+    Origin:=DefaultOrigin;
+
   with Info do
    begin
     if not UseVLink then
@@ -73,7 +83,7 @@ begin
      end
     else
      begin
-      ExeCmd[1]:='vlink -b raw $FLAGS $GCSECTIONS $OPT $STRIP -o $EXE -T $RES';
+      ExeCmd[1]:='vlink -b rawbin1 $FLAGS $GCSECTIONS $OPT $STRIP -o $EXE -T $RES';
      end;
    end;
 end;
@@ -81,7 +91,7 @@ end;
 
 procedure TLinkerSinclairQL.SetDefaultInfo;
 begin
-  if target_info.system = system_m68k_Atari then
+  if target_info.system = system_m68k_sinclairql then
     SetSinclairQLInfo;
 end;
 
@@ -108,21 +118,21 @@ begin
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   while assigned(HPath) do
-   begin
-    s:=HPath.Str;
-    if (cs_link_on_target in current_settings.globalswitches) then
-     s:=ScriptFixFileName(s);
-    LinkRes.Add('-L'+s);
-    HPath:=TCmdStrListItem(HPath.Next);
-   end;
+    begin
+      s:=HPath.Str;
+      if (cs_link_on_target in current_settings.globalswitches) then
+        s:=ScriptFixFileName(s);
+      LinkRes.Add('-L'+s);
+      HPath:=TCmdStrListItem(HPath.Next);
+    end;
   HPath:=TCmdStrListItem(LibrarySearchPath.First);
   while assigned(HPath) do
-   begin
-    s:=HPath.Str;
-    if s<>'' then
-     LinkRes.Add('SEARCH_DIR("'+s+'")');
-    HPath:=TCmdStrListItem(HPath.Next);
-   end;
+    begin
+      s:=HPath.Str;
+      if s<>'' then
+        LinkRes.Add('SEARCH_DIR("'+s+'")');
+      HPath:=TCmdStrListItem(HPath.Next);
+    end;
 
   LinkRes.Add('INPUT (');
   { add objectfiles, start with prt0 always }
@@ -132,72 +142,46 @@ begin
       LinkRes.AddFileName(maybequoted(s));
     end;
   while not ObjectFiles.Empty do
-   begin
-    s:=ObjectFiles.GetFirst;
-    if s<>'' then
-     begin
-      { vlink doesn't use SEARCH_DIR for object files }
-      if UseVLink then
-       s:=FindObjectFile(s,'',false);
-      LinkRes.AddFileName(maybequoted(s));
-     end;
-   end;
+    begin
+      s:=ObjectFiles.GetFirst;
+      if s<>'' then
+        begin
+          { vlink doesn't use SEARCH_DIR for object files }
+          if UseVLink then
+             s:=FindObjectFile(s,'',false);
+          LinkRes.AddFileName(maybequoted(s));
+       end;
+    end;
 
   { Write staticlibraries }
   if not StaticLibFiles.Empty then
-   begin
-     { vlink doesn't need, and doesn't support GROUP }
-    if not UseVLink then
-     begin
-      LinkRes.Add(')');
-      LinkRes.Add('GROUP(');
-     end;
-    while not StaticLibFiles.Empty do
-     begin
-      S:=StaticLibFiles.GetFirst;
-      LinkRes.AddFileName(maybequoted(s));
-     end;
-   end;
+    begin
+      { vlink doesn't need, and doesn't support GROUP }
+      if not UseVLink then
+        begin
+          LinkRes.Add(')');
+          LinkRes.Add('GROUP(');
+        end;
+      while not StaticLibFiles.Empty do
+        begin
+          S:=StaticLibFiles.GetFirst;
+          LinkRes.AddFileName(maybequoted(s));
+        end;
+    end;
 
-  if not UseVLink then
-   begin
-    LinkRes.Add(')');
+  LinkRes.Add(')');
 
-    { 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) }
-    linklibc:=false;
-    while not SharedLibFiles.Empty do
-     begin
-      S:=SharedLibFiles.GetFirst;
-      if s<>'c' then
-       begin
-        i:=Pos(target_info.sharedlibext,S);
-        if i>0 then
-         Delete(S,i,255);
-        LinkRes.Add('-l'+s);
-       end
-      else
-       begin
-        LinkRes.Add('-l'+s);
-        linklibc:=true;
-       end;
-     end;
-    { be sure that libc&libgcc is the last lib }
-    if linklibc then
-     begin
-      LinkRes.Add('-lc');
-      LinkRes.Add('-lgcc');
-     end;
-   end
-  else
-   begin
-    while not SharedLibFiles.Empty do
-     begin
-      S:=SharedLibFiles.GetFirst;
-      LinkRes.Add('lib'+s+target_info.staticlibext);
-     end;
-    LinkRes.Add(')');
-   end;
+  with LinkRes do
+    begin
+      Add('');
+      Add('SECTIONS');
+      Add('{');
+      Add('  . = 0x'+hexstr(Origin,8)+';');
+      Add('  .text : { *(.text .text.* _CODE _CODE.* ) }');
+      Add('  .data : { *(.data .data.* .rodata .rodata.* .fpc.* ) }');
+      Add('  .bss  : { *(_BSS _BSS.*) *(.bss .bss.*) *(_BSSEND _BSSEND.*) *(_HEAP _HEAP.*) *(.stack .stack.*) *(_STACK _STACK.*) }');
+      Add('}');
+    end;
 
 { Write and Close response }
   linkres.writetodisk;