Ver Fonte

+ patched to 1.1.0 with former 1.09patch from peter

michael há 25 anos atrás
pai
commit
665c1f6410

+ 2 - 2
compiler/Makefile

@@ -277,9 +277,9 @@ override LOCALDEF+=-dGDB -dBROWSERLOG
 ifeq ($(CPU_TARGET),i386)
 # also insert MMX support
 override LOCALDEF+=-dSUPPORT_MMX
-# We don't need the intel and binary writer on linux...
+# We don't need the intel writer on linux...
 ifdef inlinux
-override LOCALDEF+=-dNOAG386INT -dNOAG386BIN
+override LOCALDEF+=-dNOAG386INT
 endif
 endif
 

+ 2 - 2
compiler/Makefile.fpc

@@ -80,9 +80,9 @@ override LOCALDEF+=-dGDB -dBROWSERLOG
 ifeq ($(CPU_TARGET),i386)
 # also insert MMX support
 override LOCALDEF+=-dSUPPORT_MMX
-# We don't need the intel and binary writer on linux...
+# We don't need the intel writer on linux...
 ifdef inlinux
-override LOCALDEF+=-dNOAG386INT -dNOAG386BIN
+override LOCALDEF+=-dNOAG386INT
 endif
 endif
 

+ 62 - 36
compiler/aasm.pas

@@ -89,12 +89,15 @@ unit aasm;
 
   { asm symbol functions }
     type
-       TAsmsymtype=(AS_NONE,AS_EXTERNAL,AS_LOCAL,AS_GLOBAL);
+       TAsmsymbind=(AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL);
+
+       TAsmsymtype=(AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION);
 
        pasmsymbol = ^tasmsymbol;
        tasmsymbol = object(tnamedindexobject)
-         orgtyp,
-         typ     : TAsmsymtype;
+         orgbind,
+         bind      : TAsmsymbind;
+         typ       : TAsmsymtype;
          proclocal : boolean;
          { this need to be incremented with every symbol loading into the
            paasmoutput, thus in loadsym/loadref/const_symbol (PFV) }
@@ -107,10 +110,10 @@ unit aasm;
          { alternate symbol which can be used for 'renaming' needed for
            inlining }
          altsymbol : pasmsymbol;
-         constructor init(const s:string;_typ:TAsmsymtype);
+         constructor init(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
          procedure reset;
          function  is_used:boolean;
-         procedure settyp(t:tasmsymtype);
+         procedure setbind(t:tasmsymbind);
          procedure setaddress(sec:tsection;offset,len:longint);
          procedure GenerateAltSymbol;
        end;
@@ -160,6 +163,8 @@ unit aasm;
           constructor init(_sym:PAsmSymbol;siz:longint);
           constructor initname(const _name : string;siz:longint);
           constructor initname_global(const _name : string;siz:longint);
+          constructor initdataname(const _name : string;siz:longint);
+          constructor initdataname_global(const _name : string;siz:longint);
        end;
 
        pai_symbol_end = ^tai_symbol_end;
@@ -362,7 +367,7 @@ type
     procedure getlabelnr(var l : longint);
 
     function  newasmsymbol(const s : string) : pasmsymbol;
-    function  newasmsymboltyp(const s : string;_typ:TAsmSymType) : pasmsymbol;
+    function  newasmsymboltype(const s : string;_bind:TAsmSymBind;_typ:TAsmsymtype) : pasmsymbol;
     function  getasmsymbol(const s : string) : pasmsymbol;
     function  renameasmsymbol(const sold, snew : string):pasmsymbol;
 
@@ -406,7 +411,7 @@ uses
       begin
          inherited init;
          typ:=ait_datablock;
-         sym:=newasmsymboltyp(_name,AS_LOCAL);
+         sym:=newasmsymboltype(_name,AB_LOCAL,AT_DATA);
          { keep things aligned }
          if _size<=0 then
            _size:=4;
@@ -419,7 +424,7 @@ uses
       begin
          inherited init;
          typ:=ait_datablock;
-         sym:=newasmsymboltyp(_name,AS_GLOBAL);
+         sym:=newasmsymboltype(_name,AB_GLOBAL,AT_DATA);
          { keep things aligned }
          if _size<=0 then
            _size:=4;
@@ -438,14 +443,14 @@ uses
          typ:=ait_symbol;
          sym:=_sym;
          size:=siz;
-         is_global:=(sym^.typ=AS_GLOBAL);
+         is_global:=(sym^.bind=AB_GLOBAL);
       end;
 
     constructor tai_symbol.initname(const _name : string;siz:longint);
       begin
          inherited init;
          typ:=ait_symbol;
-         sym:=newasmsymboltyp(_name,AS_LOCAL);
+         sym:=newasmsymboltype(_name,AB_LOCAL,AT_FUNCTION);
          size:=siz;
          is_global:=false;
       end;
@@ -454,7 +459,25 @@ uses
       begin
          inherited init;
          typ:=ait_symbol;
-         sym:=newasmsymboltyp(_name,AS_GLOBAL);
+         sym:=newasmsymboltype(_name,AB_GLOBAL,AT_FUNCTION);
+         size:=siz;
+         is_global:=true;
+      end;
+
+    constructor tai_symbol.initdataname(const _name : string;siz:longint);
+      begin
+         inherited init;
+         typ:=ait_symbol;
+         sym:=newasmsymboltype(_name,AB_LOCAL,AT_DATA);
+         size:=siz;
+         is_global:=false;
+      end;
+
+    constructor tai_symbol.initdataname_global(const _name : string;siz:longint);
+      begin
+         inherited init;
+         typ:=ait_symbol;
+         sym:=newasmsymboltype(_name,AB_GLOBAL,AT_DATA);
          size:=siz;
          is_global:=true;
       end;
@@ -475,7 +498,7 @@ uses
       begin
          inherited init;
          typ:=ait_symbol_end;
-         sym:=newasmsymboltyp(_name,AS_GLOBAL);
+         sym:=newasmsymboltype(_name,AB_GLOBAL,AT_NONE);
       end;
 
 
@@ -674,7 +697,7 @@ uses
         typ:=ait_label;
         l:=_l;
         l^.is_set:=true;
-        is_global:=(l^.typ=AS_GLOBAL);
+        is_global:=(l^.bind=AB_GLOBAL);
       end;
 
 
@@ -834,7 +857,7 @@ uses
                                   AsmSymbol
 *****************************************************************************}
 
-    constructor tasmsymbol.init(const s:string;_typ:TAsmsymtype);
+    constructor tasmsymbol.init(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
       begin;
       {$IFDEF NEWST}
         inherited init(s);
@@ -842,7 +865,8 @@ uses
         inherited initname(s);
       {$ENDIF NEWST}
         reset;
-        orgtyp:=_typ;
+        orgbind:=_bind;
+        bind:=_bind;
         typ:=_typ;
       end;
 
@@ -850,7 +874,7 @@ uses
       begin
         if not assigned(altsymbol) then
          begin
-           new(altsymbol,init(name+'_'+tostr(nextaltnr),typ));
+           new(altsymbol,init(name+'_'+tostr(nextaltnr),bind,typ));
            { also copy the amount of references }
            altsymbol^.refs:=refs;
            inc(nextaltnr);
@@ -864,7 +888,7 @@ uses
         address:=0;
         size:=0;
         idx:=-1;
-        typ:=AS_EXTERNAL;
+        bind:=AB_EXTERNAL;
         proclocal:=false;
         { mainly used to remove unused labels from the codesegment }
         refs:=0;
@@ -875,10 +899,10 @@ uses
         is_used:=(refs>0);
       end;
 
-    procedure tasmsymbol.settyp(t:tasmsymtype);
+    procedure tasmsymbol.setbind(t:tasmsymbind);
       begin
-        typ:=t;
-        orgtyp:=t;
+        bind:=t;
+        orgbind:=t;
       end;
 
     procedure tasmsymbol.setaddress(sec:tsection;offset,len:longint);
@@ -888,8 +912,8 @@ uses
         size:=len;
         { when the typ was reset to External, set it back to the original
           type it got when defined }
-        if (typ=AS_EXTERNAL) and (orgtyp<>AS_NONE) then
-         typ:=orgtyp;
+        if (bind=AB_EXTERNAL) and (orgbind<>AB_NONE) then
+         bind:=orgbind;
       end;
 
 
@@ -901,7 +925,7 @@ uses
       begin;
         labelnr:=nextlabelnr;
         inc(nextlabelnr);
-        inherited init(target_asm.labelprefix+tostr(labelnr),AS_LOCAL);
+        inherited init(target_asm.labelprefix+tostr(labelnr),AB_LOCAL,AT_FUNCTION);
         proclocal:=true;
         is_set:=false;
       end;
@@ -912,9 +936,9 @@ uses
         labelnr:=nextlabelnr;
         inc(nextlabelnr);
         if (cs_create_smart in aktmoduleswitches) then
-          inherited init('_$'+current_module^.modulename^+'$_L'+tostr(labelnr),AS_GLOBAL)
+          inherited init('_$'+current_module^.modulename^+'$_L'+tostr(labelnr),AB_GLOBAL,AT_DATA)
         else
-          inherited init(target_asm.labelprefix+tostr(labelnr),AS_LOCAL);
+          inherited init(target_asm.labelprefix+tostr(labelnr),AB_LOCAL,AT_DATA);
         is_set:=false;
         { write it always }
         refs:=1;
@@ -943,27 +967,26 @@ uses
            exit;
          end;
         { Not found, insert it as an External }
-        hp:=new(pasmsymbol,init(s,AS_EXTERNAL));
+        hp:=new(pasmsymbol,init(s,AB_EXTERNAL,AT_FUNCTION));
         asmsymbollist^.insert(hp);
         newasmsymbol:=hp;
       end;
 
 
-    function  newasmsymboltyp(const s : string;_typ:TAsmSymType) : pasmsymbol;
+    function  newasmsymboltype(const s : string;_bind:TAsmSymBind;_typ:Tasmsymtype) : pasmsymbol;
       var
         hp : pasmsymbol;
       begin
         hp:=pasmsymbol(asmsymbollist^.search(s));
         if assigned(hp) then
+         hp^.setbind(_bind)
+        else
          begin
-           hp^.settyp(_typ);
-           newasmsymboltyp:=hp;
-           exit;
+           { Not found, insert it as an External }
+           hp:=new(pasmsymbol,init(s,_bind,_typ));
+           asmsymbollist^.insert(hp);
          end;
-        { Not found, insert it as an External }
-        hp:=new(pasmsymbol,init(s,_typ));
-        asmsymbollist^.insert(hp);
-        newasmsymboltyp:=hp;
+        newasmsymboltype:=hp;
       end;
 
 
@@ -1008,7 +1031,7 @@ uses
       begin
         if (pasmsymbol(p)^.refs>0) and
            (pasmsymbol(p)^.section=Sec_none) and
-           (pasmsymbol(p)^.typ<>AS_EXTERNAL) then
+           (pasmsymbol(p)^.bind<>AB_EXTERNAL) then
          Message1(asmw_e_undefined_label,pasmsymbol(p)^.name);
       end;
 
@@ -1067,7 +1090,10 @@ uses
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:28  michael
+  Revision 1.3  2000-07-13 12:08:24  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:28  michael
   + removed logs
 
 }

+ 5 - 2
compiler/ag386att.pas

@@ -658,7 +658,7 @@ unit ag386att;
              begin
                if (pai_label(hp)^.l^.is_used) then
                 begin
-                  if pai_label(hp)^.l^.typ=AS_GLOBAL then
+                  if pai_label(hp)^.l^.bind=AB_GLOBAL then
                    begin
                      AsmWrite('.globl'#9);
                      AsmWriteLn(pai_label(hp)^.l^.name);
@@ -902,7 +902,10 @@ unit ag386att;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:28  michael
+  Revision 1.3  2000-07-13 12:08:24  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:28  michael
   + removed logs
 
 }

+ 26 - 17
compiler/ag386bin.pas

@@ -34,7 +34,7 @@ unit ag386bin;
        cpubase,cobjects,aasm,files,assemble;
 
     type
-      togtype=(og_none,og_dbg,og_coff,og_pecoff);
+      togtype=(og_none,og_dbg,og_coff,og_pecoff,og_elf);
 
       pi386binasmlist=^ti386binasmlist;
       ti386binasmlist=object
@@ -83,7 +83,7 @@ unit ag386bin;
 {$ifdef GDB}
        gdb,
 {$endif}
-       og386,og386dbg,og386cff;
+       og386,og386dbg,og386cff,og386elf;
 
 {$ifdef GDB}
 
@@ -267,7 +267,7 @@ unit ag386bin;
 
         if (nidx=n_textline) and assigned(funcname) and
            (target_os.use_function_relative_addresses) then
-          objectoutput^.WriteStabs(sec_code,pgenericcoffoutput(objectoutput)^.sects[sec_code]^.len-funcname^.address,
+          objectoutput^.WriteStabs(sec_code,objectoutput^.sectionsize(sec_code)-funcname^.address,
               nil,nidx,0,line,false)
         else
           begin
@@ -277,7 +277,7 @@ unit ag386bin;
               sec:=sec_data
             else
               sec:=sec_bss;
-            objectoutput^.WriteStabs(sec,pgenericcoffoutput(objectoutput)^.sects[sec]^.len,
+            objectoutput^.WriteStabs(sec,objectoutput^.sectionsize(sec),
               nil,nidx,0,line,true);
           end;
       end;
@@ -311,7 +311,7 @@ unit ag386bin;
            hp:=newasmsymbol('Ltext'+ToStr(IncludeCount));
            if currpass=1 then
              begin
-                hp^.settyp(AS_LOCAL);
+                hp^.setbind(AB_LOCAL);
                 hp^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,0);
              end
            else
@@ -358,13 +358,12 @@ unit ag386bin;
         hp:=newasmsymbol('Letext');
         if currpass=1 then
           begin
-            hp^.settyp(AS_LOCAL);
+            hp^.setbind(AB_LOCAL);
             hp^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,0);
           end
         else
           objectoutput^.writesymbol(hp);
-        EmitStabs('"",'+tostr(n_sourcefile)+
-             ',0,0,Letext');
+        EmitStabs('"",'+tostr(n_sourcefile)+',0,0,Letext');
         objectalloc^.setsection(store_sec);
       end;
 {$endif GDB}
@@ -509,7 +508,7 @@ unit ag386bin;
                   begin
                     if pai_datablock(hp)^.is_global then
                      begin
-                       pai_datablock(hp)^.sym^.settyp(AS_EXTERNAL);
+                       pai_datablock(hp)^.sym^.setbind(AB_COMMON);
                        pai_datablock(hp)^.sym^.setaddress(sec_none,pai_datablock(hp)^.size,pai_datablock(hp)^.size);
                      end
                     else
@@ -519,7 +518,7 @@ unit ag386bin;
                          objectalloc^.sectionalign(4)
                        else if l>1 then
                          objectalloc^.sectionalign(2);
-                       pai_datablock(hp)^.sym^.settyp(AS_LOCAL);
+                       pai_datablock(hp)^.sym^.setbind(AB_LOCAL);
                        pai_datablock(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,
                          pai_datablock(hp)^.size);
                        objectalloc^.sectionalloc(pai_datablock(hp)^.size);
@@ -529,9 +528,9 @@ unit ag386bin;
 {$endif}
                    begin
                      if pai_datablock(hp)^.is_global then
-                      pai_datablock(hp)^.sym^.settyp(AS_GLOBAL)
+                      pai_datablock(hp)^.sym^.setbind(AB_GLOBAL)
                      else
-                      pai_datablock(hp)^.sym^.settyp(AS_LOCAL);
+                      pai_datablock(hp)^.sym^.setbind(AB_LOCAL);
                      l:=pai_datablock(hp)^.size;
                      if l>2 then
                        objectalloc^.sectionalign(4)
@@ -588,17 +587,22 @@ unit ag386bin;
              ait_symbol :
                begin
                  if pai_symbol(hp)^.is_global then
-                  pai_symbol(hp)^.sym^.settyp(AS_GLOBAL)
+                  pai_symbol(hp)^.sym^.setbind(AB_GLOBAL)
                  else
-                  pai_symbol(hp)^.sym^.settyp(AS_LOCAL);
+                  pai_symbol(hp)^.sym^.setbind(AB_LOCAL);
                  pai_symbol(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,0);
                end;
+             ait_symbol_end :
+               begin
+                 if target_info.target=target_i386_linux then
+                  pai_symbol(hp)^.sym^.size:=objectalloc^.sectionsize-pai_symbol(hp)^.sym^.address;
+                end;
              ait_label :
                begin
                  if pai_label(hp)^.is_global then
