소스 검색

* lineinfo fixed for binary writer
* add tai_directive to replace old tai_direct calls
in powerpc

git-svn-id: trunk@1139 -

peter 20 년 전
부모
커밋
82faa95118

+ 4 - 3
compiler/Makefile

@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2005/08/10]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2005/09/08]
 #
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-emx i386-watcom i386-netwlibc i386-wince m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd x86_64-win64 arm-linux arm-wince
@@ -234,6 +234,7 @@ override PACKAGE_NAME=compiler
 override PACKAGE_VERSION=2.0.0
 unexport FPC_VERSION FPC_COMPILERINFO
 CYCLETARGETS=i386 powerpc sparc arm x86_64
+ALLTARGETS=$(CYCLETARGETS) m68k
 ifdef ALPHA
 PPC_TARGET=alpha
 endif
@@ -2617,14 +2618,14 @@ tempclean:
 	-$(DEL) $(PPCROSSNAME) $(TEMPNAME) $(TEMPNAME1) $(TEMPNAME2) $(TEMPNAME3) $(MSG2INC)
 execlean :
 	-$(DEL) ppc386$(EXEEXT) ppcaxp$(EXEEXT) ppc68k$(EXEEXT) ppcx64$(EXEEXT) ppcppc$(EXEEXT) ppcsparc$(EXEEXT) $(EXENAME)
-$(addsuffix _clean,$(CYCLETARGETS)):
+$(addsuffix _clean,$(ALLTARGETS)):
 	-$(DELTREE) $(addprefix $(subst _clean,,$@),/units)
 	-$(DEL) $(addprefix $(subst _clean,,$@)/,*$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT))
 	-$(DEL) $(addprefix $(subst _clean,,$@)/,ppc386$(EXEEXT) ppcaxp$(EXEEXT) ppc68k$(EXEEXT) ppcx64$(EXEEXT) ppcppc$(EXEEXT) ppcppc$(EXEEXT) $(EXENAME))
 cycleclean: cleanall $(addsuffix _clean,$(PPC_TARGET))
 	-$(DEL) $(EXENAME)
 clean: tempclean execlean cleanall $(addsuffix _clean,$(PPC_TARGET)) $(addsuffix _clean,$(TARGET_DIRS))
-distclean: tempclean execlean cleanall $(addsuffix _clean,$(CYCLETARGETS)) $(addsuffix _distclean,$(TARGET_DIRS))
+distclean: tempclean execlean cleanall $(addsuffix _clean,$(ALLTARGETS)) $(addsuffix _distclean,$(TARGET_DIRS))
 $(MSG2INC): $(COMPILER_TARGETDIR) $(COMPILER_UNITTARGETDIR) $(COMPILERUTILSDIR)/msg2inc.pp
 	$(COMPILER) -FE. $(COMPILERUTILSDIR)/msg2inc.pp
 msgtxt.inc: $(MSGFILE)

+ 5 - 2
compiler/Makefile.fpc

@@ -34,6 +34,9 @@ unexport FPC_VERSION FPC_COMPILERINFO
 # Which platforms are ready for inclusion in the cycle
 CYCLETARGETS=i386 powerpc sparc arm x86_64
 
+# All supported targets used for clean
+ALLTARGETS=$(CYCLETARGETS) m68k
+
 # Allow ALPHA, POWERPC, M68K, I386 defines for target cpu
 ifdef ALPHA
 PPC_TARGET=alpha
@@ -294,7 +297,7 @@ tempclean:
 execlean :
         -$(DEL) ppc386$(EXEEXT) ppcaxp$(EXEEXT) ppc68k$(EXEEXT) ppcx64$(EXEEXT) ppcppc$(EXEEXT) ppcsparc$(EXEEXT) $(EXENAME)
 
-$(addsuffix _clean,$(CYCLETARGETS)):
+$(addsuffix _clean,$(ALLTARGETS)):
         -$(DELTREE) $(addprefix $(subst _clean,,$@),/units)
         -$(DEL) $(addprefix $(subst _clean,,$@)/,*$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT))
         -$(DEL) $(addprefix $(subst _clean,,$@)/,ppc386$(EXEEXT) ppcaxp$(EXEEXT) ppc68k$(EXEEXT) ppcx64$(EXEEXT) ppcppc$(EXEEXT) ppcppc$(EXEEXT) $(EXENAME))
@@ -304,7 +307,7 @@ cycleclean: cleanall $(addsuffix _clean,$(PPC_TARGET))
 
 clean: tempclean execlean cleanall $(addsuffix _clean,$(PPC_TARGET)) $(addsuffix _clean,$(TARGET_DIRS))
 
