ソースを参照

* support multiple asmlabel types, renamed getlabel to
getjumplabel and added type para to getlabel for specific types
* moved lineinfo generation from assemble and aggas to dbgstabs

git-svn-id: trunk@1120 -

peter 20 年 前
コミット
a3ab2053c9
68 ファイル変更822 行追加1274 行削除
  1. 49 50
      compiler/aasmbase.pas
  2. 89 81
      compiler/aasmtai.pas
  3. 13 191
      compiler/aggas.pas
  4. 1 3
      compiler/aoptda.pas
  5. 2 2
      compiler/aoptobj.pas
  6. 1 1
      compiler/arm/aasmcpu.pas
  7. 5 5
      compiler/arm/cgcpu.pas
  8. 3 3
      compiler/arm/narmcnv.pas
  9. 2 2
      compiler/arm/rgcpu.pas
  10. 196 413
      compiler/assemble.pas
  11. 5 5
      compiler/cg64f32.pas
  12. 2 2
      compiler/cgobj.pas
  13. 23 23
      compiler/cresstr.pas
  14. 27 1
      compiler/dbgbase.pas
  15. 135 2
      compiler/dbgstabs.pas
  16. 8 8
      compiler/dwarf.pas
  17. 15 18
      compiler/fppu.pas
  18. 0 173
      compiler/gdb.pas
  19. 3 11
      compiler/i386/ag386nsm.pas
  20. 2 2
      compiler/i386/cgcpu.pas
  21. 2 4
      compiler/i386/daopt386.pas
  22. 2 2
      compiler/i386/n386add.pas
  23. 4 4
      compiler/i386/n386mat.pas
  24. 1 1
      compiler/i386/n386set.pas
  25. 1 1
      compiler/i386/popt386.pas
  26. 4 4
      compiler/m68k/cgcpu.pas
  27. 3 3
      compiler/m68k/n68kmat.pas
  28. 4 4
      compiler/m68k/ncpuadd.pas
  29. 6 6
      compiler/ncgadd.pas
  30. 1 1
      compiler/ncgbas.pas
  31. 2 2
      compiler/ncgcal.pas
  32. 4 4
      compiler/ncgcnv.pas
  33. 34 34
      compiler/ncgflw.pas
  34. 3 3
      compiler/ncginl.pas
  35. 5 5
      compiler/ncgld.pas
  36. 2 2
      compiler/ncgmat.pas
  37. 5 5
      compiler/ncgmem.pas
  38. 1 1
      compiler/ncgopt.pas
  39. 10 10
      compiler/ncgset.pas
  40. 14 18
      compiler/ncgutil.pas
  41. 1 1
      compiler/nobj.pas
  42. 13 15
      compiler/parser.pas
  43. 4 4
      compiler/pdecl.pas
  44. 27 18
      compiler/pmodules.pas
  45. 3 9
      compiler/powerpc/agppcmpw.pas
  46. 3 3
      compiler/powerpc/cgcpu.pas
  47. 7 7
      compiler/powerpc/nppcadd.pas
  48. 3 3
      compiler/powerpc/nppccnv.pas
  49. 1 1
      compiler/powerpc/nppcmat.pas
  50. 1 1
      compiler/powerpc/nppcset.pas
  51. 2 2
      compiler/procinfo.pas
  52. 6 1
      compiler/psub.pas
  53. 2 9
      compiler/psystem.pas
  54. 2 20
      compiler/rautils.pas
  55. 4 4
      compiler/sparc/cgcpu.pas
  56. 4 4
      compiler/sparc/ncpucnv.pas
  57. 1 1
      compiler/sparc/ncpumat.pas
  58. 1 1
      compiler/sparc/ncpuset.pas
  59. 4 4
      compiler/symdef.pas
  60. 2 2
      compiler/symsym.pas
  61. 6 6
      compiler/symtable.pas
  62. 20 25
      compiler/systems/t_win.pas
  63. 4 11
      compiler/x86/agx86int.pas
  64. 2 2
      compiler/x86/cgx86.pas
  65. 1 1
      compiler/x86/nx86add.pas
  66. 5 5
      compiler/x86/nx86cnv.pas
  67. 3 3
      compiler/x86/nx86set.pas
  68. 1 1
      compiler/x86_64/nx64add.pas

+ 49 - 50
compiler/aasmbase.pas

@@ -97,16 +97,17 @@ interface
          procedure setaddress(_pass:byte;sec:TAsmSection;offset,len:aint);
        end;
 
+       { is the label only there for getting an address (e.g. for i/o
+         checks -> alt_addr) or is it a jump target (alt_jump), for debug
+         info alt_dbgline and alt_dbgfile }
+       TAsmLabelType = (alt_jump,alt_addr,alt_data,alt_dbgline,alt_dbgfile);
+
        TAsmLabel = class(TAsmSymbol)
-         { this is set by the tai_label.Init }
-         is_set,
-         { is the label only there for getting an address (e.g. for i/o }
-         { checks -> true) or is it a jump target (false)               }
-         is_addr : boolean;
-         labelnr : longint;
-         constructor create(nr:longint);
-         constructor createdata(const modulename:string;nr:longint);
-         constructor createaddr(nr:longint);
+         labelnr   : longint;
+         labeltype : TAsmLabelType;
+         is_set    : boolean;
+         constructor createlocal(nr:longint;ltyp:TAsmLabelType);
+         constructor createglobal(const modulename:string;nr:longint;ltyp:TAsmLabelType);
          function getname:string;override;
        end;
 
@@ -154,7 +155,7 @@ interface
 
        TAsmObjectData = class(TLinkedListItem)
        private
-         FName      : string{$ifndef VER1_9_4}[80]{$endif};
+         FName      : string[80];
          FCurrSec   : TAsmSection;
          FSects     : TDictionary;
          FCAsmSection : TAsmSectionClass;
@@ -179,7 +180,7 @@ interface
          procedure setsection(asec:tasmsection);
          procedure alloc(len:aint);
          procedure allocalign(len:longint);
-         procedure allocstabs(p:pchar);
+         procedure allocstab(p:pchar);
          procedure allocsymbol(currpass:byte;p:tasmsymbol;len:aint);
          procedure writebytes(var data;len:aint);
          procedure writereloc(data,len:aint;p:tasmsymbol;relative:TAsmRelocationType);virtual;abstract;
@@ -205,7 +206,7 @@ interface
        TAsmLibraryData = class(TLinkedListItem)
        private
          nextaltnr   : longint;
-         nextlabelnr : longint;
+         nextlabelnr : array[Tasmlabeltype] of longint;
        public
          name,
          realname     : string[80];
@@ -222,15 +223,16 @@ interface
          function  newasmsymbol(const s : string;_bind:TAsmSymBind;_typ:TAsmsymtype) : tasmsymbol;
          function  getasmsymbol(const s : string) : tasmsymbol;
          function  renameasmsymbol(const sold, snew : string):tasmsymbol;
-         function  newasmlabel(nr:longint;is_addr,is_data:boolean) : tasmlabel;
+         function  newasmlabel(nr:longint;alt:tasmlabeltype;is_global:boolean) : tasmlabel;
          {# create a new assembler label }
-         procedure getlabel(var l : tasmlabel);
+         procedure getlabel(var l : tasmlabel;alt:tasmlabeltype);
+         {# create a new assembler label for jumps }
+         procedure getjumplabel(var l : tasmlabel);
          { make l as a new label and flag is_addr }
          procedure getaddrlabel(var l : tasmlabel);
          { make l as a new label and flag is_data }
          procedure getdatalabel(var l : tasmlabel);
          {# return a label number }
-         procedure getlabelnr(var l : longint);
          procedure CreateUsedAsmSymbolList;
          procedure DestroyUsedAsmSymbolList;
          procedure UsedAsmSymbolListInsert(p:tasmsymbol);
@@ -242,6 +244,9 @@ interface
          procedure UsedAsmSymbolListCheckUndefined;
        end;
 
+    const
+      { alt_jump,alt_addr,alt_data,alt_dbgline,alt_dbgfile }
+      asmlabeltypeprefix : array[tasmlabeltype] of char = ('j','a','d','l','f');
 
     var
       objectlibrary : tasmlibrarydata;
@@ -337,33 +342,26 @@ implementation
                                  TAsmLabel
 *****************************************************************************}
 
-    constructor tasmlabel.create(nr:longint);
+    constructor tasmlabel.createlocal(nr:longint;ltyp:TAsmLabelType);
       begin;
         labelnr:=nr;
-        inherited create(target_asm.labelprefix+tostr(labelnr),AB_LOCAL,AT_FUNCTION);
+        labeltype:=ltyp;
+        inherited create(target_asm.labelprefix+asmlabeltypeprefix[labeltype]+tostr(labelnr),AB_LOCAL,AT_FUNCTION);
         is_set:=false;
-        is_addr := false;
       end;
 
 
-    constructor tasmlabel.createdata(const modulename:string;nr:longint);
+    constructor tasmlabel.createglobal(const modulename:string;nr:longint;ltyp:TAsmLabelType);
       begin;
         labelnr:=nr;
-        inherited create('_$'+modulename+'$_L'+tostr(labelnr),AB_GLOBAL,AT_DATA);
+        inherited create('_$'+modulename+'$_L'+asmlabeltypeprefix[labeltype]+tostr(labelnr),AB_GLOBAL,AT_DATA);
+        labeltype:=ltyp;
         is_set:=false;
-        is_addr := false;
         { write it always }
         increfs;
       end;
 
 
-    constructor tasmlabel.createaddr(nr:longint);
-      begin;
-        self.create(nr);
-        is_addr := true;
-      end;
-
-
     function tasmlabel.getname:string;
       begin
         getname:=inherited getname;
@@ -652,7 +650,7 @@ implementation
       end;
 
 
-    procedure TAsmObjectData.allocstabs(p:pchar);
+    procedure TAsmObjectData.allocstab(p:pchar);
       begin
         if not(assigned(FStabsSec) and assigned(FStabStrSec)) then
           internalerror(200402254);
@@ -715,6 +713,8 @@ implementation
 ****************************************************************************}
 
     constructor TAsmLibraryData.create(const n:string);
+      var
+        alt : TAsmLabelType;
       begin
         inherited create;
         realname:=n;
@@ -724,7 +724,8 @@ implementation
         symbolsearch.usehash;
         { labels }
         nextaltnr:=1;
-        nextlabelnr:=1;
+        for alt:=low(TAsmLabelType) to high(TAsmLabelType) do
+          nextlabelnr[alt]:=1;
         { ppu }
         asmsymbolppuidx:=0;
         asmsymbolidx:=nil;
@@ -894,49 +895,47 @@ implementation
       end;
 
 
-    function  TAsmLibraryData.newasmlabel(nr:longint;is_addr,is_data:boolean) : tasmlabel;
+    function  TAsmLibraryData.newasmlabel(nr:longint;alt:tasmlabeltype;is_global:boolean) : tasmlabel;
       var
         hp : tasmlabel;
       begin
-        if is_addr then
-         hp:=tasmlabel.createaddr(nr)
-        else if is_data then
-         hp:=tasmlabel.createdata(name,nr)
-        else
-         hp:=tasmlabel.create(nr);
+        if is_global then
+         hp:=tasmlabel.createglobal(name,nr,alt)
+       else
+         hp:=tasmlabel.createlocal(nr,alt);
         symbolsearch.insert(hp);
         newasmlabel:=hp;
       end;
 
 
-    procedure TAsmLibraryData.getlabel(var l : tasmlabel);
+    procedure TAsmLibraryData.getlabel(var l : tasmlabel;alt:tasmlabeltype);
       begin
-        l:=tasmlabel.create(nextlabelnr);
-        inc(nextlabelnr);
+        l:=tasmlabel.createlocal(nextlabelnr[alt],alt);
+        inc(nextlabelnr[alt]);
         symbolsearch.insert(l);
       end;
 
-
-    procedure TAsmLibraryData.getdatalabel(var l : tasmlabel);
+    procedure TAsmLibraryData.getjumplabel(var l : tasmlabel);
       begin
-        l:=tasmlabel.createdata(name,nextlabelnr);
-        inc(nextlabelnr);
+        l:=tasmlabel.createlocal(nextlabelnr[alt_jump],alt_jump);
+        inc(nextlabelnr[alt_jump]);
         symbolsearch.insert(l);
       end;
 
 
-    procedure TAsmLibraryData.getaddrlabel(var l : tasmlabel);
+    procedure TAsmLibraryData.getdatalabel(var l : tasmlabel);
       begin
-        l:=tasmlabel.createaddr(nextlabelnr);
-        inc(nextlabelnr);
+        l:=tasmlabel.createglobal(name,nextlabelnr[alt_addr],alt_addr);
+        inc(nextlabelnr[alt_addr]);
         symbolsearch.insert(l);
       end;
 
 
-    procedure TAsmLibraryData.getlabelnr(var l : longint);
+    procedure TAsmLibraryData.getaddrlabel(var l : tasmlabel);
       begin
-         l:=nextlabelnr;
-         inc(nextlabelnr);
+        l:=tasmlabel.createlocal(nextlabelnr[alt_addr],alt_addr);
+        inc(nextlabelnr[alt_addr]);
+        symbolsearch.insert(l);
       end;
 
 

+ 89 - 81
compiler/aasmtai.pas

@@ -45,7 +45,6 @@ interface
           ait_align,
           ait_section,
           ait_comment,
-          ait_direct,
           ait_string,
           ait_instruction,
           ait_datablock,
@@ -68,12 +67,9 @@ interface
           ait_real_80bit,
           ait_comp_64bit,
           ait_real_128bit,
-{$ifdef GDB}
-          ait_stabn,
-          ait_stabs,
+          ait_stab,
           ait_force_line,
-          ait_stab_function_name,
-{$endif GDB}
+          ait_function_name,
 {$ifdef alpha}
           { the follow is for the DEC Alpha }
           ait_frame,
@@ -110,7 +106,6 @@ interface
           'align',
           'section',
           'comment',
-          'direct',
           'string',
           'instruction',
           'datablock',
@@ -131,12 +126,9 @@ interface
           'real_80bit',
           'comp_64bit',
           'real_128bit',
-{$ifdef GDB}
-          'stabn',
-          'stabs',
+          'stab',
           'force_line',
-          'stab_funcname',
-{$endif GDB}
+          'function_name',
 {$ifdef alpha}
           { the follow is for the DEC Alpha }
           'frame',
@@ -211,25 +203,21 @@ interface
 { a new ait type!                                                              }
     const
       SkipInstr = [ait_comment, ait_symbol,ait_section
-{$ifdef GDB}
-                   ,ait_stabs, ait_stabn, ait_stab_function_name, ait_force_line
-{$endif GDB}
+                   ,ait_stab, ait_function_name, ait_force_line
                    ,ait_regalloc, ait_tempalloc, ait_symbol_end];
 
 { ait_* types which do not have line information (and hence which are of type
   tai, otherwise, they are of type tailineinfo }
       SkipLineInfo =[ait_label,
                      ait_regalloc,ait_tempalloc,
-{$ifdef GDB}
-                  ait_stabn,ait_stabs,ait_stab_function_name,
-{$endif GDB}
-                  ait_cutobject,ait_marker,ait_align,ait_section,ait_comment,
-                  ait_const_8bit,ait_const_16bit,ait_const_32bit,ait_const_64bit,ait_const_128bit,
-                  ait_const_sleb128bit,ait_const_uleb128bit,
-                  ait_const_rva_symbol,ait_const_indirect_symbol,
-                  ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_real_128bit,
-                  ait_non_lazy_symbol_pointer
-                  ];
+                     ait_stab,ait_function_name,
+                     ait_cutobject,ait_marker,ait_align,ait_section,ait_comment,
+                     ait_const_8bit,ait_const_16bit,ait_const_32bit,ait_const_64bit,ait_const_128bit,
+                     ait_const_sleb128bit,ait_const_uleb128bit,
+                     ait_const_rva_symbol,ait_const_indirect_symbol,
+                     ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_real_128bit,
+                     ait_non_lazy_symbol_pointer
+                    ];
 
 
     type
@@ -325,16 +313,6 @@ interface
           procedure derefimpl;override;
        end;
 
-       { Directly output data to final assembler file }
-       tai_direct = class(tailineinfo)
-          str : pchar;
-          constructor Create(_str : pchar);
-          destructor Destroy; override;
-          constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
-          procedure ppuwrite(ppufile:tcompilerppufile);override;
-          function getcopy:tlinkedlistitem;override;
-       end;
-
        { Generates an assembler comment }
        tai_comment = class(tai)
           str : pchar;
@@ -454,6 +432,26 @@ interface
           procedure ppuwrite(ppufile:tcompilerppufile);override;
        end;
 
+       tstabtype = (stab_stabs,stab_stabn,stab_stabd);
+
+       tai_stab = class(tai)
+          str : pchar;
+          stabtype : tstabtype;
+          constructor Create(_stabtype:tstabtype;_str : pchar);
+          constructor Create_str(_stabtype:tstabtype;const s:string);
+          destructor Destroy;override;
+       end;
+
+       tai_force_line = class(tailineinfo)
+          constructor Create;
+       end;
+
+       tai_function_name = class(tai)
+          funcname : pstring;
+          constructor create(const s:string);
+          destructor destroy;override;
+       end;
+
        { Insert a cut to split assembler into several smaller files }
        tai_cutobject = class(tai)
           place : tcutplace;
@@ -586,7 +584,8 @@ interface
          information in the .o file. The stabs for the types must be defined
          before they can be referenced and therefor they need to be written
          first (PFV) }
-       Tasmlist=(al_typestabs,
+       Tasmlist=(al_debugstart,
+                 al_debugtypes,
                  al_procedures,
                  al_globals,
                  al_const,
@@ -600,10 +599,12 @@ interface
                  al_rtti,
                  al_dwarf,
                  al_picdata,
-                 al_resourcestrings);
+                 al_resourcestrings,
+                 al_debugend);
     const
        TasmlistStr : array[tasmlist] of string[24] =(
-           'al_typestabs',
+           'al_debugstart',
+           'al_debugtypes',
            'al_procedures',
            'al_globals',
            'al_const',
@@ -617,7 +618,12 @@ interface
            'al_rtti',
            'al_dwarf',
            'al_picdata',
-           'al_resourcestrings');
+           'al_resourcestrings',
+           'al_debugend');
+
+      regallocstr : array[tregalloctype] of string[10]=('allocated','released','sync','resized');
+      tempallocstr : array[boolean] of string[10]=('released','allocated');
+      stabtypestr : array[tstabtype] of string[5]=('stabs','stabn','stabd');
 
     var
       { array with all class types for tais }
@@ -1530,25 +1536,25 @@ implementation
 
 
 {****************************************************************************
-                              TAI_DIRECT
+          tai_comment  comment to be inserted in the assembler file
  ****************************************************************************}
 
-     constructor tai_direct.Create(_str : pchar);
+     constructor tai_comment.Create(_str : pchar);
 
        begin
           inherited Create;
-          typ:=ait_direct;
+          typ:=ait_comment;
           str:=_str;
        end;
 
-    destructor tai_direct.destroy;
+    destructor tai_comment.destroy;
 
       begin
          strdispose(str);
          inherited Destroy;
       end;
 
-    constructor tai_direct.ppuload(t:taitype;ppufile:tcompilerppufile);
+    constructor tai_comment.ppuload(t:taitype;ppufile:tcompilerppufile);
       var
         len : longint;
       begin
@@ -1560,7 +1566,7 @@ implementation
       end;
 
 
-    procedure tai_direct.ppuwrite(ppufile:tcompilerppufile);
+    procedure tai_comment.ppuwrite(ppufile:tcompilerppufile);
       var
         len : longint;
       begin
@@ -1571,67 +1577,67 @@ implementation
       end;
 
 
-    function tai_direct.getcopy : tlinkedlistitem;
+    function tai_comment.getcopy : tlinkedlistitem;
       var
         p : tlinkedlistitem;
       begin
         p:=inherited getcopy;
-        getmem(tai_direct(p).str,strlen(str)+1);
-        move(str^,tai_direct(p).str^,strlen(str)+1);
+        getmem(tai_comment(p).str,strlen(str)+1);
+        move(str^,tai_comment(p).str^,strlen(str)+1);
         getcopy:=p;
       end;
 
 
 {****************************************************************************
-          tai_comment  comment to be inserted in the assembler file
+                              TAI_STABS
  ****************************************************************************}
 
-     constructor tai_comment.Create(_str : pchar);
-
-       begin
-          inherited Create;
-          typ:=ait_comment;
-          str:=_str;
-       end;
+    constructor tai_stab.create(_stabtype:tstabtype;_str : pchar);
+      begin
+         inherited create;
+         typ:=ait_stab;
+         str:=_str;
+         stabtype:=_stabtype;
+      end;
 