-                  pai_label(hp)^.l^.settyp(AS_GLOBAL)
+                  pai_label(hp)^.l^.setbind(AB_GLOBAL)
                  else
-                  pai_label(hp)^.l^.settyp(AS_LOCAL);
+                  pai_label(hp)^.l^.setbind(AB_LOCAL);
                  pai_label(hp)^.l^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,0);
                end;
              ait_string :
@@ -963,6 +967,8 @@ unit ag386bin;
             objectoutput:=new(pdjgppcoffoutput,init(smart));
           og_pecoff :
             objectoutput:=new(pwin32coffoutput,init(smart));
+          og_elf :
+            objectoutput:=new(pelf32output,init(smart));
         end;
         objectalloc:=new(pobjectalloc,init);
         SmartAsm:=smart;
@@ -979,7 +985,10 @@ unit ag386bin;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:29  michael
+  Revision 1.3  2000-07-13 12:08:24  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:29  michael
   + removed logs
 
 }

+ 5 - 2
compiler/ag386int.pas

@@ -594,7 +594,7 @@ ait_stab_function_name : ;
 
     procedure writeexternal(p:pnamedindexobject);{$ifndef FPC}far;{$endif}
       begin
-        if pasmsymbol(p)^.typ=AS_EXTERNAL then
+        if pasmsymbol(p)^.bind=AB_EXTERNAL then
          currentasmlist^.AsmWriteln(#9'EXTRN'#9+p^.name);
       end;
 
@@ -645,7 +645,10 @@ ait_stab_function_name : ;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:30  michael
+  Revision 1.3  2000-07-13 12:08:24  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:30  michael
   + removed logs
 
 }

+ 5 - 2
compiler/ag386nsm.pas

@@ -725,7 +725,7 @@ unit ag386nsm;
 
     procedure writeexternal(p:pnamedindexobject);{$ifndef FPC}far;{$endif}
       begin
-        if pasmsymbol(p)^.typ=AS_EXTERNAL then
+        if pasmsymbol(p)^.bind=AB_EXTERNAL then
          currentasmlist^.AsmWriteln('EXTERN'#9+p^.name);
       end;
 
@@ -774,7 +774,10 @@ unit ag386nsm;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:30  michael
+  Revision 1.3  2000-07-13 12:08:24  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:30  michael
   + removed logs
 
 }

+ 8 - 2
compiler/assemble.pas

@@ -516,7 +516,8 @@ begin
   {$ifndef NoAg386Bin}
      as_i386_dbg,
      as_i386_coff,
-     as_i386_pecoff :
+     as_i386_pecoff,
+     as_i386_elf :
        begin
          case aktoutputformat of
            as_i386_dbg :
@@ -525,6 +526,8 @@ begin
              b:=new(pi386binasmlist,Init(og_coff,smart));
            as_i386_pecoff :
              b:=new(pi386binasmlist,Init(og_pecoff,smart));
+           as_i386_elf :
+             b:=new(pi386binasmlist,Init(og_elf,smart));
          end;
          b^.WriteBin;
          dispose(b,done);
@@ -603,7 +606,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:32  michael
+  Revision 1.3  2000-07-13 12:08:24  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:32  michael
   + removed logs
 
 }

+ 5 - 1
compiler/browcol.pas

@@ -1250,6 +1250,7 @@ end;
          vs_Value : ;
          vs_Const : CurName:=CurName+'const ';
          vs_Var   : CurName:=CurName+'var ';
+         vs_Out   : CurName:=CurName+'out ';
        end;
        if assigned(dc^.paratype.def) then
          CurName:=CurName+GetDefinitionStr(dc^.paratype.def);
@@ -2093,7 +2094,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:32  michael
+  Revision 1.3  2000-07-13 12:08:24  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:32  michael
   + removed logs
 
 }

+ 46 - 10
compiler/cg386cal.pas

@@ -75,11 +75,50 @@ implementation
              end;
         end;
 
+      procedure prepareout(const r : treference);
+
+        var
+           hr : treference;
+           pushed : tpushed;
+
+        begin
+           { out parameters needs to be finalized }
+           if (defcoll^.paratype.def^.needs_inittable) then
+             begin
+                reset_reference(hr);
+                hr.symbol:=defcoll^.paratype.def^.get_inittable_label;
+                emitpushreferenceaddr(hr);
+                emitpushreferenceaddr(r);
+                emitcall('FPC_FINALIZE');
+             end
+           else
+           { or at least it zeroed out }
+             begin
+                case defcoll^.paratype.def^.size of
+                   1:
+                     emit_const_ref(A_MOV,S_B,0,newreference(r));
+                   2:
+                     emit_const_ref(A_MOV,S_W,0,newreference(r));
+                   4:
+                     emit_const_ref(A_MOV,S_L,0,newreference(r));
+                   else
+                     begin
+                        pushusedregisters(pushed,$ff);
+                        emit_const(A_PUSH,S_W,0);
+                        push_int(defcoll^.paratype.def^.size);
+                        emitpushreferenceaddr(r);
+                        emitcall('FPC_FILLCHAR');
+                        popusedregisters(pushed);
+                     end
+                end;
+             end;
+        end;
       var
          otlabel,oflabel : pasmlabel;
          { temporary variables: }
          tempdeftype : tdeftype;
          r : preference;
+
       begin
          { set default para_alignment to target_os.stackalignment }
          if para_alignment=0 then
@@ -145,7 +184,7 @@ implementation
                 end;
            end
          { handle call by reference parameter }
-         else if (defcoll^.paratyp=vs_var) then
+         else if (defcoll^.paratyp in [vs_var,vs_out]) then
            begin
               if (p^.left^.location.loc<>LOC_REFERENCE) then
                 CGMessage(cg_e_var_must_be_reference);
@@ -166,6 +205,8 @@ implementation
                 end
               else
                 emitpushreferenceaddr(p^.left^.location.reference);
+              if defcoll^.paratyp=vs_out then
+                prepareout(p^.left^.location.reference);
               del_reference(p^.left^.location.reference);
            end
          else
@@ -309,11 +350,7 @@ implementation
               p^.right:=getcopy(p^.right);
               { disable further inlining of the same proc
                 in the args }
-{$ifdef INCLUDEOK}
               exclude(p^.procdefinition^.proccalloptions,pocall_inline);
-{$else}
-              p^.procdefinition^.proccalloptions:=p^.procdefinition^.proccalloptions-[pocall_inline];
-{$endif}
            end
          else
            { parameters not necessary anymore (JM) }
@@ -949,11 +986,7 @@ implementation
                 { inlined code is in inlinecode }
                 begin
                    { set poinline again }
-{$ifdef INCLUDEOK}
                    include(p^.procdefinition^.proccalloptions,pocall_inline);
-{$else}
-                   p^.procdefinition^.proccalloptions:=p^.procdefinition^.proccalloptions+[pocall_inline];
-{$endif}
                    { process the inlinecode }
                    secondpass(inlinecode);
                    { free the args }
@@ -1478,7 +1511,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:32  michael
+  Revision 1.3  2000-07-13 12:08:24  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:32  michael
   + removed logs
 
 }

+ 5 - 2
compiler/cg386ld.pas

@@ -258,7 +258,7 @@ implementation
                            end;
                          { in case call by reference, then calculate. Open array
                            is always an reference! }
-                         if (pvarsym(p^.symtableentry)^.varspez=vs_var) or
+                         if (pvarsym(p^.symtableentry)^.varspez in [vs_var,vs_out]) or
                             is_open_array(pvarsym(p^.symtableentry)^.vartype.def) or
                             is_array_of_const(pvarsym(p^.symtableentry)^.vartype.def) or
                             ((pvarsym(p^.symtableentry)^.varspez=vs_const) and
@@ -1002,7 +1002,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:34  michael
+  Revision 1.3  2000-07-13 12:08:25  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:34  michael
   + removed logs
 
 }

+ 5 - 4
compiler/cgai386.pas

@@ -2855,9 +2855,7 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
          begin
             { not all kind of parameters need to be finalized  }
             if (psym(p)^.owner^.symtabletype=parasymtable) and
-              ((pvarsym(p)^.varspez=vs_var)  or
-               (pvarsym(p)^.varspez=vs_const) { and
-               (dont_copy_const_param(pvarsym(p)^.definition)) } ) then
+              (pvarsym(p)^.varspez in [vs_out,vs_var,vs_const]) then
               exit;
             if assigned(procinfo) then
               procinfo^.flags:=procinfo^.flags or pi_needs_implicit_finally;
@@ -3971,7 +3969,10 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:37  michael
+  Revision 1.3  2000-07-13 12:08:25  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:37  michael
   + removed logs
 
 }

+ 5 - 2
compiler/cpuasm.pas

@@ -779,7 +779,7 @@ begin
             { instruction size will then always become 2 (PFV) }
             relsize:=(InsOffset+2)-l;
             if (not assigned(sym) or
-                ((sym^.typ<>AS_EXTERNAL) and (sym^.address<>0))) and
+                ((sym^.bind<>AB_EXTERNAL) and (sym^.address<>0))) and
                (relsize>=-128) and (relsize<=127) then
              ot:=OT_IMM32 or OT_SHORT
             else
@@ -1673,7 +1673,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:38  michael
+  Revision 1.3  2000-07-13 12:08:25  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:38  michael
   + removed logs
 
 }

+ 5 - 2
compiler/cresstr.pas

@@ -180,7 +180,7 @@ begin
   if not(assigned(resourcestringlist)) then
     resourcestringlist:=new(paasmoutput,init);
   resourcestringlist^.insert(new(pai_const,init_32bit(resstrcount)));
-  resourcestringlist^.insert(new(pai_symbol,initname_global(current_module^.modulename^+'_'+'RESOURCESTRINGLIST',0)));
+  resourcestringlist^.insert(new(pai_symbol,initdataname_global(current_module^.modulename^+'_'+'RESOURCESTRINGLIST',0)));
   R:=PResourceStringItem(List.First);
   While assigned(R) do
    begin
@@ -284,7 +284,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:39  michael
+  Revision 1.3  2000-07-13 12:08:25  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:39  michael
   + removed logs
 
 }

+ 6 - 3
compiler/globals.pas

@@ -64,13 +64,13 @@ unit globals;
 
        delphimodeswitches : tmodeswitches=
          [m_delphi,m_tp,m_all,m_class,m_objpas,m_result,m_string_pchar,
-          m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring];
+          m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,m_out];
        fpcmodeswitches    : tmodeswitches=
          [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
           m_cvar_support,m_initfinal,m_add_pointer];
        objfpcmodeswitches : tmodeswitches=
          [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
-          m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer];
+          m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer,m_out];
        tpmodeswitches     : tmodeswitches=
          [m_tp7,m_tp,m_all,m_tp_procvar];
        gpcmodeswitches    : tmodeswitches=
@@ -1587,7 +1587,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:41  michael
+  Revision 1.3  2000-07-13 12:08:25  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:41  michael
   + removed logs
 
 }

+ 6 - 2
compiler/globtype.pas

@@ -128,7 +128,8 @@ interface
          m_autoderef,           { does auto dereferencing of struct. vars }
          m_initfinal,           { initialization/finalization for units }
          m_add_pointer,         { allow pointer add/sub operations }
-         m_default_ansistring   { ansistring turned on by default }
+         m_default_ansistring,  { ansistring turned on by default }
+         m_out                  { support the calling convention OUT }
        );
        tmodeswitches = set of tmodeswitch;
 
@@ -199,7 +200,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:41  michael
+  Revision 1.3  2000-07-13 12:08:25  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:41  michael
   + removed logs
 
 }

+ 18 - 3
compiler/hcgdata.pas

@@ -3,7 +3,7 @@
     Copyright (c) 1998-2000 by Florian Klaempfl
 
     Routines for the code generation of data structures
-    like VMT,Messages
+    like VMT, Messages, VTables, Interfaces descs
 
     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
@@ -41,13 +41,25 @@ interface
     function gendmt(_class : pobjectdef) : pasmlabel;
 {$endif WITHDMT}
 
+{ define INTERFACE_SUPPORT}
+
+{$ifdef INTERFACE_SUPPORT}
+    function genintftable(_class: pobjectdef): pasmlabel;
+{$endif INTERFACE_SUPPORT}
+
 implementation
 
     uses
        strings,cobjects,
        globtype,globals,verbose,
        symconst,types,
-       hcodegen;
+       hcodegen, systems, files
+{$ifdef INTERFACE_SUPPORT}
+{$ifdef i386}
+       ,cg386ic
+{$endif}
+{$endif INTERFACE_SUPPORT}
+       ;
 
 
 {*****************************************************************************
@@ -731,7 +743,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:41  michael
+  Revision 1.3  2000-07-13 12:08:26  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:41  michael
   + removed logs
 
 }

+ 6 - 1
compiler/i386tab.inc

@@ -9276,8 +9276,13 @@
     flags   : if_pent or if_3dnow or if_fpu
   )
 );
+
+{
   $Log$
-  Revision 1.2  2000-07-13 11:32:42  michael
+  Revision 1.3  2000-07-13 12:08:26  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:42  michael
   + removed logs
  
 }

+ 10 - 1
compiler/og386.pas

@@ -70,6 +70,7 @@ unit og386;
          procedure NextSmartName;
          procedure initwriting(Aplace:tcutplace);virtual;
          procedure donewriting;virtual;
+         function  sectionsize(s:tsection):longint;virtual;
          procedure setsectionsizes(var s:tsecsize);virtual;
          procedure writebytes(var data;len:longint);virtual;
          procedure writealloc(len:longint);virtual;
@@ -225,6 +226,11 @@ unit og386;
         writer^.close;
       end;
 
+    function tobjectoutput.sectionsize(s:tsection):longint;
+      begin
+        sectionsize:=0;
+      end;
+
     procedure tobjectoutput.setsectionsizes(var s:tsecsize);
       begin
       end;
@@ -273,7 +279,10 @@ unit og386;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:43  michael
+  Revision 1.3  2000-07-13 12:08:26  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:43  michael
   + removed logs
 
 }

+ 77 - 58
compiler/og386cff.pas

@@ -87,13 +87,13 @@ unit og386cff;
          strpos  : longint;
          section : tsection;
          value   : longint;
-         typ     : TAsmsymtype;
+         typ     : TAsmsymbind;
        end;
 
        pcoffsection = ^tcoffsection;
        tcoffsection = object
           index  : tsection;
-          secidx : longint;
+          secsymidx : longint; { index for the section in symtab }
           data   : PDynamicArray;
           size,
           fillsize,
@@ -125,6 +125,7 @@ unit og386cff;
          destructor  done;virtual;
          procedure initwriting(Aplace:tcutplace);virtual;
          procedure donewriting;virtual;
+         function  sectionsize(s:tsection):longint;virtual;
          procedure setsectionsizes(var s:tsecsize);virtual;
          procedure writebytes(var data;len:longint);virtual;
          procedure writealloc(len:longint);virtual;
@@ -230,7 +231,7 @@ unit og386cff;
     constructor tcoffsection.init(sec:TSection;Aflags:longint);
       begin
         index:=sec;
-        secidx:=0;
+        secsymidx:=0;
         flags:=AFlags;
         { alignment after section }
         case sec of
@@ -381,6 +382,15 @@ unit og386cff;
       end;
 
 
+    function tgenericcoffoutput.sectionsize(s:tsection):longint;
+      begin
+        if assigned(sects[s]) then
+         sectionsize:=sects[s]^.len
+        else
+         sectionsize:=0;
+      end;
+
+
     function tgenericcoffoutput.text_flags : longint;
       begin
         text_flags:=0;
@@ -469,10 +479,13 @@ unit og386cff;
         if pos=-1 then
          sym.name:=s;
         sym.value:=p^.size;