-distclean: tempclean execlean cleanall $(addsuffix _clean,$(CYCLETARGETS)) $(addsuffix _distclean,$(TARGET_DIRS))
+distclean: tempclean execlean cleanall $(addsuffix _clean,$(ALLTARGETS)) $(addsuffix _distclean,$(TARGET_DIRS))
 
 
 #####################################################################

+ 3 - 2
compiler/aasmbase.pas

@@ -50,6 +50,7 @@ interface
          sec_code,sec_data,sec_rodata,sec_bss,sec_threadvar,
          sec_common, { used for executable creation }
          sec_custom, { custom section, no prefix }
+         sec_stub,   { used for darwin import stubs }
          { stabs }
          sec_stab,sec_stabstr,
          { win32 }
@@ -185,8 +186,7 @@ interface
          procedure writebytes(var data;len:aint);
          procedure writereloc(data,len:aint;p:tasmsymbol;relative:TAsmRelocationType);virtual;abstract;
          procedure writesymbol(p:tasmsymbol);virtual;abstract;
-         procedure writestabs(offset:aint;p:pchar;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
-         procedure writesymstabs(offset:aint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
+         procedure writestab(offset:aint;ps:tasmsymbol;nidx,nother,line:longint;p:pchar);virtual;abstract;
          procedure beforealloc;virtual;
          procedure beforewrite;virtual;
          procedure afteralloc;virtual;
@@ -575,6 +575,7 @@ implementation
           'code','data','rodata','bss','threadvar',
           'common',
           'note',
+          'text',
           'stab','stabstr',
           'idata2','idata4','idata5','idata6','idata7','edata',
           'eh_frame',

+ 58 - 9
compiler/aasmtai.pas

@@ -50,6 +50,7 @@ interface
           ait_datablock,
           ait_symbol,
           ait_symbol_end, { needed to calc the size of a symbol }
+          ait_directive,
           ait_label,
           { the const_xx must be below each other so it can be used as
             array index }
@@ -87,9 +88,7 @@ interface
           ait_regalloc,
           ait_tempalloc,
           { used to mark assembler blocks and inlined functions }
-          ait_marker,
-          { special symbol for darwin pic code }
-          ait_non_lazy_symbol_pointer
+          ait_marker
           );
 
     const
@@ -111,6 +110,7 @@ interface
           'datablock',
           'symbol',
           'symbol_end',
+          'symbol_directive',
           'label',
           'const_128bit',
           'const_64bit',
@@ -144,8 +144,7 @@ interface
           'cut',
           'regalloc',
           'tempalloc',
-          'marker',
-          'non_lazy_symbol_pointer'
+          'marker'
           );
 
     type
@@ -158,7 +157,7 @@ interface
 {$endif arm}
 {$ifdef m68k}
        { m68k only }
-       ,top_reglist
+       ,top_regset
 {$endif m68k}
        { i386 only});
 
@@ -204,7 +203,7 @@ interface
     const
       SkipInstr = [ait_comment, ait_symbol,ait_section
                    ,ait_stab, ait_function_name, ait_force_line
-                   ,ait_regalloc, ait_tempalloc, ait_symbol_end];
+                   ,ait_regalloc, ait_tempalloc, ait_symbol_end, ait_directive];
 
 { ait_* types which do not have line information (and hence which are of type
   tai, otherwise, they are of type tailineinfo }
@@ -215,8 +214,7 @@ interface
                      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_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_real_128bit
                     ];
 
 
@@ -303,6 +301,18 @@ interface
           procedure derefimpl;override;
        end;
 
+       tasmdirective=(asd_non_lazy_symbol_pointer,asd_indirect_symbol,asd_lazy_symbol_pointer,
+                      asd_extern,asd_nasm_import);
+
+       tai_directive = class(tailineinfo)
+          name : pstring;
+          directive : tasmdirective;
+          constructor Create(_directive:tasmdirective;const _name:string);
+          destructor Destroy;override;
+          constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
+          procedure ppuwrite(ppufile:tcompilerppufile);override;
+       end;
+
        { Generates an assembler label }
        tai_label = class(tai)
           is_global : boolean;
@@ -624,6 +634,10 @@ interface
       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');
+      directivestr : array[tasmdirective] of string[24]=(
+        'non_lazy_symbol_pointer','indirect_symbol','lazy_symbol_pointer',
+        'extern','nasm_import'
+      );
 
     var
       { array with all class types for tais }
@@ -1040,6 +1054,41 @@ implementation
       end;
 
 