-    destructor tai_comment.destroy;
+    constructor tai_stab.create_str(_stabtype:tstabtype;const s:string);
+      begin
+         self.create(_stabtype,strpnew(s));
+      end;
 
+    destructor tai_stab.destroy;
       begin
          strdispose(str);
-         inherited Destroy;
+         inherited destroy;
       end;
 
-    constructor tai_comment.ppuload(t:taitype;ppufile:tcompilerppufile);
-      var
-        len : longint;
+
+{****************************************************************************
+                            TAI_FORCE_LINE
+ ****************************************************************************}
+
+    constructor tai_force_line.create;
       begin
-        inherited ppuload(t,ppufile);
-        len:=ppufile.getlongint;
-        getmem(str,len+1);
-        ppufile.getdata(str^,len);
-        str[len]:=#0;
+         inherited create;
+         typ:=ait_force_line;
       end;
 
 
-    procedure tai_comment.ppuwrite(ppufile:tcompilerppufile);
-      var
-        len : longint;
+{****************************************************************************
+                              TAI_FUNCTION_NAME
+ ****************************************************************************}
+
+    constructor tai_function_name.create(const s:string);
       begin
-        inherited ppuwrite(ppufile);
-        len:=strlen(str);
-        ppufile.putlongint(len);
-        ppufile.putdata(str^,len);
+         inherited create;
+         typ:=ait_function_name;
+         funcname:=stringdup(s);
       end;
 
-
-    function tai_comment.getcopy : tlinkedlistitem;
-      var
-        p : tlinkedlistitem;
+    destructor tai_function_name.destroy;
       begin
-        p:=inherited getcopy;
-        getmem(tai_comment(p).str,strlen(str)+1);
-        move(str^,tai_comment(p).str^,strlen(str)+1);
-        getcopy:=p;
+         stringdispose(funcname);
+         inherited destroy;
       end;
 
 
@@ -2107,12 +2113,14 @@ implementation
           virtual;abstract; to prevent a lot of warnings of unimplemented abstract methods
           when tai_cpu is created (PFV) }
         internalerror(200404091);
+        result:=false;
       end;
 
 
     function tai_cpu_abstract.spilling_get_operation_type(opnr: longint): topertype;
       begin
         internalerror(200404091);
+        result:=operand_readwrite;
       end;
 
 

+ 13 - 191
compiler/aggas.pas

@@ -52,20 +52,12 @@ interface
         function sectionname(atype:tasmsectiontype;const aname:string):string;virtual;
         procedure WriteSection(atype:tasmsectiontype;const aname:string);
         procedure WriteExtraHeader;virtual;
-{$ifdef GDB}
-        procedure WriteFileLineInfo(var fileinfo : tfileposinfo);
-        procedure WriteFileEndInfo;
-{$endif}
         procedure WriteInstruction(hp: tai);  virtual; abstract;
       public
         procedure WriteTree(p:TAAsmoutput);override;
         procedure WriteAsmList;override;
       end;
 
-    const
-      regname_count=45;
-      regname_count_bsstart=32;   { Largest power of 2 out of regname_count. }
-
 
 implementation
 
@@ -73,26 +65,12 @@ implementation
       cutils,globtype,systems,
       fmodule,finput,verbose,
       itcpugas
-{$ifdef GDB}
-{$IFDEF USE_SYSUTILS}
-{$ELSE USE_SYSUTILS}
-      ,strings
-{$ENDIF USE_SYSUTILS}
-      ,gdb
-{$endif GDB}
       ;
 
     const
       line_length = 70;
 
-var
-{$ifdef GDB}
-      n_line       : byte;     { different types of source lines }
-      linecount,
-      includecount : longint;
-      funcname     : pchar;
-      stabslastfileinfo : tfileposinfo;
-{$endif}
+    var
       CurrSecType  : TAsmSectionType; { last section type written }
       lastfileinfo : tfileposinfo;
       infile,
@@ -212,78 +190,6 @@ var
 {                          GNU Assembler writer                              }
 {****************************************************************************}
 