-        sym.typ:=p^.typ;
+        sym.typ:=p^.bind;
+        { coff doesn't have common, replace with external }
+        if sym.typ=AB_COMMON then
+          sym.typ:=AB_EXTERNAL;
         { if local of global then set the section value to the address
           of the symbol }
-        if p^.typ in [AS_LOCAL,AS_GLOBAL] then
+        if sym.typ in [AB_LOCAL,AB_GLOBAL] then
          begin
            sym.section:=p^.section;
            sym.value:=p^.address+sects[p^.section]^.mempos;
@@ -480,13 +493,13 @@ unit og386cff;
         { update the asmsymbol index }
         p^.idx:=syms^.count;
         { store the symbol, but not the local ones (PM) }
-        if (p^.typ<>AS_LOCAL) or ((copy(s,1,2)<>'.L') and
+        if (sym.typ<>AB_LOCAL) or ((copy(s,1,2)<>'.L') and
           ((copy(s,1,1)<>'L') or not win32)) then
           syms^.write(sym,1);
         { make the exported syms known to the objectwriter
           (needed for .a generation) }
-        if (p^.typ=AS_GLOBAL) or
-           ((p^.typ=AS_EXTERNAL) and (sym.value=p^.size) and (sym.value>0)) then
+        if (sym.typ=AB_GLOBAL) or
+           ((sym.typ=AB_EXTERNAL) and (sym.value=p^.size) and (sym.value>0)) then
           writer^.writesym(p^.name);
       end;
 
@@ -676,6 +689,48 @@ unit og386cff;
       end;
 
 
+    procedure tgenericcoffoutput.setsectionsizes(var s:tsecsize);
+      var
+        align,
+        mempos : longint;
+        sec : tsection;
+      begin
+        { multiply stab with real size }
+        s[sec_stab]:=s[sec_stab]*sizeof(coffstab);
+        { if debug then also count header stab }
+        if (cs_debuginfo in aktmoduleswitches) then
+         begin
+           inc(s[sec_stab],sizeof(coffstab));
+           inc(s[sec_stabstr],length(SplitFileName(current_module^.mainsource^))+2);
+         end;
+        { fix all section }
+        mempos:=0;
+        for sec:=low(tsection) to high(tsection) do
+         begin
+           if (s[sec]>0) and (not assigned(sects[sec])) then
+             createsection(sec);
+           if assigned(sects[sec]) then
+            begin
+              sects[sec]^.size:=s[sec];
+              sects[sec]^.mempos:=mempos;
+              { calculate the alignment }
+              align:=sects[sec]^.align;
+              sects[sec]^.fillsize:=align-(sects[sec]^.size and (align-1));
+              if sects[sec]^.fillsize=align then
+               sects[sec]^.fillsize:=0;
+              { next section position, not for win32 which uses
+                relative addresses }
+              if not win32 then
+                inc(mempos,sects[sec]^.size+sects[sec]^.fillsize);
+            end;
+         end;
+      end;
+
+
+{***********************************************
+             Writing to disk
+***********************************************}
+
     procedure tgenericcoffoutput.write_relocs(s:pcoffsection);
       var
         rel  : coffreloc;
@@ -687,8 +742,8 @@ unit og386cff;
            rel.address:=r^.address;
            if assigned(r^.symbol) then
             begin
-              if (r^.symbol^.typ=AS_LOCAL) then
-               rel.sym:=2*sects[r^.symbol^.section]^.secidx
+              if (r^.symbol^.bind=AB_LOCAL) then
+               rel.sym:=2*sects[r^.symbol^.section]^.secsymidx
               else
                begin
                  if r^.symbol^.idx=-1 then
@@ -697,7 +752,7 @@ unit og386cff;
                end;
             end
            else if r^.section<>sec_none then
-            rel.sym:=2*sects[r^.section]^.secidx
+            rel.sym:=2*sects[r^.section]^.secsymidx
            else
             rel.sym:=0;
            case r^.relative of
@@ -751,7 +806,7 @@ unit og386cff;
         for sec:=low(tsection) to high(tsection) do
          if assigned(sects[sec]) then
           begin
-            write_symbol(target_asm.secnames[sec],-1,sects[sec]^.mempos,sects[sec]^.secidx,3,1);
+            write_symbol(target_asm.secnames[sec],-1,sects[sec]^.mempos,sects[sec]^.secsymidx,3,1);
             fillchar(secrec,sizeof(secrec),0);
             secrec.len:=sects[sec]^.len;
             secrec.nrelocs:=sects[sec]^.nrelocs;
@@ -762,12 +817,12 @@ unit og386cff;
         for i:=1 to syms^.count do
          begin
            syms^.read(sym,1);
-           if sym.typ=AS_LOCAL then
+           if sym.typ=AB_LOCAL then
              globalval:=3
            else
              globalval:=2;
            if assigned(sects[sym.section]) then
-             sectionval:=sects[sym.section]^.secidx
+             sectionval:=sects[sym.section]^.secsymidx
            else
              sectionval:=0;
            write_symbol(sym.name,sym.strpos,sym.value,sectionval,globalval,0);
@@ -775,48 +830,9 @@ unit og386cff;
       end;
 
 
-    procedure tgenericcoffoutput.setsectionsizes(var s:tsecsize);
-      var
-        align,
-        mempos : longint;
-        sec : tsection;
-      begin
-        { multiply stab with real size }
-        s[sec_stab]:=s[sec_stab]*sizeof(coffstab);
-        { if debug then also count header stab }
-        if (cs_gdb_lineinfo in aktglobalswitches) or
-           (cs_debuginfo in aktmoduleswitches) then
-         begin
-           inc(s[sec_stab],sizeof(coffstab));
-           inc(s[sec_stabstr],length(SplitFileName(current_module^.mainsource^))+2);
-         end;
-        { fix all section }
-        mempos:=0;
-        for sec:=low(tsection) to high(tsection) do
-         begin
-           if (s[sec]>0) and (not assigned(sects[sec])) then
-             createsection(sec);
-           if assigned(sects[sec]) then
-            begin
-              sects[sec]^.size:=s[sec];
-              sects[sec]^.mempos:=mempos;
-              { calculate the alignment }
-              align:=sects[sec]^.align;
-              sects[sec]^.fillsize:=align-(sects[sec]^.size and (align-1));
-              if sects[sec]^.fillsize=align then
-               sects[sec]^.fillsize:=0;
-              { next section position, not for win32 which uses
-                relative addresses }
-              if not win32 then
-                inc(mempos,sects[sec]^.size+sects[sec]^.fillsize);
-            end;
-         end;
-      end;
-
-
     procedure tgenericcoffoutput.writetodisk;
       var
-        datapos,secidx,
+        datapos,secsymidx,
         nsects,sympos,i : longint;
         gotreloc : boolean;
         sec    : tsection;
@@ -851,12 +867,12 @@ unit og386cff;
         datapos:=sizeof(coffheader)+sizeof(coffsechdr)*nsects;
         initsym:=2; { 2 for the file }
         { sections first }
-        secidx:=0;
+        secsymidx:=0;
         for sec:=low(tsection) to high(tsection) do
          if assigned(sects[sec]) then
           begin
-            inc(secidx);
-            sects[sec]^.secidx:=secidx;
+            inc(secsymidx);
+            sects[sec]^.secsymidx:=secsymidx;
             sects[sec]^.datapos:=datapos;
             if assigned(sects[sec]^.data) then
               inc(datapos,sects[sec]^.len);
@@ -1003,7 +1019,10 @@ unit og386cff;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:43  michael
+  Revision 1.3  2000-07-13 12:08:26  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:43  michael
   + removed logs
 
 }

+ 8 - 5
compiler/og386dbg.pas

@@ -92,12 +92,12 @@ unit og386dbg;
          end;
         p^.idx:=nsyms;
         write('symbol [',nsyms,'] '+p^.name+' (',target_asm.secnames[p^.section],',',p^.address,',',p^.size,',');
-        case p^.typ of
-          AS_LOCAL :
+        case p^.bind of
+          AB_LOCAL :
             writeln('local)');
-          AS_GLOBAL :
+          AB_GLOBAL :
             writeln('global)');
-          AS_EXTERNAL :
+          AB_EXTERNAL :
             writeln('extern)');
         else
           writeln('unknown)');
@@ -180,7 +180,10 @@ unit og386dbg;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:43  michael
+  Revision 1.3  2000-07-13 12:08:26  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:43  michael
   + removed logs
 
 }

+ 634 - 457
compiler/og386elf.pas

@@ -29,134 +29,98 @@ unit og386elf;
   interface
 
     uses
-       cobjects,og386,cpubase,aasm;
-
-    const
-      R_386_32 = 1;                    { ordinary absolute relocation }
-      R_386_PC32 = 2;                  { PC-relative relocation }
-      R_386_GOT32 = 3;                 { an offset into GOT }
-      R_386_PLT32 = 4;                 { a PC-relative offset into PLT }
-      R_386_GOTOFF = 9;                { an offset from GOT base }
-      R_386_GOTPC = 10;                { a PC-relative offset _to_ GOT }
-
-      SHT_PROGBITS = 1;
-      SHT_NOBITS = 8;
-
-      SHF_WRITE = 1;
-      SHF_ALLOC = 2;
-      SHF_EXECINSTR = 4;
+       cobjects,
+       systems,cpubase,aasm,og386;
 
     type
-  telf32header=packed record
-      magic0123         : longint;
-      file_class        : byte;
-      data_encoding     : byte;
-      file_version      : byte;
-      padding           : array[$07..$0f] of byte;
-      e_type            : word;
-      e_machine         : word;
-      e_version         : longint;
-      e_entry           : longint;                  // entrypoint
-      e_phoff           : longint;                  // program header offset
-      e_shoff           : longint;                  // sections header offset
-      e_flags           : longint;
-      e_ehsize          : word;             // elf header size in bytes
-      e_phentsize       : word;             // size of an entry in the program header array
-      e_phnum           : word;             // 0..e_phnum-1 of entrys
-      e_shentsize       : word;             // size of an entry in sections header array
-      e_shnum           : word;             // 0..e_shnum-1 of entrys
-      e_shstrndx        : word;             // index of string section header
-  end;
-
-  telf32sechdr=packed record
-      sh_name           : longint;
-      sh_type           : longint;
-      sh_flags          : longint;
-      sh_addr           : longint;
-      sh_offset         : longint;
-      sh_size           : longint;
-      sh_link           : longint;
-      sh_info           : longint;
-      sh_addralign      : longint;
-      sh_entsize        : longint;
-    end;
-
-
        preloc = ^treloc;
        treloc = packed record
           next     : preloc;
           address  : longint;
           symbol   : pasmsymbol;
-          {section  : tsection;} { only used if symbol=nil }
-          typ      : byte;
+          section  : tsection; { only used if symbol=nil }
+          typ      : relative_type;
        end;
 
        psymbol = ^tsymbol;
        tsymbol = packed record
-         strpos  : longint;
-         section : longint;
+         name    : longint;
+         section : tsection;
          value   : longint;
+         bind    : TAsmsymbind;
          typ     : TAsmsymtype;
          size    : longint;
-         globnum : longint;
-         next,
-         nextfwd : psymbol;
        end;
 
-       pelfsection = ^telfsection;
-       telfsection = object
-          index : tsection;
-          name  : string[16];
-          elftype,
-          elfflags,
-          align : longint;
+       pelf32section = ^telf32section;
+       telf32section = object
+          name      : string[16];
+          secshidx,
+          secsymidx : longint; { index for the section in symtab }
+          shstridx,
+          shtype,
+          shflags,
+          shlink,
+          shinfo,
+          addralign,
+          entsize   : longint;
+          { size of the data and in the file }
           data  : PDynamicArray;
-          len,
-          pos,
+          datalen,
+          datapos   : longint;
+          { settings after setsectionsize }
+          size      : longint;
+          fillsize  : longint;
+          { relocation }
           nrelocs   : longint;
           relochead : PReloc;
           reloctail : ^PReloc;
-
-          rel       : PDynamicArray;
-          gsyms     : PSymbol;
-
-          constructor init(sec:TSection;Atype,Aflags,Aalign:longint);
-          constructor initname(const Aname:string;Atype,Aflags,Aalign:longint);
+          relocsect : PElf32Section;
+          constructor init(sec:TSection);
+          constructor initname(const Aname:string;Atype,Aflags,Alink,Ainfo,Aalign,Aentsize:longint);
           destructor  done;
-          procedure  write(var d;l:longint);
-          procedure  alloc(l:longint);
-          procedure  addsymreloc(ofs:longint;p:pasmsymbol;relative:relative_type);
-          procedure  addsectionreloc(ofs:longint;sec:tsection);
+          function  write(var d;l:longint):longint;
+          function  writestr(const s:string):longint;
+          procedure align(l:longint);
+          procedure alloc(l:longint);
+          procedure addsymreloc(ofs:longint;p:pasmsymbol;relative:relative_type);
+          procedure addsectionreloc(ofs:longint;sec:tsection;relative:relative_type);
        end;
 
-       pelfoutput = ^telfoutput;
-       telfoutput = object(tobjectoutput)
-         sects   : array[TSection] of PElfSection;
-         symtab_sect,
-         strtab_sect,
-         shstrtab_sect,
-         gotpc_sect,
-         gotoff_sect,
-         got_sect,
-         plt_sect,
-         sym_sect  : PElfSection;
+       pelf32output = ^telf32output;
+       telf32output = object(tobjectoutput)
+         sects   : array[TSection] of pelf32Section;
+         symtabsect,
+         strtabsect,
+         shstrtabsect,
+         gotpcsect,
+         gotoffsect,
+         gotsect,
+         pltsect,
+         symsect  : pelf32Section;
          strs,
          syms    : Pdynamicarray;
          initsym : longint;
-         constructor init;
+         constructor init(smart:boolean);
          destructor  done;virtual;
-         procedure initwriting;virtual;
+         procedure initwriting(Aplace:tcutplace);virtual;
          procedure donewriting;virtual;
+         function  sectionsize(s:tsection):longint;virtual;
+         procedure setsectionsizes(var s:tsecsize);virtual;
          procedure writebytes(var data;len:longint);virtual;
          procedure writealloc(len:longint);virtual;
+         procedure writealign(len:longint);virtual;
          procedure writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);virtual;
          procedure writesymbol(p:pasmsymbol);virtual;
          procedure writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);virtual;
+         procedure writesymstabs(section:tsection;offset:longint;p:pchar;ps:pasmsymbol;
+           nidx,nother,line:longint;reloc:boolean);virtual;
        private
-         procedure createsection(sec:tsection;const name:string);
-         procedure write_relocs(s:pcoffsection);
-         procedure write_symbol(const name:string;strpos,value,section,typ,aux:longint);
-         procedure write_symbols;
+         procedure createsection(sec:tsection);
+         procedure createrelocsection(s:pelf32section);
+         procedure createshstrtab;
+         procedure createsymtab;
+         procedure writesectionheader(s:pelf32section);
          procedure writetodisk;
        end;
 
@@ -167,88 +131,223 @@ unit og386elf;
         strings,verbose,
         globtype,globals,files;
 
-      type
-      { Structures which are written directly to the output file }
+    const
+      R_386_32 = 1;                    { ordinary absolute relocation }
+      R_386_PC32 = 2;                  { PC-relative relocation }
+      R_386_GOT32 = 3;                 { an offset into GOT }
+      R_386_PLT32 = 4;                 { a PC-relative offset into PLT }
+      R_386_GOTOFF = 9;                { an offset from GOT base }
+      R_386_GOTPC = 10;                { a PC-relative offset _to_ GOT }
 
+      SHN_UNDEF     = 0;
+      SHN_ABS       = $fff1;
+      SHN_COMMON    = $fff2;
 
-      const
-        sec_2_str : array[tsection] of string[8]=('',
-          '.text','.data','.bss',
-          '.stab','.stabstr',
-          '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
-          ''
-        );
+      SHT_NULL     = 0;
+      SHT_PROGBITS = 1;
+      SHT_SYMTAB   = 2;
+      SHT_STRTAB   = 3;
+      SHT_RELA     = 4;
+      SHT_HASH     = 5;
+      SHT_DYNAMIC  = 6;
+      SHT_NOTE     = 7;
+      SHT_NOBITS   = 8;
+      SHT_REL      = 9;
+      SHT_SHLIB    = 10;
+      SHT_DYNSYM   = 11;
+
+      SHF_WRITE     = 1;
+      SHF_ALLOC     = 2;
+      SHF_EXECINSTR = 4;
+
+      STB_LOCAL   = 0;
+      STB_GLOBAL  = 1;
+      STB_WEAK    = 2;
+
+      STT_NOTYPE  = 0;
+      STT_OBJECT  = 1;
+      STT_FUNC    = 2;
+      STT_SECTION = 3;
+      STT_FILE    = 4;
+
+      type
+      { Structures which are written directly to the output file }
+        telf32header=packed record
+          magic0123         : longint;
+          file_class        : byte;
+          data_encoding     : byte;
+          file_version      : byte;
+          padding           : array[$07..$0f] of byte;
+          e_type            : word;
+          e_machine         : word;
+          e_version         : longint;
+          e_entry           : longint;          { entrypoint }
+          e_phoff           : longint;          { program header offset }
+          e_shoff           : longint;          { sections header offset }
+          e_flags           : longint;
+          e_ehsize          : word;             { elf header size in bytes }
+          e_phentsize       : word;             { size of an entry in the program header array }
+          e_phnum           : word;             { 0..e_phnum-1 of entrys }
+          e_shentsize       : word;             { size of an entry in sections header array }
+          e_shnum           : word;             { 0..e_shnum-1 of entrys }
+          e_shstrndx        : word;             { index of string section header }
+        end;
+        telf32sechdr=packed record
+          sh_name           : longint;
+          sh_type           : longint;
+          sh_flags          : longint;
+          sh_addr           : longint;
+          sh_offset         : longint;
+          sh_size           : longint;
+          sh_link           : longint;
+          sh_info           : longint;
+          sh_addralign      : longint;
+          sh_entsize        : longint;
+        end;
+        pelf32reloc=^telf32reloc;
+        telf32reloc=packed record
+          address : longint;
+          info    : longint; { bit 0-7: type, 8-31: symbol }
+        end;
+        pelf32symbol=^telf32symbol;
+        telf32symbol=packed record
+          st_name  : longint;
+          st_value : longint;
+          st_size  : longint;
+          st_info  : byte; { bit 0-3: type, 4-7: bind }
+          st_other : byte;
+          st_shndx : word;
+        end;
+        pelf32stab=^telf32stab;
+        telf32stab=packed record
+          strpos  : longint;
+          ntype   : byte;
+          nother  : byte;
+          ndesc   : word;
+          nvalue  : longint;
+        end;
 
 
 {****************************************************************************
                                TSection
 ****************************************************************************}
 