+{****************************************************************************
+                               TAI_SYMBOL_END
+ ****************************************************************************}
+
+    constructor tai_directive.Create(_directive:tasmdirective;const _name:string);
+      begin
+         inherited Create;
+         typ:=ait_directive;
+         name:=stringdup(_name);
+         directive:=_directive;
+      end;
+
+
+    destructor tai_directive.Destroy;
+      begin
+        stringdispose(name);
+      end;
+
+
+    constructor tai_directive.ppuload(t:taitype;ppufile:tcompilerppufile);
+      begin
+        inherited ppuload(t,ppufile);
+        name:=stringdup(ppufile.getstring);
+        directive:=tasmdirective(ppufile.getbyte);
+      end;
+
+
+    procedure tai_directive.ppuwrite(ppufile:tcompilerppufile);
+      begin
+        inherited ppuwrite(ppufile);
+        ppufile.putstring(name^);
+        ppufile.putbyte(byte(directive));
+      end;
+
+
 {****************************************************************************
                                TAI_CONST
  ****************************************************************************}

+ 24 - 5
compiler/aggas.pas

@@ -197,6 +197,7 @@ implementation
           '.text','.data','.data','.bss','.threadvar',
           'common',
           '.note',
+          '__TEXT', { stubs }
           '.stab','.stabstr',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
@@ -218,14 +219,27 @@ implementation
       begin
         AsmLn;
         case target_info.system of
-         system_powerpc_darwin, system_i386_OS2, system_i386_EMX: ;
+         system_i386_OS2,
+         system_i386_EMX : ;
+         system_powerpc_darwin :
+           begin
+             if atype=sec_stub then
+               AsmWrite('.section ');
+           end;
          else
           AsmWrite('.section ');
         end;
         s:=sectionname(atype,aname);
         AsmWrite(s);
-        if atype=sec_fpc then
-          AsmWrite(', "a", @progbits');
+        case atype of
+          sec_fpc :
+            AsmWrite(', "a", @progbits');
+          sec_stub :
+            begin
+              if target_info.system=system_powerpc_darwin then
+                AsmWrite(',__symbol_stub1,symbol_stubs,pure_instructions,16');
+            end;
+        end;
         AsmLn;
         CurrSecType:=atype;
       end;
@@ -753,8 +767,13 @@ implementation
              else if tai_marker(hp).kind=InlineEnd then
                dec(InlineLevel);
 
-           ait_non_lazy_symbol_pointer:
-             AsmWriteLn('.non_lazy_symbol_pointer');
+           ait_directive :
+             begin
+               AsmWrite('.'+directivestr[tai_directive(hp).directive]+' ');
+               if assigned(tai_directive(hp).name) then
+                 AsmWrite(tai_directive(hp).name^);
+               AsmLn;
+             end;
 
            else
              internalerror(10000);

+ 1 - 1
compiler/aoptobj.pas

@@ -877,7 +877,7 @@ Unit AoptObj;
 {$define rangewason}
 {$r-}
 {$endif}
-    function tAOptObj.getjumplabelwithsym(sym: tasmlabel): tai;
+    function tAOptObj.getlabelwithsym(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! }

+ 12 - 15
compiler/assemble.pas

@@ -741,7 +741,7 @@ Implementation
               inc(p);
             case p^ of
               #0 :
-                break; 
+                break;
               ' ' :
                 inc(p);
               '0'..'9' :
@@ -777,24 +777,24 @@ Implementation
                     begin
                       if (relocsym.section<>sym.section) then
                         internalerror(2005091810);
-                      relocsym:=nil; 
+                      relocsym:=nil;
                     end
                   else
                     begin
                       relocsym:=sym;
-                    end; 
+                    end;
                   exprvalue:=sym.address;
                 end;
               '+' :
                 begin
                   { nothing, by default addition is done }
                   inc(p);
-                end;  
+                end;
               '-' :
                 begin
                   gotmin:=true;
                   inc(p);
-                end;  
+                end;
               else
                 internalerror(200509189);
             end;
@@ -806,6 +806,8 @@ Implementation
           result:=true;
         end;
 
+      const
+        N_Function = $24; { function or const }
       var
         ofs,
         nline,
@@ -843,7 +845,7 @@ Implementation
         if currpass=1 then
           objectdata.allocstab(pstr)
         else
-          begin  
+          begin
             { Stabs format: nidx,nother,nline[,offset] }
             if not consumenumber(pcurr,nidx) then
               internalerror(200509182);
@@ -862,15 +864,10 @@ Implementation
                 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);
+            if (nidx=N_Function) and
+               target_info.use_function_relative_addresses then
+              ofs:=0;
+            objectdata.writestab(ofs,relocsym,nidx,nother,nline,pstr);
           end;
         if assigned(pendquote) then
           pendquote^:='"';

+ 10 - 0
compiler/dbgbase.pas

@@ -107,4 +107,14 @@ implementation
         CDebugInfo[t]:=c;
       end;
 