-{$ifdef GDB}
-      procedure TGNUAssembler.WriteFileLineInfo(var fileinfo : tfileposinfo);
-        var
-          curr_n : byte;
-        begin
-          if (CurrSecType<>sec_code) or
-             not ((cs_debuginfo in aktmoduleswitches) or
-                  (cs_gdb_lineinfo in aktglobalswitches)) then
-            exit;
-        { file changed ? (must be before line info) }
-          if (fileinfo.fileindex<>0) and
-             (stabslastfileinfo.fileindex<>fileinfo.fileindex) then
-           begin
-             infile:=current_module.sourcefiles.get_file(fileinfo.fileindex);
-             if assigned(infile) then
-              begin
-                if includecount=0 then
-                 curr_n:=n_sourcefile
-                else
-                 curr_n:=n_includefile;
-                if (infile.path^<>'') then
-                 begin
-                   AsmWriteLn(#9'.stabs "'+BsToSlash(FixPath(infile.path^,false))+'",'+
-                     tostr(curr_n)+',0,0,'+target_asm.labelprefix+'text'+ToStr(IncludeCount));
-                 end;
-                AsmWriteLn(#9'.stabs "'+FixFileName(infile.name^)+'",'+
-                  tostr(curr_n)+',0,0,'+target_asm.labelprefix+'text'+ToStr(IncludeCount));
-                AsmWriteLn(target_asm.labelprefix+'text'+ToStr(IncludeCount)+':');
-                inc(includecount);
-                { force new line info }
-                stabslastfileinfo.line:=-1;
-              end;
-           end;
-        { line changed ? }
-          if (stabslastfileinfo.line<>fileinfo.line) and (fileinfo.line<>0) then
-           begin
-             if (n_line=n_textline) and assigned(funcname) and
-                (target_info.use_function_relative_addresses) then
-              begin
-                AsmWriteLn(target_asm.labelprefix+'l'+tostr(linecount)+':');
-                AsmWrite(#9'.stabn '+tostr(n_line)+',0,'+tostr(fileinfo.line)+','+
-                           target_asm.labelprefix+'l'+tostr(linecount)+' - ');
-                AsmWritePChar(FuncName);
-                AsmLn;
-                inc(linecount);
-              end
-             else
-              AsmWriteLn(#9'.stabd'#9+tostr(n_line)+',0,'+tostr(fileinfo.line));
-           end;
-          stabslastfileinfo:=fileinfo;
-        end;
-
-
-      procedure TGNUAssembler.WriteFileEndInfo;
-        begin
-          if (CurrSecType<>sec_code) or
-             not ((cs_debuginfo in aktmoduleswitches) or
-                  (cs_gdb_lineinfo in aktglobalswitches)) then
-            exit;
-          if (stabslastfileinfo.fileindex<>0) then
-            begin
-              AsmWriteLn(#9'.stabs "",'+tostr(n_sourcefile)+',0,0,'+target_asm.labelprefix+'text'+ToStr(IncludeCount));
-              AsmWriteLn(target_asm.labelprefix+'text'+ToStr(IncludeCount)+':');
-              inc(includecount);
-            end;
-          { force writing all fileinfo }
-          FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
-        end;
-
-{$endif GDB}
-
-
     function TGNUAssembler.sectionname(atype:tasmsectiontype;const aname:string):string;
       const
         secnames : array[tasmsectiontype] of string[12] = ('',
@@ -310,12 +216,6 @@ var
       var
         s : string;
       begin
-{$ifdef GDB}
-        { Maybe write end of section }
-        if currsectype<>sec_none then
-          WriteFileEndInfo;
-{$endif GDB}
-
         AsmLn;
         case target_info.system of
          system_powerpc_darwin, system_i386_OS2, system_i386_EMX: ;
@@ -327,31 +227,11 @@ var
         if atype=sec_fpc then
           AsmWrite(', "a", @progbits');
         AsmLn;
-{$ifdef GDB}
-        { this is needed for line info in data }
-        funcname:=nil;
-        case atype of
-          sec_code :
-            n_line:=n_textline;
-          sec_rodata,
-          sec_data :
-            n_line:=n_dataline;
-          sec_bss  :
-            n_line:=n_bssline;
-          else
-            n_line:=n_dataline;
-        end;
-        { force writing all fileinfo }
-        FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
-{$endif GDB}
         CurrSecType:=atype;
       end;
 
 
     procedure TGNUAssembler.WriteTree(p:TAAsmoutput);
-    const
-      regallocstr : array[tregalloctype] of string[10]=(' allocated',' released',' sync',' resized');
-      tempallocstr : array[boolean] of string[10]=(' released',' allocated');
     var
       ch       : char;
       hp       : tai;
@@ -385,10 +265,6 @@ var
           begin
             hp1 := hp as tailineinfo;
             aktfilepos:=hp1.fileinfo;
-{$ifdef GDB}
-             { maybe write stabs }
-             WriteFileLineInfo(hp1.fileinfo);
-{$endif GDB}
              { no line info for inlined code }
              if do_line and (inlinelevel=0) then
               begin
@@ -458,6 +334,7 @@ var
                      hp:=tai(hp.next);
                      AsmWrite(',');
                    until false;
+                   AsmWrite(' ');
                    AsmWriteLn(regallocstr[tai_regalloc(hp).ratype]);
                  end;
              end;
@@ -473,7 +350,7 @@ var
                    else
 {$endif EXTDEBUG}
                      AsmWriteLn(target_asm.comment+'Temp '+tostr(tai_tempalloc(hp).temppos)+','+
-                       tostr(tai_tempalloc(hp).tempsize)+tempallocstr[tai_tempalloc(hp).allocation]);
+                       tostr(tai_tempalloc(hp).tempsize)+' '+tempallocstr[tai_tempalloc(hp).allocation]);
                  end;
              end;
 
@@ -502,17 +379,12 @@ var
            ait_section :
              begin
                if tai_section(hp).sectype<>sec_none then
-                begin
-                  WriteSection(tai_section(hp).sectype,tai_section(hp).name^);
-{$ifdef GDB}
-                  lastfileinfo.line:=-1;
-{$endif GDB}
-                end
+                 WriteSection(tai_section(hp).sectype,tai_section(hp).name^)
                else
-                begin
+                 begin
 {$ifdef EXTDEBUG}
-                  AsmWrite(target_asm.comment);
-                  AsmWriteln(' sec_none');
+                   AsmWrite(target_asm.comment);
+                   AsmWriteln(' sec_none');
 {$endif EXTDEBUG}
                 end;
              end;
@@ -730,20 +602,6 @@ var
                AsmLn;
              end;
 
-           ait_direct :
-             begin
-               AsmWritePChar(tai_direct(hp).str);
-               AsmLn;
-{$IfDef GDB}
-               if strpos(tai_direct(hp).str,'.data')<>nil then
-                 n_line:=n_dataline
-               else if strpos(tai_direct(hp).str,'.text')<>nil then
-                 n_line:=n_textline
-               else if strpos(tai_direct(hp).str,'.bss')<>nil then
-                 n_line:=n_bssline;
-{$endif GDB}
-             end;
-
            ait_string :
              begin
                pos:=0;
@@ -850,33 +708,18 @@ var
                WriteInstruction(hp);
              end;
 
-{$ifdef GDB}
-           ait_stabs :
-             begin
-               if assigned(tai_stabs(hp).str) then
-                 begin
-                   AsmWrite(#9'.stabs ');
-                   AsmWritePChar(tai_stabs(hp).str);
-                   AsmLn;
-                 end;
-             end;
-
-           ait_stabn :
+           ait_stab :
              begin
-               if assigned(tai_stabn(hp).str) then
+               if assigned(tai_stab(hp).str) then
                  begin
-                   AsmWrite(#9'.stabn ');
-                   AsmWritePChar(tai_stabn(hp).str);
+                   AsmWrite(#9'.'+stabtypestr[tai_stab(hp).stabtype]+' ');
+                   AsmWritePChar(tai_stab(hp).str);
                    AsmLn;
                  end;
              end;
 
-           ait_force_line :
-             stabslastfileinfo.line:=0;
-
-           ait_stab_function_name:
-             funcname:=tai_stab_function_name(hp).str;
-{$endif GDB}
+           ait_force_line,
+           ait_function_name : ;
 
            ait_cutobject :
              begin
@@ -898,13 +741,6 @@ var
                        CurrSecType:=tai_section(hp.next).sectype;
                      hp:=tai(hp.next);
                    end;
-{$ifdef GDB}
-                  { force write of filename }
-                  FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
-                  includecount:=0;
-                  funcname:=nil;
-                  WriteFileLineInfo(aktfilepos);
-{$endif GDB}
                   if CurrSecType<>sec_none then
                     WriteSection(CurrSecType,'');
                   AsmStartSize:=AsmSize;
@@ -946,9 +782,6 @@ var
 {$endif}
 
       CurrSecType:=sec_none;
-{$ifdef GDB}
-      FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
-{$endif GDB}
       FillChar(lastfileinfo,sizeof(lastfileinfo),0);
       LastInfile:=nil;
 
@@ -971,12 +804,6 @@ var
     { to get symify to work }
       AsmWriteLn(#9'.file "'+FixFileName(n+e)+'"');
       WriteExtraHeader;
-{$ifdef GDB}
-      n_line:=n_bssline;
-      funcname:=nil;
-      linecount:=1;
-      includecount:=0;
-{$endif GDB}
       AsmStartSize:=AsmSize;
       symendcount:=0;
 
@@ -987,11 +814,6 @@ var
           AsmWriteLn(target_asm.comment+'End asmlist '+TasmlistStr[hal]);
         end;
 
-      {$ifdef GDB}
-      if CurrSecType<>sec_none then
-        WriteFileEndInfo;
-      {$ENDIF}
-
       AsmLn;
 {$ifdef EXTDEBUG}
       if assigned(current_module.mainsource) then

+ 1 - 3
compiler/aoptda.pas

@@ -97,9 +97,7 @@ Unit aoptda;
             ait_label:
               If (Pai_label(p)^.l^.is_used) Then
                 CurProp^.DestroyAllRegs(InstrSinceLastMod);
-    {$ifdef GDB}
-            ait_stabs, ait_stabn, ait_stab_function_name:;
-    {$endif GDB}
+            ait_stab, ait_force_line, ait_function_name:;
             ait_instruction:
               if not(PInstr(p)^.is_jmp) then
                 begin

+ 2 - 2
compiler/aoptobj.pas

@@ -877,7 +877,7 @@ Unit AoptObj;
 {$define rangewason}
 {$r-}
 {$endif}
-    function tAOptObj.getlabelwithsym(sym: tasmlabel): tai;
+    function tAOptObj.getjumplabelwithsym(sym: tasmlabel): tai;
       begin
         if (sym.labelnr >= labelinfo^.lowlabel) and
            (sym.labelnr <= labelinfo^.highlabel) then   { range check, a jump can go past an assembler block! }
@@ -957,7 +957,7 @@ Unit AoptObj;
                       insertllitem(asml,p1,p1.next,tai_comment.Create(
                         strpnew('previous label inserted'))));
       {$endif finaldestdebug}
-                      objectlibrary.getlabel(l);
+                      objectlibrary.getjumplabel(l);
                       insertllitem(p1,p1.next,tai_label.Create(l));
                       tasmlabel(taicpu(hp).oper[0]^.ref^.symbol).decrefs;
                       hp.oper[0]^.ref^.symbol := l;

+ 1 - 1
compiler/arm/aasmcpu.pas

@@ -667,7 +667,7 @@ implementation
               begin
                 lastpos:=curpos;
                 hp:=tai(curtai.next);
-                objectlibrary.getlabel(l);
+                objectlibrary.getjumplabel(l);
                 curdata.insert(taicpu.op_sym(A_B,l));
                 curdata.concat(tai_label.create(l));
                 list.insertlistafter(curtai,curdata);

+ 5 - 5
compiler/arm/cgcpu.pas

@@ -560,7 +560,7 @@ unit cgcpu;
             begin
                reference_reset(hr);
 
-               objectlibrary.getlabel(l);
+               objectlibrary.getjumplabel(l);
                cg.a_label(current_procinfo.aktlocaldata,l);
                hr.symboldata:=current_procinfo.aktlocaldata.last;
                current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(longint(a)));
@@ -624,7 +624,7 @@ unit cgcpu;
             tmpreg:=getintregister(list,OS_INT);
             if assigned(ref.symbol) then
               begin
-                objectlibrary.getlabel(l);
+                objectlibrary.getjumplabel(l);
                 cg.a_label(current_procinfo.aktlocaldata,l);
                 tmpref.symboldata:=current_procinfo.aktlocaldata.last;
 
@@ -1157,7 +1157,7 @@ unit cgcpu;
         }
         { create consts entry }
         reference_reset(tmpref);
-        objectlibrary.getlabel(l);
+        objectlibrary.getjumplabel(l);
         cg.a_label(current_procinfo.aktlocaldata,l);
         tmpref.symboldata:=current_procinfo.aktlocaldata.last;
 
@@ -1239,7 +1239,7 @@ unit cgcpu;
         var
           l : tasmlabel;
         begin
-          objectlibrary.getlabel(l);
+          objectlibrary.getjumplabel(l);
           a_load_const_reg(list,OS_INT,count,countreg);
           cg.a_label(list,l);
           srcref.addressmode:=AM_POSTINDEXED;
@@ -1357,7 +1357,7 @@ unit cgcpu;
       begin
         if not(cs_check_overflow in aktlocalswitches) then
           exit;
-        objectlibrary.getlabel(hl);
+        objectlibrary.getjumplabel(hl);
         case ovloc.loc of
           LOC_VOID:
             begin

+ 3 - 3
compiler/arm/narmcnv.pas

@@ -172,8 +172,8 @@ implementation
       begin
          oldtruelabel:=truelabel;
          oldfalselabel:=falselabel;
-         objectlibrary.getlabel(truelabel);
-         objectlibrary.getlabel(falselabel);
+         objectlibrary.getjumplabel(truelabel);
+         objectlibrary.getjumplabel(falselabel);
          secondpass(left);
          if codegenerror then
           exit;
@@ -237,7 +237,7 @@ implementation
             LOC_JUMP :
               begin
                 hregister:=cg.getintregister(exprasmlist,OS_INT);
-                objectlibrary.getlabel(hlabel);
+                objectlibrary.getjumplabel(hlabel);
                 cg.a_label(exprasmlist,truelabel);
                 cg.a_load_const_reg(exprasmlist,OS_INT,1,hregister);
                 cg.a_jmp_always(exprasmlist,hlabel);

+ 2 - 2
compiler/arm/rgcpu.pas

@@ -64,7 +64,7 @@ unit rgcpu;
             helplist:=taasmoutput.create;
             reference_reset(tmpref);
             { create consts entry }
-            objectlibrary.getlabel(l);
+            objectlibrary.getjumplabel(l);
             cg.a_label(current_procinfo.aktlocaldata,l);
             tmpref.symboldata:=current_procinfo.aktlocaldata.last;
 
@@ -112,7 +112,7 @@ unit rgcpu;
             helplist:=taasmoutput.create;
             reference_reset(tmpref);
             { create consts entry }
-            objectlibrary.getlabel(l);
+            objectlibrary.getjumplabel(l);
             cg.a_label(current_procinfo.aktlocaldata,l);
             tmpref.symboldata:=current_procinfo.aktlocaldata.last;
 

+ 196 - 413
compiler/assemble.pas

@@ -143,19 +143,7 @@ interface
         currlistidx  : byte;
         currlist     : TAAsmoutput;
         currpass     : byte;
-{$ifdef GDB}
-        n_line       : byte;     { different types of source lines }
-        linecount,
-        includecount : longint;
-        funcname     : tasmsymbol;
-        stabslastfileinfo : tfileposinfo;
-        procedure convertstabs(p:pchar);
-        procedure emitlineinfostabs(nidx,line : longint);
-        procedure emitstabs(s:string);
-        procedure WriteFileLineInfo(var fileinfo : tfileposinfo);
-        procedure StartFileLineInfo;
-        procedure EndFileLineInfo;
-{$endif}
+        procedure convertstab(p:pchar);
         function  MaybeNextList(var hp:Tai):boolean;
         function  TreePass0(hp:Tai):Tai;
         function  TreePass1(hp:Tai):Tai;
@@ -188,10 +176,6 @@ Implementation
 {$ifdef memdebug}
       cclasses,
 {$endif memdebug}
-{$ifdef GDB}
-      finput,
-      gdb,
-{$endif GDB}
 {$ifdef m68k}
       cpuinfo,
 {$endif m68k}
@@ -694,273 +678,203 @@ Implementation
       end;
 
 
-{$ifdef GDB}
-    procedure TInternalAssembler.convertstabs(p:pchar);
-      var
-        ofs,
-        nidx,nother,ii,i,line,j : longint;
-        code : integer;
-        hp : pchar;
-        reloc : boolean;
-        ps : tasmsymbol;
-        s : string;
-      begin
-        ofs:=0;
-        reloc:=true;
-        ps:=nil;
-        if p[0]='"' then
-         begin
-           i:=1;
-           { we can have \" inside the string !! PM }
-           while not ((p[i]='"') and (p[i-1]<>'\')) do
-            inc(i);
-           p[i]:=#0;
-           ii:=i;
-           hp:=@p[1];
-           s:=StrPas(@P[i+2]);
-         end
-        else
-         begin
-           hp:=nil;
-           s:=StrPas(P);
-           i:=-2; {needed below (PM) }
-         end;
-      { When in pass 1 then only alloc and leave }
-        if currpass=1 then
-         begin
-           objectdata.allocstabs(hp);
-           if assigned(hp) then
-            p[i]:='"';
-           exit;
-         end;
-      { Parse the rest of the stabs }
-        if s='' then
-         internalerror(33000);
-        j:=pos(',',s);
-        if j=0 then
-         internalerror(33001);
-        Val(Copy(s,1,j-1),nidx,code);
-        if code<>0 then
-         internalerror(33002);
-        i:=i+2+j;
-        Delete(s,1,j);
-        j:=pos(',',s);
-        if (j=0) then
-         internalerror(33003);
-        Val(Copy(s,1,j-1),nother,code);
-        if code<>0 then
-         internalerror(33004);
-        i:=i+j;
-        Delete(s,1,j);
-        j:=pos(',',s);
-        if j=0 then
-         begin
-           j:=256;
-           ofs:=-1;
-         end;
-        Val(Copy(s,1,j-1),line,code);
-        if code<>0 then
-          internalerror(33005);
-        if ofs=0 then
-          begin
-            Delete(s,1,j);
-            i:=i+j;
-            Val(s,ofs,code);
-            if code=0 then
-              reloc:=false
-            else
-              begin
-                ofs:=0;
-                s:=strpas(@p[i]);
-                { handle asmsymbol or
-                    asmsymbol - asmsymbol }
-                j:=pos(' ',s);
-                if j=0 then
-                  j:=pos('-',s);
-                { also try to handle
-                  asmsymbol + constant
-                  or
-                  asmsymbol - constant }
-                if j=0 then
-                  j:=pos('+',s);
-
-                if j<>0 then
-                  begin
-                    Val(Copy(s,j+1,255),ofs,code);
-                    if code<>0 then
-                      ofs:=0
-                    else
-                    { constant reading successful,
-                      avoid further treatment by
-                      setting s[j] to '+' }
-                      s[j]:='+';
-                  end
-                else
-                { single asmsymbol }
-                  j:=256;
-                { the symbol can be external
-                  so we must use newasmsymbol and
-                  not getasmsymbol !! PM }
-                ps:=objectlibrary.newasmsymbol(copy(s,1,j-1),AB_EXTERNAL,AT_NONE);
-                if not assigned(ps) then
-                  internalerror(33006)
-                else
-                  begin
-                    ofs:=ofs+ps.address;
-                    reloc:=true;
-                    objectlibrary.UsedAsmSymbolListInsert(ps);
-                  end;
-                if (j<256) and (s[j]<>'+') then
-                  begin
-                    i:=i+j;
-                    s:=strpas(@p[i]);
-                    if (s<>'') and (s[1]=' ') then
-                      begin
-                         j:=0;
-                         while (s[j+1]=' ') do
-                           inc(j);
-                         i:=i+j;
-                         s:=strpas(@p[i]);
-                      end;
-                    ps:=objectlibrary.getasmsymbol(s);
-                    if not assigned(ps) then
-                      internalerror(33007)
-                    else
-                      begin
-                        if ps.section<>objectdata.currsec then
-                          internalerror(33008);
-                        ofs:=ofs-ps.address;
-                        reloc:=false;
-                        objectlibrary.UsedAsmSymbolListInsert(ps);
-                      end;
-                  end;
-              end;
-          end;
-        { External references (AB_EXTERNAL and AB_COMMON) need a symbol relocation }
-        if assigned(ps) and (ps.currbind in [AB_EXTERNAL,AB_COMMON]) then
-          begin
-            if currpass=2 then
-              begin
-                objectdata.writesymbol(ps);
-                objectoutput.exportsymbol(ps);
-              end;
-            objectdata.writeSymStabs(ofs,hp,ps,nidx,nother,line,reloc)
-          end
-        else
-          objectdata.writeStabs(ofs,hp,nidx,nother,line,reloc);
-        if assigned(hp) then
-         p[ii]:='"';
-      end;
-
+    procedure TInternalAssembler.convertstab(p:pchar);
 
-    procedure TInternalAssembler.emitlineinfostabs(nidx,line : longint);
-      begin
-        if currpass=1 then
-          begin
-            objectdata.allocstabs(nil);
-            exit;
-          end;
-
-        if (nidx=n_textline) and assigned(funcname) and
-           (target_info.use_function_relative_addresses) then
-          objectdata.writeStabs(objectdata.currsec.datasize-funcname.address,nil,nidx,0,line,false)
-        else
-          objectdata.writeStabs(objectdata.currsec.datasize,nil,nidx,0,line,true);
-      end;
-
-
-    procedure TInternalAssembler.emitstabs(s:string);
-      begin
-        s:=s+#0;
-        ConvertStabs(@s[1]);
-      end;
-
-
-    procedure TInternalAssembler.WriteFileLineInfo(var fileinfo : tfileposinfo);
-      var
-        curr_n : byte;
-        hp : tasmsymbol;
-        infile : tinputfile;
-      begin
-        if (objectdata.currsec.sectype<>sec_code) or
-           not ((cs_debuginfo in aktmoduleswitches) or
-           (cs_gdb_lineinfo in aktglobalswitches)) then
-         exit;
+        function consumecomma(var p:pchar):boolean;
+        begin
+          while (p^=' ') do
+            inc(p);
+          result:=(p^=',');
+          inc(p);
+        end;
 
-        { file changed ? (must be before line info) }
-        if (fileinfo.fileindex<>0) and
-           (stabslastfileinfo.fileindex<>fileinfo.fileindex) then
-         begin
-           infile:=current_module.sourcefiles.get_file(fileinfo.fileindex);
-           if assigned(infile) then
+        function consumenumber(var p:pchar;out value:longint):boolean;
+        var
+          hs : string;
+          len,
+          code : integer;
+        begin
+          value:=0;
+          while (p^=' ') do
+            inc(p);
+          len:=0;
+          while (p^ in ['0'..'9']) do
             begin
-              if includecount=0 then
-               curr_n:=n_sourcefile
-              else
-               curr_n:=n_includefile;
-              { get symbol for this includefile }
-              hp:=objectlibrary.newasmsymbol('Ltext'+ToStr(IncludeCount),AB_LOCAL,AT_FUNCTION);
-              if currpass=1 then
+              inc(len);
+              hs[len]:=p^;
+              inc(p);
+            end;
+          if len>0 then
+            begin
+              hs[0]:=chr(len);
+              val(hs,value,code);
+            end
+          else
+            code:=-1;
+          result:=(code=0);
+        end;
+
+        function consumeoffset(var p:pchar;out relocsym:tasmsymbol;out value:longint):boolean;
+        var
+          hs        : string;
+          len,
+          code      : integer;
+          pstart    : pchar;
+          sym       : tasmsymbol;
+          exprvalue : longint;
+          gotmin,
+          dosub     : boolean;
+        begin
+          result:=false;
+          value:=0;
+          relocsym:=nil;
+          gotmin:=false;
+          repeat
+            dosub:=false;
+            exprvalue:=0;
+            if gotmin then
+              begin
+                dosub:=true;
+                gotmin:=false;
+              end;
+            while (p^=' ') do
+              inc(p);
+            case p^ of
+              #0 :
+                break; 
+              ' ' :
+                inc(p);
+              '0'..'9' :
                 begin
-                  objectdata.allocsymbol(currpass,hp,0);
-                  objectlibrary.UsedAsmSymbolListInsert(hp);
-                end
+                  len:=0;
+                  while (p^ in ['0'..'9']) do
+                    begin
+                      inc(len);
+                      hs[len]:=p^;
+                      inc(p);
+                    end;
+                  hs[0]:=chr(len);
+                  val(hs,exprvalue,code);
+                end;
+              '.','_',
+              'A'..'Z',
+              'a'..'z' :
+                begin
+                  pstart:=p;
+                  while not(p^ in [#0,' ','-','+']) do
+                    inc(p);
+                  len:=p-pstart;
+                  if len>255 then
+                    internalerror(200509187);
+                  move(pstart^,hs[1],len);
+                  hs[0]:=chr(len);
+                  sym:=objectlibrary.newasmsymbol(hs,AB_EXTERNAL,AT_NONE);
+                  if not assigned(sym) then
+                    internalerror(200509188);
+                  objectlibrary.UsedAsmSymbolListInsert(sym);
+                  { Second symbol? }
+                  if assigned(relocsym) then
+                    begin
+                      if (relocsym.section<>sym.section) then
+                        internalerror(2005091810);
+                      relocsym:=nil; 
+                    end
+                  else
+                    begin
+                      relocsym:=sym;
+                    end; 
+                  exprvalue:=sym.address;
+                end;
+              '+' :
+                begin
+                  { nothing, by default addition is done }
+                  inc(p);
+                end;  
+              '-' :
+                begin
+                  gotmin:=true;
+                  inc(p);
+                end;  
               else
-                objectdata.writesymbol(hp);
-              { emit stabs }
-              if (infile.path^<>'') then
-                EmitStabs('"'+BsToSlash(FixPath(infile.path^,false))+'",'+tostr(curr_n)+
-                          ',0,0,Ltext'+ToStr(IncludeCount));
-              EmitStabs('"'+FixFileName(infile.name^)+'",'+tostr(curr_n)+
-                        ',0,0,Ltext'+ToStr(IncludeCount));
-              inc(includecount);
-              { force new line info }
-              stabslastfileinfo.line:=-1;
+                internalerror(200509189);
             end;
-         end;
-
-        { line changed ? }
-        if (stabslastfileinfo.line<>fileinfo.line) and (fileinfo.line<>0) then
-          emitlineinfostabs(n_line,fileinfo.line);
-        stabslastfileinfo:=fileinfo;
-      end;
-
+            if dosub then
+              dec(value,exprvalue)
+            else
+              inc(value,exprvalue);
+          until false;
+          result:=true;
+        end;
 
-    procedure TInternalAssembler.StartFileLineInfo;
       var
-        fileinfo : tfileposinfo;
+        ofs,
+        nline,
+        nidx,
+        nother,
+        i         : longint;
+        relocsym  : tasmsymbol;
+        pstr,
+        pcurr,
+        pendquote : pchar;
       begin
-        FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
-        n_line:=n_bssline;
-        funcname:=nil;
-        linecount:=1;
-        includecount:=0;
-        fileinfo.fileindex:=1;
-        fileinfo.line:=0;
-        WriteFileLineInfo(fileinfo);
-      end;
-
+        pcurr:=nil;
+        pstr:=nil;
+        pendquote:=nil;
 
-    procedure TInternalAssembler.EndFileLineInfo;
-      var
-        hp : tasmsymbol;
-      begin
-        if (objectdata.currsec.sectype<>sec_code) or
-           not ((cs_debuginfo in aktmoduleswitches) or
-                (cs_gdb_lineinfo in aktglobalswitches)) then
-           exit;
-        hp:=objectlibrary.newasmsymbol('Ltext'+ToStr(IncludeCount),AB_LOCAL,AT_FUNCTION);
-        if currpass=1 then
+        { Parse string part }
+        if p[0]='"' then
           begin
-            objectdata.allocsymbol(currpass,hp,0);
-            objectlibrary.UsedAsmSymbolListInsert(hp);
+            pstr:=@p[1];
+            { Ignore \" inside the string }
+            i:=1;
+            while not((p[i]='"') and (p[i-1]<>'\')) and
+                  (p[i]<>#0) do
+              inc(i);
+            pendquote:=@p[i];
+            pendquote^:=#0;
+            pcurr:=@p[i+1];
+            if not consumecomma(pcurr) then
+              internalerror(200509181);
           end
         else
-          objectdata.writesymbol(hp);
-        EmitStabs('"",'+tostr(n_sourcefile)+',0,0,Ltext'+ToStr(IncludeCount));
-        inc(IncludeCount);
+          pcurr:=p;
+
+        { When in pass 1 then only alloc and leave }
+        if currpass=1 then
+          objectdata.allocstab(pstr)
+        else
+          begin  
+            { Stabs format: nidx,nother,nline[,offset] }
+            if not consumenumber(pcurr,nidx) then
+              internalerror(200509182);
+            if not consumecomma(pcurr) then
+              internalerror(200509183);
+            if not consumenumber(pcurr,nother) then
+              internalerror(200509184);
+            if not consumecomma(pcurr) then
+              internalerror(200509185);
+            if not consumenumber(pcurr,nline) then
+              internalerror(200509186);
+            if consumecomma(pcurr) then
+              consumeoffset(pcurr,relocsym,ofs)
+            else
+              begin
+                ofs:=0;
+                relocsym:=nil;
+              end;
+            { External references (AB_EXTERNAL and AB_COMMON) need a symbol relocation }
+            if assigned(relocsym) then
+              begin
+                objectdata.writesymbol(relocsym);
+                objectoutput.exportsymbol(relocsym);
+                objectdata.writeSymStabs(ofs,pstr,relocsym,nidx,nother,nline,true);
+              end
+            else
+              objectdata.writeStabs(ofs,pstr,nidx,nother,nline,false);
+          end;
+        if assigned(pendquote) then
+          pendquote^:='"';
       end;
-{$endif GDB}
 
 
     function TInternalAssembler.MaybeNextList(var hp:Tai):boolean;
@@ -1067,17 +981,6 @@ Implementation
         inlinelevel:=0;
         while assigned(hp) do
          begin
-{$ifdef GDB}
-           { write stabs, no line info for inlined code }
-           if (inlinelevel=0) and
-              ((cs_debuginfo in aktmoduleswitches) or
-               (cs_gdb_lineinfo in aktglobalswitches)) then
-            begin
-              if (objectdata.currsec<>nil) and
-                 not(hp.typ in SkipLineInfo) then
-               WriteFileLineInfo(tailineinfo(hp).fileinfo);
-            end;
-{$endif GDB}
            case hp.typ of
              ait_align :
                begin
@@ -1130,50 +1033,16 @@ Implementation
                end;
              ait_section:
                begin
-{$ifdef GDB}
-//                 emitlineinfostabs(n_line,0);
-{$endif GDB}
                  { use cached value }
                  objectdata.setsection(Tai_section(hp).sec);
-{$ifdef GDB}
-                 case Tai_section(hp).sectype of
-                   sec_code :
-                     n_line:=n_textline;
-                   sec_data :
-                     n_line:=n_dataline;
-                   sec_bss :
-                     n_line:=n_bssline;
-                   else
-                     n_line:=n_dataline;
-                 end;
-                 { force writing all fileinfo }
-                 FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
-{$endif GDB}
-               end;
-{$ifdef GDB}
-             ait_stabn :
-               begin
-                 if assigned(Tai_stabn(hp).str) then
-                   convertstabs(Tai_stabn(hp).str);
-               end;
-             ait_stabs :
-               begin
-                 if assigned(Tai_stabs(hp).str) then
-                   convertstabs(Tai_stabs(hp).str);
                end;
-             ait_stab_function_name :
+             ait_stab :
                begin
-                 if assigned(Tai_stab_function_name(hp).str) then
-                  begin
-                    funcname:=objectlibrary.getasmsymbol(strpas(Tai_stab_function_name(hp).str));
-                    objectlibrary.UsedAsmSymbolListInsert(funcname);
-                  end
-                 else
-                  funcname:=nil;
+                 if assigned(Tai_stab(hp).str) then
+                   convertstab(Tai_stab(hp).str);
                end;
-             ait_force_line :
-               stabslastfileinfo.line:=0;
-{$endif}
+             ait_function_name,
+             ait_force_line : ;
              ait_symbol :
                begin
                  objectdata.allocsymbol(currpass,Tai_symbol(hp).sym,0);
@@ -1196,8 +1065,6 @@ Implementation
                objectdata.alloc(Tai_string(hp).len);
              ait_instruction :
                begin
-{$ifdef i386}
-{$ifndef NOAG386BIN}
                  objectdata.alloc(Taicpu(hp).Pass1(objectdata.currsec.datasize));
                  { fixup the references }
                  for i:=1 to Taicpu(hp).ops do
@@ -1215,30 +1082,7 @@ Implementation
                        end;
                      end;
                   end;
-{$endif NOAG386BIN}
-{$endif i386}
-{$ifdef arm}
-                 objectdata.alloc(Taicpu(hp).Pass1(objectdata.currsec.datasize));
-                 { fixup the references }
-                 for i:=1 to Taicpu(hp).ops do
-                  begin
-                    with Taicpu(hp).oper[i-1]^ do
-                     begin
-                       case typ of
-                         top_ref :
-                           begin
-                             if assigned(ref^.symbol) then
-                              objectlibrary.UsedAsmSymbolListInsert(ref^.symbol);
-                             if assigned(ref^.relsymbol) then
-                              objectlibrary.UsedAsmSymbolListInsert(ref^.symbol);
-                           end;
-                       end;
-                     end;
-                  end;
-{$endif arm}
                end;
-             ait_direct :
-               Message(asmw_f_direct_not_supported);
              ait_cutobject :
                if SmartAsm then
                 break;
@@ -1268,17 +1112,6 @@ Implementation
         { main loop }
         while assigned(hp) do
          begin
-{$ifdef GDB}
-           { write stabs, no line info for inlined code }
-           if (inlinelevel=0) and
-              ((cs_debuginfo in aktmoduleswitches) or
-               (cs_gdb_lineinfo in aktglobalswitches)) then
-            begin
-              if (objectdata.currsec<>nil) and
-                 not(hp.typ in SkipLineInfo) then
-               WriteFileLineInfo(tailineinfo(hp).fileinfo);
-            end;
-{$endif GDB}
            case hp.typ of
              ait_align :
                begin
@@ -1289,22 +1122,8 @@ Implementation
                end;
              ait_section :
                begin
-{$ifdef GDB}
-//                 emitlineinfostabs(n_line,0);
-{$endif GDB}
                  { use cached value }
                  objectdata.setsection(Tai_section(hp).sec);
-{$ifdef GDB}
-                 case Tai_section(hp).sectype of
-                  sec_code : n_line:=n_textline;
-                  sec_data : n_line:=n_dataline;
-                   sec_bss : n_line:=n_bssline;
-                 else
-                  n_line:=n_dataline;
-                 end;
-                 { force writing all fileinfo }
-                 FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
-{$endif GDB}
                end;
              ait_symbol :
                begin
@@ -1331,11 +1150,7 @@ Implementation
              ait_comp_64bit :
                begin
 {$ifdef x86}
-{$ifdef FPC}
                  co:=comp(Tai_comp_64bit(hp).value);
-{$else}
-                 co:=Tai_comp_64bit(hp).value;
-{$endif}
                  objectdata.writebytes(co,8);
 {$endif x86}
                end;
@@ -1356,7 +1171,8 @@ Implementation
                          objectdata.writebytes(v,tai_const(hp).size);
                        end
                      else
-                       objectdata.writereloc(Tai_const(hp).value,Tai_const(hp).size,Tai_const(hp).sym,RELOC_ABSOLUTE);
+                       objectdata.writereloc(Tai_const(hp).value,Tai_const(hp).size,
+                                             Tai_const(hp).sym,RELOC_ABSOLUTE);
                    end
                  else
                    objectdata.writebytes(Tai_const(hp).value,tai_const(hp).size);
@@ -1372,19 +1188,10 @@ Implementation
                end;
              ait_instruction :
                Taicpu(hp).Pass2(objectdata);
-{$ifdef GDB}
-             ait_stabn :
-               convertstabs(Tai_stabn(hp).str);
-             ait_stabs :
-               convertstabs(Tai_stabs(hp).str);
-             ait_stab_function_name :
-               if assigned(Tai_stab_function_name(hp).str) then
-                 funcname:=objectlibrary.getasmsymbol(strpas(Tai_stab_function_name(hp).str))
-               else
-                 funcname:=nil;
-             ait_force_line :
-               stabslastfileinfo.line:=0;
-{$endif}
+             ait_stab :
+               convertstab(Tai_stab(hp).str);
+             ait_function_name,
+             ait_force_line : ;
              ait_cutobject :
                if SmartAsm then
                 break;
@@ -1433,9 +1240,6 @@ Implementation
         objectdata.resetsections;
         objectdata.beforealloc;
         objectdata.createsection(sec_code,'',0,[]);
-{$ifdef GDB}
-        StartFileLineInfo;
-{$endif GDB}
         { start with list 1 }
         currlistidx:=1;
         currlist:=list[currlistidx];
@@ -1446,9 +1250,6 @@ Implementation
            MaybeNextList(hp);
          end;
         objectdata.createsection(sec_code,'',0,[]);
-{$ifdef GDB}
-        EndFileLineInfo;
-{$endif GDB}
         objectdata.afteralloc;
         { check for undefined labels and reset }
         objectlibrary.UsedAsmSymbolListCheckUndefined;
@@ -1462,9 +1263,6 @@ Implementation
         objectdata.resetsections;
         objectdata.beforewrite;
         objectdata.createsection(sec_code,'',0,[]);
-{$ifdef GDB}
-        StartFileLineInfo;
-{$endif GDB}
         { start with list 1 }
         currlistidx:=1;
         currlist:=list[currlistidx];
@@ -1475,9 +1273,6 @@ Implementation
            MaybeNextList(hp);
          end;
         objectdata.createsection(sec_code,'',0,[]);
-{$ifdef GDB}
-        EndFileLineInfo;
-{$endif GDB}
         objectdata.afterwrite;
 
         { don't write the .o file if errors have occured }
@@ -1533,13 +1328,7 @@ Implementation
            objectdata.resetsections;
            objectdata.beforealloc;
            objectdata.createsection(startsectype,'',0,[]);
-{$ifdef GDB}
-           StartFileLineInfo;
-{$endif GDB}
            TreePass1(hp);
-{$ifdef GDB}
-           EndFileLineInfo;
-{$endif GDB}
            objectdata.afteralloc;
            { check for undefined labels }
            objectlibrary.UsedAsmSymbolListCheckUndefined;
@@ -1554,16 +1343,10 @@ Implementation
            objectdata.resetsections;
            objectdata.beforewrite;
            objectdata.createsection(startsectype,'',0,[]);
-{$ifdef GDB}
-           StartFileLineInfo;
-{$endif GDB}
            hp:=TreePass2(hp);
            { save section type for next loop, must be done before EndFileLineInfo
              because that changes the section to sec_code }
            startsectype:=objectdata.currsec.sectype;
-{$ifdef GDB}
-           EndFileLineInfo;
-{$endif GDB}
            objectdata.afterwrite;
            { leave if errors have occured }
            if errorcount>0 then
@@ -1629,7 +1412,7 @@ Implementation
       begin
         to_do:=[low(Tasmlist)..high(Tasmlist)];
         if not(cs_debuginfo in aktmoduleswitches) then
-          exclude(to_do,al_typestabs);
+          exclude(to_do,al_debugtypes);
         if usedeffileforexports then
           exclude(to_do,al_exports);
         {$warning TODO internal writer support for dwarf}

+ 5 - 5
compiler/cg64f32.pas

@@ -589,7 +589,7 @@ unit cg64f32;
                  hreg:=cg.getintregister(list,OS_32);
                  a_load64high_ref_reg(list,l.reference,hreg);
                end;
-             objectlibrary.getlabel(poslabel);
+             objectlibrary.getjumplabel(poslabel);
 
              { check high dword, must be 0 (for positive numbers) }
              cg.a_cmp_const_reg_label(list,OS_32,OC_EQ,0,hreg,poslabel);
@@ -597,7 +597,7 @@ unit cg64f32;
              { It can also be $ffffffff, but only for negative numbers }
              if from_signed and to_signed then
                begin
-                 objectlibrary.getlabel(neglabel);
+                 objectlibrary.getjumplabel(neglabel);
                  cg.a_cmp_const_reg_label(list,OS_32,OC_EQ,-1,hreg,neglabel);
                end;
              { For all other values we have a range check error }
@@ -620,7 +620,7 @@ unit cg64f32;
 
              if from_signed and to_signed then
                begin
-                 objectlibrary.getlabel(endlabel);
+                 objectlibrary.getjumplabel(endlabel);
                  cg.a_jmp_always(list,endlabel);
                  { if the high dword = $ffffffff, then the low dword (when }
                  { considered as a longint) must be < 0                    }
@@ -635,7 +635,7 @@ unit cg64f32;
                      a_load64low_ref_reg(list,l.reference,hreg);
                    end;
                  { get a new neglabel (JM) }
-                 objectlibrary.getlabel(neglabel);
+                 objectlibrary.getjumplabel(neglabel);
                  cg.a_cmp_const_reg_label(list,OS_32,OC_LT,0,hreg,neglabel);
 
                  cg.a_call_name(list,'FPC_RANGEERROR');
@@ -687,7 +687,7 @@ unit cg64f32;
                    else
                      cg.a_load_ref_reg(list,opsize,OS_32,l.reference,hreg);
                  end;
-               objectlibrary.getlabel(poslabel);
+               objectlibrary.getjumplabel(poslabel);
                cg.a_cmp_const_reg_label(list,opsize,OC_GTE,0,hreg,poslabel);
 
                cg.a_call_name(list,'FPC_RANGEERROR');

+ 2 - 2
compiler/cgobj.pas

@@ -1736,7 +1736,7 @@ implementation
         hreg:=getintregister(list,OS_INT);
         a_load_loc_reg(list,OS_INT,l,hreg);
         a_op_const_reg(list,OP_SUB,OS_INT,aint(lto),hreg);
-        objectlibrary.getlabel(neglabel);
+        objectlibrary.getjumplabel(neglabel);
         {
         if from_signed then
           a_cmp_const_reg_label(list,OS_INT,OC_GTE,aint(hto-lto),hreg,neglabel)
@@ -1778,7 +1778,7 @@ implementation
         if (cs_check_object in aktlocalswitches) or
            (cs_check_range in aktlocalswitches) then
          begin
-           objectlibrary.getlabel(oklabel);
+           objectlibrary.getjumplabel(oklabel);
            a_cmp_const_reg_label(list,OS_ADDR,OC_NE,0,reg,oklabel);
            cgpara1.init;
            paramanager.getintparaloc(pocall_default,1,cgpara1);

+ 23 - 23
compiler/cresstr.pas

@@ -1,7 +1,7 @@
 {
     Copyright (c) 1998-2002 by Michael van Canneyt
 
-    Handles al_resourcestrings
+    Handles resourcestrings
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@ Type
     procedure CalcHash;
   end;
 
-  Tal_resourcestrings=class
+  Tresourcestrings=class
   private
     List : TLinkedList;
   public
@@ -53,7 +53,7 @@ Type
   end;
 
 var
-  al_resourcestrings : Tal_resourcestrings;
+  resourcestrings : Tresourcestrings;
 
 
 implementation
@@ -113,27 +113,27 @@ end;
 
 
 { ---------------------------------------------------------------------
-                          Tal_resourcestrings
+                          Tresourcestrings
   ---------------------------------------------------------------------}
 
-Constructor Tal_resourcestrings.Create;
+Constructor Tresourcestrings.Create;
 begin
   List:=TStringList.Create;
   ResStrCount:=0;
 end;
 
 
-Destructor Tal_resourcestrings.Destroy;
+Destructor Tresourcestrings.Destroy;
 begin
   List.Free;
 end;
 
 
 { ---------------------------------------------------------------------
-    Create the full asmlist for al_resourcestrings.
+    Create the full asmlist for resourcestrings.
   ---------------------------------------------------------------------}
 
-procedure Tal_resourcestrings.CreateResourceStringList;
+procedure Tresourcestrings.CreateResourceStringList;
 
   Procedure AppendToAsmResList (P : TResourceStringItem);
   Var
@@ -144,11 +144,11 @@ procedure Tal_resourcestrings.CreateResourceStringList;
     with p Do
      begin
        if (Value=nil) or (len=0) then
-         asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_sym(nil))
+         asmlist[al_resourcestrings].concat(tai_const.create_sym(nil))
        else
          begin
             objectlibrary.getdatalabel(l1);
-            asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_sym(l1));
+            asmlist[al_resourcestrings].concat(tai_const.create_sym(l1));
             maybe_new_object_file(asmlist[al_const]);
             asmlist[al_const].concat(tai_align.Create(const_align(sizeof(aint))));
             asmlist[al_const].concat(tai_const.create_aint(-1));
@@ -161,12 +161,12 @@ procedure Tal_resourcestrings.CreateResourceStringList;
             asmlist[al_const].concat(tai_const.create_8bit(0));
          end;
        { append Current value (nil) and hash...}
-       asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_sym(nil));
-       asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_32bit(longint(hash)));
+       asmlist[al_resourcestrings].concat(tai_const.create_sym(nil));
+       asmlist[al_resourcestrings].concat(tai_const.create_32bit(longint(hash)));
        { Append the name as a ansistring. }
        objectlibrary.getdatalabel(l1);
        l:=length(name);
-       asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_sym(l1));
+       asmlist[al_resourcestrings].concat(tai_const.create_sym(l1));
        maybe_new_object_file(asmlist[al_const]);
        asmlist[al_const].concat(tai_align.create(const_align(sizeof(aint))));
        asmlist[al_const].concat(tai_const.create_aint(-1));
@@ -183,21 +183,21 @@ procedure Tal_resourcestrings.CreateResourceStringList;
 Var
   R : tresourceStringItem;
 begin
-  if asmlist[aasmtai.al_resourcestrings]=nil then
-    asmlist[aasmtai.al_resourcestrings]:=taasmoutput.create;
-  maybe_new_object_file(asmlist[aasmtai.al_resourcestrings]);
-  new_section(asmlist[aasmtai.al_resourcestrings],sec_data,'',4);
-  asmlist[aasmtai.al_resourcestrings].concat(tai_align.create(const_align(sizeof(aint))));
-  asmlist[aasmtai.al_resourcestrings].concat(tai_symbol.createname_global(
+  if asmlist[al_resourcestrings]=nil then
+    asmlist[al_resourcestrings]:=taasmoutput.create;
+  maybe_new_object_file(asmlist[al_resourcestrings]);
+  new_section(asmlist[al_resourcestrings],sec_data,'',4);
+  asmlist[al_resourcestrings].concat(tai_align.create(const_align(sizeof(aint))));
+  asmlist[al_resourcestrings].concat(tai_symbol.createname_global(
     make_mangledname('RESOURCESTRINGLIST',current_module.localsymtable,''),AT_DATA,0));
-  asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_32bit(resstrcount));
+  asmlist[al_resourcestrings].concat(tai_const.create_32bit(resstrcount));
   R:=TResourceStringItem(List.First);
   while assigned(R) do
    begin
      AppendToAsmResList(R);
      R:=TResourceStringItem(R.Next);
    end;
-  asmlist[aasmtai.al_resourcestrings].concat(tai_symbol_end.createname(
+  asmlist[al_resourcestrings].concat(tai_symbol_end.createname(
     current_module.modulename^+'_'+'RESOURCESTRINGLIST'));
 end;
 
@@ -206,7 +206,7 @@ end;
     Insert 1 resource string in all tables.
   ---------------------------------------------------------------------}
 
-function  Tal_resourcestrings.Register(const name : string;p : pchar;len : longint) : longint;
+function  Tresourcestrings.Register(const name : string;p : pchar;len : longint) : longint;
 begin
   List.Concat(tResourceStringItem.Create(lower(current_module.modulename^+'.'+Name),p,len));
   Register:=ResStrCount;
@@ -214,7 +214,7 @@ begin
 end;
 
 
-Procedure Tal_resourcestrings.WriteResourceFile(const FileName : String);
+Procedure Tresourcestrings.WriteResourceFile(const FileName : String);
 Type
   TMode = (quoted,unquoted);
 Var

+ 27 - 1
compiler/dbgbase.pas

@@ -26,10 +26,15 @@ unit dbgbase;
 interface
 
     uses
-      systems;
+      systems,
+      aasmtai;
 
     type
       TDebugInfo=class
+        constructor Create;virtual;
+        procedure insertmodulestart(list:taasmoutput);virtual;
+        procedure insertmoduleend(list:taasmoutput);virtual;
+        procedure insertlineinfo(list:taasmoutput);virtual;
       end;
       TDebugInfoClass=class of TDebugInfo;
 
@@ -47,6 +52,27 @@ implementation
     uses
       verbose;
 
+
+    constructor tdebuginfo.Create;
+      begin
+      end;
+
+
+    procedure tdebuginfo.insertmodulestart(list:taasmoutput);
+      begin
+      end;
+
+
+    procedure tdebuginfo.insertmoduleend(list:taasmoutput);
+      begin
+      end;
+
+
+    procedure tdebuginfo.insertlineinfo(list:taasmoutput);
+      begin
+      end;
+
+
     procedure InitDebugInfo;
       begin
         if not assigned(CDebugInfo[target_dbg.id]) then

+ 135 - 2
compiler/dbgstabs.pas

@@ -26,16 +26,149 @@ unit dbgstabs;
 interface
 
     uses
-      DbgBase;
+      DbgBase,
+      aasmtai;
 
     type
       TDebugInfoStabs=class(TDebugInfo)
+        procedure insertmodulestart(list:taasmoutput);override;
+        procedure insertmoduleend(list:taasmoutput);override;
+        procedure insertlineinfo(list:taasmoutput);override;
       end;
 
 implementation
 
     uses
-      Systems;
+      cutils,
+      systems,globals,
+      aasmbase,
+      finput,fmodule;
+
+    const
+      N_GSYM = $20;
+      N_STSYM = 38;     { initialized const }
+      N_LCSYM = 40;     { non initialized variable}
+      N_Function = $24; { function or const }
+      N_TextLine = $44;
+      N_DataLine = $46;
+      N_BssLine = $48;
+      N_RSYM = $40;     { register variable }
+      N_LSYM = $80;
+      N_tsym = 160;
+      N_SourceFile = $64;
+      N_IncludeFile = $84;
+      N_BINCL = $82;
+      N_EINCL = $A2;
+      N_EXCL  = $C2;
+
+    procedure tdebuginfostabs.insertlineinfo(list:taasmoutput);
+      var
+        currfileinfo,
+        lastfileinfo : tfileposinfo;
+        currfuncname : pstring;
+        currsectype  : tasmsectiontype;
+        hlabel       : tasmlabel;
+        hp : tai;
+        infile : tinputfile;
+      begin
+        FillChar(lastfileinfo,sizeof(lastfileinfo),0);
+        currfuncname:=nil;
+        currsectype:=sec_code;
+        hp:=Tai(list.first);
+        while assigned(hp) do
+          begin
+            case hp.typ of
+              ait_section :
+                currsectype:=tai_section(hp).sectype;
+              ait_function_name :
+                currfuncname:=tai_function_name(hp).funcname;
+              ait_force_line :
+                lastfileinfo.line:=-1;
+            end;
+
+            if (currsectype=sec_code) and
+               (hp.typ=ait_instruction) then
+              begin
+                currfileinfo:=tailineinfo(hp).fileinfo;
+                { file changed ? (must be before line info) }
+                if (currfileinfo.fileindex<>0) and
+                   (lastfileinfo.fileindex<>currfileinfo.fileindex) then
+                  begin
+                    infile:=current_module.sourcefiles.get_file(currfileinfo.fileindex);
+                    if assigned(infile) then
+                      begin
+                        objectlibrary.getlabel(hlabel,alt_dbgfile);
+                        { emit stabs }
+                        if (infile.path^<>'') then
+                          list.insertbefore(Tai_stab.Create_str(stab_stabs,'"'+BsToSlash(FixPath(infile.path^,false))+'",'+tostr(n_includefile)+
+                                            ',0,0,'+hlabel.name),hp);
+                        list.insertbefore(Tai_stab.Create_str(stab_stabs,'"'+FixFileName(infile.name^)+'",'+tostr(n_includefile)+
+                                          ',0,0,'+hlabel.name),hp);
+                        list.insertbefore(tai_label.create(hlabel),hp);
+                        { force new line info }
+                        lastfileinfo.line:=-1;
+                      end;
+                  end;
+
+                { line changed ? }
+                if (lastfileinfo.line<>currfileinfo.line) and (currfileinfo.line<>0) then
+                  begin
+                     if assigned(currfuncname) and
+                        (target_info.use_function_relative_addresses) then
+                      begin
+                        objectlibrary.getlabel(hlabel,alt_dbgline);
+                        list.insertbefore(Tai_stab.Create_str(stab_stabn,tostr(n_textline)+',0,'+tostr(currfileinfo.line)+','+
+                                          hlabel.name+' - '+currfuncname^),hp);
+                        list.insertbefore(tai_label.create(hlabel),hp);
+                      end
+                     else
+                      list.insertbefore(Tai_stab.Create_str(stab_stabd,tostr(n_textline)+',0,'+tostr(currfileinfo.line)),hp);
+                  end;
+                lastfileinfo:=currfileinfo;
+              end;
+
+            hp:=tai(hp.next);
+          end;
+      end;
+
+
+    procedure tdebuginfostabs.insertmodulestart(list:taasmoutput);
+      var
+        hlabel : tasmlabel;
+        infile : tinputfile;
+        templist : taasmoutput;
+      begin
+        { emit main source n_sourcefile }
+        objectlibrary.getlabel(hlabel,alt_dbgfile);
+        infile:=current_module.sourcefiles.get_file(1);
+        templist:=taasmoutput.create;
+        new_section(templist,sec_code,'',0);
+        if (infile.path^<>'') then
+          templist.concat(Tai_stab.Create_str(stab_stabs,'"'+BsToSlash(FixPath(infile.path^,false))+'",'+tostr(n_sourcefile)+
+                      ',0,0,'+hlabel.name));
+        templist.concat(Tai_stab.Create_str(stab_stabs,'"'+FixFileName(infile.name^)+'",'+tostr(n_sourcefile)+
+                    ',0,0,'+hlabel.name));
+        templist.concat(tai_label.create(hlabel));
+        list.insertlist(templist);
+        templist.free;
+      end;
+
+
+    procedure tdebuginfostabs.insertmoduleend(list:taasmoutput);
+      var
+        hlabel : tasmlabel;
+        templist : taasmoutput;
+      begin
+        { emit empty n_sourcefile }
+        objectlibrary.getlabel(hlabel,alt_dbgfile);
+        templist:=taasmoutput.create;
+        new_section(templist,sec_code,'',0);
+        templist.concat(Tai_stab.Create_str(stab_stabs,'"",'+tostr(n_sourcefile)+',0,0,'+hlabel.name));
+        templist.concat(tai_label.create(hlabel));
+        list.insertlist(templist);
+        templist.free;
+      end;
+
 
     const
       dbg_stabs_info : tdbginfo =

+ 8 - 8
compiler/dwarf.pas

@@ -270,10 +270,10 @@ implementation
            BYTE    return address register
            <...>   start sequence
         }
-        objectlibrary.getlabel(cielabel);
+        objectlibrary.getjumplabel(cielabel);
         list.concat(tai_label.create(cielabel));
-        objectlibrary.getlabel(lenstartlabel);
-        objectlibrary.getlabel(lenendlabel);
+        objectlibrary.getjumplabel(lenstartlabel);
+        objectlibrary.getjumplabel(lenendlabel);
         list.concat(tai_const.create_rel_sym(ait_const_32bit,lenstartlabel,lenendlabel));
         list.concat(tai_label.create(lenstartlabel));
         list.concat(tai_const.create_32bit(longint($ffffffff)));
@@ -309,8 +309,8 @@ implementation
                   if (hp.ops<>1) or
                      (hp.oper[0].typ<>dop_reloffset) then
                     internalerror(200404126);
-                  objectlibrary.getlabel(lenstartlabel);
-                  objectlibrary.getlabel(lenendlabel);
+                  objectlibrary.getjumplabel(lenstartlabel);
+                  objectlibrary.getjumplabel(lenendlabel);
                   { FDE
                      DWORD length
                      DWORD CIE-pointer = cielabel
@@ -350,8 +350,8 @@ implementation
       begin
         if assigned(FFrameStartLabel) then
           internalerror(200404129);
-        objectlibrary.getlabel(FFrameStartLabel);
-        objectlibrary.getlabel(FFrameEndLabel);
+        objectlibrary.getjumplabel(FFrameStartLabel);
+        objectlibrary.getjumplabel(FFrameEndLabel);
         FLastloclabel:=FFrameStartLabel;
         list.concat(tai_label.create(FFrameStartLabel));
         al_dwarf.concat(tdwarfitem.create_reloffset(DW_CFA_start_frame,doe_32bit,FFrameStartLabel,FFrameEndLabel));
@@ -376,7 +376,7 @@ implementation
       begin
         if FLastloclabel=nil then
           internalerror(200404082);
-        objectlibrary.getlabel(currloclabel);
+        objectlibrary.getjumplabel(currloclabel);
         list.concat(tai_label.create(currloclabel));
         al_dwarf.concat(tdwarfitem.create_reloffset(DW_CFA_advance_loc4,doe_32bit,FLastloclabel,currloclabel));
         FLastloclabel:=currloclabel;

+ 15 - 18
compiler/fppu.pas

@@ -597,22 +597,19 @@ uses
            s:=librarydata.asmsymbolidx^[i-1];
            if not assigned(s) then
             internalerror(200208071);
-           asmsymtype:=1;
            if s.Classtype=tasmlabel then
-            begin
-              if tasmlabel(s).is_addr then
-               asmsymtype:=4
-              else if tasmlabel(s).typ=AT_DATA then
-               asmsymtype:=3
-              else
-               asmsymtype:=2;
-            end;
+             asmsymtype:=2
+           else
+             asmsymtype:=1;
            ppufile.putbyte(asmsymtype);
            case asmsymtype of
              1 :
                ppufile.putstring(s.name);
-             2..4 :
-               ppufile.putlongint(tasmlabel(s).labelnr);
+             2 :
+               begin
+                 ppufile.putbyte(byte(tasmlabel(s).labeltype));
+                 ppufile.putlongint(tasmlabel(s).labelnr);
+               end;
            end;
            ppufile.putbyte(byte(s.defbind));
            ppufile.putbyte(byte(s.typ));
@@ -856,6 +853,7 @@ uses
         labelnr,
         i     : longint;
         name  : string;
+        labeltype : tasmlabeltype;
         bind  : TAsmSymBind;
         typ   : TAsmSymType;
         asmsymtype : byte;
@@ -871,8 +869,11 @@ uses
               case asmsymtype of
                 1 :
                   name:=ppufile.getstring;
-                2..4 :
-                  labelnr:=ppufile.getlongint;
+                2 :
+                  begin
+                    labeltype:=tasmlabeltype(ppufile.getbyte);
+                    labelnr:=ppufile.getlongint;
+                  end;
                 else
                   internalerror(200208192);
               end;
@@ -882,11 +883,7 @@ uses
                 1 :
                  librarydata.asmsymbolidx^[i-1]:=librarydata.newasmsymbol(name,bind,typ);
                 2 :
-                 librarydata.asmsymbolidx^[i-1]:=librarydata.newasmlabel(labelnr,false,false);
-                3 :
-                 librarydata.asmsymbolidx^[i-1]:=librarydata.newasmlabel(labelnr,false,true);
-                4 :
-                 librarydata.asmsymbolidx^[i-1]:=librarydata.newasmlabel(labelnr,true,false);
+                 librarydata.asmsymbolidx^[i-1]:=librarydata.newasmlabel(labelnr,labeltype,(typ=AT_DATA));
               end;
             end;
          end;

+ 0 - 173
compiler/gdb.pas

@@ -48,30 +48,6 @@ Const
     N_EINCL = $A2;
     N_EXCL  = $C2;
 
-    type
-       tai_stabs = class(tai)
-          str : pchar;
-          constructor Create(_str : pchar);
-          destructor Destroy;override;
-       end;
-
-       tai_stabn = class(tai)
-          str : pchar;
-          constructor Create(_str : pchar);
-          destructor Destroy;override;
-       end;
-
-       { insert a cut to split into several smaller files }
-       tai_force_line = class(tailineinfo)
-          constructor Create;
-       end;
-
-       tai_stab_function_name = class(tai)
-          str : pchar;
-          constructor create(_str : pchar);
-          destructor destroy;override;
-       end;
-
     const
        DBX_counter : plongint = nil;
        do_count_dbx : boolean = false;
@@ -81,153 +57,4 @@ Const
 
 uses fmodule;
 
-{ to use N_EXCL we have to count the character in the stabs for
-N_BINCL to N_EINCL
-  Code comes from stabs.c for ld
-      if (type == N_BINCL)
-    (
-      bfd_vma val;
-      int nest;
-      bfd_byte *incl_sym;
-      struct stab_link_includes_entry *incl_entry;
-      struct stab_link_includes_totals *t;
-      struct stab_excl_list *ne;
-
-      val = 0;
-      nest = 0;
-      for (incl_sym = sym + STABSIZE;
-           incl_sym < symend;
-           incl_sym += STABSIZE)
-        (
-          int incl_type;
-
-          incl_type = incl_sym[TYPEOFF];
-          if (incl_type == 0)
-        break;
-          else if (incl_type == N_EINCL)
-        (
-          if (nest == 0)
-            break;
-          --nest;
-        )
-          else if (incl_type == N_BINCL)
-        ++nest;
-          else if (nest == 0)
-        (
-          const char *str;
-
-          str = ((char *) stabstrbuf
-             + stroff
-             + bfd_get_32 (abfd, incl_sym + STRDXOFF));
-          for (; *str != '\0'; str++)
-            (
-              val += *str;
-              if *str == '('
-            (
-               Skip the file number.
-              ++str;
-              while (isdigit ((unsigned char) *str))
-                ++str;
-              --str;
-            )
-            )
-        )
-        ) }
-
-
-   procedure count_dbx(st : pchar);
-     var i : longint;
-         do_count : boolean;
-     begin
-     do_count := false;
-     if assigned(dbx_counter) then
-       begin
-{$IfDef ExtDebugDbx }
-        Comment(V_Info,'Counting '+st);
-        Comment(V_Info,'count =  '+tostr(dbx_counter^));
-        Comment(V_Info,'addr = '+tostr(longint(dbx_counter)));
-{$EndIf ExtDebugDbx }
-          i:=0;
-          while i<=strlen(st) do
-            begin
-               if st[i] = '"' then
-                 if do_count then exit
-                 else do_count := true
-               else
-               if do_count then
-                 begin
-                   dbx_counter^ := dbx_counter^+byte(st[i]);
-                   { skip file number }
-                   if st[i] = '(' then
-                     begin
-                        inc(i);
-                        while st[i] in ['0'..'9'] do inc(i);
-                        dec(i);
-                     end;
-                 end;
-               inc(i);
-            end;
-       end;
-     end;
-
-
-    constructor tai_stabs.create(_str : pchar);
-
-      begin
-         inherited create;
-         typ:=ait_stabs;
-
-if current_module.modulename^='NCNV' then
-  current_module:=current_module;
-
-         str:=_str;
-         if do_count_dbx then
-           begin
-              count_dbx(str);
-           end;
-      end;
-
-    destructor tai_stabs.destroy;
-
-      begin
-         strdispose(str);
-         inherited destroy;
-      end;
-
-    constructor tai_stabn.create(_str : pchar);
-
-      begin
-         inherited create;
-         typ:=ait_stabn;
-         str:=_str;
-      end;
-
-    destructor tai_stabn.destroy;
-
-      begin
-         strdispose(str);
-         inherited destroy;
-      end;
-
-    constructor tai_force_line.create;
-
-      begin
-         inherited create;
-         typ:=ait_force_line;
-      end;
-
-    constructor tai_stab_function_name.create(_str : pchar);
-
-      begin
-         inherited create;
-         typ:=ait_stab_function_name;
-         str:=_str;
-      end;
-
-    destructor tai_stab_function_name.destroy;
-
-      begin
-         strdispose(str);
-         inherited destroy;
-      end;
 end.

+ 3 - 11
compiler/i386/ag386nsm.pas

@@ -644,12 +644,6 @@ interface
                 AsmWriteLn(tai_label(hp).l.name+':');
              end;
 
-           ait_direct :
-             begin
-               AsmWritePChar(tai_direct(hp).str);
-               AsmLn;
-             end;
-
            ait_symbol :
              begin
                if tai_symbol(hp).is_global then
@@ -719,12 +713,10 @@ interface
                   AsmLn;
                 end;
              end;
-{$ifdef GDB}
-           ait_stabn,
-           ait_stabs,
+
+           ait_stab,
            ait_force_line,
-           ait_stab_function_name : ;
-{$endif GDB}
+           ait_function_name : ;
 
            ait_cutobject :
              begin

+ 2 - 2
compiler/i386/cgcpu.pas

@@ -328,8 +328,8 @@ unit cgcpu;
         { so we have to access every page first              }
         if target_info.system=system_i386_win32 then
           begin
-             objectlibrary.getlabel(again);
-             objectlibrary.getlabel(ok);
+             objectlibrary.getjumplabel(again);
+             objectlibrary.getjumplabel(ok);
              a_label(list,again);
              list.concat(Taicpu.op_const_reg(A_CMP,S_L,winstackpagesize,NR_EDI));
              a_jmp_cond(list,OC_B,ok);

+ 2 - 4
compiler/i386/daopt386.pas

@@ -1090,7 +1090,7 @@ end;
 
 function labelCanBeSkipped(p: tai_label): boolean;
 begin
-  labelCanBeSkipped := not(p.l.is_used) or p.l.is_addr;
+  labelCanBeSkipped := not(p.l.is_used) or (p.l.labeltype<>alt_jump);
 end;
 
 {******************* The Data Flow Analyzer functions ********************}
@@ -2363,9 +2363,7 @@ begin
           end;
 {$endif JumpAnal}
 
-{$ifdef GDB}
-        ait_stabs, ait_stabn, ait_stab_function_name:;
-{$endif GDB}
+        ait_stab, ait_force_line, ait_function_name:;
         ait_align: ; { may destroy flags !!! }
         ait_instruction:
           begin

+ 2 - 2
compiler/i386/n386add.pas

@@ -168,7 +168,7 @@ interface
          begin
            if cs_check_overflow in aktlocalswitches  then
             begin
-              objectlibrary.getlabel(hl4);
+              objectlibrary.getjumplabel(hl4);
               if unsigned then
                 cg.a_jmp_flags(exprasmlist,F_AE,hl4)
               else
@@ -364,7 +364,7 @@ interface
       emit_reg(A_MUL,S_L,r);
       if cs_check_overflow in aktlocalswitches  then
        begin
-         objectlibrary.getlabel(hl4);
+         objectlibrary.getjumplabel(hl4);
          cg.a_jmp_flags(exprasmlist,F_AE,hl4);
          cg.a_call_name(exprasmlist,'FPC_OVERFLOW');
          cg.a_label(exprasmlist,hl4);

+ 4 - 4
compiler/i386/n386mat.pas

@@ -113,7 +113,7 @@ implementation
                 begin
                   { a jump, but less operations }
                   emit_reg_reg(A_TEST,S_L,hreg1,hreg1);
-                  objectlibrary.getlabel(hl);
+                  objectlibrary.getjumplabel(hl);
                   cg.a_jmp_flags(exprasmlist,F_NS,hl);
                   if power=1 then
                     emit_reg(A_INC,S_L,hreg1)
@@ -253,9 +253,9 @@ implementation
 
               { the damned shift instructions work only til a count of 32 }
               { so we've to do some tricks here                           }
-              objectlibrary.getlabel(l1);
-              objectlibrary.getlabel(l2);
-              objectlibrary.getlabel(l3);
+              objectlibrary.getjumplabel(l1);
+              objectlibrary.getjumplabel(l2);
+              objectlibrary.getjumplabel(l3);
               emit_const_reg(A_CMP,S_L,64,NR_ECX);
               cg.a_jmp_flags(exprasmlist,F_L,l1);
               emit_reg_reg(A_XOR,S_L,hreg64lo,hreg64lo);

+ 1 - 1
compiler/i386/n386set.pas

@@ -107,7 +107,7 @@ implementation
              { case expr greater than max_ => goto elselabel }
              cg.a_cmp_const_reg_label(exprasmlist,opsize,jmp_gt,aint(max_),hregister,elselabel);
           end;
-        objectlibrary.getlabel(table);
+        objectlibrary.getjumplabel(table);
         { make it a 32bit register }
         indexreg:=cg.makeregsize(exprasmlist,hregister,OS_INT);
         cg.a_load_reg_reg(exprasmlist,opsize,OS_INT,hregister,indexreg);

+ 1 - 1
compiler/i386/popt386.pas

@@ -507,7 +507,7 @@ var
                   insertllitem(asml,p1,p1.next,tai_comment.Create(
                     strpnew('previous label inserted'))));
   {$endif finaldestdebug}
-                  objectlibrary.getlabel(l);
+                  objectlibrary.getjumplabel(l);
                   insertllitem(asml,p1,p1.next,tai_label.Create(l));
                   tasmlabel(taicpu(hp).oper[0]^.ref^.symbol).decrefs;
                   hp.oper[0]^.ref^.symbol := l;

+ 4 - 4
compiler/m68k/cgcpu.pas

@@ -956,9 +956,9 @@ unit cgcpu;
                    helpsize := len - len mod 4;
                    len := len mod 4;
                    list.concat(taicpu.op_const_reg(A_MOVE,S_L,helpsize div 4,hregister));
-                   objectlibrary.getlabel(hl2);
+                   objectlibrary.getjumplabel(hl2);
                    a_jmp_always(list,hl2);
-                   objectlibrary.getlabel(hl);
+                   objectlibrary.getjumplabel(hl);
                    a_label(list,hl);
                    list.concat(taicpu.op_ref_ref(A_MOVE,S_L,hp1,hp2));
                    a_label(list,hl2);
@@ -976,9 +976,9 @@ unit cgcpu;
                    { Fast 68010 loop mode with no possible alignment problems }
                    helpsize := len;
                    list.concat(taicpu.op_const_reg(A_MOVE,S_L,helpsize,hregister));
-                   objectlibrary.getlabel(hl2);
+                   objectlibrary.getjumplabel(hl2);
                    a_jmp_always(list,hl2);
-                   objectlibrary.getlabel(hl);
+                   objectlibrary.getjumplabel(hl);
                    a_label(list,hl);
                    list.concat(taicpu.op_ref_ref(A_MOVE,S_B,hp1,hp2));
                    a_label(list,hl2);

+ 3 - 3
compiler/m68k/n68kmat.pas

@@ -143,7 +143,7 @@ implementation
      if aktoptprocessor <> MC68000 then
        begin
          { verify if denominator is zero }
-         objectlibrary.getlabel(continuelabel);
+         objectlibrary.getjumplabel(continuelabel);
          { compare against zero, if not zero continue }
          cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_NE,0,denum,continuelabel);
 //       paraloc1.init;
@@ -189,7 +189,7 @@ implementation
      if aktoptprocessor <> MC68000 then
        begin
          { verify if denominator is zero }
-         objectlibrary.getlabel(continuelabel);
+         objectlibrary.getjumplabel(continuelabel);
          { compare against zero, if not zero continue }
          cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_NE,0,denum,continuelabel);
 //         cg.a_param_const(exprasmlist, OS_S32,200,paramanager.getintparaloc(pocall_default,1));
@@ -204,7 +204,7 @@ implementation
          { we extend the sign to the high doword register by inverting }
          { all the bits.                                             }
          exprasmlist.concat(taicpu.op_reg(A_CLR,S_L,tmpreg));
-         objectlibrary.getlabel(signlabel);
+         objectlibrary.getjumplabel(signlabel);
          exprasmlist.concat(taicpu.op_reg(A_TST,S_L,tmpreg));
          cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_A,0,tmpreg,signlabel);
          { its a negative value, therefore change sign }

+ 4 - 4
compiler/m68k/ncpuadd.pas

@@ -264,9 +264,9 @@ implementation
             if isjump then
               begin
                  otl:=truelabel;
-                 objectlibrary.getlabel(truelabel);
+                 objectlibrary.getjumplabel(truelabel);
                  ofl:=falselabel;
-                 objectlibrary.getlabel(falselabel);
+                 objectlibrary.getjumplabel(falselabel);
               end;
             secondpass(left);
             if left.location.loc in [LOC_FLAGS,LOC_JUMP] then
@@ -281,9 +281,9 @@ implementation
             if isjump then
               begin
                  otl:=truelabel;
-                 objectlibrary.getlabel(truelabel);
+                 objectlibrary.getjumplabel(truelabel);
                  ofl:=falselabel;
-                 objectlibrary.getlabel(falselabel);
+                 objectlibrary.getjumplabel(falselabel);
               end;
             secondpass(right);
             if right.location.loc in [LOC_FLAGS,LOC_JUMP] then

+ 6 - 6
compiler/ncgadd.pas

@@ -99,9 +99,9 @@ interface
         if isjump then
           begin
              otl:=truelabel;
-             objectlibrary.getlabel(truelabel);
+             objectlibrary.getjumplabel(truelabel);
              ofl:=falselabel;
-             objectlibrary.getlabel(falselabel);
+             objectlibrary.getjumplabel(falselabel);
           end;
         secondpass(left);
         if left.location.loc in [LOC_FLAGS,LOC_JUMP] then
@@ -121,9 +121,9 @@ interface
         if isjump then
           begin
              otl:=truelabel;
-             objectlibrary.getlabel(truelabel);
+             objectlibrary.getjumplabel(truelabel);
              ofl:=falselabel;
-             objectlibrary.getlabel(falselabel);
+             objectlibrary.getjumplabel(falselabel);
           end;
         secondpass(right);
         if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
@@ -386,7 +386,7 @@ interface
               andn :
                 begin
                    otl:=truelabel;
-                   objectlibrary.getlabel(truelabel);
+                   objectlibrary.getjumplabel(truelabel);
                    secondpass(left);
                    maketojumpbool(exprasmlist,left,lr_load_regvars);
                    cg.a_label(exprasmlist,truelabel);
@@ -395,7 +395,7 @@ interface
               orn :
                 begin
                    ofl:=falselabel;
-                   objectlibrary.getlabel(falselabel);
+                   objectlibrary.getjumplabel(falselabel);
                    secondpass(left);
                    maketojumpbool(exprasmlist,left,lr_load_regvars);
                    cg.a_label(exprasmlist,falselabel);

+ 1 - 1
compiler/ncgbas.pas

@@ -338,7 +338,7 @@ interface
         if nf_block_with_exit in flags then
           begin
             oldexitlabel:=current_procinfo.aktexitlabel;
-            objectlibrary.getlabel(current_procinfo.aktexitlabel);
+            objectlibrary.getjumplabel(current_procinfo.aktexitlabel);
           end;
 
         { do second pass on left node }

+ 2 - 2
compiler/ncgcal.pas

@@ -325,8 +325,8 @@ implementation
            begin
              otlabel:=truelabel;
              oflabel:=falselabel;
-             objectlibrary.getlabel(truelabel);
-             objectlibrary.getlabel(falselabel);
+             objectlibrary.getjumplabel(truelabel);
+             objectlibrary.getjumplabel(falselabel);
              secondpass(left);
 
              { release memory for refcnt out parameters }

+ 4 - 4
compiler/ncgcnv.pas

@@ -372,8 +372,8 @@ interface
       begin
          oldtruelabel:=truelabel;
          oldfalselabel:=falselabel;
-         objectlibrary.getlabel(truelabel);
-         objectlibrary.getlabel(falselabel);
+         objectlibrary.getjumplabel(truelabel);
+         objectlibrary.getjumplabel(falselabel);
          secondpass(left);
          location_copy(location,left.location);
          { byte(boolean) or word(wordbool) or longint(longbool) must }
@@ -409,7 +409,7 @@ interface
          hr : treference;
       begin
          location_reset(location,LOC_REGISTER,OS_ADDR);
-         objectlibrary.getlabel(l1);
+         objectlibrary.getjumplabel(l1);
          case left.location.loc of
             LOC_CREGISTER,LOC_REGISTER:
               begin
@@ -464,7 +464,7 @@ interface
             else
               internalerror(121120001);
          end;
-         objectlibrary.getlabel(l1);
+         objectlibrary.getjumplabel(l1);
          cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,location.register,l1);
          hd:=tobjectdef(left.resulttype.def);
          while assigned(hd) do

+ 34 - 34
compiler/ncgflw.pas

@@ -109,9 +109,9 @@ implementation
       begin
          location_reset(location,LOC_VOID,OS_NO);
 
-         objectlibrary.getlabel(lloop);
-         objectlibrary.getlabel(lcont);
-         objectlibrary.getlabel(lbreak);
+         objectlibrary.getjumplabel(lloop);
+         objectlibrary.getjumplabel(lcont);
+         objectlibrary.getjumplabel(lbreak);
          { arrange continue and breaklabels: }
          oldflowcontrol:=flowcontrol;
          oldclabel:=aktcontinuelabel;
@@ -192,8 +192,8 @@ implementation
 
          otlabel:=truelabel;
          oflabel:=falselabel;
-         objectlibrary.getlabel(truelabel);
-         objectlibrary.getlabel(falselabel);
+         objectlibrary.getjumplabel(truelabel);
+         objectlibrary.getjumplabel(falselabel);
          secondpass(left);
 
 (*
@@ -237,7 +237,7 @@ implementation
            begin
               if assigned(right) then
                 begin
-                   objectlibrary.getlabel(hl);
+                   objectlibrary.getjumplabel(hl);
                    { do go back to if line !! }
 (*
                    if not(cs_regvars in aktglobalswitches) then
@@ -345,9 +345,9 @@ implementation
          oldflowcontrol:=flowcontrol;
          oldclabel:=aktcontinuelabel;
          oldblabel:=aktbreaklabel;
-         objectlibrary.getlabel(aktcontinuelabel);
-         objectlibrary.getlabel(aktbreaklabel);
-         objectlibrary.getlabel(l3);
+         objectlibrary.getjumplabel(aktcontinuelabel);
+         objectlibrary.getjumplabel(aktbreaklabel);
+         objectlibrary.getjumplabel(l3);
 
          { only calculate reference }
          opsize := def_cgsize(left.resulttype.def);
@@ -768,7 +768,7 @@ implementation
     function tcglabelnode.getasmlabel : tasmlabel;
       begin
         if not(assigned(asmlabel)) then
-          objectlibrary.getlabel(asmlabel);
+          objectlibrary.getjumplabel(asmlabel);
         result:=asmlabel
       end;
 
@@ -938,20 +938,20 @@ implementation
            end;
 
          { get new labels for the control flow statements }
-         objectlibrary.getlabel(exittrylabel);
-         objectlibrary.getlabel(exitexceptlabel);
+         objectlibrary.getjumplabel(exittrylabel);
+         objectlibrary.getjumplabel(exitexceptlabel);
          if assigned(aktbreaklabel) then
            begin
-              objectlibrary.getlabel(breaktrylabel);
-              objectlibrary.getlabel(continuetrylabel);
-              objectlibrary.getlabel(breakexceptlabel);
-              objectlibrary.getlabel(continueexceptlabel);
+              objectlibrary.getjumplabel(breaktrylabel);
+              objectlibrary.getjumplabel(continuetrylabel);
+              objectlibrary.getjumplabel(breakexceptlabel);
+              objectlibrary.getjumplabel(continueexceptlabel);
            end;
 
-         objectlibrary.getlabel(exceptlabel);
-         objectlibrary.getlabel(doexceptlabel);
-         objectlibrary.getlabel(endexceptlabel);
-         objectlibrary.getlabel(lastonlabel);
+         objectlibrary.getjumplabel(exceptlabel);
+         objectlibrary.getjumplabel(doexceptlabel);
+         objectlibrary.getjumplabel(endexceptlabel);
+         objectlibrary.getjumplabel(lastonlabel);
 
          get_exception_temps(exprasmlist,excepttemps);
          new_exception(exprasmlist,excepttemps,exceptlabel);
@@ -1010,8 +1010,8 @@ implementation
 
               { the destruction of the exception object must be also }
               { guarded by an exception frame                        }
-              objectlibrary.getlabel(doobjectdestroy);
-              objectlibrary.getlabel(doobjectdestroyandreraise);
+              objectlibrary.getjumplabel(doobjectdestroy);
+              objectlibrary.getjumplabel(doobjectdestroyandreraise);
 
               get_exception_temps(exprasmlist,destroytemps);
               new_exception(exprasmlist,destroytemps,doobjectdestroyandreraise);
@@ -1166,7 +1166,7 @@ implementation
 
          oldflowcontrol:=flowcontrol;
          flowcontrol:=[];
-         objectlibrary.getlabel(nextonlabel);
+         objectlibrary.getjumplabel(nextonlabel);
 
          { send the vmt parameter }
          reference_reset_symbol(href2,objectlibrary.newasmsymbol(excepttype.vmt_mangledname,AB_EXTERNAL,AT_DATA),0);
@@ -1198,7 +1198,7 @@ implementation
 
          { in the case that another exception is risen
            we've to destroy the old one                }
-         objectlibrary.getlabel(doobjectdestroyandreraise);
+         objectlibrary.getjumplabel(doobjectdestroyandreraise);
 
          { call setjmp, and jump to finally label on non-zero result }
          get_exception_temps(exprasmlist,excepttemps);
@@ -1209,21 +1209,21 @@ implementation
          if assigned(right) then
            begin
               oldaktexitlabel:=current_procinfo.aktexitlabel;
-              objectlibrary.getlabel(exitonlabel);
+              objectlibrary.getjumplabel(exitonlabel);
               current_procinfo.aktexitlabel:=exitonlabel;
               if assigned(aktbreaklabel) then
                begin
                  oldaktcontinuelabel:=aktcontinuelabel;
                  oldaktbreaklabel:=aktbreaklabel;
-                 objectlibrary.getlabel(breakonlabel);
-                 objectlibrary.getlabel(continueonlabel);
+                 objectlibrary.getjumplabel(breakonlabel);
+                 objectlibrary.getjumplabel(continueonlabel);
                  aktcontinuelabel:=continueonlabel;
                  aktbreaklabel:=breakonlabel;
                end;
 
               secondpass(right);
            end;
-         objectlibrary.getlabel(doobjectdestroy);
+         objectlibrary.getjumplabel(doobjectdestroy);
          cg.a_label(exprasmlist,doobjectdestroyandreraise);
 
          free_exception(exprasmlist,excepttemps,0,doobjectdestroy,false);
@@ -1320,9 +1320,9 @@ implementation
          { check if child nodes do a break/continue/exit }
          oldflowcontrol:=flowcontrol;
          flowcontrol:=[];
-         objectlibrary.getlabel(finallylabel);
-         objectlibrary.getlabel(endfinallylabel);
-         objectlibrary.getlabel(reraiselabel);
+         objectlibrary.getjumplabel(finallylabel);
+         objectlibrary.getjumplabel(endfinallylabel);
+         objectlibrary.getjumplabel(reraiselabel);
 
          { the finally block must catch break, continue and exit }
          { statements                                            }
@@ -1330,7 +1330,7 @@ implementation
          if implicitframe then
            exitfinallylabel:=finallylabel
          else
-           objectlibrary.getlabel(exitfinallylabel);
+           objectlibrary.getjumplabel(exitfinallylabel);
          current_procinfo.aktexitlabel:=exitfinallylabel;
          if assigned(aktbreaklabel) then
           begin
@@ -1343,8 +1343,8 @@ implementation
               end
             else
               begin
-                objectlibrary.getlabel(breakfinallylabel);
-                objectlibrary.getlabel(continuefinallylabel);
+                objectlibrary.getjumplabel(breakfinallylabel);
+                objectlibrary.getjumplabel(continuefinallylabel);
               end;
             aktcontinuelabel:=continuefinallylabel;
             aktbreaklabel:=breakfinallylabel;

+ 3 - 3
compiler/ncginl.pas

@@ -196,8 +196,8 @@ implementation
        paramanager.getintparaloc(pocall_default,4,paraloc4);
        otlabel:=truelabel;
        oflabel:=falselabel;
-       objectlibrary.getlabel(truelabel);
-       objectlibrary.getlabel(falselabel);
+       objectlibrary.getjumplabel(truelabel);
+       objectlibrary.getjumplabel(falselabel);
        secondpass(tcallparanode(left).left);
        maketojumpbool(exprasmlist,tcallparanode(left).left,lr_load_regvars);
        cg.a_label(exprasmlist,falselabel);
@@ -345,7 +345,7 @@ implementation
          begin
            { length in ansi/wide strings is at offset -sizeof(aint) }
            location_force_reg(exprasmlist,left.location,OS_ADDR,false);
-           objectlibrary.getlabel(lengthlab);
+           objectlibrary.getjumplabel(lengthlab);
            cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,left.location.register,lengthlab);
            reference_reset_base(href,left.location.register,-sizeof(aint));
            hregister:=cg.makeregsize(exprasmlist,left.location.register,OS_INT);

+ 5 - 5
compiler/ncgld.pas

@@ -155,8 +155,8 @@ implementation
                          call and then the address load to be sure that the
                          register that is used for returning is the same (PFV)
                        }
-                       objectlibrary.getlabel(norelocatelab);
-                       objectlibrary.getlabel(endrelocatelab);
+                       objectlibrary.getjumplabel(norelocatelab);
+                       objectlibrary.getjumplabel(endrelocatelab);
                        { make sure hregister can't allocate the register necessary for the parameter }
                        paraloc1.init;
                        paramanager.getintparaloc(pocall_default,1,paraloc1);
@@ -395,8 +395,8 @@ implementation
 
         otlabel:=truelabel;
         oflabel:=falselabel;
-        objectlibrary.getlabel(truelabel);
-        objectlibrary.getlabel(falselabel);
+        objectlibrary.getjumplabel(truelabel);
+        objectlibrary.getjumplabel(falselabel);
 
         {
           in most cases we can process first the right node which contains
@@ -670,7 +670,7 @@ implementation
                 end;
               LOC_JUMP :
                 begin
-                  objectlibrary.getlabel(hlabel);
+                  objectlibrary.getjumplabel(hlabel);
                   cg.a_label(exprasmlist,truelabel);
                   cg.a_load_const_loc(exprasmlist,1,left.location);
                   cg.a_jmp_always(exprasmlist,hlabel);

+ 2 - 2
compiler/ncgmat.pas

@@ -304,7 +304,7 @@ implementation
                     "Cardinal($ffffffff) div 16" overflows! (JM) }
                   If is_signed(left.resulttype.def) Then
                     Begin
-                      objectlibrary.getlabel(hl);
+                      objectlibrary.getjumplabel(hl);
                       cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_GT,0,hreg1,hl);
                       if power=1 then
                         cg.a_op_const_reg(exprasmlist,OP_ADD,OS_INT,1,hreg1)
@@ -327,7 +327,7 @@ implementation
                   { verify if the divisor is zero, if so return an error
                     immediately
                   }
-                  objectlibrary.getlabel(hl);
+                  objectlibrary.getjumplabel(hl);
                   cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_NE,0,hdenom,hl);
                   paraloc1.init;
                   paramanager.getintparaloc(pocall_default,1,paraloc1);

+ 5 - 5
compiler/ncgmem.pas

@@ -386,7 +386,7 @@ implementation
             objectlibrary.getaddrlabel(withstartlabel);
             objectlibrary.getaddrlabel(withendlabel);
             cg.a_label(exprasmlist,withstartlabel);
-            al_withdebug.concat(Tai_stabs.Create(strpnew(
+            al_withdebug.concat(Tai_stab.create(stab_stabs,strpnew(
                '"with'+tostr(withlevel)+':'+tostr(symtablestack.getnewtypecount)+
                '=*'+tstoreddef(left.resulttype.def).numberstring+'",'+
                tostr(N_LSYM)+',0,0,'+tostr(refnode.location.reference.offset))));
@@ -510,8 +510,8 @@ implementation
                    hreg:=cg.getintregister(exprasmlist,OS_INT);
                    cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,hreg);
                  end;
-               objectlibrary.getlabel(neglabel);
-               objectlibrary.getlabel(poslabel);
+               objectlibrary.getjumplabel(neglabel);
+               objectlibrary.getjumplabel(poslabel);
                cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_LT,0,hreg,poslabel);
                cg.a_cmp_loc_reg_label(exprasmlist,OS_INT,OC_BE,hightree.location,hreg,neglabel);
                cg.a_label(exprasmlist,poslabel);
@@ -780,9 +780,9 @@ implementation
               if isjump then
                begin
                  otl:=truelabel;
-                 objectlibrary.getlabel(truelabel);
+                 objectlibrary.getjumplabel(truelabel);
                  ofl:=falselabel;
-                 objectlibrary.getlabel(falselabel);
+                 objectlibrary.getjumplabel(falselabel);
                end;
               secondpass(right);
 

+ 1 - 1
compiler/ncgopt.pas

@@ -135,7 +135,7 @@ begin
   if checklength then
     begin
       { is it already maximal? }
-      objectlibrary.getlabel(l);
+      objectlibrary.getjumplabel(l);
       if tg.istemp(left.location.reference) then
         len:=255
       else

+ 10 - 10
compiler/ncgset.pas

@@ -273,7 +273,7 @@ implementation
             { allocate a register for the result }
             location.register := cg.getintregister(exprasmlist,location.size);
             { Get a label to jump to the end }
-            objectlibrary.getlabel(l);
+            objectlibrary.getjumplabel(l);
 
             { clear the register value, indicating result is FALSE }
             cg.a_load_const_reg(exprasmlist,location.size,0,location.register);
@@ -340,7 +340,7 @@ implementation
               end;
              { To compensate for not doing a second pass }
              right.location.reference.symbol:=nil;
-             objectlibrary.getlabel(l3);
+             objectlibrary.getjumplabel(l3);
              cg.a_jmp_always(exprasmlist,l3);
              { Now place the end label if IN success }
              cg.a_label(exprasmlist,l);
@@ -597,7 +597,7 @@ implementation
 {$ifndef cpu64bit}
                 if opsize in [OS_S64,OS_64] then
                   begin
-                     objectlibrary.getlabel(l1);
+                     objectlibrary.getjumplabel(l1);
                      cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_NE, aint(hi(int64(t^._low))),hregister2,l1);
                      cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_EQ, aint(lo(int64(t^._low))),hregister, blocklabel(t^.blockid));
                      cg.a_label(exprasmlist,l1);
@@ -621,7 +621,7 @@ implementation
 {$ifndef cpu64bit}
                      if opsize in [OS_64,OS_S64] then
                        begin
-                          objectlibrary.getlabel(l1);
+                          objectlibrary.getjumplabel(l1);
                           cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_lt, aint(hi(int64(t^._low))),
                                hregister2, elselabel);
                           cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_gt, aint(hi(int64(t^._low))),
@@ -640,7 +640,7 @@ implementation
 {$ifndef cpu64bit}
                 if opsize in [OS_S64,OS_64] then
                   begin
-                     objectlibrary.getlabel(l1);
+                     objectlibrary.getjumplabel(l1);
                      cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_lt, aint(hi(int64(t^._high))), hregister2,
                            blocklabel(t^.blockid));
                      cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_gt, aint(hi(int64(t^._high))), hregister2,
@@ -696,10 +696,10 @@ implementation
          location_reset(location,LOC_VOID,OS_NO);
 
          { Allocate labels }
-         objectlibrary.getlabel(endlabel);
-         objectlibrary.getlabel(elselabel);
+         objectlibrary.getjumplabel(endlabel);
+         objectlibrary.getjumplabel(elselabel);
          for i:=0 to blocks.count-1 do
-           objectlibrary.getlabel(pcaseblock(blocks[i])^.blocklabel);
+           objectlibrary.getjumplabel(pcaseblock(blocks[i])^.blocklabel);
 
          with_sign:=is_signed(left.resulttype.def);
          if with_sign then
@@ -720,9 +720,9 @@ implementation
          if left.location.loc=LOC_JUMP then
           begin
             otl:=truelabel;
-            objectlibrary.getlabel(truelabel);
+            objectlibrary.getjumplabel(truelabel);
             ofl:=falselabel;
-            objectlibrary.getlabel(falselabel);
+            objectlibrary.getjumplabel(falselabel);
             isjump:=true;
           end;
          secondpass(left);

+ 14 - 18
compiler/ncgutil.pas

@@ -429,7 +429,7 @@ implementation
                   begin
                     cg.a_label(list,truelabel);
                     cg.a_load_const_reg(list,OS_INT,1,hregister);
-                    objectlibrary.getlabel(hl);
+                    objectlibrary.getjumplabel(hl);
                     cg.a_jmp_always(list,hl);
                     cg.a_label(list,falselabel);
                     cg.a_load_const_reg(list,OS_INT,0,hregister);
@@ -515,7 +515,7 @@ implementation
                begin
                  cg.a_label(list,truelabel);
                  cg.a_load_const_reg(list,dst_size,1,hregister);
-                 objectlibrary.getlabel(hl);
+                 objectlibrary.getjumplabel(hl);
                  cg.a_jmp_always(list,hl);
                  cg.a_label(list,falselabel);
                  cg.a_load_const_reg(list,dst_size,0,hregister);
@@ -578,7 +578,7 @@ implementation
             begin
               cg.a_label(list,truelabel);
               cg.a_load_const_reg(list,dst_size,1,hregister);
-              objectlibrary.getlabel(hl);
+              objectlibrary.getjumplabel(hl);
               cg.a_jmp_always(list,hl);
               cg.a_label(list,falselabel);
               cg.a_load_const_reg(list,dst_size,0,hregister);
@@ -1659,16 +1659,13 @@ implementation
           hs:=current_procinfo.procdef.aliasnames.getfirst;
           if hs='' then
             break;
-{$ifdef GDB}
-          if (cs_debuginfo in aktmoduleswitches) and
-             target_info.use_function_relative_addresses then
-          list.concat(Tai_stab_function_name.create(strpnew(hs)));
-{$endif GDB}
           if (cs_profile in aktmoduleswitches) or
              (po_global in current_procinfo.procdef.procoptions) then
             list.concat(Tai_symbol.createname_global(hs,AT_FUNCTION,0))
           else
             list.concat(Tai_symbol.createname(hs,AT_FUNCTION,0));
+          if target_info.use_function_relative_addresses then
+            list.concat(Tai_function_name.create(hs));
         until false;
       end;
 
@@ -1717,13 +1714,13 @@ implementation
 {$ifdef GDB}
         if (cs_debuginfo in aktmoduleswitches) then
           begin
-            objectlibrary.getlabel(stabsendlabel);
+            objectlibrary.getjumplabel(stabsendlabel);
             cg.a_label(list,stabsendlabel);
             { define calling EBP as pseudo local var PM }
             { this enables test if the function is a local one !! }
             {if  assigned(current_procinfo.parent) and
                 (current_procinfo.procdef.parast.symtablelevel>normal_function_level) then
-              list.concat(Tai_stabs.Create(strpnew(
+              list.concat(Tai_stab.create(stab_stabs,strpnew(
                '"parent_ebp:'+tstoreddef(voidpointertype.def).numberstring+'",'+
                tostr(N_LSYM)+',0,0,'+tostr(current_procinfo.parent_framepointer_offset)))); }
 
@@ -1735,21 +1732,21 @@ implementation
 {$warning Need to add gdb support for ret in param register calling}
                     if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
                       begin
-                        list.concat(Tai_stabs.Create(strpnew(
+                        list.concat(Tai_stab.create(stab_stabs,strpnew(
                            '"'+current_procinfo.procdef.procsym.name+':X*'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
                            tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
                         if (m_result in aktmodeswitches) then
-                          list.concat(Tai_stabs.Create(strpnew(
+                          list.concat(Tai_stab.create(stab_stabs,strpnew(
                              '"RESULT:X*'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
                              tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))))
                       end
                     else
                       begin
-                        list.concat(Tai_stabs.Create(strpnew(
+                        list.concat(Tai_stab.create(stab_stabs,strpnew(
                            '"'+current_procinfo.procdef.procsym.name+':X'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
                            tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
                         if (m_result in aktmodeswitches) then
-                          list.concat(Tai_stabs.Create(strpnew(
+                          list.concat(Tai_stab.create(stab_stabs,strpnew(
                              '"RESULT:X'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
                              tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
                        end;
@@ -1764,9 +1761,8 @@ implementation
                 strpcopy(strend(p),'-');
                 strpcopy(strend(p),current_procinfo.procdef.mangledname);
               end;
-            list.concat(Tai_stabn.Create(strnew(p)));
-            {List.concat(Tai_stabn.Create(strpnew('192,0,0,'
-             +current_procinfo.procdef.mangledname))));
+            list.concat(Tai_stab.Create(stab_stabn,strnew(p)));
+            {List.concat(Tai_stab.Create_str(stab_stabn,'192,0,0,'+current_procinfo.procdef.mangledname)));
             p[0]:='2';p[1]:='2';p[2]:='4';
             strpcopy(strend(p),'_end');}
             strpcopy(p,'224,0,0,'+stabsendlabel.name);
@@ -1776,7 +1772,7 @@ implementation
                 strpcopy(strend(p),current_procinfo.procdef.mangledname);
               end;
             list.concatlist(asmlist[al_withdebug]);
-            list.concat(Tai_stabn.Create(strnew(p)));
+            list.concat(Tai_stab.Create(stab_stabn,strnew(p)));
              { strpnew('224,0,0,'
              +current_procinfo.procdef.mangledname+'_end'))));}
             freemem(p,2*mangled_length+50);

+ 1 - 1
compiler/nobj.pas

@@ -1285,7 +1285,7 @@ implementation
          begin
            do_count_dbx:=true;
            if assigned(_class.owner) and assigned(_class.owner.name) then
-             asmlist[al_globals].concat(Tai_stabs.Create(strpnew('"vmt_'+_class.owner.name^+_class.name+':S'+
+             asmlist[al_globals].concat(Tai_stab.create(stab_stabs,strpnew('"vmt_'+_class.owner.name^+_class.name+':S'+
                tstoreddef(vmttype.def).numberstring+'",'+tostr(N_STSYM)+',0,0,'+_class.vmt_mangledname)));
          end;
 {$endif GDB}

+ 13 - 15
compiler/parser.pas

@@ -247,24 +247,22 @@ implementation
 *****************************************************************************}
 
     procedure init_module;
-
-      var to_create:set of Tasmlist;
-          i:Tasmlist;
+      var
+        i : Tasmlist;
       begin
          exprasmlist:=taasmoutput.create;
-         { Create assembler output lists for CG }
-         to_create:=[al_procedures,al_typestabs,al_globals,al_const,
-                     al_threadvars,al_withdebug,al_typedconsts,al_rotypedconsts,al_rtti,al_picdata];
          for i:=low(Tasmlist) to high(Tasmlist) do
-           if i in to_create then
-             asmlist[i]:=Taasmoutput.create
-           else
-             asmlist[i]:=nil;
+           asmlist[i]:=Taasmoutput.create;
 
+         { PIC data }
+{$ifdef powerpc}
          if target_info.system=system_powerpc_darwin then
            asmlist[al_picdata].concat(tai_simple.create(ait_non_lazy_symbol_pointer));
+{$endif powerpc}
+
          { Resource strings }
-         cresstr.al_resourcestrings:=Tal_resourcestrings.Create;
+         cresstr.resourcestrings:=Tresourcestrings.Create;
+
          { use the librarydata from current_module }
          objectlibrary:=current_module.librarydata;
       end;
@@ -287,7 +285,7 @@ implementation
          d.free;
 {$endif}
          { resource strings }
-         cresstr.al_resourcestrings.free;
+         cresstr.resourcestrings.free;
          objectlibrary:=nil;
       end;
 
@@ -322,7 +320,7 @@ implementation
           oldasmlist:array[Tasmlist] of Taasmoutput;
           oldobjectlibrary : tasmlibrarydata;
         { al_resourcestrings }
-          Oldal_resourcestrings : tal_resourcestrings;
+          Oldresourcestrings : tresourcestrings;
         { akt.. things }
           oldaktlocalswitches  : tlocalswitches;
           oldaktmoduleswitches : tmoduleswitches;
@@ -382,7 +380,7 @@ implementation
             oldasmlist:=asmlist;
             oldexprasmlist:=exprasmlist;
             oldobjectlibrary:=objectlibrary;
-            Oldal_resourcestrings:=al_resourcestrings;
+            Oldresourcestrings:=resourcestrings;
           { save akt... state }
           { handle the postponed case first }
            if localswitcheschanged then
@@ -545,7 +543,7 @@ implementation
                    exprasmlist:=oldexprasmlist;
                    asmlist:=oldasmlist;
                    { object data }
-                   al_resourcestrings:=Oldal_resourcestrings;
+                   resourcestrings:=oldresourcestrings;
                    objectlibrary:=oldobjectlibrary;
                    { restore previous scanner }
                    if assigned(old_compiled_module) then

+ 4 - 4
compiler/pdecl.pas

@@ -333,21 +333,21 @@ implementation
                        { avoid wrong unused warnings web bug 801 PM }
                        inc(ttypesym(srsym).refs);
 {$ifdef GDB_UNUSED}
-                       if (cs_debuginfo in aktmoduleswitches) and assigned(al_typestabs) and
+                       if (cs_debuginfo in aktmoduleswitches) and assigned(al_debugtypes) and
                           (tsym(p).owner.symtabletype in [globalsymtable,staticsymtable]) then
                         begin
                           ttypesym(p).isusedinstab:=true;
-{                          ttypesym(p).concatstabto(al_typestabs);}
+{                          ttypesym(p).concatstabto(al_debugtypes);}
                           {not stabs for forward defs }
                           if not Ttypesym(p).isstabwritten then
                             begin
                               if Ttypesym(p).restype.def.typesym=p then
-                                Tstoreddef(Ttypesym(p).restype.def).concatstabto(al_typestabs)
+                                Tstoreddef(Ttypesym(p).restype.def).concatstabto(al_debugtypes)
                               else
                                 begin
                                   stab_str:=Ttypesym(p).stabstring;
                                   if assigned(stab_str) then
-                                    al_typestabs.concat(Tai_stabs.create(stab_str));
+                                    al_debugtypes.concat(Tai_stab.create(stab_stabs,stab_str));
                                   Ttypesym(p).isstabwritten:=true;
                                 end;
                             end;

+ 27 - 18
compiler/pmodules.pas

@@ -100,6 +100,15 @@ implementation
            KeepShared.Free;
          end;
 
+        { Start and end of debuginfo, at least required for stabs
+          to insert n_sourcefile lines }
+        if (cs_debuginfo in aktmoduleswitches) or
+           (cs_gdb_lineinfo in aktglobalswitches) then
+          begin
+            debuginfo.insertmodulestart(asmlist[al_debugstart]);
+            debuginfo.insertmoduleend(asmlist[al_debugend]);
+          end;
+
         { create the .s file and assemble it }
         GenerateAsm(false);
 
@@ -185,13 +194,13 @@ implementation
         if assigned(asmlist[aasmtai.al_resourcestrings]) then
           fixseg(asmlist[aasmtai.al_resourcestrings],sec_data,'____seg_resstrings');
 {$ifdef GDB}
-        if assigned(asmlist[al_typestabs]) then
+        if assigned(asmlist[al_debugtypes]) then
           begin
             oldaktfilepos:=aktfilepos;
             aktfilepos.line:=0;
-            asmlist[al_typestabs].insert(Tai_symbol.Createname('gcc2_compiled',AT_DATA,0));
-            asmlist[al_typestabs].insert(Tai_symbol.Createname('fpc_compiled',AT_DATA,0));
-//            fixseg(asmlist[al_typestabs],sec_code,'____seg_debug');
+            asmlist[al_debugtypes].insert(Tai_symbol.Createname('gcc2_compiled',AT_DATA,0));
+            asmlist[al_debugtypes].insert(Tai_symbol.Createname('fpc_compiled',AT_DATA,0));
+//            fixseg(asmlist[al_debugtypes],sec_code,'____seg_debug');
             aktfilepos:=oldaktfilepos;
           end;
 {$endif GDB}
@@ -342,7 +351,7 @@ implementation
            hp:=tused_unit(hp.next);
          end;
         { Add program resources, if any }
-        if asmlist[aasmtai.al_resourcestrings]<>nil then
+        If resourcestrings.ResStrCount>0 then
          begin
            ResourceStringTables.concat(Tai_const.Createname(make_mangledname('RESOURCESTRINGLIST',current_module.localsymtable,''),AT_DATA,0));
            Inc(Count);
@@ -719,7 +728,7 @@ implementation
                    dependent stabs }
                  write_used_unit_type_info(pu.u);
                  if assigned(pu.u.globalsymtable) then
-                   tglobalsymtable(pu.u.globalsymtable).concattypestabto(asmlist[al_typestabs]);
+                   tglobalsymtable(pu.u.globalsymtable).concattypestabto(asmlist[al_debugtypes]);
                end;
              pu:=tused_unit(pu.next);
            end;
@@ -743,8 +752,8 @@ implementation
           end
         else
           st:=current_module.localsymtable;
-        new_section(asmlist[al_typestabs],sec_data,lower(st.name^),0);
-        asmlist[al_typestabs].concat(tai_symbol.Createname_global(make_mangledname('DEBUGINFO',st,''),AT_DATA,0));
+        new_section(asmlist[al_debugtypes],sec_data,lower(st.name^),0);
+        asmlist[al_debugtypes].concat(tai_symbol.Createname_global(make_mangledname('DEBUGINFO',st,''),AT_DATA,0));
         { first write all global/local symbols again to a temp list. This will flag
           all required tdefs. After that the temp list can be removed since the debuginfo is already
           written to the stabs when the variables/consts were written }
@@ -761,16 +770,16 @@ implementation
         write_used_unit_type_info(current_module);
         { last write the types from this unit }
         if assigned(current_module.globalsymtable) then
-          tglobalsymtable(current_module.globalsymtable).concattypestabto(asmlist[al_typestabs]);
+          tglobalsymtable(current_module.globalsymtable).concattypestabto(asmlist[al_debugtypes]);
         if assigned(current_module.localsymtable) then
-          tstaticsymtable(current_module.localsymtable).concattypestabto(asmlist[al_typestabs]);
+          tstaticsymtable(current_module.localsymtable).concattypestabto(asmlist[al_debugtypes]);
         { include files }
         if (cs_gdb_dbx in aktglobalswitches) then
           begin
-            asmlist[al_typestabs].concat(tai_comment.Create(strpnew('EINCL of global '+
+            asmlist[al_debugtypes].concat(tai_comment.Create(strpnew('EINCL of global '+
               tglobalsymtable(current_module.globalsymtable).name^+' has index '+
               tostr(tglobalsymtable(current_module.globalsymtable).moduleid))));
-            asmlist[al_typestabs].concat(Tai_stabs.Create(strpnew('"'+
+            asmlist[al_debugtypes].concat(Tai_stab.create(stab_stabs,strpnew('"'+
               tglobalsymtable(current_module.globalsymtable).name^+'",'+
               tostr(N_EINCL)+',0,0,0')));
             tglobalsymtable(current_module.globalsymtable).dbx_count_ok:={true}false;
@@ -1263,13 +1272,13 @@ implementation
          consume(_POINT);
 
          { Generate resoucestrings }
-         If al_resourcestrings.ResStrCount>0 then
+         If resourcestrings.ResStrCount>0 then
           begin
-            al_resourcestrings.CreateResourceStringList;
+            resourcestrings.CreateResourceStringList;
             current_module.flags:=current_module.flags or uf_has_resources;
             { only write if no errors found }
             if (Errorcount=0) then
-             al_resourcestrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
+             resourcestrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
           end;
 
          if (Errorcount=0) then
@@ -1564,12 +1573,12 @@ implementation
             BinaryContainsExports then
            asmlist[al_procedures].concat(tai_const.create_sym(exportlib.edatalabel));
 
-         If al_resourcestrings.ResStrCount>0 then
+         If resourcestrings.ResStrCount>0 then
           begin
-            al_resourcestrings.CreateResourceStringList;
+            resourcestrings.CreateResourceStringList;
             { only write if no errors found }
             if (Errorcount=0) then
-             al_resourcestrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
+             resourcestrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
           end;
 
          { finalize? }

+ 3 - 9
compiler/powerpc/agppcmpw.pas

@@ -1221,15 +1221,9 @@ var
                 ;
               ait_instruction:
                 WriteInstruction(hp);
-{$ifdef GDB}
-              ait_stabn: ;
-              ait_stabs: ;
-
-              ait_force_line :
-                 stabslastfileinfo.line:=0;
-
-              ait_stab_function_name: ;
-{$endif GDB}
+              ait_stab,
+              ait_force_line,
+              ait_function_name : ;
               ait_cutobject :
                 begin
                   InternalError(2004101101);  {Smart linking is done transparently by the MPW linker.}

+ 3 - 3
compiler/powerpc/cgcpu.pas

@@ -1883,7 +1883,7 @@ const
             { explicitely allocate R_0 since it can be used safely here }
             { (for holding date that's being copied)                    }
             a_reg_alloc(list,NR_F0);
-            objectlibrary.getlabel(lab);
+            objectlibrary.getjumplabel(lab);
             a_label(list, lab);
             list.concat(taicpu.op_reg_reg_const(A_SUBIC_,countreg,countreg,1));
             list.concat(taicpu.op_reg_ref(A_LFDU,NR_F0,src));
@@ -1935,7 +1935,7 @@ const
             { explicitely allocate R_0 since it can be used safely here }
             { (for holding date that's being copied)                    }
             a_reg_alloc(list,NR_R0);
-            objectlibrary.getlabel(lab);
+            objectlibrary.getjumplabel(lab);
             a_label(list, lab);
             list.concat(taicpu.op_reg_reg_const(A_SUBIC_,countreg,countreg,1));
             list.concat(taicpu.op_reg_ref(A_LWZU,NR_R0,src));
@@ -1987,7 +1987,7 @@ const
       begin
          if not(cs_check_overflow in aktlocalswitches) then
           exit;
-         objectlibrary.getlabel(hl);
+         objectlibrary.getjumplabel(hl);
          if not ((def.deftype=pointerdef) or
                 ((def.deftype=orddef) and
                  (torddef(def).typ in [u64bit,u16bit,u32bit,u8bit,uchar,

+ 7 - 7
compiler/powerpc/nppcadd.pas

@@ -281,9 +281,9 @@ interface
             if isjump then
               begin
                  otl:=truelabel;
-                 objectlibrary.getlabel(truelabel);
+                 objectlibrary.getjumplabel(truelabel);
                  ofl:=falselabel;
-                 objectlibrary.getlabel(falselabel);
+                 objectlibrary.getjumplabel(falselabel);
               end;
             secondpass(left);
             if left.location.loc in [LOC_FLAGS,LOC_JUMP] then
@@ -300,9 +300,9 @@ interface
             if isjump then
               begin
                  otl:=truelabel;
-                 objectlibrary.getlabel(truelabel);
+                 objectlibrary.getjumplabel(truelabel);
                  ofl:=falselabel;
-                 objectlibrary.getlabel(falselabel);
+                 objectlibrary.getjumplabel(falselabel);
               end;
             secondpass(right);
             if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
@@ -378,7 +378,7 @@ interface
                    andn :
                      begin
                         otl:=truelabel;
-                        objectlibrary.getlabel(truelabel);
+                        objectlibrary.getjumplabel(truelabel);
                         secondpass(left);
                         maketojumpbool(exprasmlist,left,lr_load_regvars);
                         cg.a_label(exprasmlist,truelabel);
@@ -387,7 +387,7 @@ interface
                    orn :
                      begin
                         ofl:=falselabel;
-                        objectlibrary.getlabel(falselabel);
+                        objectlibrary.getjumplabel(falselabel);
                         secondpass(left);
                         maketojumpbool(exprasmlist,left,lr_load_regvars);
                         cg.a_label(exprasmlist,falselabel);
@@ -1447,7 +1447,7 @@ interface
                       exprasmlist.concat(taicpu.op_reg_reg_reg(A_MULLW,location.register,
                         left.location.register,right.location.register));
                       { g_overflowcheck generates a OC_AE instead of OC_EQ :/ }
-                      objectlibrary.getlabel(hl);
+                      objectlibrary.getjumplabel(hl);
                       tcgppc(cg).a_jmp_cond(exprasmlist,OC_EQ,hl);
                       cg.a_call_name(exprasmlist,'FPC_OVERFLOW');
                       cg.a_label(exprasmlist,hl);

+ 3 - 3
compiler/powerpc/nppccnv.pas

@@ -251,8 +251,8 @@ implementation
       begin
          oldtruelabel:=truelabel;
          oldfalselabel:=falselabel;
-         objectlibrary.getlabel(truelabel);
-         objectlibrary.getlabel(falselabel);
+         objectlibrary.getjumplabel(truelabel);
+         objectlibrary.getjumplabel(falselabel);
          secondpass(left);
          if codegenerror then
           exit;
@@ -312,7 +312,7 @@ implementation
             LOC_JUMP :
               begin
                 hreg1:=cg.getintregister(exprasmlist,OS_INT);
-                objectlibrary.getlabel(hlabel);
+                objectlibrary.getjumplabel(hlabel);
                 cg.a_label(exprasmlist,truelabel);
                 cg.a_load_const_reg(exprasmlist,OS_INT,1,hreg1);
                 cg.a_jmp_always(exprasmlist,hlabel);

+ 1 - 1
compiler/powerpc/nppcmat.pas

@@ -337,7 +337,7 @@ end;
         location.register:=resultreg;
         if right.nodetype <> ordconstn then
           begin
-            objectlibrary.getlabel(hl);
+            objectlibrary.getjumplabel(hl);
             exprasmlist.concat(taicpu.op_cond_sym(A_BC,zerocond,hl));
             cg.a_call_name(exprasmlist,'FPC_DIVBYZERO');
             cg.a_label(exprasmlist,hl);

+ 1 - 1
compiler/powerpc/nppcset.pas

@@ -93,7 +93,7 @@ implementation
              { case expr greater than max_ => goto elselabel }
              cg.a_cmp_const_reg_label(exprasmlist,opsize,jmp_gt,aint(max_),hregister,elselabel);
           end;
-        objectlibrary.getlabel(table);
+        objectlibrary.getjumplabel(table);
         { make it a 32bit register }
         // allocate base and index registers register
         indexreg:= cg.makeregsize(exprasmlist, hregister, OS_INT);

+ 2 - 2
compiler/procinfo.pas

@@ -144,8 +144,8 @@ implementation
         aktlocaldata:=Taasmoutput.Create;
         reference_reset(save_regs_ref);
         { labels }
-        objectlibrary.getlabel(aktexitlabel);
-        objectlibrary.getlabel(gotlabel);
+        objectlibrary.getjumplabel(aktexitlabel);
+        objectlibrary.getjumplabel(gotlabel);
       end;
 
 

+ 6 - 1
compiler/psub.pas

@@ -95,7 +95,7 @@ implementation
        scanner,import,gendef,
        pbase,pstatmnt,pdecl,pdecsub,pexports,
        { codegen }
-       tgobj,cgobj,
+       tgobj,cgobj,dbgbase,
        ncgutil,regvars
 {$ifdef arm}
        ,aasmcpu
@@ -849,6 +849,11 @@ implementation
             insertpcrelativedata(aktproccode,aktlocaldata);
 {$endif ARM}
 
+            { insert line debuginfo }
+            if (cs_debuginfo in aktmoduleswitches) or
+               (cs_gdb_lineinfo in aktglobalswitches) then
+              debuginfo.insertlineinfo(aktproccode);
+
             { add the procedure to the al_procedures }
             maybe_new_object_file(asmlist[al_procedures]);
             new_section(asmlist[al_procedures],sec_code,lower(procdef.mangledname),aktalignment.procalign);

+ 2 - 9
compiler/psystem.pas

@@ -45,9 +45,6 @@ implementation
       systems,
       symconst,symtype,symsym,symdef,symtable,
       aasmtai,aasmcpu,ncgutil,fmodule,
-{$ifdef GDB}
-      gdb,
-{$endif GDB}
       node,nbas,nflw,nset,ncon,ncnv,nld,nmem,ncal,nmat,nadd,ninl,nopt
       ;
 
@@ -508,7 +505,6 @@ implementation
         aiclass[ait_align]:=tai_align;
         aiclass[ait_section]:=tai_section;
         aiclass[ait_comment]:=tai_comment;
-        aiclass[ait_direct]:=tai_direct;
         aiclass[ait_string]:=tai_string;
         aiclass[ait_instruction]:=taicpu;
         aiclass[ait_datablock]:=tai_datablock;
@@ -525,12 +521,9 @@ implementation
         aiclass[ait_real_64bit]:=tai_real_64bit;
         aiclass[ait_real_80bit]:=tai_real_80bit;
         aiclass[ait_comp_64bit]:=tai_comp_64bit;
-{$ifdef GDB}
-        aiclass[ait_stabn]:=tai_stabn;
-        aiclass[ait_stabs]:=tai_stabs;
+        aiclass[ait_stab]:=tai_stab;
         aiclass[ait_force_line]:=tai_force_line;
-        aiclass[ait_stab_function_name]:=tai_stab_function_name;
-{$endif GDB}
+        aiclass[ait_function_name]:=tai_function_name;
 {$ifdef alpha}
           { the follow is for the DEC Alpha }
         aiclass[ait_frame]:=tai_frame;

+ 2 - 20
compiler/rautils.pas

@@ -194,7 +194,6 @@ Function SearchIConstant(const s:string; var l:aint): boolean;
 ---------------------------------------------------------------------}
 
   Procedure ConcatPasString(p : TAAsmoutput;s:string);
-  Procedure ConcatDirect(p : TAAsmoutput;s:string);
   Procedure ConcatLabel(p: TAAsmoutput;var l : tasmlabel);
   Procedure ConcatConstant(p : TAAsmoutput;value: aint; constsize:byte);
   Procedure ConcatConstSymbol(p : TAAsmoutput;const sym:string;symtyp:tasmsymtype;l:aint);
@@ -1096,7 +1095,7 @@ function TLocalLabel.Gettasmlabel:tasmlabel;
 begin
   if not assigned(lab) then
    begin
-     objectlibrary.getlabel(lab);
+     objectlibrary.getjumplabel(lab);
      { this label is forced to be used so it's always written }
      lab.increfs;
    end;
@@ -1386,7 +1385,7 @@ Begin
     labelsym :
       begin
         if not(assigned(tlabelsym(sym).asmblocklabel)) then
-          objectlibrary.getlabel(tlabelsym(sym).asmblocklabel);
+          objectlibrary.getjumplabel(tlabelsym(sym).asmblocklabel);
         hl:=tlabelsym(sym).asmblocklabel;
         if emit then
          tlabelsym(sym).defined:=true
@@ -1427,23 +1426,6 @@ end;
      p.concat(Tai_string.Create(s));
   end;
 
-  Procedure ConcatDirect(p : TAAsmoutput;s:string);
-  {*********************************************************************}
-  { PROCEDURE ConcatDirect(s:string)                                    }
-  {  Description: This routine output the string directly to the asm    }
-  {  output, it is only sed when writing special labels in AT&T mode,   }
-  {  and should not be used without due consideration, since it may     }
-  {  cause problems.                                                    }
-  {*********************************************************************}
-  Var
-   pc: PChar;
-  Begin
-     getmem(pc,length(s)+1);
-     p.concat(Tai_direct.Create(strpcopy(pc,s)));
-  end;
-
-
-
 
 Procedure ConcatConstant(p: TAAsmoutput; value: aint; constsize:byte);
 {*********************************************************************}

+ 4 - 4
compiler/sparc/cgcpu.pas

@@ -930,7 +930,7 @@ implementation
       var
         hl : tasmlabel;
       begin
-        objectlibrary.getlabel(hl);
+        objectlibrary.getjumplabel(hl);
         a_load_const_reg(list,size,1,reg);
         a_jmp_flags(list,f,hl);
         a_load_const_reg(list,size,0,reg);
@@ -955,7 +955,7 @@ implementation
       begin
         if not(cs_check_overflow in aktlocalswitches) then
           exit;
-        objectlibrary.getlabel(hl);
+        objectlibrary.getjumplabel(hl);
         case ovloc.loc of
           LOC_VOID:
             begin
@@ -1140,7 +1140,7 @@ implementation
                 a_load_const_reg(list,OS_INT,count,countreg);
                 { explicitely allocate R_O0 since it can be used safely here }
                 { (for holding date that's being copied)                    }
-                objectlibrary.getlabel(lab);
+                objectlibrary.getjumplabel(lab);
                 a_label(list, lab);
                 list.concat(taicpu.op_ref_reg(A_LD,src,tmpreg1));
                 list.concat(taicpu.op_reg_ref(A_ST,tmpreg1,dst));
@@ -1228,7 +1228,7 @@ implementation
                 a_load_const_reg(list,OS_INT,len,countreg);
                 { explicitely allocate R_O0 since it can be used safely here }
                 { (for holding date that's being copied)                    }
-                objectlibrary.getlabel(lab);
+                objectlibrary.getjumplabel(lab);
                 a_label(list, lab);
                 list.concat(taicpu.op_ref_reg(A_LDUB,src,tmpreg1));
                 list.concat(taicpu.op_reg_ref(A_STB,tmpreg1,dst));

+ 4 - 4
compiler/sparc/ncpucnv.pas

@@ -147,7 +147,7 @@ implementation
         else
           begin
             objectlibrary.getdatalabel(l1);
-            objectlibrary.getlabel(l2);
+            objectlibrary.getjumplabel(l2);
             reference_reset_symbol(href,l1,0);
             hregister:=cg.getintregister(exprasmlist,OS_32);
             cg.a_load_loc_reg(exprasmlist,OS_32,left.location,hregister);
@@ -228,8 +228,8 @@ implementation
       begin
         oldtruelabel:=truelabel;
         oldfalselabel:=falselabel;
-        objectlibrary.getlabel(truelabel);
-        objectlibrary.getlabel(falselabel);
+        objectlibrary.getjumplabel(truelabel);
+        objectlibrary.getjumplabel(falselabel);
         secondpass(left);
         if codegenerror then
           exit;
@@ -279,7 +279,7 @@ implementation
           LOC_JUMP :
             begin
               hreg1:=cg.getintregister(exprasmlist,OS_INT);
-              objectlibrary.getlabel(hlabel);
+              objectlibrary.getjumplabel(hlabel);
               cg.a_label(exprasmlist,truelabel);
               cg.a_load_const_reg(exprasmlist,OS_INT,1,hreg1);
               cg.a_jmp_always(exprasmlist,hlabel);

+ 1 - 1
compiler/sparc/ncpumat.pas

@@ -139,7 +139,7 @@ implementation
 
              if (nodetype = modn) then
                begin
-                 objectlibrary.getlabel(overflowlabel);
+                 objectlibrary.getjumplabel(overflowlabel);
                  ai:=taicpu.op_cond_sym(A_Bxx,C_O,overflowlabel);
                  ai.delayslot_annulled:=true;
                  exprasmlist.concat(ai);

+ 1 - 1
compiler/sparc/ncpuset.pas

@@ -93,7 +93,7 @@ unit ncpuset;
              { case expr greater than max_ => goto elselabel }
              cg.a_cmp_const_reg_label(exprasmlist,opsize,jmp_gt,aint(max_),hregister,elselabel);
           end;
-        objectlibrary.getlabel(table);
+        objectlibrary.getjumplabel(table);
         indexreg:=cg.getaddressregister(exprasmlist);
         cg.a_op_const_reg_reg(exprasmlist,OP_SHL,OS_ADDR,2,hregister,indexreg);
         { create reference }

+ 4 - 4
compiler/symdef.pas

@@ -1243,7 +1243,7 @@ implementation
         { to avoid infinite loops }
         stab_state := stab_state_writing;
         stab_str := allstabstring;
-        asmList.concat(Tai_stabs.Create(stab_str));
+        asmList.concat(Tai_stab.create(stab_stabs,stab_str));
         stab_state := stab_state_written;
       end;
 {$endif GDB}
@@ -2710,7 +2710,7 @@ implementation
                       st := ttypesym(typesym).name
                     else
                       st := ' ';
-                    asmlist.concat(Tai_stabs.create(stabstr_evaluate(
+                    asmlist.concat(Tai_stab.create(stab_stabs,stabstr_evaluate(
                             '"$1:t${numberstring}=*$2=xs$3:",${N_LSYM},0,0,0',
                             [st,nb,pointertype.def.typesym.name])));
                   end;
@@ -4388,7 +4388,7 @@ implementation
         numberstring;
         { write stabs }
         stab_state:=stab_state_writing;
-        asmList.concat(Tai_stabs.Create(stabstring));
+        asmList.concat(Tai_stab.create(stab_stabs,stabstring));
         if not(po_external in procoptions) then
           begin
             tparasymtable(parast).concatstabto(asmlist);
@@ -5667,7 +5667,7 @@ implementation
             oldtypesym:=typesym;
             typesym:=nil;
             stab_str := allstabstring;
-            asmList.concat(Tai_stabs.Create(stab_str));
+            asmList.concat(Tai_stab.create(stab_stabs,stab_str));
             typesym:=oldtypesym;
           end
         else

+ 2 - 2
compiler/symsym.pas

@@ -502,7 +502,7 @@ implementation
       begin
         stabstr:=stabstring;
         if stabstr<>nil then
-          asmlist.concat(Tai_stabs.create(stabstr));
+          asmlist.concat(Tai_stab.create(stab_stabs,stabstr));
       end;
 {$endif GDB}
 
@@ -2161,7 +2161,7 @@ implementation
          consttype.reset;
          value.len:=l;
          if t=constresourcestring then
-           ResStrIndex:=al_resourcestrings.Register(name,pchar(value.valueptr),value.len);
+           ResStrIndex:=resourcestrings.Register(name,pchar(value.valueptr),value.len);
       end;
 
 

+ 6 - 6
compiler/symtable.pas

@@ -901,7 +901,7 @@ implementation
                   begin
                     stabstr:=Tsym(p).stabstring;
                     if stabstr<>nil then
-                      asmlist.concat(Tai_stabs.create(stabstr));
+                      asmlist.concat(Tai_stab.create(stab_stabs,stabstr));
                     Tsym(p).isstabwritten:=true;
                   end;
               end;
@@ -1406,7 +1406,7 @@ implementation
                   begin
                      asmList.concat(tai_comment.Create(strpnew('"repeated" unit '+name^
                               +' has index '+tostr(moduleid)+' dbx count = '+tostr(dbx_count))));
-                     asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'
+                     asmList.concat(Tai_stab.create(stab_stabs,strpnew('"'+name^+'",'
                        +tostr(N_EXCL)+',0,0,'+tostr(dbx_count))));
                      exit;
                   end
@@ -1416,7 +1416,7 @@ implementation
                     dbx_counter := nil;
                     do_count_dbx:=false;
                     if (symtabletype = globalsymtable) then
-                      asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0')));
+                      asmList.concat(Tai_stab.create(stab_stabs,strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0')));
                     dbx_counter := @dbx_count;
                     dbx_count:=0;
                     do_count_dbx:=assigned(dbx_counter);
@@ -1434,7 +1434,7 @@ implementation
                   begin
                     dbx_counter := prev_dbx_count;
                     do_count_dbx:=false;
-                    asmList.concat(Tai_stabs.Create(strpnew('"'+name^+'",'
+                    asmList.concat(Tai_stab.create(stab_stabs,strpnew('"'+name^+'",'
                       +tostr(N_EINCL)+',0,0,0')));
                     do_count_dbx:=assigned(dbx_counter);
                     dbx_count_ok := {true}false;
@@ -1533,8 +1533,8 @@ implementation
              unittypecount:=1;
              pglobaltypecount := @unittypecount;
              {moduleid:=current_module.unitcount;}
-             {al_typestabs.concat(tai_comment.Create(strpnew('Global '+name^+' has index '+tostr(moduleid))));
-             al_typestabs.concat(Tai_stabs.Create(strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0')));}
+             {al_debugtypes.concat(tai_comment.Create(strpnew('Global '+name^+' has index '+tostr(moduleid))));
+             al_debugtypes.concat(Tai_stab.create(stab_stabs,strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0')));}
              {inc(current_module.unitcount);}
              { we can't use dbx_vcount, because we don't know
                if the object file will be loaded before or afeter PM }

+ 20 - 25
compiler/systems/t_win.pas

@@ -241,13 +241,14 @@ implementation
              hp2:=twin32imported_item(hp1.imported_items.first);
              while assigned(hp2) do
                begin
-                 if (aktoutputformat in [as_i386_tasm,as_i386_masm]) then
+{$warning TODO nasm lib, tai_direct not supported}
+                 {if (aktoutputformat in [as_i386_tasm,as_i386_masm]) then
                    p:=strpnew(#9+'EXTRN '+hp2.func^)
                  else
                    p:=strpnew(#9+'EXTERN '+hp2.func^);
                  asmlist[al_imports].concat(tai_direct.create(p));
                  p:=strpnew(#9+'import '+hp2.func^+' '+hp1.dllname^+' '+hp2.name^);
-                 asmlist[al_imports].concat(tai_direct.create(p));
+                 asmlist[al_imports].concat(tai_direct.create(p));}
                  hp2:=twin32imported_item(hp2.next);
                end;
              hp1:=timportlist(hp1.next);
@@ -312,22 +313,19 @@ implementation
                  { create indirect jump }
                  if not hp2.is_var then
                   begin
-                    objectlibrary.getlabel(lcode);
+                    objectlibrary.getjumplabel(lcode);
                   {$ifdef ARM}
-                    objectlibrary.getlabel(lpcode);
+                    objectlibrary.getjumplabel(lpcode);
                   {$endif ARM}
                     { place jump in al_procedures, insert a code section in the
                       al_imports to reduce the amount of .s files (PFV) }
                     new_section(asmlist[al_imports],sec_code,'',0);
-{$IfDef GDB}
-                    if (cs_debuginfo in aktmoduleswitches) then
-                      asmlist[al_imports].concat(Tai_stab_function_name.Create(nil));
-{$EndIf GDB}
                     if assigned(hp2.procdef) then
                       mangledstring:=hp2.procdef.mangledname
                     else
                       mangledstring:=hp2.func^;
                     asmlist[al_imports].concat(Tai_symbol.Createname_global(mangledstring,AT_FUNCTION,0));
+                    asmlist[al_imports].concat(Tai_function_name.Create(''));
                   {$ifdef ARM}
                     reference_reset_symbol(href,lpcode,0);
                     asmlist[al_imports].concat(Taicpu.op_reg_ref(A_LDR,NR_R12,href));
@@ -350,7 +348,7 @@ implementation
                  new_section(asmlist[al_imports],sec_idata7,'',0);
                  asmlist[al_imports].concat(Tai_const.Create_rva_sym(lhead));
                  { fixup }
-                 objectlibrary.getlabel(tasmlabel(hp2.lab));
+                 objectlibrary.getjumplabel(tasmlabel(hp2.lab));
                  new_section(asmlist[al_imports],sec_idata4,'',0);
                  asmlist[al_imports].concat(Tai_const.Create_rva_sym(hp2.lab));
                  { add jump field to al_imports }
@@ -440,9 +438,9 @@ implementation
               { align al_procedures for the jumps }
               new_section(asmlist[al_imports],sec_code,'',sizeof(aint));
               { Get labels for the sections }
-              objectlibrary.getlabel(l1);
-              objectlibrary.getlabel(l2);
-              objectlibrary.getlabel(l3);
+              objectlibrary.getjumplabel(l1);
+              objectlibrary.getjumplabel(l2);
+              objectlibrary.getjumplabel(l3);
               new_section(asmlist[al_imports],sec_idata2,'',0);
               { pointer to procedure names }
               asmlist[al_imports].concat(Tai_const.Create_rva_sym(l2));
@@ -464,7 +462,7 @@ implementation
               hp2:=twin32imported_item(hp1.imported_items.first);
               while assigned(hp2) do
                 begin
-                   objectlibrary.getlabel(tasmlabel(hp2.lab));
+                   objectlibrary.getjumplabel(tasmlabel(hp2.lab));
                    if hp2.name^<>'' then
                      asmlist[al_imports].concat(Tai_const.Create_rva_sym(hp2.lab))
                    else
@@ -482,22 +480,19 @@ implementation
                 begin
                    if not hp2.is_var then
                     begin
-                      objectlibrary.getlabel(l4);
+                      objectlibrary.getjumplabel(l4);
                     {$ifdef ARM}
-                      objectlibrary.getlabel(l5);
+                      objectlibrary.getjumplabel(l5);
                     {$endif ARM}
                       { create indirect jump and }
                       { place jump in al_procedures }
                       new_section(asmlist[al_imports],sec_code,'',0);
-{$IfDef GDB}
-                      if (cs_debuginfo in aktmoduleswitches) then
-                        asmlist[al_imports].concat(tai_stab_function_name.create(nil));
-{$EndIf GDB}
                       if assigned(hp2.procdef) then
                         mangledstring:=hp2.procdef.mangledname
                       else
                         mangledstring:=hp2.func^;
                       asmlist[al_imports].concat(Tai_symbol.Createname_global(mangledstring,AT_FUNCTION,0));
+                      asmlist[al_imports].concat(tai_function_name.create(''));
                     {$ifdef ARM}
                       reference_reset_symbol(href,l5,0);
                       asmlist[al_imports].concat(Taicpu.op_reg_ref(A_LDR,NR_R12,href));
@@ -725,10 +720,10 @@ implementation
          ordinal_min:=$7FFFFFFF;
          entries:=0;
          named_entries:=0;
-         objectlibrary.getlabel(dll_name_label);
-         objectlibrary.getlabel(export_address_table);
-         objectlibrary.getlabel(export_name_table_pointers);
-         objectlibrary.getlabel(export_ordinal_table);
+         objectlibrary.getjumplabel(dll_name_label);
+         objectlibrary.getjumplabel(export_address_table);
+         objectlibrary.getjumplabel(export_name_table_pointers);
+         objectlibrary.getjumplabel(export_ordinal_table);
 
          { count entries }
          while assigned(hp) do
@@ -800,7 +795,7 @@ implementation
            begin
               if (hp.options and eo_name)<>0 then
                 begin
-                   objectlibrary.getlabel(name_label);
+                   objectlibrary.getjumplabel(name_label);
                    name_table_pointers.concat(Tai_const.Create_rva_sym(name_label));
                    ordinal_table.concat(Tai_const.Create_16bit(hp.index-ordinal_base));
                    name_table.concat(Tai_align.Create_op(2,0));
@@ -881,7 +876,7 @@ implementation
                  s:='';
              end;
              p:=strpnew(#9+'export '+s+' '+hp.name^+' '+tostr(hp.index));
-             asmlist[al_exports].concat(tai_direct.create(p));
+             {asmlist[al_exports].concat(tai_direct.create(p));}
              hp:=texported_item(hp.next);
            end;
       end;

+ 4 - 11
compiler/x86/agx86int.pas

@@ -643,11 +643,6 @@ implementation
                    DoNotSplitLine:=true;
                 end;
              end;
-           ait_direct :
-             begin
-               AsmWritePChar(tai_direct(hp).str);
-               AsmLn;
-             end;
            ait_symbol :
              begin
                if tai_symbol(hp).is_global then
@@ -746,13 +741,11 @@ implementation
                 end;
                AsmLn;
              end;
-{$ifdef GDB}
-           ait_stabn,
-           ait_stabs,
+
+           ait_stab,
            ait_force_line,
-           ait_stab_function_name :
-             ;
-{$endif GDB}
+           ait_function_name : ;
+
            ait_cutobject :
              begin
                { only reset buffer if nothing has changed }

+ 2 - 2
compiler/x86/cgx86.pas

@@ -1728,7 +1728,7 @@ unit cgx86;
                  end
                else
                  begin
-                    objectlibrary.getlabel(again);
+                    objectlibrary.getjumplabel(again);
                     getcpuregister(list,NR_EDI);
                     list.concat(Taicpu.op_const_reg(A_MOV,S_L,localsize div winstackpagesize,NR_EDI));
                     a_label(list,again);
@@ -1814,7 +1814,7 @@ unit cgx86;
       begin
          if not(cs_check_overflow in aktlocalswitches) then
           exit;
-         objectlibrary.getlabel(hl);
+         objectlibrary.getjumplabel(hl);
          if not ((def.deftype=pointerdef) or
                 ((def.deftype=orddef) and
                  (torddef(def).typ in [u64bit,u16bit,u32bit,u8bit,uchar,

+ 1 - 1
compiler/x86/nx86add.pas

@@ -176,7 +176,7 @@ unit nx86add;
          begin
            if cs_check_overflow in aktlocalswitches  then
             begin
-              objectlibrary.getlabel(hl4);
+              objectlibrary.getjumplabel(hl4);
               if unsigned then
                 cg.a_jmp_flags(exprasmlist,F_AE,hl4)
               else

+ 5 - 5
compiler/x86/nx86cnv.pas

@@ -102,8 +102,8 @@ implementation
       begin
          oldtruelabel:=truelabel;
          oldfalselabel:=falselabel;
-         objectlibrary.getlabel(truelabel);
-         objectlibrary.getlabel(falselabel);
+         objectlibrary.getjumplabel(truelabel);
+         objectlibrary.getjumplabel(falselabel);
          secondpass(left);
          if codegenerror then
           exit;
@@ -161,7 +161,7 @@ implementation
             LOC_JUMP :
               begin
                 hregister:=cg.getintregister(exprasmlist,OS_INT);
-                objectlibrary.getlabel(hlabel);
+                objectlibrary.getjumplabel(hlabel);
                 cg.a_label(exprasmlist,truelabel);
                 cg.a_load_const_reg(exprasmlist,OS_INT,1,hregister);
                 cg.a_jmp_always(exprasmlist,hlabel);
@@ -233,7 +233,7 @@ implementation
                      if it is 1 then we add $80000000 000000000
                      as double                                  }
                    objectlibrary.getdatalabel(l1);
-                   objectlibrary.getlabel(l2);
+                   objectlibrary.getjumplabel(l2);
 
                    if not(signtested) then
                      begin
@@ -348,7 +348,7 @@ implementation
                      if it is 1 then we add $80000000 000000000
                      as double                                  }
                    objectlibrary.getdatalabel(l1);
-                   objectlibrary.getlabel(l2);
+                   objectlibrary.getjumplabel(l2);
 
                    if not(signtested) then
                      begin

+ 3 - 3
compiler/x86/nx86set.pas

@@ -235,7 +235,7 @@ implementation
             else
               location.resflags:=F_E;
 
-            objectlibrary.getlabel(l);
+            objectlibrary.getjumplabel(l);
 
             { how much have we already substracted from the x in the }
             { "x in [y..z]" expression                               }
@@ -377,8 +377,8 @@ implementation
                if right.location.loc=LOC_CONSTANT then
                 begin
                   location.resflags:=F_C;
-                  objectlibrary.getlabel(l);
-                  objectlibrary.getlabel(l2);
+                  objectlibrary.getjumplabel(l);
+                  objectlibrary.getjumplabel(l2);
 
                   { load constants to a register }
                   if left.nodetype=ordconstn then

+ 1 - 1
compiler/x86_64/nx64add.pas

@@ -66,7 +66,7 @@ interface
       emit_reg(A_MUL,S_Q,r);
       if cs_check_overflow in aktlocalswitches  then
        begin
-         objectlibrary.getlabel(hl4);
+         objectlibrary.getjumplabel(hl4);
          cg.a_jmp_flags(exprasmlist,F_AE,hl4);
          cg.a_call_name(exprasmlist,'FPC_OVERFLOW');
          cg.a_label(exprasmlist,hl4);