-    constructor telfsection.init(sec:TSection;Atype,Aflags,Aalign:longint);
+    constructor telf32section.init(sec:TSection);
+      var
+        Aflags,Atype,Aalign,Aentsize : longint;
       begin
-        index:=sec;
-        name:=sec_2_str[sec];
-        elftype:=AType;
-        elfflags:=AFlags;
-        align:=Aalign;
-        relocHead:=nil;
-        relocTail:=@relocHead;
-        Len:=0;
-        Pos:=0;
-        NRelocs:=0;
-        if sec=sec_bss then
-         data:=nil
-        else
-         new(Data,Init(1,8192));
-        new(rel,Init(1,8192));
-        gsyms:=nil;
+        Aflags:=0;
+        Atype:=0;
+        Aalign:=0;
+        Aentsize:=0;
+        case sec of
+          sec_code :
+            begin
+              Aflags:=SHF_ALLOC or SHF_EXECINSTR;
+              AType:=SHT_PROGBITS;
+              AAlign:=16;
+            end;
+          sec_data :
+            begin
+              Aflags:=SHF_ALLOC or SHF_WRITE;
+              AType:=SHT_PROGBITS;
+              AAlign:=4;
+            end;
+          sec_bss :
+            begin
+              Aflags:=SHF_ALLOC or SHF_WRITE;
+              AType:=SHT_NOBITS;
+              AAlign:=4;
+            end;
+        end;
+        initname(target_asm.secnames[sec],Atype,Aflags,0,0,Aalign,Aentsize);
       end;
 
 
-    constructor initname(const Aname:string;Atype,Aflags,Aalign:longint);
+    constructor telf32section.initname(const Aname:string;Atype,Aflags,Alink,Ainfo,Aalign,Aentsize:longint);
       begin
-        index:=sec_none;
         name:=Aname;
-        elftype:=AType;
-        elfflags:=AFlags;
-        align:=Aalign;
+        secshidx:=0;
+        secsymidx:=0;
+        shstridx:=0;
+        shtype:=AType;
+        shflags:=AFlags;
+        shlink:=Alink;
+        shinfo:=Ainfo;
+        addralign:=Aalign;
+        entsize:=Aentsize;
+        { setsectionsize data }
+        fillsize:=0;
+        size:=0;
+        { data }
+        dataLen:=0;
+        dataPos:=0;
+        if shtype=SHT_NOBITS then
+         data:=nil
+        else
+         new(Data,Init(1,8192));
+        { relocation }
+        NRelocs:=0;
         relocHead:=nil;
         relocTail:=@relocHead;
-        Len:=0;
-        Pos:=0;
-        NRelocs:=0;
-        new(Data,Init(1,8192));
-        new(rel,Init(1,8192));
-        gsyms:=nil;
+        relocsect:=nil;
       end;
 
-    destructor telfsection.done;
+
+    destructor telf32section.done;
       begin
         if assigned(Data) then
           dispose(Data,done);
-        if assigned(rel) then
-          dispose(rel,done);
       end;
 
 
-    procedure telfsection.write(var d;l:longint);
+    function telf32section.write(var d;l:longint):longint;
       begin
+        write:=datalen;
         if not assigned(Data) then
          Internalerror(3334441);
         Data^.write(d,l);
-        inc(len,l);
+        inc(datalen,l);
       end;
 
 
-    procedure telfsection.alloc(l:longint);
+    function telf32section.writestr(const s:string):longint;
+      begin
+        writestr:=datalen;
+        if not assigned(Data) then
+         Internalerror(3334441);
+        Data^.write(s[1],length(s));
+        inc(datalen,length(s));
+      end;
+
+
+    procedure telf32section.align(l:longint);
+      var
+        i : longint;
+        empty : array[0..63] of char;
+      begin
+        i:=datalen mod l;
+        if i>0 then
+         begin
+           if assigned(data) then
+            begin
+              fillchar(empty,sizeof(empty),0);
+              data^.write(empty,l-i);
+            end;
+           inc(datalen,l-i);
+         end;
+      end;
+
+
+    procedure telf32section.alloc(l:longint);
       begin
         if assigned(Data) then
          Internalerror(3334442);
-        inc(len,l);
+        inc(datalen,l);
       end;
 
 
-    procedure telfsection.addsymreloc(ofs:longint;p:pasmsymbol;typ:byte);
+    procedure telf32section.addsymreloc(ofs:longint;p:pasmsymbol;relative:relative_type);
       var
         r : PReloc;
       begin
@@ -258,13 +357,13 @@ unit og386elf;
         r^.next:=nil;
         r^.address:=ofs;
         r^.symbol:=p;
-        {r^.section:=sec_none;}
-        r^.typ:=typ;
+        r^.section:=sec_none;
+        r^.typ:=relative;
         inc(nrelocs);
       end;
 
 
-{    procedure telfsection.addsectionreloc(ofs:longint;sec:tsection);
+    procedure telf32section.addsectionreloc(ofs:longint;sec:tsection;relative:relative_type);
       var
         r : PReloc;
       begin
@@ -275,13 +374,13 @@ unit og386elf;
         r^.address:=ofs;
         r^.symbol:=nil;
         r^.section:=sec;
-        r^.relative:=relative_false;
+        r^.typ:=relative;
         inc(nrelocs);
-      end; }
+      end;
 
 
 {****************************************************************************
-                            Genericcoffoutput
+                            TElf32Output
 ****************************************************************************}
 
     const
@@ -293,31 +392,34 @@ unit og386elf;
       strsresize   = 8192;
 {$endif}
 
-    constructor telfoutputput.init;
+    constructor telf32output.init(smart:boolean);
       begin
-        inherited init;
+        inherited init(smart);
       end;
 
 
-    destructor telfoutputput.done;
+    destructor telf32output.done;
       begin
         inherited done;
       end;
 
 
-    procedure telfoutputput.initwriting;
+    procedure telf32output.initwriting(Aplace:tcutplace);
       var
         s : string;
       begin
-        inherited initwriting;
+        inherited initwriting(Aplace);
         { reset }
         initsym:=0;
         new(syms,init(sizeof(TSymbol),symbolresize));
         FillChar(Sects,sizeof(Sects),0);
         { default sections }