+
+    const
+      dbg_none_info : tdbginfo =
+         (
+           id     : dbg_none;
+           idtxt  : 'NONE';
+         );
+
+initialization
+  RegisterDebugInfo(dbg_none_info,tdebuginfo);
 end.

+ 16 - 3
compiler/i386/ag386nsm.pas

@@ -358,6 +358,7 @@ interface
           '.text','.data','.rodata','.bss','.tbss',
           'common',
           '.note',
+          '.text',
           '.stab','.stabstr',
           '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
           '.eh_frame',
@@ -380,9 +381,6 @@ interface
       end;
 
     procedure T386NasmAssembler.WriteTree(p:taasmoutput);
-    const
-      regallocstr : array[tregalloctype] of string[10]=(' allocated',' released',' sync',' resized');
-      tempallocstr : array[boolean] of string[10]=(' released',' allocated');
     var
       s : string;
       hp       : tai;
@@ -747,6 +745,21 @@ interface
              else if tai_marker(hp).kind=InlineEnd then
                dec(InlineLevel);
 
+           ait_directive :
+             begin
+               case tai_directive(hp).directive of
+                 asd_nasm_import :
+                   AsmWrite('import ');
+                 asd_extern :
+                   AsmWrite('EXTERN ');
+                 else
+                   internalerror(200509191);
+               end;
+               if assigned(tai_directive(hp).name) then
+                 AsmWrite(tai_directive(hp).name^);
+               AsmLn;
+             end;
+
            else
              internalerror(10000);
          end;

+ 8 - 70
compiler/ogcoff.pas

@@ -70,8 +70,7 @@ interface
          function  sectionname(atype:tasmsectiontype;const aname:string):string;override;
          procedure writereloc(data,len:aint;p:tasmsymbol;relative:TAsmRelocationType);override;
          procedure writesymbol(p:tasmsymbol);override;
-         procedure writestabs(offset:aint;p:pchar;nidx,nother,line:longint;reloc:boolean);override;
-         procedure writesymstabs(offset:aint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);override;
+         procedure writestab(offset:aint;ps:tasmsymbol;nidx,nother,line:longint;p:pchar);override;
          procedure beforealloc;override;
          procedure beforewrite;override;
          procedure afteralloc;override;
@@ -557,6 +556,7 @@ const go32v2stub : array[0..2047] of byte=(
           '.text','.data','.data','.bss','.threadvar',
           'common',
           '.note',
+          '.text',
           '.stab','.stabstr',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
@@ -660,74 +660,14 @@ const go32v2stub : array[0..2047] of byte=(
       end;
 
 
-    procedure tcoffobjectdata.writestabs(offset:aint;p:pchar;nidx,nother,line:longint;reloc : boolean);
+    procedure tcoffobjectdata.writestab(offset:aint;ps:tasmsymbol;nidx,nother,line:longint;p:pchar);
       var
         stab : coffstab;
         curraddr : longint;
       begin
-        { local var can be at offset -1 !! PM }
-        if reloc then
-         begin
-           if (offset=-1) then
-            begin
-              if currsec=nil then
-               offset:=0
-              else
-               offset:=currsec.datasize;
-            end;
-           if (currsec<>nil) then
-            inc(offset,currsec.datapos);
-         end;
-        if assigned(p) and (p[0]<>#0) then
-         begin
-           stab.strpos:=stabstrsec.datasize;
-           stabstrsec.write(p^,strlen(p)+1);
-         end
-        else
-         stab.strpos:=0;
-        stab.ntype:=nidx;
-        stab.ndesc:=line;
-        stab.nother:=nother;
-        stab.nvalue:=offset;
-        StabsSec.write(stab,sizeof(stab));
-        { when the offset is not 0 then write a relocation, take also the
-          hdrstab into account with the offset }
-        if reloc then
-         begin
-           { current address }
-           curraddr:=StabsSec.mempos+StabsSec.datasize;
-           if DLLSource and RelocSection then
-           { avoid relocation in the .stab section
-             because it ends up in the .reloc section instead }
-             StabsSec.addsectionreloc(curraddr-4,currsec,RELOC_RVA)
-           else
-             StabsSec.addsectionreloc(curraddr-4,currsec,RELOC_ABSOLUTE);
-         end;
-      end;
-
-
-    procedure tcoffobjectdata.writesymstabs(offset:aint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);
-      var
-        stab : coffstab;
-        curraddr : longint;
-      begin
-        { do not use the size stored in offset field
-         this is DJGPP specific ! PM }
-        if win32 then
+        { Win32 does not need an offset if a symbol is provided }
+        if win32 and assigned(ps) then
           offset:=0;
-        { local var can be at offset -1 !! PM }
-        if reloc then
-         begin
-           if (offset=-1) then
-            begin
-              if currsec=nil then
-               offset:=0
-              else
-               offset:=currsec.datasize;
-            end;
-           if (currsec<>nil) then
-            inc(offset,currsec.mempos);
-         end;
         if assigned(p) and (p[0]<>#0) then
          begin
            stab.strpos:=StabStrSec.datasize;
@@ -740,9 +680,7 @@ const go32v2stub : array[0..2047] of byte=(
         stab.nother:=nother;
         stab.nvalue:=offset;
         StabsSec.write(stab,sizeof(stab));
-        { when the offset is not 0 then write a relocation, take also the
-          hdrstab into account with the offset }
-        if reloc then
+        if assigned(ps) then
          begin
            { current address }
            curraddr:=StabsSec.mempos+StabsSec.datasize;
@@ -786,7 +724,7 @@ const go32v2stub : array[0..2047] of byte=(
         { create stabs sections if debugging }
         if (cs_debuginfo in aktmoduleswitches) then
          begin
-           writestabs(0,nil,0,0,0,false);
+           writestab(0,nil,0,0,0,nil);
            { write zero pchar and name together (PM) }
            s:=#0+SplitFileName(current_module.mainsource^)+#0;
            stabstrsec.write(s[1],length(s));
@@ -1077,7 +1015,7 @@ const go32v2stub : array[0..2047] of byte=(
            if StabsSec<>nil then
             begin
               { first stabs for main source }
-              writestabs(0,nil,0,0,0,false);
+              writestab(0,nil,0,0,0,nil);
               s:=#0+SplitFileName(current_module.mainsource^)+#0;
               stabstrsec.write(s[1],length(s));
               { header stab }

+ 6 - 40
compiler/ogelf.pas

@@ -72,8 +72,7 @@ interface
          function  sectionname(atype:tasmsectiontype;const aname:string):string;override;
          procedure writereloc(data,len:aint;p:tasmsymbol;relative:TAsmRelocationType);override;
          procedure writesymbol(p:tasmsymbol);override;
-         procedure writestabs(offset:aint;p:pchar;nidx,nother,line:longint;reloc:boolean);override;
-         procedure writesymstabs(offset:aint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);override;
+         procedure writestab(offset:aint;ps:tasmsymbol;nidx,nother,line:longint;p:pchar);override;
          procedure beforealloc;override;
          procedure beforewrite;override;
        end;
@@ -355,6 +354,7 @@ implementation
 {$endif userodata}
           'common',
           '.note',
+          '.text', { darwin stubs }
           '.stab','.stabstr',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
@@ -429,20 +429,10 @@ implementation
       end;
 
 
-    procedure telf32objectdata.writestabs(offset:aint;p:pchar;nidx,nother,line:longint;reloc : boolean);
+    procedure telf32objectdata.writestab(offset:aint;ps:tasmsymbol;nidx,nother,line:longint;p:pchar);
       var
         stab : telf32stab;
       begin
-        if reloc then
-         begin
-           if (offset=-1) then
-            begin
-              if currsec=nil then
-               offset:=0
-              else
-               offset:=currsec.datasize;
-            end;
-         end;
         fillchar(stab,sizeof(telf32stab),0);
         if assigned(p) and (p[0]<>#0) then
          begin
@@ -454,32 +444,8 @@ implementation
         stab.nother:=nother;
         stab.nvalue:=offset;
         stabssec.write(stab,sizeof(stab));
-        { when the offset is not 0 then write a relocation, take also the
-          hdrstab into account with the offset }
-        if reloc then
-         stabssec.addsectionreloc(stabssec.datasize-4,currsec,RELOC_ABSOLUTE);
-      end;
-
-
-    procedure telf32objectdata.writesymstabs(offset:aint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);
-      var
-        stab : telf32stab;
-      begin
-        fillchar(stab,sizeof(telf32stab),0);
-        if assigned(p) and (p[0]<>#0) then
-         begin
-           stab.strpos:=stabstrsec.datasize;
-           stabstrsec.write(p^,strlen(p)+1);
-         end;
-        stab.ntype:=nidx;
-        stab.ndesc:=line;
-        stab.nother:=nother;
-        stab.nvalue:=0;
-        stabssec.write(stab,sizeof(stab));
-        { when the offset is not 0 then write a relocation, take also the
-          hdrstab into account with the offset }
-        if reloc then
-         stabssec.addsymreloc(stabssec.datasize-4,ps,RELOC_ABSOLUTE);
+        if assigned(ps) then
+          stabssec.addsymreloc(stabssec.datasize-4,ps,RELOC_ABSOLUTE);
       end;
 
 
@@ -501,7 +467,7 @@ implementation
         { create stabs sections if debugging }
         if (cs_debuginfo in aktmoduleswitches) then
          begin
-           writestabs(0,nil,0,0,0,false);
+           writestab(0,nil,0,0,0,nil);
            { write zero pchar and name together (PM) }
            s:=#0+SplitFileName(current_module.mainsource^)+#0;
            stabstrsec.write(s[1],length(s));

+ 1 - 1
compiler/parser.pas

@@ -257,7 +257,7 @@ implementation
          { PIC data }
 {$ifdef powerpc}
          if target_info.system=system_powerpc_darwin then
-           asmlist[al_picdata].concat(tai_simple.create(ait_non_lazy_symbol_pointer));
+           asmlist[al_picdata].concat(tai_directive.create(asd_non_lazy_symbol_pointer,''));
 {$endif powerpc}
 
          { Resource strings }

+ 2 - 158
compiler/powerpc/agppcmpw.pas

@@ -39,10 +39,6 @@ interface
         procedure WriteAsmList;override;
         Function  DoAssemble:boolean;override;
         procedure WriteExternals;
-{$ifdef GDB}
-        procedure WriteFileLineInfo(var fileinfo : tfileposinfo);
-        procedure WriteFileEndInfo;
-{$endif}
         procedure WriteAsmFileHeader;
       private
         procedure WriteInstruction(hp : tai);
@@ -77,20 +73,9 @@ interface
         'csect', {data}
         'csect', {read only data}
         'csect', {bss} 'csect',
-        'csect','csect','csect','csect','','','','','','','','',''
+        'csect','csect','csect','csect','','','','','','','','','',''
       );
 
-{$ifdef GDB}
-var
-      n_line       : byte;     { different types of source lines }
-      linecount,
-      includecount : longint;
-      funcname     : pchar;
-      stabslastfileinfo : tfileposinfo;
-      isInFunction: Boolean;
-      firstLineInFunction: longint;
-{$endif}
-
     type
       t64bitarray = array[0..7] of byte;
       t32bitarray = array[0..3] of byte;
@@ -559,7 +544,7 @@ var
               GetAdjacentTaiSymbol:= true;
               Break;
             end;
-          ait_stab_function_name:
+          ait_function_name:
             hp:=tai(hp.next);
           else
             begin
@@ -610,16 +595,6 @@ var
       AsmWrite(s);
       AsmWriteLn('[PR]');
 
-      {$ifdef GDB}
-      if ((cs_debuginfo in aktmoduleswitches) or
-           (cs_gdb_lineinfo in aktglobalswitches)) then
-        begin
-          //info for debuggers:
-          firstLineInFunction:= stabslastfileinfo.line;
-          AsmWriteLn(#9'beginf ' + tostr(firstLineInFunction));
-          isInFunction:= true;
-        end;
-      {$endif}
       {Write all labels: }
       hp:= first;
       repeat
@@ -697,85 +672,6 @@ var
         (#9'dc.l'#9,#9'dc.w'#9,#9'dc.b'#9);
 
 
-{$ifdef GDB}
-    procedure TPPCMPWAssembler.WriteFileLineInfo(var fileinfo : tfileposinfo);
-        var
-          curr_n : byte;
-        begin
-          if 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 "'+lower(BsToSlash(FixPath(infile.path^,false)))+'",'+
-                     tostr(curr_n)+',0,0,'+target_asm.labelprefix+'text'+ToStr(IncludeCount));
-                 end;
-
-                AsmWriteLn(#9'.stabs "'+lower(FixFileName(infile.name^))+'",'+
-                  tostr(curr_n)+',0,0,'+target_asm.labelprefix+'text'+ToStr(IncludeCount));
-              *)
-              AsmWriteLn(#9'file '''+lower(FixFileName(infile.name^))+'''');
-
-              (*
-                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));
-            *)
-            if isInFunction then
-              AsmWriteln(#9'line '+ tostr(fileinfo.line - firstLineInFunction + 1));
-          end;
-          stabslastfileinfo:=fileinfo;
-        end;
-
-      procedure TPPCMPWAssembler.WriteFileEndInfo;
-
-        begin
-          if not ((cs_debuginfo in aktmoduleswitches) or
-             (cs_gdb_lineinfo in aktglobalswitches)) then
-           exit;
-          AsmLn;
-          (*
-          AsmWriteLn(ait_section2str(sec_code));
-          AsmWriteLn(#9'.stabs "",'+tostr(n_sourcefile)+',0,0,'+target_asm.labelprefix+'etext');
-          AsmWriteLn(target_asm.labelprefix+'etext:');
-          *)
-        end;
-
-{$endif}
-
     procedure TPPCMPWAssembler.WriteTree(p:TAAsmoutput);
     var
       s,
@@ -813,13 +709,6 @@ var
            begin
              hp1 := hp as tailineinfo;
 
-{$ifdef GDB}
-             { write debug info }
-             if (cs_debuginfo in aktmoduleswitches) or
-                (cs_gdb_lineinfo in aktglobalswitches) then
-               WriteFileLineInfo(hp1.fileinfo);
-{$endif GDB}
-
              if do_line then
               begin
            { load infile }
@@ -899,9 +788,6 @@ var
 
                     AsmLn;
                     AsmWriteLn(#9+secnames[tai_section(hp).sectype]+' '+cur_CSECT_name+cur_CSECT_class);
-{$ifdef GDB}
-                    lastfileinfo.line:=-1;
-{$endif GDB}
                   end;
                  LasTSec:=tai_section(hp).sectype;
                end;
@@ -1185,11 +1071,6 @@ var
                       end;
                   end;
                end;
-             ait_direct:
-               begin
-                  AsmWritePChar(tai_direct(hp).str);
-                  AsmLn;
-               end;
              ait_symbol:
                begin
                   if tai_symbol(hp).sym.typ=AT_FUNCTION then
@@ -1208,16 +1089,6 @@ var
                     InternalError(2003071301);
                 end;
               ait_symbol_end:
-{$ifdef GDB}
-                if isInFunction then
-                  if ((cs_debuginfo in aktmoduleswitches) or
-                       (cs_gdb_lineinfo in aktglobalswitches)) then
-                    begin
-                      //info for debuggers:
-                      AsmWriteLn(#9'endf ' + tostr(stabslastfileinfo.line));
-                      isInFunction:= false;
-                    end
-{$endif GDB}
                 ;
               ait_instruction:
                 WriteInstruction(hp);
@@ -1374,12 +1245,7 @@ var
     end;
 
     procedure TPPCMPWAssembler.WriteAsmList;
-
-
-{$ifdef GDB}
     var
-      fileinfo : tfileposinfo;
-{$endif GDB}
       hal : tasmlist;
     begin
 {$ifdef EXTDEBUG}
@@ -1387,24 +1253,6 @@ var
        comment(v_info,'Start writing MPW-styled assembler output for '+current_module.mainsource^);
 {$endif}
       LasTSec:=sec_none;
-{$ifdef GDB}
-      FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
-{$endif GDB}
-{$ifdef GDB}
-      //n_line:=n_bssline;
-      funcname:=nil;
-      linecount:=1;
-      includecount:=0;
-      fileinfo.fileindex:=1;
-      fileinfo.line:=1;
-
-      isInFunction:= false;
-      firstLineInFunction:= 0;
-
-      { Write main file }
-      WriteFileLineInfo(fileinfo);
-
-{$endif GDB}
 
       WriteAsmFileHeader;
       WriteExternals;
@@ -1416,10 +1264,6 @@ var
           AsmWriteLn(target_asm.comment+'End asmlist '+TasmlistStr[hal]);
         end;
 
-      {$ifdef GDB}
-      WriteFileEndInfo;
-      {$ENDIF}
-
       AsmWriteLn(#9'end');
       AsmLn;
 

+ 4 - 8
compiler/powerpc/cgcpu.pas

@@ -369,14 +369,13 @@ const
           asmlist[al_imports]:=TAAsmoutput.create;
 
         asmlist[al_imports].concat(Tai_section.Create(sec_data,'',0));
-        asmlist[al_imports].concat(Tai_direct.create(strpnew('.section __TEXT,__symbol_stub1,symbol_stubs,pure_instructions,16')));
+        asmlist[al_imports].concat(Tai_section.create(sec_stub,'',0));
         asmlist[al_imports].concat(Tai_align.Create(4));
         result := objectlibrary.newasmsymbol(stubname,AB_EXTERNAL,AT_FUNCTION);
         asmlist[al_imports].concat(Tai_symbol.Create(result,0));
-        asmlist[al_imports].concat(Tai_direct.create(strpnew((#9+'.indirect_symbol ')+s)));
+        asmlist[al_imports].concat(tai_directive.create(asd_indirect_symbol,s));
         l1 := objectlibrary.newasmsymbol('L'+s+'$lazy_ptr',AB_EXTERNAL,AT_FUNCTION);
         reference_reset_symbol(href,l1,0);
-{$ifdef powerpc}
         href.refaddr := addr_hi;
         asmlist[al_imports].concat(taicpu.op_reg_ref(A_LIS,NR_R11,href));
         href.refaddr := addr_lo;
@@ -384,13 +383,10 @@ const
         asmlist[al_imports].concat(taicpu.op_reg_ref(A_LWZU,NR_R12,href));
         asmlist[al_imports].concat(taicpu.op_reg(A_MTCTR,NR_R12));
         asmlist[al_imports].concat(taicpu.op_none(A_BCTR));
-{$else powerpc}
-        internalerror(2004010502);
-{$endif powerpc}
         asmlist[al_imports].concat(Tai_section.Create(sec_data,'',0));
-        asmlist[al_imports].concat(Tai_direct.create(strpnew('.lazy_symbol_pointer')));
+        asmlist[al_imports].concat(tai_directive.create(asd_lazy_symbol_pointer,''));
         asmlist[al_imports].concat(Tai_symbol.Create(l1,0));
-        asmlist[al_imports].concat(Tai_direct.create(strpnew((#9+'.indirect_symbol ')+s)));
+        asmlist[al_imports].concat(tai_directive.create(asd_indirect_symbol,s));
         asmlist[al_imports].concat(tai_const.createname(strpnew('dyld_stub_binding_helper'),AT_FUNCTION,0));
       end;
 

+ 3 - 2
compiler/psystem.pas

@@ -123,7 +123,7 @@ implementation
 
 {$ifdef cpufpemu}
         { Normal types }
-        { we use the same types as without emulator, the only
+        (* we use the same types as without emulator, the only
           difference is that direct calls to the emulator are generated
         if (cs_fp_emulation in aktmoduleswitches) then
           begin
@@ -135,7 +135,7 @@ implementation
             addtype('Extended',pbestrealtype^);
           end
         else
-        }
+        *)
 {$endif cpufpemu}
           begin
             addtype('Single',s32floattype);
@@ -510,6 +510,7 @@ implementation
         aiclass[ait_datablock]:=tai_datablock;
         aiclass[ait_symbol]:=tai_symbol;
         aiclass[ait_symbol_end]:=tai_symbol_end;
+        aiclass[ait_directive]:=tai_directive;
         aiclass[ait_label]:=tai_label;
         aiclass[ait_const_64bit]:=tai_const;
         aiclass[ait_const_32bit]:=tai_const;

+ 2 - 2
compiler/rautils.pas

@@ -848,7 +848,7 @@ Begin
           arraydef,
           floatdef :
             SetSize(tabstractvarsym(sym).getsize,false);
-          { makes no sense when using sse instructions (FK)
+          (* makes no sense when using sse instructions (FK)
           arraydef :
             begin
               { for arrays try to get the element size, take care of
@@ -859,7 +859,7 @@ Begin
                harrdef:=tarraydef(harrdef.elementtype.def);
               SetSize(harrdef.elesize,false);
             end;
-          }
+          *)
         end;
         hasvar:=true;
         SetupVar:=true;

+ 1 - 0
compiler/systems/t_linux.pas

@@ -209,6 +209,7 @@ const
 {$ifdef powerpc}platform_select='-b elf32-powerpc -m elf32ppclinux';{$endif}
 {$ifdef sparc}  platform_select='-b elf32-sparc -m elf32_sparc';{$endif}
 {$ifdef arm}    platform_select='';{$endif} {unknown :( }
+{$ifdef m68k}    platform_select='';{$endif} {unknown :( }
 
 {$ifdef m68k}
 var

+ 2 - 8
compiler/systems/t_win.pas

@@ -241,14 +241,8 @@ implementation
              hp2:=twin32imported_item(hp1.imported_items.first);
              while assigned(hp2) do
                begin
-{$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_directive.create(asd_extern,hp2.func^));
+                 asmlist[al_imports].concat(tai_directive.create(asd_nasm_import,hp2.func^+' '+hp1.dllname^+' '+hp2.name^));
                  hp2:=twin32imported_item(hp2.next);
                end;
              hp1:=timportlist(hp1.next);

+ 18 - 2
compiler/x86/agx86int.pas

@@ -60,13 +60,13 @@ implementation
 
       secnames : array[TAsmSectionType] of string[4] = ('',
         'CODE','DATA','DATA','BSS','',
-        '','','','','','',
+        '','','','','','','',
         '','','','','','',''
       );
 
       secnamesml64 : array[TAsmSectionType] of string[7] = ('',
         '_TEXT','_DATE','_DATA','_BSS','',
-        '','','','',
+        '','','','','',
         'idata$2','idata$4','idata$5','idata$6','idata$7','edata',
         '','',''
       );
@@ -787,6 +787,22 @@ implementation
                else if tai_marker(hp).kind=InlineEnd then
                  dec(InlineLevel);
              end;
+
+           ait_directive :
+             begin
+               case tai_directive(hp).directive of
+                 asd_nasm_import :
+                   AsmWrite('import ');
+                 asd_extern :
+                   AsmWrite('EXTRN ');
+                 else
+                   internalerror(200509192);
+               end;
+               if assigned(tai_directive(hp).name) then
+                 AsmWrite(tai_directive(hp).name^);
+               AsmLn;
+             end;
+
            else
             internalerror(10000);
          end;