-        new(symtab_sect,initname('.symtab',2,4));
-        new(strtab_sect,initname('.strtab',3,1));
-        new(shstrtab_sect,initname('.shstrtab',3,1));
+        new(symtabsect,initname('.symtab',2,0,0,0,4,16));
+        new(strtabsect,initname('.strtab',3,0,0,0,1,0));
+        new(shstrtabsect,initname('.shstrtab',3,0,0,0,1,0));
+        { insert the empty and filename as first in strtab }
+        strtabsect^.writestr(#0);
+        strtabsect^.writestr(SplitFileName(current_module^.mainsource^)+#0);
         { we need at least the following sections }
         createsection(sec_code);
         createsection(sec_data);
@@ -335,13 +437,12 @@ unit og386elf;
       end;
 
 
-    procedure telfoutputput.donewriting;
+    procedure telf32output.donewriting;
       var
         sec : tsection;
       begin
         writetodisk;
         dispose(syms,done);
-        dispose(strs,done);
         for sec:=low(tsection) to high(tsection) do
          if assigned(sects[sec]) then
           dispose(sects[sec],done);
@@ -349,42 +450,24 @@ unit og386elf;
       end;
 
 
-    procedure telfoutputput.createsection(sec:tsection);
-      var
-        Aflags,AType,AAlign : longint;
+    function telf32output.sectionsize(s:tsection):longint;
       begin
-        Aflags:=0;
-        Atype:=0;
-        case sec of
-          sec_code :
-            begin
-              Aflags:=SHF_ALLOC or SHF_EXECINSTR;
-              AType:=SHT_PROGBITS;
-              AAlign:=16;
-            end;
-          sec_data :
-            begin
-              Aflags:=SHF_ALLOC or SHF_WRITE;
-              AType:=SHT_PROGBITS;
-              AAlign:=4;
-            end;
-          sec_bss :
-            begin
-              Aflags:=SHF_ALLOC or SHF_WRITE;
-              AType:=SHT_NOBITS;
-              AAlign:=4;
-            end;
-        end;
-        sects[sec]:=new(PElfSection,init(Sec,AType,Aflags,AAlign));
+        if assigned(sects[s]) then
+         sectionsize:=sects[s]^.datalen
+        else
+         sectionsize:=0;
+      end;
+
+
+    procedure telf32output.createsection(sec:tsection);
+      begin
+        sects[sec]:=new(pelf32Section,init(Sec));
       end;
 
 
-    procedure telfoutputput.writesymbol(p:pasmsymbol);
+    procedure telf32output.writesymbol(p:pasmsymbol);
       var
-        pos : longint;
         sym : tsymbol;
-        c   : char;
-        s   : string;
       begin
         { already written ? }
         if p^.idx<>-1 then
@@ -392,45 +475,40 @@ unit og386elf;
         { be sure that the section will exists }
         if (p^.section<>sec_none) and not(assigned(sects[p^.section])) then
           createsection(p^.section);
-        { symbolname }
-        pos:=strs^.usedsize+4;
-        c:=#0;
-        s:=p^.name;
-        if length(s)>8 then
-         begin
-           s:=s+#0;
-           strs^.write(s[1],length(s));
-         end
-        else
-         pos:=-1;
         FillChar(sym,sizeof(sym),0);
-        sym.strpos:=pos;
-        if pos=-1 then
-         sym.name:=s;
-        sym.value:=p^.size;
+        { symbolname, write the #0 separate to overcome 255+1 char not possible }
+        sym.name:=strtabsect^.writestr(p^.name);
+        strtabsect^.writestr(#0);
+        sym.size:=p^.size;
+        sym.bind:=p^.bind;
         sym.typ:=p^.typ;
         { if local of global then set the section value to the address
           of the symbol }
-        if p^.typ in [AS_LOCAL,AS_GLOBAL] then
-         begin
-           sym.section:=ord(p^.section);
-           sym.value:=p^.address;
-         end;
+        case sym.bind of
+          AB_LOCAL,
+          AB_GLOBAL :
+            begin
+              sym.section:=p^.section;
+              sym.value:=p^.address;
+            end;
+          AB_COMMON :
+            begin
+              sym.value:=$10;
+            end;
+        end;
         { update the asmsymbol index }
         p^.idx:=syms^.count;
         { store the symbol, but not the local ones (PM) }
-        if (p^.typ<>AS_LOCAL) or ((copy(s,1,2)<>'.L') and
-          ((copy(s,1,1)<>'L') or not win32)) then
+        if (sym.bind<>AB_LOCAL) {or (copy(p^.name,1,2)<>'.L')} then
           syms^.write(sym,1);
         { make the exported syms known to the objectwriter
           (needed for .a generation) }
-        if (p^.typ=AS_GLOBAL) or
-           ((p^.typ=AS_EXTERNAL) and (sym.value=p^.size) and (sym.value>0)) then
+        if (sym.bind in [AB_GLOBAL,AB_COMMON]) then
           writer^.writesym(p^.name);
       end;
 
 
-    procedure telfoutputput.writebytes(var data;len:longint);
+    procedure telf32output.writebytes(var data;len:longint);
       begin
         if not assigned(sects[currsec]) then
          createsection(currsec);
@@ -438,7 +516,7 @@ unit og386elf;
       end;
 
 
-    procedure telfoutputput.writealloc(len:longint);
+    procedure telf32output.writealloc(len:longint);
       begin
         if not assigned(sects[currsec]) then
          createsection(currsec);
@@ -446,60 +524,60 @@ unit og386elf;
       end;
 
 
-    procedure telfoutputput.writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);
+    procedure telf32output.writealign(len:longint);
+      var modulo : longint;
+      begin
+        if not assigned(sects[currsec]) then
+         createsection(currsec);
+        modulo:=sects[currsec]^.datalen mod len;
+        if modulo > 0 then
+          sects[currsec]^.alloc(len-modulo);
+      end;
+
+
+    procedure telf32output.writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);
+      var
+        symaddr : longint;
       begin
         if not assigned(sects[currsec]) then
          createsection(currsec);
         if assigned(p) then
          begin
+           { real address of the symbol }
+           symaddr:=p^.address;
            { no symbol relocation need inside a section }
            if p^.section=currsec then
              begin
-               if relative=relative_false then
-                 begin
-                   sects[currsec]^.addsectionreloc(sects[currsec]^.len,currsec);
-                   inc(data,p^.address);
-                 end
-               else if relative=relative_true then
-                 begin
-                   inc(data,p^.address-len-sects[currsec]^.len);
-                 end
-               else if relative=relative_rva then
-                 begin
-                   { don't know if this can happens !! }
-                   { does this work ?? }
-                   sects[currsec]^.addsectionreloc(sects[currsec]^.len,currsec);
-                   inc(data,p^.address);
-                 end;
+               case relative of
+                 relative_false :
+                   begin
+                     sects[currsec]^.addsectionreloc(sects[currsec]^.datalen,currsec,relative_false);
+                     inc(data,symaddr);
+                   end;
+                 relative_true :
+                   begin
+                     inc(data,symaddr-len-sects[currsec]^.datalen);
+                   end;
+                 relative_rva :
+                   internalerror(3219583);
+               end;
              end
            else
              begin
                writesymbol(p);
-               if (p^.section<>sec_none) and (relative=relative_false) then
-                 begin
-                   sects[currsec]^.addsectionreloc(sects[currsec]^.len,p^.section);
-                 end
-               else
-                 sects[currsec]^.addsymreloc(sects[currsec]^.len,p,relative);
-               if not win32 then {seems wrong to me (PM) }
+               if (p^.section<>sec_none) and (relative<>relative_true) then
                 begin
-                  {if p^.section<>sec_none then
-                    this is the cause of the strange
-                    feature see Note (5) before
-                    address contains the size for
-                    global vars switched to common }
-                    inc(data,p^.address);
+                  sects[currsec]^.addsectionreloc(sects[currsec]^.datalen,p^.section,relative);
+                  inc(data,symaddr);
                 end
                else
-                if (relative<>relative_true) and (p^.section<>sec_none) then
-                 inc(data,p^.address);
+                sects[currsec]^.addsymreloc(sects[currsec]^.datalen,p,relative);
                if relative=relative_true then
                 begin
-                  if win32 then
-                    {inc(data,4-len)}
-                    dec(data,len-4{+p^.address})
+                  if p^.bind=AB_EXTERNAL then
+                   dec(data,len)
                   else
-                    dec(data,len+sects[currsec]^.len);
+                   dec(data,len+sects[currsec]^.datalen);
                 end;
             end;
          end;
@@ -507,27 +585,26 @@ unit og386elf;
       end;
 
 
-    procedure telfoutputput.writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc : boolean);
+    procedure telf32output.writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc : boolean);
       var
-        stab : coffstab;
+        stab : telf32stab;
         s : tsection;
       begin
-        if section=sec_none then
-         s:=currsec
-        else
-         s:=section;
-        { local var can be at offset -1 !! PM }
-        if (offset=-1) and reloc then
+        s:=section;
+        if reloc then
          begin
-           if s=sec_none then
-            offset:=0
-           else
-            offset:=sects[s]^.len;
+           if (offset=-1) then
+            begin
+              if s=sec_none then
+               offset:=0
+              else
+               offset:=sects[s]^.datalen;
+            end;
          end;
-        fillchar(stab,sizeof(coffstab),0);
+        fillchar(stab,sizeof(telf32stab),0);
         if assigned(p) and (p[0]<>#0) then
          begin
-           stab.strpos:=sects[sec_stabstr]^.len;
+           stab.strpos:=sects[sec_stabstr]^.datalen;
            sects[sec_stabstr]^.write(p^,strlen(p)+1);
          end;
         stab.ntype:=nidx;
@@ -538,34 +615,118 @@ unit og386elf;
         { when the offset is not 0 then write a relocation, take also the
           hdrstab into account with the offset }
         if reloc then
-          sects[sec_stab]^.addsectionreloc(sects[sec_stab]^.len-4,s);
+         sects[sec_stab]^.addsectionreloc(sects[sec_stab]^.datalen-4,s,relative_false);
+      end;
+
+
+    procedure telf32output.writesymstabs(section:tsection;offset:longint;p:pchar;ps:pasmsymbol;
+                                                 nidx,nother,line:longint;reloc:boolean);
+      var
+        stab : telf32stab;
+        s : tsection;
+      begin
+        s:=section;
+        if reloc then
+         begin
+           if (offset=-1) then
+            begin
+              if s=sec_none then
+               offset:=0
+              else
+               offset:=sects[s]^.datalen;
+            end;
+         end;
+        fillchar(stab,sizeof(telf32stab),0);
+        if assigned(p) and (p[0]<>#0) then
+         begin
+           stab.strpos:=sects[sec_stabstr]^.datalen;
+           sects[sec_stabstr]^.write(p^,strlen(p)+1);
+         end;
+        stab.ntype:=nidx;
+        stab.ndesc:=line;
+        stab.nother:=nother;
+        stab.nvalue:=offset;
+        sects[sec_stab]^.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
+         sects[sec_stab]^.addsymreloc(sects[sec_stab]^.datalen-4,ps,relative_false);
+      end;
+
+
+    procedure telf32output.setsectionsizes(var s:tsecsize);
+      var
+        align : longint;
+        sec : tsection;
+      begin
+        { multiply stab with real size }
+        s[sec_stab]:=s[sec_stab]*sizeof(telf32stab);
+        { if debug then also count header stab }
+        if (cs_debuginfo in aktmoduleswitches) then
+         begin
+           inc(s[sec_stab],sizeof(telf32stab));
+           inc(s[sec_stabstr],length(SplitFileName(current_module^.mainsource^))+2);
+         end;
+        { fix all section }
+        for sec:=low(tsection) to high(tsection) do
+         begin
+           if (s[sec]>0) and (not assigned(sects[sec])) then
+             createsection(sec);
+           if assigned(sects[sec]) then
+            begin
+              sects[sec]^.size:=s[sec];
+              { calculate the alignment }
+              align:=sects[sec]^.addralign;
+              sects[sec]^.fillsize:=align-(sects[sec]^.size and (align-1));
+              if sects[sec]^.fillsize=align then
+               sects[sec]^.fillsize:=0;
+            end;
+         end;
       end;
 
 
-    procedure telfoutputput.write_relocs(s:pcoffsection);
+{***********************************************
+             Writing to disk
+***********************************************}
+
+    procedure telf32output.createrelocsection(s:pelf32section);
       var
-        rel  : coffreloc;
+        rel  : telf32reloc;
         hr,r : preloc;
+        relsym,reltyp : longint;
       begin
+        { create the reloc section }
+        new(s^.relocsect,initname('.rel'+s^.name,9,0,symtabsect^.secshidx,s^.secshidx,4,8));
+        { add the relocations }
         r:=s^.relochead;
         while assigned(r) do
          begin
            rel.address:=r^.address;
            if assigned(r^.symbol) then
             begin
-              if (r^.symbol^.typ=AS_LOCAL) then
-               rel.sym:=2*ord(r^.symbol^.section)
+              if (r^.symbol^.bind=AB_LOCAL) then
+               relsym:=sects[r^.symbol^.section]^.secsymidx
               else
-               rel.sym:=r^.symbol^.idx+initsym;
+               begin
+                 if r^.symbol^.idx=-1 then
+                   internalerror(4321);
+                 relsym:=(r^.symbol^.idx+initsym);
+               end;
             end
            else
-            rel.sym:=2*ord(r^.section);
-           case r^.relative of
-             relative_true  : rel.relative:=$14;
-             relative_false : rel.relative:=$6;
-             relative_rva   : rel.relative:=$7;
+            if r^.section<>sec_none then
+             relsym:=sects[r^.section]^.secsymidx
+            else
+             relsym:=SHN_UNDEF;
+           case r^.typ of
+             relative_true :
+               reltyp:=R_386_PC32;
+             relative_false :
+               reltyp:=R_386_32;
            end;
-           writer^.write(rel,sizeof(rel));
+           rel.info:=(relsym shl 8) or reltyp;
+           { write reloc }
+           s^.relocsect^.write(rel,sizeof(rel));
            { goto next and dispose this reloc }
            hr:=r;
            r:=r^.next;
@@ -574,245 +735,261 @@ unit og386elf;
       end;
 
 
-    procedure telfoutputput.write_symbol(const name:string;strpos,value,section,typ,aux:longint);
+    procedure telf32output.createsymtab;
       var
-        sym : coffsymbol;
-      begin
-        FillChar(sym,sizeof(sym),0);
-        if strpos=-1 then
-         move(name[1],sym.name,length(name))
-        else
-         sym.strpos:=strpos;
-        sym.value:=value;
-        sym.section:=section;
-        sym.typ:=typ;
-        sym.aux:=aux;
-        writer^.write(sym,sizeof(sym));
-      end;
-
-
-    procedure telfoutputput.write_symbols;
-      var
-        filename : string[18];
-        sec : tsection;
-        i   : longint;
-        globalval : byte;
-        secrec : coffsectionrec;
+        elfsym : telf32symbol;
         sym : tsymbol;
+        sec : tsection;
+        locals,
+        i : longint;
       begin
-        { The `.file' record, and the file name auxiliary record. }
-        write_symbol ('.file', -1, 0, -2, $67, 1);
-        fillchar(filename,sizeof(filename),0);
-        filename:=SplitFileName(current_module^.mainsource^);
-        writer^.write(filename[1],sizeof(filename)-1);
-        { The section records, with their auxiliaries }
-        i:=0;
+        locals:=2;
+      { empty entry }
+        fillchar(elfsym,sizeof(elfsym),0);
+        symtabsect^.write(elfsym,sizeof(elfsym));
+      { filename entry }
+        elfsym.st_name:=1;
+        elfsym.st_info:=STT_FILE;
+        elfsym.st_shndx:=SHN_ABS;
+        symtabsect^.write(elfsym,sizeof(elfsym));
+      { section }
         for sec:=low(tsection) to high(tsection) do
          if assigned(sects[sec]) then
           begin
-            inc(i);
-            write_symbol(sec_2_str[sec],-1,{sects[sec]^.pos}0,i,3,1);
-            fillchar(secrec,sizeof(secrec),0);
-            secrec.len:=sects[sec]^.len;
-            secrec.nrelocs:=sects[sec]^.nrelocs;
-            writer^.write(secrec,sizeof(secrec));
+            fillchar(elfsym,sizeof(elfsym),0);
+            elfsym.st_name:=sects[sec]^.shstridx;
+            elfsym.st_info:=STT_SECTION;
+            elfsym.st_shndx:=sects[sec]^.secshidx;
+            symtabsect^.write(elfsym,sizeof(elfsym));
+            inc(locals);
           end;
-        { The real symbols. }
+      { symbols }
         syms^.seek(0);
         for i:=1 to syms^.count do
          begin
            syms^.read(sym,1);
-           if sym.typ=AS_LOCAL then
-             globalval:=3
+           fillchar(elfsym,sizeof(elfsym),0);
+           elfsym.st_name:=sym.name;
+           elfsym.st_value:=sym.value;
+           elfsym.st_size:=sym.size;
+           case sym.bind of
+             AB_LOCAL :
+               begin
+                 elfsym.st_info:=STB_LOCAL shl 4;
+                 inc(locals);
+               end;
+             AB_COMMON,
+             AB_EXTERNAL,
+             AB_GLOBAL :
+               elfsym.st_info:=STB_GLOBAL shl 4;
+           end;
+           if sym.bind<>AB_EXTERNAL then
+            begin
+              case sym.typ of
+                AT_FUNCTION :
+                  elfsym.st_info:=elfsym.st_info or STT_FUNC;
+                AT_DATA :
+                  elfsym.st_info:=elfsym.st_info or STT_OBJECT;
+              end;
+            end;
+           if sym.bind=AB_COMMON then
+            elfsym.st_shndx:=SHN_COMMON
            else
-             globalval:=2;
-           write_symbol(sym.name,sym.strpos,sym.value,sym.section,globalval,0);
+            if assigned(sects[sym.section]) then
+             elfsym.st_shndx:=sects[sym.section]^.secshidx
+            else
+             elfsym.st_shndx:=SHN_UNDEF;
+           symtabsect^.write(elfsym,sizeof(elfsym));
+         end;
+      { update the .symtab section header }
+        symtabsect^.shlink:=strtabsect^.secshidx;
+        symtabsect^.shinfo:=locals;
+      end;
+
+
+    procedure telf32output.createshstrtab;
+      var
+        sec : tsection;
+      begin
+        with shstrtabsect^ do
+         begin
+           writestr(#0);
+           symtabsect^.shstridx:=writestr('.symtab'#0);
+           strtabsect^.shstridx:=writestr('.strtab'#0);
+           shstrtabsect^.shstridx:=writestr('.shstrtab'#0);
+           for sec:=low(tsection) to high(tsection) do
+            if assigned(sects[sec]) then
+             begin
+               sects[sec]^.shstridx:=writestr(sects[sec]^.name+#0);
+               if assigned(sects[sec]^.relocsect) then
+                sects[sec]^.relocsect^.shstridx:=writestr(sects[sec]^.relocsect^.name+#0);
+             end;
          end;
       end;
 
 
-    procedure telfoutputput.writetodisk;
+    procedure telf32output.writesectionheader(s:pelf32section);
       var
+        sechdr : telf32sechdr;
+      begin
+        fillchar(sechdr,sizeof(sechdr),0);
+        sechdr.sh_name:=s^.shstridx;
+        sechdr.sh_type:=s^.shtype;
+        sechdr.sh_flags:=s^.shflags;
+        sechdr.sh_offset:=s^.datapos;
+        sechdr.sh_size:=s^.datalen;
+        sechdr.sh_link:=s^.shlink;
+        sechdr.sh_info:=s^.shinfo;
+        sechdr.sh_addralign:=s^.addralign;
+        sechdr.sh_entsize:=s^.entsize;
+        writer^.write(sechdr,sizeof(sechdr));
+      end;
+
+
+    procedure telf32output.writetodisk;
+      var
+        header : telf32header;
         datapos,
-        nsects,pos,sympos,i,fillsize : longint;
+        shoffset,
+        nsects : longint;
         sec    : tsection;
-        header : coffheader;
-        sechdr : coffsechdr;
-        empty  : array[0..15] of byte;
+        empty  : array[0..63] of byte;
       begin
       { calc amount of sections we have and align sections at 4 bytes }
         fillchar(empty,sizeof(empty),0);
-        nsects:=0;
+        nsects:=1;
+        initsym:=2;
         for sec:=low(tsection) to high(tsection) do
-        { .stabstr section length must be without alignment !! }
          if assigned(sects[sec]) then
           begin
-          { fill with zero }
-            fillsize:=4-(sects[sec]^.len and 3);
-            if fillsize<>4 then
-             begin
-               if assigned(sects[sec]^.data) then
-                 sects[sec]^.write(empty,fillsize)
-               else
-                 sects[sec]^.alloc(fillsize);
-               { .stabstr section length must be without alignment !! }
-               if (sec=sec_stabstr) then
-                 dec(sects[sec]^.len,fillsize);
-             end;
+            { each section requires a symbol for relocation }
+            sects[sec]^.secsymidx:=initsym;
+            inc(initsym);
+            { also create the index in the section header table }
+            sects[sec]^.secshidx:=nsects;
             inc(nsects);
+            if assigned(sects[sec]^.relochead) then
+             inc(nsects);
           end;
+        { add default sections follows }
+        shstrtabsect^.secshidx:=nsects;
+        inc(nsects);
+        symtabsect^.secshidx:=nsects;
+        inc(nsects);
+        strtabsect^.secshidx:=nsects;
+        inc(nsects);
+      { Create the relocation sections }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) and
+            (sects[sec]^.nrelocs>0) then
+           createrelocsection(sects[sec]);
+      { create .symtab }
+        createsymtab;
+      { create .shstrtab }
+        createshstrtab;
       { Calculate the filepositions }
-        datapos:=sizeof(coffheader)+sizeof(coffsechdr)*nsects;
-        pos:=0;
-        initsym:=2; { 2 for the file }
+        datapos:=$40; { elfheader + alignment }
         { sections first }
         for sec:=low(tsection) to high(tsection) do
          if assigned(sects[sec]) then
           begin
-            sects[sec]^.pos:=pos;
             sects[sec]^.datapos:=datapos;
-            inc(pos,sects[sec]^.len);
             if assigned(sects[sec]^.data) then
-              inc(datapos,sects[sec]^.len);
-            { align after stabstr section !! }
-            if (sec=sec_stabstr) and ((sects[sec]^.len and 3)<>0) then
-              inc(datapos,4-(sects[sec]^.len and 3));
-            inc(initsym,2); { 2 for each section }
+              inc(datapos,align(sects[sec]^.datalen,4));
           end;
-        { relocs }
+        { shstrtab }
+        shstrtabsect^.datapos:=datapos;
+        inc(datapos,align(shstrtabsect^.datalen,4));
+        { section headers }
+        shoffset:=datapos;
+        inc(datapos,nsects*sizeof(telf32sechdr));
+        { symtab }
+        symtabsect^.datapos:=datapos;
+        inc(datapos,align(symtabsect^.datalen,4));
+        { strtab }
+        strtabsect^.datapos:=datapos;
+        inc(datapos,align(strtabsect^.datalen,4));
+        { .rel sections }
         for sec:=low(tsection) to high(tsection) do
-         if assigned(sects[sec]) then
+         if assigned(sects[sec]) and
+            assigned(sects[sec]^.relocsect) then
           begin
-            sects[sec]^.relocpos:=datapos;
-            inc(datapos,10*sects[sec]^.nrelocs);
+            sects[sec]^.relocsect^.datapos:=datapos;
+            inc(datapos,align(sects[sec]^.relocsect^.datalen,4));
           end;
-        { symbols }
-        sympos:=datapos;
-      { COFF header }
-        fillchar(header,sizeof(coffheader),0);
-        header.mach:=$14c;
-        header.nsects:=nsects;
-        header.sympos:=sympos;
-        header.syms:=syms^.count+initsym;
-        if not win32 then
-         header.flag:=$104;
+      { Write ELF Header }
+        fillchar(header,sizeof(header),0);
+        header.magic0123:=$464c457f; { = #127'ELF' }
+        header.file_class:=1;
+        header.data_encoding:=1;
+        header.file_version:=1;
+        header.e_type:=1;
+        header.e_machine:=3;
+        header.e_version:=1;
+        header.e_shoff:=shoffset;
+        header.e_shstrndx:=shstrtabsect^.secshidx;
+        header.e_shnum:=nsects;
+        header.e_ehsize:=sizeof(telf32header);
+        header.e_shentsize:=sizeof(telf32sechdr);
         writer^.write(header,sizeof(header));
-      { Section headers }
-        for sec:=low(tsection) to high(tsection) do
-         if assigned(sects[sec]) then
-          begin
-            fillchar(sechdr,sizeof(sechdr),0);
-            move(sec_2_str[sec][1],sechdr.name,length(sec_2_str[sec]));
-            if not win32 then
-              sechdr.vsize:=sects[sec]^.pos
-            else if sec=sec_bss then
-              sechdr.vsize:=sects[sec]^.len;
-            sechdr.datalen:=sects[sec]^.len;
-            { apparently win32 asw leaves section at datapos zero }
-            { this was an error by me (PM) }
-            if (sects[sec]^.len>0) and assigned(sects[sec]^.data) then
-              sechdr.datapos:=sects[sec]^.datapos;
-            sechdr.relocpos:=sects[sec]^.relocpos;
-            sechdr.nrelocs:=sects[sec]^.nrelocs;
-            sechdr.flags:=sects[sec]^.flags;
-            writer^.write(sechdr,sizeof(sechdr));
-          end;
+        writer^.write(empty,$40-sizeof(header)); { align }
       { Sections }
         for sec:=low(tsection) to high(tsection) do
          if assigned(sects[sec]) and
             assigned(sects[sec]^.data) then
           begin
             { For the stab section we need an HdrSym which can now be
-              calculated more easily }
-            if sec=sec_stab then
-             begin
-               pcoffstab(sects[sec_stab]^.data^.data)^.nvalue:=sects[sec_stabstr]^.len;
-               pcoffstab(sects[sec_stab]^.data^.data)^.strpos:=1;
-               pcoffstab(sects[sec_stab]^.data^.data)^.ndesc:=
-                 (sects[sec_stab]^.len div sizeof(coffstab))-1{+1 according to gas output PM};
+                calculated more easily }
+              if sec=sec_stab then
+               begin
+               pelf32stab(sects[sec_stab]^.data^.data)^.nvalue:=sects[sec_stabstr]^.datalen;
+               pelf32stab(sects[sec_stab]^.data^.data)^.strpos:=1;
+               pelf32stab(sects[sec_stab]^.data^.data)^.ndesc:=
+                 (sects[sec_stab]^.datalen div sizeof(telf32stab))-1{+1 according to gas output PM};
              end;
+            { save the original section length }
+            sects[sec]^.align(4);
             writer^.write(sects[sec]^.data^.data^,sects[sec]^.data^.usedsize);
           end;
-      { Relocs }
+      { .shstrtab }
+        shstrtabsect^.align(4);
+        writer^.write(shstrtabsect^.data^.data^,shstrtabsect^.data^.usedsize);
+      { section headers, start with an empty header for sh_undef }
+        writer^.write(empty,sizeof(telf32sechdr));
         for sec:=low(tsection) to high(tsection) do
          if assigned(sects[sec]) then
-          write_relocs(sects[sec]);
-      { Symbols }
-        write_symbols;
-      { Strings }
-        i:=strs^.usedsize+4;
-        writer^.write(i,4);
-        writer^.write(strs^.data^,strs^.usedsize);
-      end;
-
-
-{****************************************************************************
-                            DJGppcoffoutput
-****************************************************************************}
-
-    constructor tdjgppcoffoutput.init;
-      begin
-        inherited init;
-        win32:=false;
-      end;
-
-    function tdjgppcoffoutput.text_flags : longint;
-      begin
-        text_flags:=$20;
-      end;
-
-    function tdjgppcoffoutput.data_flags : longint;
-      begin
-        data_flags:=$40;
-      end;
-
-    function tdjgppcoffoutput.bss_flags : longint;
-      begin
-        bss_flags:=$80;
-      end;
-
-    function tdjgppcoffoutput.info_flags : longint;
-      begin
-        writeln('djgpp coff doesn''t support info sections');
-        info_flags:=$40;
-      end;
-
-
-{****************************************************************************
-                            Win32coffoutput
-****************************************************************************}
-
-    constructor twin32coffoutput.init;
-      begin
-        inherited init;
-        win32:=true;
-      end;
-
-    function twin32coffoutput.text_flags : longint;
-      begin
-        text_flags:={ $60500020}$60300020{changed to get same as asw.exe (PM)};
-      end;
-
-    function twin32coffoutput.data_flags : longint;
-      begin
-        data_flags:=$c0300040;
-      end;
-
-    function twin32coffoutput.bss_flags : longint;
-      begin
-        bss_flags:=$c0300080;
-      end;
-
-    function twin32coffoutput.info_flags : longint;
-      begin
-        info_flags:=$100a00;
-      end;
+          begin
+            writesectionheader(sects[sec]);
+            if assigned(sects[sec]^.relocsect) then
+             writesectionheader(sects[sec]^.relocsect);
+          end;
+        writesectionheader(shstrtabsect);
+        writesectionheader(symtabsect);
+        writesectionheader(strtabsect);
+      { .symtab }
+        symtabsect^.align(4);
+        writer^.write(symtabsect^.data^.data^,symtabsect^.data^.usedsize);
+      { .strtab }
+        strtabsect^.align(4);
+        writer^.write(strtabsect^.data^.data^,strtabsect^.data^.usedsize);
+      { .rel sections }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) and
+            assigned(sects[sec]^.relocsect) then
+          begin
+            sects[sec]^.relocsect^.align(4);
+            writer^.write(sects[sec]^.relocsect^.data^.data^,sects[sec]^.relocsect^.data^.usedsize);
+          end;
+        end;
 
 
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:43  michael
+  Revision 1.3  2000-07-13 12:08:26  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:43  michael
   + removed logs
 
 }

+ 7 - 1
compiler/options.pas

@@ -1236,6 +1236,9 @@ begin
   def_symbol('CORRECTFLDCW');
   def_symbol('ENHANCEDRAISE');
 
+{ New since 1.09 }
+  def_symbol('HASOUT');
+
 { some stuff for TP compatibility }
 {$ifdef i386}
   def_symbol('CPU86');
@@ -1488,7 +1491,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:44  michael
+  Revision 1.3  2000-07-13 12:08:26  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:44  michael
   + removed logs
 
 }

+ 13 - 31
compiler/pdecl.pas

@@ -92,7 +92,10 @@ unit pdecl;
           else
             if try_to_consume(_CONST) then
               varspez:=vs_const
-            else
+          else
+            if try_to_consume(_OUT) then
+              varspez:=vs_out
+          else
               varspez:=vs_value;
           inserthigh:=false;
           tt.reset;
@@ -113,11 +116,7 @@ unit pdecl;
                      vs^.varspez:=vs_var;
                    { insert the sym in the parasymtable }
                      pprocdef(aktprocdef)^.parast^.insert(vs);
-{$ifdef INCLUDEOK}
                      include(aktprocdef^.procoptions,po_containsself);
-{$else}
-                     aktprocdef^.procoptions:=aktprocdef^.procoptions+[po_containsself];
-{$endif}
                      inc(procinfo^.selfpointer_offset,vs^.address);
                    end;
                   consume(idtoken);
@@ -215,7 +214,11 @@ unit pdecl;
                      vs:=new(pvarsym,init(s,tt));
                      vs^.varspez:=varspez;
                    { we have to add this to avoid var param to be in registers !!!}
-                     if (varspez in [vs_var,vs_const]) and push_addr_param(tt.def) then
+                   { I don't understand the comment above,                          }
+                   { but I suppose the comment is wrong and                         }
+                   { it means that the address of var parameters can be placed      }
+                   { in a register (FK)                                             }
+                     if (varspez in [vs_var,vs_const,vs_out]) and push_addr_param(tt.def) then
                        include(vs^.varoptions,vo_regable);
 
                    { insert the sym in the parasymtable }
@@ -284,11 +287,7 @@ unit pdecl;
                 s:=sc^.get_with_tokeninfo(tokenpos);
                 ss:=new(pvarsym,init(s,tt));
                 if is_threadvar then
-{$ifdef INCLUDEOK}
                   include(ss^.varoptions,vo_is_thread_var);
-{$else}
-                  ss^.varoptions:=ss^.varoptions+[vo_is_thread_var];
-{$endif}
                 st^.insert(ss);
                 { static data fields are inserted in the globalsymtable }
                 if (st^.symtabletype=objectsymtable) and
@@ -390,11 +389,7 @@ unit pdecl;
 {$endif fixLeaksOnError}
                   dispose(sc,done);
                   aktvarsym:=new(pvarsym,init_C(s,target_os.Cprefix+C_name,tt));
-{$ifdef INCLUDEOK}
                   include(aktvarsym^.varoptions,vo_is_external);
-{$else}
-                  aktvarsym^.varoptions:=aktvarsym^.varoptions+[vo_is_external];
-{$endif}
                   symtablestack^.insert(aktvarsym);
                   tokenpos:=storetokenpos;
                   symdone:=true;
@@ -593,11 +588,7 @@ unit pdecl;
 {$endif}
                     end;
                    if extern_aktvarsym then
-{$ifdef INCLUDEOK}
                     include(aktvarsym^.varoptions,vo_is_external);
-{$else}
-                    aktvarsym^.varoptions:=aktvarsym^.varoptions+[vo_is_external];
-{$endif}
                    { insert in the stack/datasegment }
                    symtablestack^.insert(aktvarsym);
                    tokenpos:=storetokenpos;
@@ -620,17 +611,9 @@ unit pdecl;
                 else
                  if (is_object) and (cs_static_keyword in aktmoduleswitches) and (idtoken=_STATIC) then
                   begin
-{$ifdef INCLUDEOK}
                     include(current_object_option,sp_static);
-{$else}
-                    current_object_option:=current_object_option+[sp_static];
-{$endif}
                     insert_syms(symtablestack,sc,tt,false);
-{$ifdef INCLUDEOK}
                     exclude(current_object_option,sp_static);
-{$else}
-                    current_object_option:=current_object_option-[sp_static];
-{$endif}
                     consume(_STATIC);
                     consume(_SEMICOLON);
                     symdone:=true;
@@ -1171,11 +1154,7 @@ unit pdecl;
            Begin
               Message1(parser_w_not_supported_for_inline,tokenstring(t));
               Message(parser_w_inlining_disabled);
-{$ifdef INCLUDEOK}
               exclude(aktprocsym^.definition^.proccalloptions,pocall_inline);
-{$else}
-              aktprocsym^.definition^.proccalloptions:=aktprocsym^.definition^.proccalloptions-[pocall_inline];
-{$endif}
            End;
       end;
 
@@ -1257,7 +1236,10 @@ unit pdecl;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:44  michael
+  Revision 1.3  2000-07-13 12:08:26  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:44  michael
   + removed logs
 
 }

+ 10 - 7
compiler/pmodules.pas

@@ -173,7 +173,7 @@ unit pmodules;
         With ResourceStringTables do}
           begin
           ResourceStringTables.insert(new(pai_const,init_32bit(count)));
-          ResourceStringTables.insert(new(pai_symbol,initname_global('FPC_RESOURCESTRINGTABLES',0)));
+          ResourceStringTables.insert(new(pai_symbol,initdataname_global('FPC_RESOURCESTRINGTABLES',0)));
           ResourceStringTables.concat(new(pai_symbol_end,initname('FPC_RESOURCESTRINGTABLES')));
           end;
         { insert in data segment }
@@ -225,7 +225,7 @@ unit pmodules;
         { TableCount,InitCount }
         unitinits.insert(new(pai_const,init_32bit(0)));
         unitinits.insert(new(pai_const,init_32bit(count)));
-        unitinits.insert(new(pai_symbol,initname_global('INITFINAL',0)));
+        unitinits.insert(new(pai_symbol,initdataname_global('INITFINAL',0)));
         unitinits.concat(new(pai_symbol_end,initname('INITFINAL')));
         { insert in data segment }
         if (cs_create_smart in aktmoduleswitches) then
@@ -273,11 +273,11 @@ unit pmodules;
 {$ifdef m68k}
          if target_info.target<>target_m68k_PalmOS then
            begin
-              datasegment^.concat(new(pai_symbol,initname_global('HEAP_SIZE',0)));
+              datasegment^.concat(new(pai_symbol,initdataname_global('HEAP_SIZE',0)));
               datasegment^.concat(new(pai_const,init_32bit(heapsize)));
            end;
 {$else m68k}
-         datasegment^.concat(new(pai_symbol,initname_global('HEAPSIZE',4)));
+         datasegment^.concat(new(pai_symbol,initdataname_global('HEAPSIZE',4)));
          datasegment^.concat(new(pai_const,init_32bit(heapsize)));
 {$endif m68k}
       end;
@@ -298,7 +298,7 @@ unit pmodules;
           target_i386_GO32V2 :
             begin
               { stacksize can be specified }
-              datasegment^.concat(new(pai_symbol,initname_global('__stklen',4)));
+              datasegment^.concat(new(pai_symbol,initdataname_global('__stklen',4)));
               datasegment^.concat(new(pai_const,init_32bit(stacksize)));
             end;
 {$endif i386}
@@ -306,7 +306,7 @@ unit pmodules;
           target_m68k_Atari :
             begin
               { stacksize can be specified }
-              datasegment^.concat(new(pai_symbol,initname_global('__stklen',4)));
+              datasegment^.concat(new(pai_symbol,initdataname_global('__stklen',4)));
               datasegment^.concat(new(pai_const,init_32bit(stacksize)));
             end;
 {$endif m68k}
@@ -1707,7 +1707,10 @@ unit pmodules;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:45  michael
+  Revision 1.3  2000-07-13 12:08:26  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:45  michael
   + removed logs
 
 }

+ 4 - 5
compiler/pstatmnt.pas

@@ -748,11 +748,7 @@ unit pstatmnt;
                  Begin
                     Message1(parser_w_not_supported_for_inline,'direct asm');
                     Message(parser_w_inlining_disabled);
-{$ifdef INCLUDEOK}
                     exclude(aktprocsym^.definition^.proccalloptions,pocall_inline);
-{$else}
-                    aktprocsym^.definition^.proccalloptions:=aktprocsym^.definition^.proccalloptions-[pocall_inline];
-{$endif}
                  End;
                asmstat:=ra386dir.assemble;
              end;
@@ -1384,7 +1380,10 @@ unit pstatmnt;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:45  michael
+  Revision 1.3  2000-07-13 12:08:27  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:45  michael
   + removed logs
 
 }

+ 4 - 26
compiler/psub.pas

@@ -470,11 +470,7 @@ begin
   end;
   if isclassmethod and
      assigned(aktprocsym) then
-{$ifdef INCLUDEOK}
     include(aktprocsym^.definition^.procoptions,po_classmethod);
-{$else}
-    aktprocsym^.definition^.procoptions:=aktprocsym^.definition^.procoptions+[po_classmethod];
-{$endif}
   consume(_SEMICOLON);
   dec(lexlevel);
 end;
@@ -574,11 +570,7 @@ end;
 procedure pd_abstract(const procnames:Tstringcontainer);
 begin
   if (po_virtualmethod in aktprocsym^.definition^.procoptions) then
-{$ifdef INCLUDEOK}
     include(aktprocsym^.definition^.procoptions,po_abstractmethod)
-{$else}
-    aktprocsym^.definition^.procoptions:=aktprocsym^.definition^.procoptions+[po_abstractmethod]
-{$endif}
   else
     Message(parser_e_only_virtual_methods_abstract);
   { the method is defined }
@@ -618,13 +610,8 @@ procedure pd_static(const procnames:Tstringcontainer);
 begin
   if (cs_static_keyword in aktmoduleswitches) then
     begin
-{$ifdef INCLUDEOK}
       include(aktprocsym^.symoptions,sp_static);
       include(aktprocsym^.definition^.procoptions,po_staticmethod);
-{$else}
-      aktprocsym^.symoptions:=aktprocsym^.symoptions+[sp_static];
-      aktprocsym^.definition^.procoptions:=aktprocsym^.definition^.procoptions+[po_staticmethod];
-{$endif}
     end;
 end;
 
@@ -651,21 +638,13 @@ begin
   do_firstpass(pt);
   if pt^.treetype=stringconstn then
     begin
-{$ifdef INCLUDEOK}
       include(aktprocsym^.definition^.procoptions,po_msgstr);
-{$else}
-      aktprocsym^.definition^.procoptions:=aktprocsym^.definition^.procoptions+[po_msgstr];
-{$endif}
       aktprocsym^.definition^.messageinf.str:=strnew(pt^.value_str);
     end
   else
    if is_constintnode(pt) then
     begin
-{$ifdef INCLUDEOK}
       include(aktprocsym^.definition^.procoptions,po_msgint);
-{$else}
-      aktprocsym^.definition^.procoptions:=aktprocsym^.definition^.procoptions+[po_msgint];
-{$endif}
       aktprocsym^.definition^.messageinf.i:=pt^.value;
     end
   else
@@ -1885,11 +1864,7 @@ begin
            vs^.fileinfo:=fileinfo;
            vs^.varspez:=varspez;
            aktprocsym^.definition^.localst^.insert(vs);
-{$ifdef INCLUDEOK}
            include(vs^.varoptions,vo_is_local_copy);
-{$else}
-           vs^.varoptions:=vs^.varoptions+[vo_is_local_copy];
-{$endif}
            vs^.varstate:=vs_assigned;
            localvarsym:=vs;
            inc(refs); { the para was used to set the local copy ! }
@@ -2083,7 +2058,10 @@ end.
 
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:46  michael
+  Revision 1.3  2000-07-13 12:08:27  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:46  michael
   + removed logs
 
 }

+ 55 - 63
compiler/ptype.pas

@@ -233,7 +233,7 @@ uses
       var
          actmembertype : tsymoptions;
          there_is_a_destructor : boolean;
-         is_a_class : boolean;
+         classtype : (ct_object,ct_class,ct_interface,ct_cppclass);
          childof : pobjectdef;
          aktclass : pobjectdef;
 
@@ -249,11 +249,7 @@ uses
            if (cs_constructor_name in aktglobalswitches) and (aktprocsym^.name<>'INIT') then
             Message(parser_e_constructorname_must_be_init);
 
-{$ifdef INCLUDEOK}
            include(aktclass^.objectoptions,oo_has_constructor);
-{$else}
-           aktclass^.objectoptions:=aktclass^.objectoptions+[oo_has_constructor];
-{$endif}
            consume(_SEMICOLON);
              begin
                 if (aktclass^.is_class) then
@@ -340,6 +336,11 @@ uses
                             consume(_CONST);
                             varspez:=vs_const;
                          end
+                       else if token=_OUT then
+                         begin
+                            consume(_OUT);
+                            varspez:=vs_out;
+                         end
                        else varspez:=vs_value;
                        sc:=idlist;
 {$ifdef fixLeaksOnError}
@@ -699,11 +700,7 @@ uses
            dec(lexlevel);
            if (cs_constructor_name in aktglobalswitches) and (aktprocsym^.name<>'DONE') then
             Message(parser_e_destructorname_must_be_done);
-{$ifdef INCLUDEOK}
            include(aktclass^.objectoptions,oo_has_destructor);
-{$else}
-           aktclass^.objectoptions:=aktclass^.objectoptions+[oo_has_destructor];
-{$endif}
            consume(_SEMICOLON);
            if not(aktprocsym^.definition^.para^.empty) then
              if not (m_tp in aktmodeswitches) then
@@ -727,13 +724,9 @@ uses
       procedure setclassattributes;
 
         begin
-           if is_a_class then
+           if classtype=ct_class then
              begin
-{$ifdef INCLUDEOK}
                 include(aktclass^.objectoptions,oo_is_class);
-{$else}
-                aktclass^.objectoptions:=aktclass^.objectoptions+[oo_is_class];
-{$endif}
                 if (cs_generate_rtti in aktlocalswitches) or
                     (assigned(aktclass^.childof) and
                      (oo_can_have_published in aktclass^.childof^.objectoptions)) then
@@ -801,7 +794,7 @@ uses
 
            { write tables for classes, this must be done before the actual
              class is written, because we need the labels defined }
-           if is_a_class then
+           if classtype=ct_class then
             begin
               methodnametable:=genpublishedmethodstable(aktclass);
               fieldtablelabel:=aktclass^.generate_field_table;
@@ -832,14 +825,14 @@ uses
                  typeglobalnumber('__vtbl_ptr_type')+'",'+tostr(N_STSYM)+',0,0,'+aktclass^.vmt_mangledname))));
            end;
 {$endif GDB}
-           datasegment^.concat(new(pai_symbol,initname_global(aktclass^.vmt_mangledname,0)));
+           datasegment^.concat(new(pai_symbol,initdataname_global(aktclass^.vmt_mangledname,0)));
 
            { determine the size with symtable^.datasize, because }
            { size gives back 4 for classes                    }
            datasegment^.concat(new(pai_const,init_32bit(aktclass^.symtable^.datasize)));
            datasegment^.concat(new(pai_const,init_32bit(-aktclass^.symtable^.datasize)));
 {$ifdef WITHDMT}
-           if not(is_a_class) then
+           if classtype=ct_object then
              begin
                 if assigned(dmtlabel) then
                   datasegment^.concat(new(pai_const_symbol,init(dmtlabel)))
@@ -858,7 +851,7 @@ uses
              datasegment^.concat(new(pai_const,init_32bit(0)));
 
            { write extended info for classes, for the order see rtl/inc/objpash.inc }
-           if is_a_class then
+           if classtype=ct_class then
             begin
               { pointer to class name string }
               datasegment^.concat(new(pai_const_symbol,init(classnamelabel)));
@@ -923,10 +916,23 @@ uses
                  end
                 else
                  begin
-                   { a mix of class and object isn't allowed }
-                   if (childof^.is_class and not is_a_class) or
-                      (not childof^.is_class and is_a_class) then
-                    Message(parser_e_mix_of_classes_and_objects);
+                   { a mix of class, interfaces, objects and cppclasses
+                     isn't allowed }
+                   case classtype of
+                      ct_class:
+                        if not(childof^.is_class) and
+                          not(childof^.is_interface) then
+                          Message(parser_e_mix_of_classes_and_objects);
+                      ct_interface:
+                        if not(childof^.is_interface) then
+                          Message(parser_e_mix_of_classes_and_objects);
+                      ct_cppclass:
+                        if not(childof^.is_cppclass) then
+                          Message(parser_e_mix_of_classes_and_objects);
+                      ct_object:
+                        if not(childof^.is_object) then
+                          Message(parser_e_mix_of_classes_and_objects);
+                   end;
                    { the forward of the child must be resolved to get
                      correct field addresses }
                    if assigned(fd) then
@@ -946,7 +952,7 @@ uses
                 consume(_RKLAMMER);
              end
            { if no parent class, then a class get tobject as parent }
-           else if is_a_class then
+           else if classtype=ct_class then
              setclassparent
            else
              aktclass:=new(pobjectdef,init(n,nil));
@@ -978,20 +984,22 @@ uses
          case token of
             _OBJECT:
               begin
-                 is_a_class:=false;
+                 classtype:=ct_object;
                  consume(_OBJECT)
               end;
             _CPPCLASS:
               begin
+                 classtype:=ct_cppclass;
                  internalerror(2003001);
               end;
             _INTERFACE:
               begin
+                 classtype:=ct_interface;
                  internalerror(2003002);
               end;
             _CLASS:
               begin
-                 is_a_class:=true;
+                 classtype:=ct_class;
                  consume(_CLASS);
                  if not(assigned(fd)) and (token=_OF) then
                    begin
@@ -1070,22 +1078,14 @@ uses
 
 
        { short class declaration ? }
-         if (not is_a_class) or (token<>_SEMICOLON) then
+         if (classtype<>ct_class) or (token<>_SEMICOLON) then
           begin
           { Parse componenten }
             repeat
               if (sp_private in actmembertype) then
-{$ifdef INCLUDEOK}
                 include(aktclass^.objectoptions,oo_has_private);
-{$else}
-                aktclass^.objectoptions:=aktclass^.objectoptions+[oo_has_private];
-{$endif}
               if (sp_protected in actmembertype) then
-{$ifdef INCLUDEOK}
                 include(aktclass^.objectoptions,oo_has_protected);
-{$else}
-                aktclass^.objectoptions:=aktclass^.objectoptions+[oo_has_protected];
-{$endif}
               case token of
               _ID : begin
                       case idtoken of
@@ -1126,23 +1126,18 @@ uses
                       parse_object_proc_directives(aktprocsym);
 {$endif newcg}
                       if (po_msgint in aktprocsym^.definition^.procoptions) then
-{$ifdef INCLUDEOK}
                         include(aktclass^.objectoptions,oo_has_msgint);
-{$else}
-                        aktclass^.objectoptions:=aktclass^.objectoptions+[oo_has_msgint];
-{$endif}
+
                       if (po_msgstr in aktprocsym^.definition^.procoptions) then
-{$ifdef INCLUDEOK}
                         include(aktclass^.objectoptions,oo_has_msgstr);
-{$else}
-                        aktclass^.objectoptions:=aktclass^.objectoptions+[oo_has_msgstr];
-{$endif}
+
                       if (po_virtualmethod in aktprocsym^.definition^.procoptions) then
-{$ifdef INCLUDEOK}
                         include(aktclass^.objectoptions,oo_has_virtual);
-{$else}
-                        aktclass^.objectoptions:=aktclass^.objectoptions+[oo_has_virtual];
-{$endif}
+
+                      { C++ classes use always C calling conventions }
+                      if aktclass^.is_cppclass then
+                        include(aktprocsym^.definition^.proccalloptions,pocall_cdecl);
+
                       parse_only:=oldparse_only;
                     end;
      _CONSTRUCTOR : begin
@@ -1155,11 +1150,12 @@ uses
                       parse_object_proc_directives(aktprocsym);
 {$endif newcg}
                       if (po_virtualmethod in aktprocsym^.definition^.procoptions) then
-{$ifdef INCLUDEOK}
                         include(aktclass^.objectoptions,oo_has_virtual);
-{$else}
-                        aktclass^.objectoptions:=aktclass^.objectoptions+[oo_has_virtual];
-{$endif}
+
+                      { C++ classes use always C calling conventions }
+                      if aktclass^.is_cppclass then
+                        include(aktprocsym^.definition^.proccalloptions,pocall_cdecl);
+
                       parse_only:=oldparse_only;
                     end;
       _DESTRUCTOR : begin
@@ -1175,11 +1171,12 @@ uses
                       parse_object_proc_directives(aktprocsym);
 {$endif newcg}
                       if (po_virtualmethod in aktprocsym^.definition^.procoptions) then
-{$ifdef INCLUDEOK}
                         include(aktclass^.objectoptions,oo_has_virtual);
-{$else}
-                        aktclass^.objectoptions:=aktclass^.objectoptions+[oo_has_virtual];
-{$endif}
+
+                      { C++ classes use always C calling conventions }
+                      if aktclass^.is_cppclass then
+                        include(aktprocsym^.definition^.proccalloptions,pocall_cdecl);
+
                       parse_only:=oldparse_only;
                     end;
              _END : begin
@@ -1553,11 +1550,7 @@ uses
                   begin
                     consume(_OF);
                     consume(_OBJECT);
-{$ifdef INCLUDEOK}
                     include(pprocvardef(tt.def)^.procoptions,po_methodpointer);
-{$else}
-                    pprocvardef(tt.def)^.procoptions:=pprocvardef(tt.def)^.procoptions+[po_methodpointer];
-{$endif}
                   end;
               end;
             _FUNCTION:
@@ -1572,11 +1565,7 @@ uses
                   begin
                     consume(_OF);
                     consume(_OBJECT);
-{$ifdef INCLUDEOK}
                     include(pprocvardef(tt.def)^.procoptions,po_methodpointer);
-{$else}
-                    pprocvardef(tt.def)^.procoptions:=pprocvardef(tt.def)^.procoptions+[po_methodpointer];
-{$endif}
                   end;
               end;
             else
@@ -1589,7 +1578,10 @@ uses
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:47  michael
+  Revision 1.3  2000-07-13 12:08:27  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:47  michael
   + removed logs
 
 }

+ 6 - 3
compiler/symconst.pas

@@ -133,9 +133,9 @@ type
     oo_has_msgint,
     oo_has_abstract,       { the object/class has an abstract method => no instances can be created }
     oo_can_have_published, { the class has rtti, i.e. you can publish properties }
-    oo_cpp_class,          { the object/class uses an C++ compatible }
+    oo_is_cppclass,        { the object/class uses an C++ compatible }
                            { class layout }
-    oo_interface           { delphi styled interface }
+    oo_is_interface        { delphi styled interface }
   );
 
   tobjectoptions=set of tobjectoption;
@@ -215,7 +215,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:49  michael
+  Revision 1.3  2000-07-13 12:08:27  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:49  michael
   + removed logs
 
 }

+ 85 - 25
compiler/symdef.inc

@@ -2484,6 +2484,7 @@
          while assigned(pdc) do
           begin
             case pdc^.paratyp of
+              vs_out,
               vs_var   : inc(l,target_os.size_of_pointer);
               vs_value,
               vs_const : if push_addr_param(pdc^.paratype.def) then
@@ -2512,7 +2513,9 @@
            else if hp^.paratyp=vs_var then
              s:=s+'var'
            else if hp^.paratyp=vs_const then
-             s:=s+'const';
+             s:=s+'const'
+           else if hp^.paratyp=vs_out then
+             s:=s+'out';
            hp:=pparaitem(hp^.previous);
            if assigned(hp) then
             s:=s+',';
@@ -3040,24 +3043,68 @@ Const local_symtable_index : longint = $8001;
 
 {$IfDef GDB}
     function tprocdef.cplusplusmangledname : string;
+
+      function getcppparaname(p : pdef) : string;
+
+        const
+           ordtype2str : array[tbasetype] of string[2] = (
+             '','','c',
+             'Uc','Us','Ul',
+             'Sc','s','l',
+             'b','b','b',
+             'Us','x','w');
+
+        var
+           s : string;
+
+        begin
+           case p^.deftype of
+              orddef:
+                s:=ordtype2str[porddef(p)^.typ];
+              pointerdef:
+                s:='P'+getcppparaname(ppointerdef(p)^.pointertype.def);
+              else
+                internalerror(2103001);
+           end;
+           getcppparaname:=s;
+        end;
+
       var
          s,s2 : string;
          param : pparaitem;
+
       begin
-      s := typesym^.name;
-      if _class <> nil then
-        begin
-        s2 := _class^.objname^;
-        s := s+'__'+tostr(length(s2))+s2;
-        end else s := s + '_';
-      param := pparaitem(para^.first);
-      while assigned(param) do
-        begin
-        s2 := param^.paratype.def^.typesym^.name;
-        s := s+tostr(length(s2))+s2;
-        param := pparaitem(param^.next);
-        end;
-      cplusplusmangledname:=s;
+         { we need this in lowercase letters! }
+         s := procsym^.name;
+         if procsym^.owner^.symtabletype=objectsymtable then
+           begin
+              s2:=pobjectdef(procsym^.owner^.defowner)^.objname^;
+              case proctypeoption of
+                 potype_destructor:
+                   s:='_$_'+tostr(length(s2))+s2;
+                 potype_constructor:
+                   s:='___'+tostr(length(s2))+s2;
+                 else
+                   s:='_'+s+'__'+tostr(length(s2))+s2;
+              end;
+
+           end
+         else s:=s+'_';
+
+         { concat modifiers }
+         { !!!!! }
+
+         { now we handle the parameters }
+         param := pparaitem(para^.first);
+         while assigned(param) do
+           begin
+              s2:=getcppparaname(param^.paratype.def);
+              if param^.paratyp in [vs_var,vs_out] then
+                s2:='R'+s2;
+              s:=s+s2;
+              param:=pparaitem(param^.next);
+           end;
+         cplusplusmangledname:=s;
       end;
 {$EndIf GDB}
 
@@ -3202,6 +3249,7 @@ Const local_symtable_index : longint = $8001;
                    vs_value: paraspec := 0;
                    vs_const: paraspec := pfConst;
                    vs_var  : paraspec := pfVar;
+                   vs_out  : paraspec := pfOut;
                  end;
                  { write flags for current parameter }
                  rttilist^.concat(new(pai_const,init_8bit(paraspec)));
@@ -3371,11 +3419,7 @@ Const local_symtable_index : longint = $8001;
              if (oo_has_vmt in c^.objectoptions) or is_class then
                begin
                   vmt_offset:=c^.vmt_offset;
-{$ifdef INCLUDEOK}
                   include(objectoptions,oo_has_vmt);
-{$else}
-                  objectoptions:=objectoptions+[oo_has_vmt];
-{$endif}
                end;
           end;
         savesize := symtable^.datasize;
@@ -3414,11 +3458,7 @@ Const local_symtable_index : longint = $8001;
           begin
              { ok, in future, the forward can be resolved }
              Message1(sym_e_class_forward_not_resolved,objname^);
-{$ifdef INCLUDEOK}
              exclude(objectoptions,oo_is_forward);
-{$else}
-             objectoptions:=objectoptions-[oo_is_forward];
-{$endif}
           end;
      end;
 
@@ -3560,6 +3600,21 @@ Const local_symtable_index : longint = $8001;
          is_class:=(oo_is_class in objectoptions);
       end;
 
+    function tobjectdef.is_object : boolean;
+      begin
+         is_object:=([oo_is_class,oo_is_interface,oo_is_cppclass]*
+           objectoptions)=[];
+      end;
+
+    function tobjectdef.is_interface : boolean;
+      begin
+         is_interface:=(oo_is_interface in objectoptions);
+      end;
+
+    function tobjectdef.is_cppclass : boolean;
+      begin
+         is_cppclass:=(oo_is_cppclass in objectoptions);
+      end;
 
 {$ifdef GDB}
     procedure addprocname(p :pnamedindexobject);
@@ -3605,7 +3660,9 @@ Const local_symtable_index : longint = $8001;
                         if para^.paratyp=vs_var then
                           argnames := argnames+'3var'
                         else if para^.paratyp=vs_const then
-                          argnames:=argnames+'5const';
+                          argnames:=argnames+'5const'
+                        else if para^.paratyp=vs_out then
+                          argnames:=argnames+'3out';
                      end
                    else
                      begin
@@ -4130,7 +4187,10 @@ Const local_symtable_index : longint = $8001;
 
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:49  michael
+  Revision 1.3  2000-07-13 12:08:27  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:49  michael
   + removed logs
  
 }

+ 8 - 2
compiler/symdefh.inc

@@ -86,7 +86,7 @@
 
        targconvtyp = (act_convertable,act_equal,act_exact);
 
-       tvarspez = (vs_value,vs_const,vs_var);
+       tvarspez = (vs_value,vs_const,vs_var,vs_out);
 
        pparaitem = ^tparaitem;
        tparaitem = object(tlinkedlist_item)
@@ -199,6 +199,9 @@
           procedure check_forwards;
           function  is_related(d : pobjectdef) : boolean;
           function  is_class : boolean;
+          function  is_interface : boolean;
+          function  is_cppclass : boolean;
+          function  is_object : boolean;
           function  next_free_name_index : longint;
           procedure insertvmt;
           procedure set_parent(c : pobjectdef);
@@ -531,7 +534,10 @@
 
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:49  michael
+  Revision 1.3  2000-07-13 12:08:27  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:49  michael
   + removed logs
  
 }

+ 9 - 32
compiler/symsym.inc

@@ -1003,22 +1003,14 @@
     constructor tvarsym.init_dll(const n : string;const tt : ttype);
       begin
          tvarsym.init(n,tt);
-{$ifdef INCLUDEOK}
          include(varoptions,vo_is_dll_var);
-{$else}
-         varoptions:=varoptions+[vo_is_dll_var];
-{$endif}
       end;
 
 
     constructor tvarsym.init_C(const n,mangled : string;const tt : ttype);
       begin
          tvarsym.init(n,tt);
-{$ifdef INCLUDEOK}
          include(varoptions,vo_is_C_var);
-{$else}
-         varoptions:=varoptions+[vo_is_C_var];
-{$endif}
          setmangledname(mangled);
       end;
 
@@ -1143,6 +1135,7 @@
          if assigned(vartype.def) then
            begin
               case varspez of
+                vs_out,
                 vs_var :
                   getpushsize:=target_os.size_of_pointer;
                 vs_value,
@@ -1194,12 +1187,8 @@
             { the data filed is generated in parser.pas
               with a tobject_FIELDNAME variable }
             { this symbol can't be loaded to a register }
-{$ifdef INCLUDEOK}
             exclude(varoptions,vo_regable);
             exclude(varoptions,vo_fpuregable);
-{$else}
-            varoptions:=varoptions-[vo_regable,vo_fpuregable];
-{$endif}
          end
         else
          if not(read_member) then
@@ -1276,12 +1265,8 @@
                    { increase datasize }
                    inc(owner^.datasize,l);
                    { this symbol can't be loaded to a register }
-{$ifdef INCLUDEOK}
                    exclude(varoptions,vo_regable);
                    exclude(varoptions,vo_fpuregable);
-{$else}
-                   varoptions:=varoptions-[vo_regable,vo_fpuregable];
-{$endif}
                  end;
                globalsymtable :
                  begin
@@ -1301,23 +1286,15 @@
                    bsssegment^.concat(new(pai_datablock,init_global(mangledname,l)));
                    inc(owner^.datasize,l);
                    { this symbol can't be loaded to a register }
-{$ifdef INCLUDEOK}
                    exclude(varoptions,vo_regable);
                    exclude(varoptions,vo_fpuregable);
-{$else}
-                   varoptions:=varoptions-[vo_regable,vo_fpuregable];
-{$endif}
                  end;
                recordsymtable,
                objectsymtable :
                  begin
                  { this symbol can't be loaded to a register }
-{$ifdef INCLUDEOK}
                    exclude(varoptions,vo_regable);
                    exclude(varoptions,vo_fpuregable);
-{$else}
-                   varoptions:=varoptions-[vo_regable,vo_fpuregable];
-{$endif}
                  { get the alignment size }
                    if (aktpackrecords=packrecord_C) then
                     begin
@@ -1464,6 +1441,7 @@
        else if (owner^.symtabletype in [parasymtable,inlineparasymtable]) then
          begin
             case varspez of
+               vs_out,
                vs_var   : st := 'v'+st;
                vs_value,
                vs_const : if push_addr_param(vartype.def) then
@@ -1627,16 +1605,16 @@
 {$endif GDB}
         if owner^.symtabletype=globalsymtable then
           begin
-             curconstsegment^.concat(new(pai_symbol,initname_global(mangledname,getsize)));
+             curconstsegment^.concat(new(pai_symbol,initdataname_global(mangledname,getsize)));
           end
         else
           if owner^.symtabletype<>unitsymtable then
             begin
               if (cs_create_smart in aktmoduleswitches) or
                  DLLSource then
-                curconstsegment^.concat(new(pai_symbol,initname_global(mangledname,getsize)))
+                curconstsegment^.concat(new(pai_symbol,initdataname_global(mangledname,getsize)))
               else
-                curconstsegment^.concat(new(pai_symbol,initname(mangledname,getsize)));
+                curconstsegment^.concat(new(pai_symbol,initdataname(mangledname,getsize)));
             end;
         aktfilepos:=storefilepos;
       end;
@@ -1946,11 +1924,7 @@
                begin
                   restype.def^.typesym:=@self;
                   synonym:=nil;
-{$ifdef INCLUDEOK}
                   include(symoptions,sp_primary_typesym);
-{$else}
-                  symoptions:=symoptions+[sp_primary_typesym];
-{$endif}
                end
              else
                begin
@@ -2183,7 +2157,10 @@
 
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:49  michael
+  Revision 1.3  2000-07-13 12:08:27  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:49  michael
   + removed logs
  
 }

+ 24 - 5
compiler/systems.pas

@@ -84,20 +84,20 @@ unit systems;
             as_i386_nasmcoff,as_i386_nasmwin32,
             as_i386_nasmelf,as_i386_nasmobj,
             as_i386_tasm,as_i386_masm,
-            as_i386_dbg,as_i386_coff,as_i386_pecoff
+            as_i386_dbg,as_i386_coff,as_i386_pecoff,as_i386_elf
             ,as_m68k_as,as_m68k_gas,as_m68k_mit,as_m68k_mot,as_m68k_mpw,
             as_alpha_as,as_powerpc_as,as_powerpc_mpw
        );
        { binary assembler writers, needed to test for -a }
      const
-       {$ifdef i386} i386asmcnt=12; {$else} i386asmcnt=0; {$endif}
+       {$ifdef i386} i386asmcnt=13; {$else} i386asmcnt=0; {$endif}
        {$ifdef m68k} m68kasmcnt=5; {$else} m68kasmcnt=0; {$endif}
        {$ifdef alpha} alphaasmcnt=1; {$else} alphaasmcnt=0; {$endif}
        {$ifdef powerpc} powerpcasmcnt=2; {$else} powerpcasmcnt=0; {$endif}
        asmcnt=i386asmcnt+m68kasmcnt+alphaasmcnt+powerpcasmcnt+1;
 
        binassem : set of tasm = [
-         as_i386_dbg,as_i386_coff,as_i386_pecoff
+         as_i386_dbg,as_i386_coff,as_i386_pecoff,as_i386_elf
        ];
 
      type
@@ -745,6 +745,22 @@ implementation
               '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
               '.stab','.stabstr')
           )
+          ,(
+            id     : as_i386_elf;
+            idtxt  : 'ELF';
+            asmbin : '';
+            asmcmd : '';
+            supported_target : target_i386_linux;
+            allowdirect : false;
+            externals : true;
+            needar : false;
+            labelprefix : '.L';
+            comment : '';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+              '.stab','.stabstr')
+          )
 {$endif i386}
 {$ifdef m68k}
           ,(
@@ -1033,7 +1049,7 @@ implementation
             resobjext   : '.or';
             exeext      : '';
             os          : os_i386_Linux;
-            assem       : as_i386_as;
+            assem       : as_i386_elf;
             assemsrc    : as_i386_as;
             ar          : ar_i386_ar;
             res         : res_none;
@@ -1644,7 +1660,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:50  michael
+  Revision 1.3  2000-07-13 12:08:28  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:50  michael
   + removed logs
 
 }

+ 4 - 5
compiler/t_linux.pas

@@ -112,11 +112,7 @@ begin
 {$IFDEF NEWST}
   exclude(aktvarsym^.properties,vo_is_dll_var);
 {$ELSE}
-{$ifdef INCLUDEOK}
   exclude(aktvarsym^.varoptions,vo_is_dll_var);
-{$else}
-  aktvarsym^.varoptions:=aktvarsym^.varoptions-[vo_is_dll_var];
-{$endif}
 {$ENDIF NEWST}
 end;
 
@@ -477,7 +473,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:50  michael
+  Revision 1.3  2000-07-13 12:08:28  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:50  michael
   + removed logs
 
 }

+ 13 - 17
compiler/tccal.pas

@@ -240,7 +240,7 @@ implementation
               if p^.left^.resulttype^.deftype=procvardef then
                 test_local_to_procvar(pprocvardef(p^.left^.resulttype),defcoll^.paratype.def);
               { property is not allowed as var parameter }
-              if (defcoll^.paratyp=vs_var) and
+              if (defcoll^.paratyp in [vs_out,vs_var]) and
                  (p^.left^.isproperty) then
                 CGMessagePos(p^.left^.fileinfo,type_e_argument_cant_be_assigned);
               { generate the high() value tree }
@@ -250,7 +250,7 @@ implementation
                      is_shortstring(defcoll^.paratype.def)) and
                      (defcoll^.paratype.def^.deftype<>formaldef) then
                 begin
-                   if (defcoll^.paratyp=vs_var) and
+                   if (defcoll^.paratyp in [vs_var,vs_out]) and
                    { allows conversion from word to integer and
                      byte to shortint }
                      (not(
@@ -311,7 +311,7 @@ implementation
               if (cs_strict_var_strings in aktlocalswitches) and
                  is_shortstring(p^.left^.resulttype) and
                  is_shortstring(defcoll^.paratype.def) and
-                 (defcoll^.paratyp=vs_var) and
+                 (defcoll^.paratyp in [vs_out,vs_var]) and
                  not(is_open_string(defcoll^.paratype.def)) and
                  not(is_equal(p^.left^.resulttype,defcoll^.paratype.def)) then
                  begin
@@ -352,6 +352,11 @@ implementation
                    make_not_regable(p^.left);
                 end;
 
+              { ansistrings out paramaters doesn't need to be  }
+              { unique, they are finalized                     }
+              if defcoll^.paratyp=vs_out then
+                make_not_regable(p^.left);
+
               if do_count then
                 set_varstate(p^.left,defcoll^.paratyp <> vs_var);
                 { must only be done after typeconv PM }
@@ -488,11 +493,7 @@ implementation
               if assigned(inlinecode) then
                 begin
                    inlined:=true;
-{$ifdef INCLUDEOK}
                    exclude(p^.procdefinition^.proccalloptions,pocall_inline);
-{$else}
-                   p^.procdefinition^.proccalloptions:=p^.procdefinition^.proccalloptions-[pocall_inline];
-{$endif}
                 end;
               p^.right:=nil;
            end;
@@ -800,7 +801,7 @@ implementation
                                        def_to:=hp^.nextpara^.paratype.def;
                                        if ((def_from^.deftype=orddef) and (def_to^.deftype=orddef)) and
                                          (is_in_limit(def_from,def_to) or
-                                         ((hp^.nextpara^.paratyp=vs_var) and
+                                         ((hp^.nextpara^.paratyp in [vs_var,vs_out]) and
                                          (def_from^.size=def_to^.size))) then
                                          begin
                                             exactmatch:=true;
@@ -1044,11 +1045,7 @@ implementation
                           begin
                              { consider it has not inlined if called
                                again inside the args }
-{$ifdef INCLUDEOK}
                              exclude(p^.procdefinition^.proccalloptions,pocall_inline);
-{$else}
-                             p^.procdefinition^.proccalloptions:=p^.procdefinition^.proccalloptions-[pocall_inline];
-{$endif}
                              firstpass(inlinecode);
                              inlined:=true;
                           end;
@@ -1212,11 +1209,7 @@ implementation
          if assigned(procs) then
            dispose(procs);
          if inlined then
-{$ifdef INCLUDEOK}
            include(p^.procdefinition^.proccalloptions,pocall_inline);
-{$else}
-           p^.procdefinition^.proccalloptions:=p^.procdefinition^.proccalloptions+[pocall_inline];
-{$endif}
          aktcallprocsym:=oldcallprocsym;
       end;
 
@@ -1236,7 +1229,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:51  michael
+  Revision 1.3  2000-07-13 12:08:28  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:51  michael
   + removed logs
 
 }

+ 5 - 2
compiler/tcld.pas

@@ -133,7 +133,7 @@ implementation
                    if (pvarsym(p^.symtableentry)^.varspez=vs_const) then
                      p^.location.loc:=LOC_MEM;
                    { we need a register for call by reference parameters }
-                   if (pvarsym(p^.symtableentry)^.varspez=vs_var) or
+                   if (pvarsym(p^.symtableentry)^.varspez in [vs_var,vs_out]) or
                       ((pvarsym(p^.symtableentry)^.varspez=vs_const) and
                       push_addr_param(pvarsym(p^.symtableentry)^.vartype.def)) or
                       { call by value open arrays are also indirect addressed }
@@ -498,7 +498,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:52  michael
+  Revision 1.3  2000-07-13 12:08:28  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:52  michael
   + removed logs
 
 }

+ 4 - 5
compiler/tcmem.pas

@@ -269,11 +269,7 @@ implementation
                      { method ? then set the methodpointer flag }
                        if (hp3^.owner^.symtabletype=objectsymtable) and
                           (pobjectdef(hp3^.owner^.defowner)^.is_class) then
-{$ifdef INCLUDEOK}
                          include(pprocvardef(p^.resulttype)^.procoptions,po_methodpointer);
-{$else}
-                         pprocvardef(p^.resulttype)^.procoptions:=pprocvardef(p^.resulttype)^.procoptions+[po_methodpointer];
-{$endif}
                        { we need to process the parameters reverse so they are inserted
                          in the correct right2left order (PFV) }
                        hp2:=pparaitem(hp3^.para^.last);
@@ -646,7 +642,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:52  michael
+  Revision 1.3  2000-07-13 12:08:28  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:52  michael
   + removed logs
 
 }

+ 6 - 1
compiler/tokens.pas

@@ -108,6 +108,7 @@ type
     _NEW,
     _NIL,
     _NOT,
+    _OUT,
     _SET,
     _SHL,
     _SHR,
@@ -311,6 +312,7 @@ const
       (str:'NEW'           ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'NIL'           ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'NOT'           ;special:false;keyword:m_all;op:_OP_NOT),
+      (str:'OUT'           ;special:false;keyword:m_out;op:NOTOKEN),
       (str:'SET'           ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'SHL'           ;special:false;keyword:m_all;op:_OP_SHL),
       (str:'SHR'           ;special:false;keyword:m_all;op:_OP_SHR),
@@ -519,7 +521,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:52  michael
+  Revision 1.3  2000-07-13 12:08:28  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:52  michael
   + removed logs
 
 }

+ 8 - 5
compiler/types.pas

@@ -235,8 +235,8 @@ implementation
                 begin
                    if not(is_equal(def1^.paratype.def,def2^.paratype.def)) or
                      ((def1^.paratyp<>def2^.paratyp) and
-                      ((def1^.paratyp=vs_var) or
-                       (def1^.paratyp=vs_var)
+                      ((def1^.paratyp in [vs_var,vs_out]) or
+                       (def2^.paratyp in [vs_var,vs_out])
                       )
                      ) then
                      begin
@@ -285,8 +285,8 @@ implementation
                 begin
                    if (isconvertable(def1^.paratype.def,def2^.paratype.def,doconv,callparan,false)=0) or
                      ((def1^.paratyp<>def2^.paratyp) and
-                      ((def1^.paratyp=vs_var) or
-                       (def1^.paratyp=vs_var)
+                      ((def1^.paratyp in [vs_out,vs_var]) or
+                       (def2^.paratyp in [vs_out,vs_var])
                       )
                      ) then
                      begin
@@ -1085,7 +1085,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:53  michael
+  Revision 1.3  2000-07-13 12:08:28  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:53  michael
   + removed logs
 
 }

+ 5 - 3
compiler/version.pas

@@ -28,9 +28,8 @@ interface
        wordversion = (1 shl 14)+0;
 
        { version string }
-
        version_nr = '1';
-       release_nr = '00';
+       release_nr = '1';
        patch_nr   = '0';
 {$ifdef newcg}
        minorpatch = ' NCG';
@@ -99,7 +98,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.2  2000-07-13 11:32:54  michael
+  Revision 1.3  2000-07-13 12:08:28  michael
+  + patched to 1.1.0 with former 1.09patch from peter
+
+  Revision 1.2  2000/07/13 11:32:54  michael
   + removed logs
 
 }