ソースを参照

* rename al_code to al_procedures, al_bss/al_data to al_globals
* more work for section smartlinking

git-svn-id: trunk@1083 -

peter 20 年 前
コミット
c3727c29b2

+ 1 - 1
compiler/aasmbase.pas

@@ -270,7 +270,7 @@ implementation
         inusedlist:=false;
         pass:=255;
         ppuidx:=-1;
-        { mainly used to remove unused labels from the al_code }
+        { mainly used to remove unused labels from the al_procedures }
         refs:=0;
       end;
 

+ 34 - 10
compiler/aasmtai.pas

@@ -587,10 +587,9 @@ interface
          before they can be referenced and therefor they need to be written
          first (PFV) }
        Tasmlist=(al_typestabs,
-                 al_code,
-                 al_bss,
-                 al_data,
-                 al_rodata,
+                 al_procedures,
+                 al_globals,
+                 al_const,
                  al_typedconsts,
                  al_rotypedconsts,
                  al_threadvars,
@@ -605,10 +604,9 @@ interface
     const
        TasmlistStr : array[tasmlist] of string[24] =(
            'al_typestabs',
-           'al_code',
-           'al_bss',
-           'al_data',
-           'al_rodata',
+           'al_procedures',
+           'al_globals',
+           'al_const',
            'al_typedconsts',
            'al_rotypedconsts',
            'al_threadvars',
@@ -644,8 +642,12 @@ interface
 
     function  use_smartlink_section:boolean;
     function  maybe_smartlink_symbol:boolean;
+
     procedure maybe_new_object_file(list:taasmoutput);
     procedure new_section(list:taasmoutput;Asectype:TAsmSectionType;Aname:string;Aalign:byte);
+    procedure section_symbol_start(list:taasmoutput;const Aname:string;Asymtyp:Tasmsymtype;
+                                   Aglobal:boolean;Asectype:TAsmSectionType;Aalign:byte);
+    procedure section_symbol_end(list:taasmoutput;const Aname:string);
 
     function ppuloadai(ppufile:tcompilerppufile):tai;
     procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
@@ -710,8 +712,7 @@ implementation
     function use_smartlink_section:boolean;
       begin
         result:=(af_smartlink_sections in target_asm.flags) and
-                (tf_smartlink_sections in target_info.flags) and
-                not(cs_debuginfo in aktmoduleswitches);
+                (tf_smartlink_sections in target_info.flags);
       end;
 
 
@@ -737,6 +738,26 @@ implementation
       end;
 
 
+    procedure section_symbol_start(list:taasmoutput;const Aname:string;Asymtyp:Tasmsymtype;
+                                   Aglobal:boolean;Asectype:TAsmSectionType;Aalign:byte);
+      begin
+        maybe_new_object_file(list);
+        list.concat(tai_section.create(Asectype,Aname,Aalign));
+        list.concat(cai_align.create(Aalign));
+        if Aglobal or
+           maybe_smartlink_symbol then
+          list.concat(tai_symbol.createname_global(Aname,Asymtyp,0))
+        else
+          list.concat(tai_symbol.createname(Aname,Asymtyp,0));
+      end;
+
+
+    procedure section_symbol_end(list:taasmoutput;const Aname:string);
+      begin
+        list.concat(tai_symbol_end.createname(Aname));
+      end;
+
+
 {****************************************************************************
                              TAI
  ****************************************************************************}
@@ -821,6 +842,9 @@ implementation
         typ:=ait_section;
         sectype:=asectype;
         secalign:=Aalign;
+        if (Aname='') and
+           use_smartlink_section then
+          internalerror(200509131);
         name:=stringdup(Aname);
         sec:=nil;
       end;

+ 42 - 46
compiler/aggas.pas

@@ -93,7 +93,7 @@ var
       funcname     : pchar;
       stabslastfileinfo : tfileposinfo;
 {$endif}
-      lasTSecType  : TAsmSectionType; { last section type written }
+      CurrSecType  : TAsmSectionType; { last section type written }
       lastfileinfo : tfileposinfo;
       infile,
       lastinfile   : tinputfile;
@@ -217,9 +217,10 @@ var
         var
           curr_n : byte;
         begin
-          if not ((cs_debuginfo in aktmoduleswitches) or
-             (cs_gdb_lineinfo in aktglobalswitches)) then
-           exit;
+          if (CurrSecType<>sec_code) or
+             not ((cs_debuginfo in aktmoduleswitches) or
+                  (cs_gdb_lineinfo in aktglobalswitches)) then
+            exit;
         { file changed ? (must be before line info) }
           if (fileinfo.fileindex<>0) and
              (stabslastfileinfo.fileindex<>fileinfo.fileindex) then
@@ -263,15 +264,21 @@ var
           stabslastfileinfo:=fileinfo;
         end;
 
-      procedure TGNUAssembler.WriteFileEndInfo;
 
+      procedure TGNUAssembler.WriteFileEndInfo;
         begin
-          if not ((cs_debuginfo in aktmoduleswitches) or
-             (cs_gdb_lineinfo in aktglobalswitches)) then
-           exit;
-          WriteSection(sec_code,'');
-          AsmWriteLn(#9'.stabs "",'+tostr(n_sourcefile)+',0,0,'+target_asm.labelprefix+'etext');
-          AsmWriteLn(target_asm.labelprefix+'etext:');
+          if (CurrSecType<>sec_code) or
+             not ((cs_debuginfo in aktmoduleswitches) or
+                  (cs_gdb_lineinfo in aktglobalswitches)) then
+            exit;
+          if (stabslastfileinfo.fileindex<>0) then
+            begin
+              AsmWriteLn(#9'.stabs "",'+tostr(n_sourcefile)+',0,0,'+target_asm.labelprefix+'text'+ToStr(IncludeCount));
+              AsmWriteLn(target_asm.labelprefix+'text'+ToStr(IncludeCount)+':');
+              inc(includecount);
+            end;
+          { force writing all fileinfo }
+          FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
         end;
 
 {$endif GDB}
@@ -292,9 +299,8 @@ var
         );
       begin
         if use_smartlink_section and
-           not (atype in [sec_bss,sec_threadvar]) and
            (aname<>'') then
-          result:='.gnu.linkonce'+copy(secnames[atype],1,2)+'.'+aname
+          result:=secnames[atype]+'.'+aname
         else
           result:=secnames[atype];
       end;
@@ -304,6 +310,12 @@ var
       var
         s : string;
       begin
+{$ifdef GDB}
+        { Maybe write end of section }
+        if currsectype<>sec_none then
+          WriteFileEndInfo;
+{$endif GDB}
+
         AsmLn;
         case target_info.system of
          system_powerpc_darwin, system_i386_OS2, system_i386_EMX: ;
@@ -312,17 +324,7 @@ var
         end;
         s:=sectionname(atype,aname);
         AsmWrite(s);
-        if copy(s,1,4)='.gnu' then
-          begin
-            case atype of
-              sec_rodata,
-              sec_data :
-                AsmWrite(',""');
-              sec_code :
-                AsmWrite(',"x"');
-            end;
-          end
-        else if atype=sec_fpc then
+        if atype=sec_fpc then
           AsmWrite(', "a", @progbits');
         AsmLn;
 {$ifdef GDB}
@@ -339,8 +341,10 @@ var
           else
             n_line:=n_dataline;
         end;
+        { force writing all fileinfo }
+        FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
 {$endif GDB}
-        LasTSecType:=atype;
+        CurrSecType:=atype;
       end;
 
 
@@ -370,10 +374,10 @@ var
 
       last_align := 2;
       InlineLevel:=0;
-      { lineinfo is only needed for al_code (PFV) }
+      { lineinfo is only needed for al_procedures (PFV) }
       do_line:=(cs_asm_source in aktglobalswitches) or
                ((cs_lineinfo in aktmoduleswitches)
-                 and (p=asmlist[al_code]));
+                 and (p=asmlist[al_procedures]));
       hp:=tai(p.first);
       while assigned(hp) do
        begin
@@ -382,10 +386,8 @@ var
             hp1 := hp as tailineinfo;
             aktfilepos:=hp1.fileinfo;
 {$ifdef GDB}
-             { write stabs }
-             if (cs_debuginfo in aktmoduleswitches) or
-                (cs_gdb_lineinfo in aktglobalswitches) then
-               WriteFileLineInfo(hp1.fileinfo);
+             { maybe write stabs }
+             WriteFileLineInfo(hp1.fileinfo);
 {$endif GDB}
              { no line info for inlined code }
              if do_line and (inlinelevel=0) then
@@ -533,8 +535,8 @@ var
                        asmwrite('.zerofill __DATA, __common, ');
                        asmwrite(tai_datablock(hp).sym.name);
                        asmwriteln(', '+tostr(tai_datablock(hp).size)+','+tostr(last_align));
-                       if not(lastSectype in [sec_data,sec_none]) then
-                         writesection(lastSectype,'');
+                       if not(CurrSecType in [sec_data,sec_none]) then
+                         writesection(CurrSecType,'');
                      end
                    else
                      begin
@@ -617,7 +619,7 @@ var
                  { Values with symbols are written on a single line to improve
                    reading of the .s file (PFV) }
                  if assigned(tai_const(hp).sym) or
-                    not(LasTSecType in [sec_data,sec_rodata]) or
+                    not(CurrSecType in [sec_data,sec_rodata]) or
                     (l>line_length) or
                     (hp.next=nil) or
                     (tai(hp.next).typ<>consttyp) or
@@ -893,7 +895,7 @@ var
                   while assigned(hp.next) and (tai(hp.next).typ in [ait_cutobject,ait_section,ait_comment]) do
                    begin
                      if tai(hp.next).typ=ait_section then
-                       lasTSectype:=tai_section(hp.next).sectype;
+                       CurrSecType:=tai_section(hp.next).sectype;
                      hp:=tai(hp.next);
                    end;
 {$ifdef GDB}
@@ -903,8 +905,8 @@ var
                   funcname:=nil;
                   WriteFileLineInfo(aktfilepos);
 {$endif GDB}
-                  if lasTSectype<>sec_none then
-                    WriteSection(lasTSectype,'');
+                  if CurrSecType<>sec_none then
+                    WriteSection(CurrSecType,'');
                   AsmStartSize:=AsmSize;
                 end;
              end;
@@ -936,9 +938,6 @@ var
       p:dirstr;
       n:namestr;
       e:extstr;
-{$ifdef GDB}
-      fileinfo : tfileposinfo;
-{$endif GDB}
       hal : tasmlist;
     begin
 {$ifdef EXTDEBUG}
@@ -946,7 +945,7 @@ var
        Comment(V_Debug,'Start writing gas-styled assembler output for '+current_module.mainsource^);
 {$endif}
 
-      LasTSectype:=sec_none;
+      CurrSecType:=sec_none;
 {$ifdef GDB}
       FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
 {$endif GDB}
@@ -977,10 +976,6 @@ var
       funcname:=nil;
       linecount:=1;
       includecount:=0;
-      fileinfo.fileindex:=1;
-      fileinfo.line:=1;
-      { Write main file }
-      WriteFileLineInfo(fileinfo);
 {$endif GDB}
       AsmStartSize:=AsmSize;
       symendcount:=0;
@@ -993,7 +988,8 @@ var
         end;
 
       {$ifdef GDB}
-      WriteFileEndInfo;
+      if CurrSecType<>sec_none then
+        WriteFileEndInfo;
       {$ENDIF}
 
       AsmLn;

+ 21 - 9
compiler/assemble.pas

@@ -882,7 +882,8 @@ Implementation
         hp : tasmsymbol;
         infile : tinputfile;
       begin
-        if not ((cs_debuginfo in aktmoduleswitches) or
+        if (objectdata.currsec.sectype<>sec_code) or
+           not ((cs_debuginfo in aktmoduleswitches) or
            (cs_gdb_lineinfo in aktglobalswitches)) then
          exit;
 
@@ -935,7 +936,7 @@ Implementation
         linecount:=1;
         includecount:=0;
         fileinfo.fileindex:=1;
-        fileinfo.line:=1;
+        fileinfo.line:=0;
         WriteFileLineInfo(fileinfo);
       end;
 
@@ -944,11 +945,11 @@ Implementation
       var
         hp : tasmsymbol;
       begin
-          if not ((cs_debuginfo in aktmoduleswitches) or
-             (cs_gdb_lineinfo in aktglobalswitches)) then
+        if (objectdata.currsec.sectype<>sec_code) or
+           not ((cs_debuginfo in aktmoduleswitches) or
+                (cs_gdb_lineinfo in aktglobalswitches)) then
            exit;
-        objectdata.createsection(sec_code,'',0,[]);
-        hp:=objectlibrary.newasmsymbol('Letext',AB_LOCAL,AT_FUNCTION);
+        hp:=objectlibrary.newasmsymbol('Ltext'+ToStr(IncludeCount),AB_LOCAL,AT_FUNCTION);
         if currpass=1 then
           begin
             objectdata.allocsymbol(currpass,hp,0);
@@ -956,7 +957,8 @@ Implementation
           end
         else
           objectdata.writesymbol(hp);
-        EmitStabs('"",'+tostr(n_sourcefile)+',0,0,Letext');
+        EmitStabs('"",'+tostr(n_sourcefile)+',0,0,Ltext'+ToStr(IncludeCount));
+        inc(IncludeCount);
       end;
 {$endif GDB}
 
@@ -1128,6 +1130,9 @@ Implementation
                end;
              ait_section:
                begin
+{$ifdef GDB}
+//                 emitlineinfostabs(n_line,0);
+{$endif GDB}
                  { use cached value }
                  objectdata.setsection(Tai_section(hp).sec);
 {$ifdef GDB}
@@ -1141,7 +1146,8 @@ Implementation
                    else
                      n_line:=n_dataline;
                  end;
-                 stabslastfileinfo.line:=-1;
+                 { force writing all fileinfo }
+                 FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
 {$endif GDB}
                end;
 {$ifdef GDB}
@@ -1283,6 +1289,9 @@ Implementation
                end;
              ait_section :
                begin
+{$ifdef GDB}
+//                 emitlineinfostabs(n_line,0);
+{$endif GDB}
                  { use cached value }
                  objectdata.setsection(Tai_section(hp).sec);
 {$ifdef GDB}
@@ -1293,7 +1302,8 @@ Implementation
                  else
                   n_line:=n_dataline;
                  end;
-                 stabslastfileinfo.line:=-1;
+                 { force writing all fileinfo }
+                 FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
 {$endif GDB}
                end;
              ait_symbol :
@@ -1435,6 +1445,7 @@ Implementation
            hp:=TreePass1(hp);
            MaybeNextList(hp);
          end;
+        objectdata.createsection(sec_code,'',0,[]);
 {$ifdef GDB}
         EndFileLineInfo;
 {$endif GDB}
@@ -1463,6 +1474,7 @@ Implementation
            hp:=TreePass2(hp);
            MaybeNextList(hp);
          end;
+        objectdata.createsection(sec_code,'',0,[]);
 {$ifdef GDB}
         EndFileLineInfo;
 {$endif GDB}

+ 14 - 14
compiler/cresstr.pas

@@ -149,16 +149,16 @@ procedure Tal_resourcestrings.CreateResourceStringList;
          begin
             objectlibrary.getdatalabel(l1);
             asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_sym(l1));
-            maybe_new_object_file(asmlist[al_typedconsts]);
-            asmlist[al_typedconsts].concat(tai_align.Create(const_align(sizeof(aint))));
-            asmlist[al_typedconsts].concat(tai_const.create_aint(-1));
-            asmlist[al_typedconsts].concat(tai_const.create_aint(len));
-            asmlist[al_typedconsts].concat(tai_label.create(l1));
+            maybe_new_object_file(asmlist[al_const]);
+            asmlist[al_const].concat(tai_align.Create(const_align(sizeof(aint))));
+            asmlist[al_const].concat(tai_const.create_aint(-1));
+            asmlist[al_const].concat(tai_const.create_aint(len));
+            asmlist[al_const].concat(tai_label.create(l1));
             getmem(s,len+1);
             move(value^,s^,len);
             s[len]:=#0;
-            asmlist[al_typedconsts].concat(tai_string.create_length_pchar(s,len));
-            asmlist[al_typedconsts].concat(tai_const.create_8bit(0));
+            asmlist[al_const].concat(tai_string.create_length_pchar(s,len));
+            asmlist[al_const].concat(tai_const.create_8bit(0));
          end;
        { append Current value (nil) and hash...}
        asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_sym(nil));
@@ -167,16 +167,16 @@ procedure Tal_resourcestrings.CreateResourceStringList;
        objectlibrary.getdatalabel(l1);
        l:=length(name);
        asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_sym(l1));
-       maybe_new_object_file(asmlist[al_typedconsts]);
-       asmlist[al_typedconsts].concat(tai_align.create(const_align(sizeof(aint))));
-       asmlist[al_typedconsts].concat(tai_const.create_aint(-1));
-       asmlist[al_typedconsts].concat(tai_const.create_aint(l));
-       asmlist[al_typedconsts].concat(tai_label.create(l1));
+       maybe_new_object_file(asmlist[al_const]);
+       asmlist[al_const].concat(tai_align.create(const_align(sizeof(aint))));
+       asmlist[al_const].concat(tai_const.create_aint(-1));
+       asmlist[al_const].concat(tai_const.create_aint(l));
+       asmlist[al_const].concat(tai_label.create(l1));
        getmem(s,l+1);
        move(Name[1],s^,l);
        s[l]:=#0;
-       asmlist[al_typedconsts].concat(tai_string.create_length_pchar(s,l));
-       asmlist[al_typedconsts].concat(tai_const.create_8bit(0));
+       asmlist[al_const].concat(tai_string.create_length_pchar(s,l));
+       asmlist[al_const].concat(tai_const.create_8bit(0));
      end;
   end;
 

+ 2 - 2
compiler/i386/ag386nsm.pas

@@ -399,10 +399,10 @@ interface
       if not assigned(p) then
        exit;
       InlineLevel:=0;
-      { lineinfo is only needed for al_code (PFV) }
+      { lineinfo is only needed for al_procedures (PFV) }
       do_line:=(cs_asm_source in aktglobalswitches) or
                ((cs_lineinfo in aktmoduleswitches)
-                 and (p=asmlist[al_code]));
+                 and (p=asmlist[al_procedures]));
       hp:=tai(p.first);
       while assigned(hp) do
        begin

+ 1 - 1
compiler/i386/n386set.pas

@@ -105,7 +105,7 @@ implementation
            (af_smartlink_sections in target_asm.flags) then
           jumpsegment:=current_procinfo.aktlocaldata
         else
-          jumpsegment:=asmlist[al_data];
+          jumpsegment:=asmlist[al_globals];
         if not(jumptable_no_range) then
           begin
              { case expr less than min_ => goto elselabel }

+ 36 - 25
compiler/ncgutil.pas

@@ -121,7 +121,7 @@ interface
 implementation
 
   uses
-    strings,
+    strings,version,
     cutils,cclasses,
     globals,systems,verbose,
     ppu,defutil,
@@ -1566,11 +1566,8 @@ implementation
 
     procedure gen_entry_code(list:TAAsmoutput);
       var
-        href : treference;
         paraloc1,
-        paraloc2,
-        paraloc3 : tcgpara;
-        hp   : tused_unit;
+        paraloc2 : tcgpara;
       begin
         paraloc1.init;
         paraloc2.init;
@@ -1606,23 +1603,6 @@ implementation
            cg.allocallcpuregisters(list);
            cg.a_call_name(list,'FPC_INITIALIZEUNITS');
            cg.deallocallcpuregisters(list);
-
-{$ifdef GDB}
-           if (cs_debuginfo in aktmoduleswitches) then
-            if target_info.system <> system_powerpc_macos then
-             begin
-               { include reference to all debuginfo sections of used units }
-               hp:=tused_unit(usedunits.first);
-               while assigned(hp) do
-                 begin
-                   If (hp.u.flags and uf_has_debuginfo)=uf_has_debuginfo then
-                     current_procinfo.aktlocaldata.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',hp.u.globalsymtable,''),AT_DATA,0));
-                   hp:=tused_unit(hp.next);
-                 end;
-               { include reference to debuginfo for this program }
-               current_procinfo.aktlocaldata.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
-             end;
-{$endif GDB}
          end;
 
 {$ifdef GDB}
@@ -1700,9 +1680,40 @@ implementation
         stabsendlabel : tasmlabel;
         mangled_length : longint;
         p : pchar;
+        hp   : tused_unit;
 {$endif GDB}
       begin
+        if (current_procinfo.procdef.proctypeoption=potype_proginit) then
+          begin
+            { Insert Ident of the compiler in the main .text section }
+            if (not (cs_create_smart in aktmoduleswitches)) then
+             begin
+               list.insert(Tai_align.Create(const_align(32)));
+               list.insert(Tai_string.Create('FPC '+full_version_string+
+                 ' ['+date_string+'] for '+target_cpu_string+' - '+target_info.shortname));
+             end;
+
+{$ifdef GDB}
+            { Reference all DEBUGINFO sections from the main .text section }
+            if (target_info.system <> system_powerpc_macos) and
+               (cs_debuginfo in aktmoduleswitches) then
+              begin
+                { include reference to all debuginfo sections of used units }
+                hp:=tused_unit(usedunits.first);
+                while assigned(hp) do
+                  begin
+                    If (hp.u.flags and uf_has_debuginfo)=uf_has_debuginfo then
+                      list.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',hp.u.globalsymtable,''),AT_DATA,0));
+                    hp:=tused_unit(hp.next);
+                  end;
+                { include reference to debuginfo for this program }
+                list.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
+              end;
+{$endif GDB}
+          end;
+
         list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname));
+
 {$ifdef GDB}
         if (cs_debuginfo in aktmoduleswitches) then
           begin
@@ -1891,7 +1902,7 @@ implementation
 
     procedure gen_external_stub(list:taasmoutput;pd:tprocdef;const externalname:string);
       begin
-        { add the procedure to the al_code }
+        { add the procedure to the al_procedures }
         maybe_new_object_file(list);
         new_section(list,sec_code,lower(pd.mangledname),aktalignment.procalign);
         list.concat(Tai_align.create(aktalignment.procalign));
@@ -1919,7 +1930,7 @@ implementation
      {$ifndef segment_threadvars}
         if (vo_is_thread_var in sym.varoptions) then
           inc(l,sizeof(aint));
-        list:=asmlist[al_bss];
+        list:=asmlist[al_globals];
         sectype:=sec_bss;
      {$else}
         if (vo_is_thread_var in sym.varoptions) then
@@ -1929,7 +1940,7 @@ implementation
           end
         else
           begin
-            list:=asmlist[al_bss];
+            list:=asmlist[al_globals];
             sectype:=sec_bss;
           end;
      {$endif}

+ 84 - 86
compiler/nobj.pas

@@ -118,7 +118,7 @@ interface
 {$endif WITHDMT}
         { interfaces }
         function  genintftable: tasmlabel;
-        { write the VMT to al_data }
+        { write the VMT to al_globals }
         procedure writevmt;
         procedure writeinterfaceids;
       end;
@@ -263,13 +263,13 @@ implementation
          objectlibrary.getdatalabel(p^.nl);
          if assigned(p^.l) then
            writenames(p^.l);
-         asmlist[al_data].concat(cai_align.create(const_align(sizeof(aint))));
-         asmlist[al_data].concat(Tai_label.Create(p^.nl));
+         asmlist[al_globals].concat(cai_align.create(const_align(sizeof(aint))));
+         asmlist[al_globals].concat(Tai_label.Create(p^.nl));
          len:=strlen(p^.data.messageinf.str);
-         asmlist[al_data].concat(tai_const.create_8bit(len));
+         asmlist[al_globals].concat(tai_const.create_8bit(len));
          getmem(ca,len+1);
          move(p^.data.messageinf.str^,ca^,len+1);
-         asmlist[al_data].concat(Tai_string.Create_pchar(ca));
+         asmlist[al_globals].concat(Tai_string.Create_pchar(ca));
          if assigned(p^.r) then
            writenames(p^.r);
       end;
@@ -281,8 +281,8 @@ implementation
            writestrentry(p^.l);
 
          { write name label }
-         asmlist[al_data].concat(Tai_const.Create_sym(p^.nl));
-         asmlist[al_data].concat(Tai_const.Createname(p^.data.mangledname,AT_FUNCTION,0));
+         asmlist[al_globals].concat(Tai_const.Create_sym(p^.nl));
+         asmlist[al_globals].concat(Tai_const.Createname(p^.data.mangledname,AT_FUNCTION,0));
 
          if assigned(p^.r) then
            writestrentry(p^.r);
@@ -305,10 +305,10 @@ implementation
 
          { now start writing of the message string table }
          objectlibrary.getdatalabel(r);
-         asmlist[al_data].concat(cai_align.create(const_align(sizeof(aint))));
-         asmlist[al_data].concat(Tai_label.Create(r));
+         asmlist[al_globals].concat(cai_align.create(const_align(sizeof(aint))));
+         asmlist[al_globals].concat(Tai_label.Create(r));
          genstrmsgtab:=r;
-         asmlist[al_data].concat(Tai_const.Create_32bit(count));
+         asmlist[al_globals].concat(Tai_const.Create_32bit(count));
          if assigned(root) then
            begin
               writestrentry(root);
@@ -323,8 +323,8 @@ implementation
            writeintentry(p^.l);
 
          { write name label }
-         asmlist[al_data].concat(Tai_const.Create_32bit(p^.data.messageinf.i));
-         asmlist[al_data].concat(Tai_const.Createname(p^.data.mangledname,AT_FUNCTION,0));
+         asmlist[al_globals].concat(Tai_const.Create_32bit(p^.data.messageinf.i));
+         asmlist[al_globals].concat(Tai_const.Createname(p^.data.mangledname,AT_FUNCTION,0));
 
          if assigned(p^.r) then
            writeintentry(p^.r);
@@ -343,10 +343,10 @@ implementation
 
          { now start writing of the message string table }
          objectlibrary.getdatalabel(r);
-         asmlist[al_data].concat(cai_align.create(const_align(sizeof(aint))));
-         asmlist[al_data].concat(Tai_label.Create(r));
+         asmlist[al_globals].concat(cai_align.create(const_align(sizeof(aint))));
+         asmlist[al_globals].concat(Tai_label.Create(r));
          genintmsgtab:=r;
-         asmlist[al_data].concat(Tai_const.Create_32bit(count));
+         asmlist[al_globals].concat(Tai_const.Create_32bit(count));
          if assigned(root) then
            begin
               writeintentry(root);
@@ -390,7 +390,7 @@ implementation
       begin
          if assigned(p^.l) then
            writedmtindexentry(p^.l);
-         al_data.concat(Tai_const.Create_32bit(p^.data.messageinf.i));
+         al_globals.concat(Tai_const.Create_32bit(p^.data.messageinf.i));
          if assigned(p^.r) then
            writedmtindexentry(p^.r);
       end;
@@ -400,7 +400,7 @@ implementation
       begin
          if assigned(p^.l) then
            writedmtaddressentry(p^.l);
-         al_data.concat(Tai_const_symbol.Createname(p^.data.mangledname,AT_FUNCTION,0));
+         al_globals.concat(Tai_const_symbol.Createname(p^.data.mangledname,AT_FUNCTION,0));
          if assigned(p^.r) then
            writedmtaddressentry(p^.r);
       end;
@@ -421,13 +421,13 @@ implementation
            begin
               objectlibrary.getdatalabel(r);
               gendmt:=r;
-              al_data.concat(cai_align.create(const_align(sizeof(aint))));
-              al_data.concat(Tai_label.Create(r));
+              al_globals.concat(cai_align.create(const_align(sizeof(aint))));
+              al_globals.concat(Tai_label.Create(r));
               { entries for caching }
-              al_data.concat(Tai_const.Create_ptr(0));
-              al_data.concat(Tai_const.Create_ptr(0));
+              al_globals.concat(Tai_const.Create_ptr(0));
+              al_globals.concat(Tai_const.Create_ptr(0));
 
-              al_data.concat(Tai_const.Create_32bit(count));
+              al_globals.concat(Tai_const.Create_32bit(count));
               if assigned(root) then
                 begin
                    writedmtindexentry(root);
@@ -482,11 +482,11 @@ implementation
                      asmlist[al_typedconsts].concat(Tai_const.Create_8bit(length(tsym(p).realname)));
                      asmlist[al_typedconsts].concat(Tai_string.Create(tsym(p).realname));
 
-                     asmlist[al_data].concat(Tai_const.Create_sym(l));
+                     asmlist[al_globals].concat(Tai_const.Create_sym(l));
                      if po_abstractmethod in pd.procoptions then
-                       asmlist[al_data].concat(Tai_const.Create_sym(nil))
+                       asmlist[al_globals].concat(Tai_const.Create_sym(nil))
                      else
-                       asmlist[al_data].concat(Tai_const.Createname(pd.mangledname,AT_FUNCTION,0));
+                       asmlist[al_globals].concat(Tai_const.Createname(pd.mangledname,AT_FUNCTION,0));
                    end;
                 end;
            end;
@@ -505,9 +505,9 @@ implementation
          if count>0 then
            begin
               objectlibrary.getdatalabel(l);
-              asmlist[al_data].concat(cai_align.create(const_align(sizeof(aint))));
-              asmlist[al_data].concat(Tai_label.Create(l));
-              asmlist[al_data].concat(Tai_const.Create_32bit(count));
+              asmlist[al_globals].concat(cai_align.create(const_align(sizeof(aint))));
+              asmlist[al_globals].concat(Tai_label.Create(l));
+              asmlist[al_globals].concat(Tai_const.Create_32bit(count));
               _class.symtable.foreach(@do_gen_published_methods,nil);
               genpublishedmethodstable:=l;
            end
@@ -868,11 +868,8 @@ implementation
       begin
         implintf:=_class.implementedinterfaces;
         curintf:=implintf.interfaces(intfindex);
-        rawdata.concat(cai_align.create(const_align(sizeof(aint))));
-        if maybe_smartlink_symbol then
-         rawdata.concat(Tai_symbol.Createname_global(gintfgetvtbllabelname(intfindex),AT_DATA ,0))
-        else
-         rawdata.concat(Tai_symbol.Createname(gintfgetvtbllabelname(intfindex),AT_DATA,0));
+
+        section_symbol_start(rawdata,gintfgetvtbllabelname(intfindex),AT_DATA,true,sec_data,const_align(sizeof(aint)));
         proccount:=implintf.implproccount(intfindex);
         for i:=1 to proccount do
           begin
@@ -882,6 +879,7 @@ implementation
             { create reference }
             rawdata.concat(Tai_const.Createname(tmps,AT_FUNCTION,0));
           end;
+        section_symbol_end(rawdata,gintfgetvtbllabelname(intfindex));
       end;
 
 
@@ -906,17 +904,17 @@ implementation
             rawdata.concat(Tai_const.Create_16bit(curintf.iidguid^.D3));
             for i:=Low(curintf.iidguid^.D4) to High(curintf.iidguid^.D4) do
               rawdata.concat(Tai_const.Create_8bit(curintf.iidguid^.D4[i]));
-            asmlist[al_data].concat(Tai_const.Create_sym(tmplabel));
+            asmlist[al_globals].concat(Tai_const.Create_sym(tmplabel));
           end
         else
           begin
             { nil for Corba interfaces }
-            asmlist[al_data].concat(Tai_const.Create_sym(nil));
+            asmlist[al_globals].concat(Tai_const.Create_sym(nil));
           end;
         { VTable }
-        asmlist[al_data].concat(Tai_const.Createname(gintfgetvtbllabelname(contintfindex),AT_DATA,0));
+        asmlist[al_globals].concat(Tai_const.Createname(gintfgetvtbllabelname(contintfindex),AT_DATA,0));
         { IOffset field }
-        asmlist[al_data].concat(Tai_const.Create_32bit(implintf.ioffsets(contintfindex)));
+        asmlist[al_globals].concat(Tai_const.Create_32bit(implintf.ioffsets(contintfindex)));
         { IIDStr }
         objectlibrary.getdatalabel(tmplabel);
         rawdata.concat(cai_align.create(const_align(sizeof(aint))));
@@ -926,7 +924,7 @@ implementation
           rawdata.concat(Tai_string.Create(upper(curintf.iidstr^)))
         else
           rawdata.concat(Tai_string.Create(curintf.iidstr^));
-        asmlist[al_data].concat(Tai_const.Create_sym(tmplabel));
+        asmlist[al_globals].concat(Tai_const.Create_sym(tmplabel));
       end;
 
 
@@ -1037,7 +1035,7 @@ implementation
         max:=_class.implementedinterfaces.count;
 
         rawdata:=TAAsmOutput.Create;
-        asmlist[al_data].concat(Tai_const.Create_16bit(max));
+        asmlist[al_globals].concat(Tai_const.Create_16bit(max));
         { Two pass, one for allocation and vtbl creation }
         for i:=1 to max do
           begin
@@ -1062,7 +1060,7 @@ implementation
               _class.implementedinterfaces.setioffsets(i,_class.implementedinterfaces.ioffsets(j));
             gintfgenentry(i,j,rawdata);
           end;
-        asmlist[al_data].concatlist(rawdata);
+        asmlist[al_globals].concatlist(rawdata);
         rawdata.free;
       end;
 
@@ -1160,8 +1158,8 @@ implementation
         { 2. step calc required fieldcount and their offsets in the object memory map
              and write data }
         objectlibrary.getdatalabel(intftable);
-        asmlist[al_data].concat(cai_align.create(const_align(sizeof(aint))));
-        asmlist[al_data].concat(Tai_label.Create(intftable));
+        asmlist[al_globals].concat(cai_align.create(const_align(sizeof(aint))));
+        asmlist[al_globals].concat(Tai_label.Create(intftable));
         { Optimize interface tables to reuse wrappers }
         gintfoptimizevtbls;
         { Write interface tables }
@@ -1179,21 +1177,21 @@ implementation
       if assigned(_class.iidguid) then
         begin
           s:=make_mangledname('IID',_class.owner,_class.objname^);
-          maybe_new_object_file(asmlist[al_data]);
-          new_section(asmlist[al_data],sec_rodata,s,const_align(sizeof(aint)));
-          asmlist[al_data].concat(Tai_symbol.Createname_global(s,AT_DATA,0));
-          asmlist[al_data].concat(Tai_const.Create_32bit(longint(_class.iidguid^.D1)));
-          asmlist[al_data].concat(Tai_const.Create_16bit(_class.iidguid^.D2));
-          asmlist[al_data].concat(Tai_const.Create_16bit(_class.iidguid^.D3));
+          maybe_new_object_file(asmlist[al_globals]);
+          new_section(asmlist[al_globals],sec_rodata,s,const_align(sizeof(aint)));
+          asmlist[al_globals].concat(Tai_symbol.Createname_global(s,AT_DATA,0));
+          asmlist[al_globals].concat(Tai_const.Create_32bit(longint(_class.iidguid^.D1)));
+          asmlist[al_globals].concat(Tai_const.Create_16bit(_class.iidguid^.D2));
+          asmlist[al_globals].concat(Tai_const.Create_16bit(_class.iidguid^.D3));
           for i:=Low(_class.iidguid^.D4) to High(_class.iidguid^.D4) do
-            asmlist[al_data].concat(Tai_const.Create_8bit(_class.iidguid^.D4[i]));
+            asmlist[al_globals].concat(Tai_const.Create_8bit(_class.iidguid^.D4[i]));
         end;
-      maybe_new_object_file(asmlist[al_data]);
+      maybe_new_object_file(asmlist[al_globals]);
       s:=make_mangledname('IIDSTR',_class.owner,_class.objname^);
-      new_section(asmlist[al_data],sec_rodata,s,0);
-      asmlist[al_data].concat(Tai_symbol.Createname_global(s,AT_DATA,0));
-      asmlist[al_data].concat(Tai_const.Create_8bit(length(_class.iidstr^)));
-      asmlist[al_data].concat(Tai_string.Create(_class.iidstr^));
+      new_section(asmlist[al_globals],sec_rodata,s,0);
+      asmlist[al_globals].concat(Tai_symbol.Createname_global(s,AT_DATA,0));
+      asmlist[al_globals].concat(Tai_const.Create_8bit(length(_class.iidstr^)));
+      asmlist[al_globals].concat(Tai_string.Create(_class.iidstr^));
     end;
 
 
@@ -1258,8 +1256,8 @@ implementation
          if is_class(_class) then
           begin
             objectlibrary.getdatalabel(classnamelabel);
-            maybe_new_object_file(asmlist[al_data]);
-            new_section(asmlist[al_data],sec_rodata,classnamelabel.name,const_align(sizeof(aint)));
+            maybe_new_object_file(asmlist[al_globals]);
+            new_section(asmlist[al_globals],sec_rodata,classnamelabel.name,const_align(sizeof(aint)));
 
             { interface table }
             if _class.implementedinterfaces.count>0 then
@@ -1268,9 +1266,9 @@ implementation
             methodnametable:=genpublishedmethodstable;
             fieldtablelabel:=_class.generate_field_table;
             { write class name }
-            asmlist[al_data].concat(Tai_label.Create(classnamelabel));
-            asmlist[al_data].concat(Tai_const.Create_8bit(length(_class.objrealname^)));
-            asmlist[al_data].concat(Tai_string.Create(_class.objrealname^));
+            asmlist[al_globals].concat(Tai_label.Create(classnamelabel));
+            asmlist[al_globals].concat(Tai_const.Create_8bit(length(_class.objrealname^)));
+            asmlist[al_globals].concat(Tai_string.Create(_class.objrealname^));
 
             { generate message and dynamic tables }
             if (oo_has_msgstr in _class.objectoptions) then
@@ -1280,30 +1278,30 @@ implementation
           end;
 
         { write debug info }
-        maybe_new_object_file(asmlist[al_data]);
-        new_section(asmlist[al_data],sec_rodata,_class.vmt_mangledname,const_align(sizeof(aint)));
+        maybe_new_object_file(asmlist[al_globals]);
+        new_section(asmlist[al_globals],sec_rodata,_class.vmt_mangledname,const_align(sizeof(aint)));
 {$ifdef GDB}
         if (cs_debuginfo in aktmoduleswitches) then
          begin
            do_count_dbx:=true;
            if assigned(_class.owner) and assigned(_class.owner.name) then
-             asmlist[al_data].concat(Tai_stabs.Create(strpnew('"vmt_'+_class.owner.name^+_class.name+':S'+
+             asmlist[al_globals].concat(Tai_stabs.Create(strpnew('"vmt_'+_class.owner.name^+_class.name+':S'+
                tstoreddef(vmttype.def).numberstring+'",'+tostr(N_STSYM)+',0,0,'+_class.vmt_mangledname)));
          end;
 {$endif GDB}
-         asmlist[al_data].concat(Tai_symbol.Createname_global(_class.vmt_mangledname,AT_DATA,0));
+         asmlist[al_globals].concat(Tai_symbol.Createname_global(_class.vmt_mangledname,AT_DATA,0));
 
          { determine the size with symtable.datasize, because }
          { size gives back 4 for classes                    }
-         asmlist[al_data].concat(Tai_const.Create(ait_const_ptr,tobjectsymtable(_class.symtable).datasize));
-         asmlist[al_data].concat(Tai_const.Create(ait_const_ptr,-int64(tobjectsymtable(_class.symtable).datasize)));
+         asmlist[al_globals].concat(Tai_const.Create(ait_const_ptr,tobjectsymtable(_class.symtable).datasize));
+         asmlist[al_globals].concat(Tai_const.Create(ait_const_ptr,-int64(tobjectsymtable(_class.symtable).datasize)));
 {$ifdef WITHDMT}
          if _class.classtype=ct_object then
            begin
               if assigned(dmtlabel) then
-                asmlist[al_data].concat(Tai_const_symbol.Create(dmtlabel)))
+                asmlist[al_globals].concat(Tai_const_symbol.Create(dmtlabel)))
               else
-                asmlist[al_data].concat(Tai_const.Create_ptr(0));
+                asmlist[al_globals].concat(Tai_const.Create_ptr(0));
            end;
 {$endif WITHDMT}
          { write pointer to parent VMT, this isn't implemented in TP }
@@ -1312,52 +1310,52 @@ implementation
          { it is not written for parents that don't have any vmt !! }
          if assigned(_class.childof) and
             (oo_has_vmt in _class.childof.objectoptions) then
-           asmlist[al_data].concat(Tai_const.Createname(_class.childof.vmt_mangledname,AT_DATA,0))
+           asmlist[al_globals].concat(Tai_const.Createname(_class.childof.vmt_mangledname,AT_DATA,0))
          else
-           asmlist[al_data].concat(Tai_const.Create_sym(nil));
+           asmlist[al_globals].concat(Tai_const.Create_sym(nil));
 
          { write extended info for classes, for the order see rtl/inc/objpash.inc }
          if is_class(_class) then
           begin
             { pointer to class name string }
-            asmlist[al_data].concat(Tai_const.Create_sym(classnamelabel));
+            asmlist[al_globals].concat(Tai_const.Create_sym(classnamelabel));
             { pointer to dynamic table or nil }
             if (oo_has_msgint in _class.objectoptions) then
-              asmlist[al_data].concat(Tai_const.Create_sym(intmessagetable))
+              asmlist[al_globals].concat(Tai_const.Create_sym(intmessagetable))
             else
-              asmlist[al_data].concat(Tai_const.Create_sym(nil));
+              asmlist[al_globals].concat(Tai_const.Create_sym(nil));
             { pointer to method table or nil }
-            asmlist[al_data].concat(Tai_const.Create_sym(methodnametable));
+            asmlist[al_globals].concat(Tai_const.Create_sym(methodnametable));
             { pointer to field table }
-            asmlist[al_data].concat(Tai_const.Create_sym(fieldtablelabel));
+            asmlist[al_globals].concat(Tai_const.Create_sym(fieldtablelabel));
             { pointer to type info of published section }
             if (oo_can_have_published in _class.objectoptions) then
-              asmlist[al_data].concat(Tai_const.Create_sym(_class.get_rtti_label(fullrtti)))
+              asmlist[al_globals].concat(Tai_const.Create_sym(_class.get_rtti_label(fullrtti)))
             else
-              asmlist[al_data].concat(Tai_const.Create_sym(nil));
+              asmlist[al_globals].concat(Tai_const.Create_sym(nil));
             { inittable for con-/destruction }
             if _class.members_need_inittable then
-              asmlist[al_data].concat(Tai_const.Create_sym(_class.get_rtti_label(initrtti)))
+              asmlist[al_globals].concat(Tai_const.Create_sym(_class.get_rtti_label(initrtti)))
             else
-              asmlist[al_data].concat(Tai_const.Create_sym(nil));
+              asmlist[al_globals].concat(Tai_const.Create_sym(nil));
             { auto table }
-            asmlist[al_data].concat(Tai_const.Create_sym(nil));
+            asmlist[al_globals].concat(Tai_const.Create_sym(nil));
             { interface table }
             if _class.implementedinterfaces.count>0 then
-              asmlist[al_data].concat(Tai_const.Create_sym(interfacetable))
+              asmlist[al_globals].concat(Tai_const.Create_sym(interfacetable))
             else
-              asmlist[al_data].concat(Tai_const.Create_sym(nil));
+              asmlist[al_globals].concat(Tai_const.Create_sym(nil));
             { table for string messages }
             if (oo_has_msgstr in _class.objectoptions) then
-              asmlist[al_data].concat(Tai_const.Create_sym(strmessagetable))
+              asmlist[al_globals].concat(Tai_const.Create_sym(strmessagetable))
             else
-              asmlist[al_data].concat(Tai_const.Create_sym(nil));
+              asmlist[al_globals].concat(Tai_const.Create_sym(nil));
           end;
          { write virtual methods }
-         writevirtualmethods(asmlist[al_data]);
-         asmlist[al_data].concat(Tai_const.create(ait_const_ptr,0));
+         writevirtualmethods(asmlist[al_globals]);
+         asmlist[al_globals].concat(Tai_const.create(ait_const_ptr,0));
          { write the size of the VMT }
-         asmlist[al_data].concat(Tai_symbol_end.Createname(_class.vmt_mangledname));
+         asmlist[al_globals].concat(Tai_symbol_end.Createname(_class.vmt_mangledname));
       end;
 
 

+ 14 - 5
compiler/ogelf.pas

@@ -236,6 +236,13 @@ implementation
               AshType:=SHT_PROGBITS;
               AAlign:=max(sizeof(aint),AAlign);
             end;
+          sec_rodata :
+            begin
+{$warning TODO Remove rodata hack}
+              Ashflags:=SHF_ALLOC or SHF_WRITE;
+              AshType:=SHT_PROGBITS;
+              AAlign:=max(sizeof(aint),AAlign);
+            end;
           sec_bss,sec_threadvar :
             begin
               Ashflags:=SHF_ALLOC or SHF_WRITE;
@@ -259,6 +266,8 @@ implementation
               AshType:=SHT_PROGBITS ;
               AAlign:=4;// max(sizeof(aint),AAlign);
             end;
+          else
+            internalerror(200509122);
         end;
         create_ext(Aname,Atype,Ashtype,Ashflags,0,0,Aalign,Aentsize);
       end;
@@ -354,9 +363,8 @@ implementation
         );
       begin
         if use_smartlink_section and
-           not (atype in [sec_bss,sec_threadvar]) and
            (aname<>'') then
-          result:='.gnu.linkonce'+copy(secnames[atype],1,2)+'.'+aname
+          result:=secnames[atype]+'.'+aname
         else
           result:=secnames[atype];
       end;
@@ -628,7 +636,9 @@ implementation
                 AB_GLOBAL :
                   elfsym.st_info:=STB_GLOBAL shl 4;
               end;
-              if sym.currbind<>AB_EXTERNAL then
+              if (sym.currbind<>AB_EXTERNAL) and
+                 not(assigned(sym.section) and
+                     (sym.section.sectype=sec_bss)) then
                begin
                  case sym.typ of
                    AT_FUNCTION :
@@ -898,8 +908,7 @@ implementation
             asmbin : '';
             asmcmd : '';
             supported_target : system_any;  //target_i386_linux;
-//            flags : [af_outputbinary,af_smartlink_sections];
-            flags : [af_outputbinary];
+            flags : [af_outputbinary,af_smartlink_sections];
             labelprefix : '.L';
             comment : '';
           );

+ 1 - 1
compiler/parser.pas

@@ -253,7 +253,7 @@ implementation
       begin
          exprasmlist:=taasmoutput.create;
          { Create assembler output lists for CG }
-         to_create:=[al_code,al_bss,al_typestabs,al_data,al_rodata,
+         to_create:=[al_procedures,al_typestabs,al_globals,al_const,
                      al_threadvars,al_withdebug,al_typedconsts,al_rotypedconsts,al_rtti,al_picdata];
          for i:=low(Tasmlist) to high(Tasmlist) do
            if i in to_create then

+ 1 - 1
compiler/pdecvar.pas

@@ -1117,7 +1117,7 @@ implementation
                    if vs.typ=globalvarsym then
                      begin
                        tglobalvarsym(vs).set_mangledname(C_Name);
-                       { insert in the al_data when it is not external }
+                       { insert in the al_globals when it is not external }
                        if (not extern_var) then
                          insertbssdata(tglobalvarsym(vs));
                        { now we can insert it in the import lib if its a dll, or

+ 74 - 62
compiler/pmodules.pas

@@ -47,6 +47,7 @@ implementation
 {$endif GDB}
        scanner,pbase,pexpr,psystem,psub,pdecsub;
 
+(*
     procedure fixseg(p:TAAsmoutput; sec:TAsmSectionType; secname: string);
       begin
         maybe_new_object_file(p);
@@ -55,7 +56,7 @@ implementation
         else
           p.insert(Tai_section.Create(sec,secname,0));
       end;
-
+*)
 
     procedure create_objectfile;
       var
@@ -103,7 +104,8 @@ implementation
         GenerateAsm(false);
 
         { Also create a smartlinked version ? }
-        if (cs_create_smart in aktmoduleswitches) then
+        if (cs_create_smart in aktmoduleswitches) and
+           not(af_smartlink_sections in target_asm.flags) then
          begin
            { regenerate the importssection for win32 }
            if assigned(asmlist[al_imports]) and
@@ -129,7 +131,8 @@ implementation
         current_module.linkunitofiles.add(current_module.objfilename^,link_static);
         current_module.flags:=current_module.flags or uf_static_linked;
 
-        if (cs_create_smart in aktmoduleswitches) then
+        if (cs_create_smart in aktmoduleswitches) and
+           not(af_smartlink_sections in target_asm.flags) then
          begin
            current_module.linkunitstaticlibs.add(current_module.staticlibfilename^,link_smart);
            current_module.flags:=current_module.flags or uf_smart_linked;
@@ -147,6 +150,7 @@ implementation
       end;
 
 
+(*
     procedure insertsegment;
       var
         oldaktfilepos : tfileposinfo;
@@ -160,17 +164,17 @@ implementation
            then
          begin
            { align the first data }
-           asmlist[al_data].insert(Tai_align.Create(const_align(32)));
-           asmlist[al_data].insert(Tai_string.Create('FPC '+full_version_string+
+           asmlist[al_globals].insert(Tai_align.Create(const_align(32)));
+           asmlist[al_globals].insert(Tai_string.Create('FPC '+full_version_string+
              ' ['+date_string+'] for '+target_cpu_string+' - '+target_info.shortname));
          end;
         { align code segment }
-        asmlist[al_code].concat(Tai_align.create(aktalignment.procalign));
+        asmlist[al_procedures].concat(Tai_align.create(aktalignment.procalign));
         { Insert start and end of sections }
-        fixseg(asmlist[al_code],sec_code,'____seg_code');
-        fixseg(asmlist[al_data],sec_data,'____seg_data');
-        fixseg(asmlist[al_rodata],sec_rodata,'____seg_rodata');
-        fixseg(asmlist[al_bss],sec_bss,'____seg_bss');
+        fixseg(asmlist[al_procedures],sec_code,'____seg_code');
+        fixseg(asmlist[al_globals],sec_data,'____seg_data');
+        fixseg(asmlist[al_const],sec_rodata,'____seg_rodata');
+//        fixseg(asmlist[al_bss],sec_bss,'____seg_bss');
         fixseg(asmlist[al_threadvars],sec_bss,'____seg_tbss');
         { we should use .rdata section for these two no ?
           .rdata is a read only data section (PM) }
@@ -187,11 +191,12 @@ implementation
             aktfilepos.line:=0;
             asmlist[al_typestabs].insert(Tai_symbol.Createname('gcc2_compiled',AT_DATA,0));
             asmlist[al_typestabs].insert(Tai_symbol.Createname('fpc_compiled',AT_DATA,0));
-            fixseg(asmlist[al_typestabs],sec_code,'____seg_debug');
+//            fixseg(asmlist[al_typestabs],sec_code,'____seg_debug');
             aktfilepos:=oldaktfilepos;
           end;
 {$endif GDB}
       end;
+*)
 
 {$ifndef segment_threadvars}
     procedure InsertThreadvarTablesTable;
@@ -218,14 +223,14 @@ implementation
            ltvTables.concat(Tai_const.Createname(make_mangledname('THREADVARLIST',current_module.localsymtable,''),AT_DATA,0));
            inc(count);
          end;
-        { TableCount }
+        { Insert TableCount at start }
         ltvTables.insert(Tai_const.Create_32bit(count));
-        ltvTables.insert(Tai_symbol.Createname_global('FPC_THREADVARTABLES',AT_DATA,0));
-        ltvTables.insert(Tai_align.Create(const_align(sizeof(aint))));
-        ltvTables.concat(Tai_symbol_end.Createname('FPC_THREADVARTABLES'));
         { insert in data segment }
-        maybe_new_object_file(asmlist[al_data]);
-        asmlist[al_data].concatlist(ltvTables);
+        maybe_new_object_file(asmlist[al_globals]);
+        new_section(asmlist[al_globals],sec_data,'FPC_THREADVARTABLES',sizeof(aint));
+        asmlist[al_globals].concat(Tai_symbol.Createname_global('FPC_THREADVARTABLES',AT_DATA,0));
+        asmlist[al_globals].concatlist(ltvTables);
+        asmlist[al_globals].concat(Tai_symbol_end.Createname('FPC_THREADVARTABLES'));
         ltvTables.free;
       end;
 
@@ -257,13 +262,14 @@ implementation
          if ltvTable.first<>nil then
           begin
             s:=make_mangledname('THREADVARLIST',current_module.localsymtable,'');
-            { add begin and end of the list }
-            ltvTable.insert(tai_symbol.Createname_global(s,AT_DATA,0));
-            ltvTable.insert(Tai_align.Create(const_align(32)));
-            ltvTable.concat(tai_const.create_sym(nil));  { end of list marker }
-            ltvTable.concat(tai_symbol_end.createname(s));
-            maybe_new_object_file(asmlist[al_data]);
-            asmlist[al_data].concatlist(ltvTable);
+            { end of the list marker }
+            ltvTable.concat(tai_const.create_sym(nil));
+            { add to datasegment }
+            maybe_new_object_file(asmlist[al_globals]);
+            new_section(asmlist[al_globals],sec_data,s,sizeof(aint));
+            asmlist[al_globals].concat(Tai_symbol.Createname_global(s,AT_DATA,0));
+            asmlist[al_globals].concatlist(ltvTable);
+            asmlist[al_globals].concat(Tai_symbol_end.Createname(s));
             current_module.flags:=current_module.flags or uf_threadvars;
           end;
          ltvTable.Free;
@@ -311,8 +317,8 @@ implementation
           ResourceInfo.concat(Tai_symbol.Createname_global('FPC_RESLOCATION',AT_DATA,0));
           ResourceInfo.Concat(Tai_const.Create_32bit(0));
           end;
-        maybe_new_object_file(asmlist[al_data]);
-        asmlist[al_data].concatlist(ResourceInfo);
+        maybe_new_object_file(asmlist[al_globals]);
+        asmlist[al_globals].concatlist(ResourceInfo);
         ResourceInfo.free;
         end;
     end;
@@ -341,14 +347,14 @@ implementation
            ResourceStringTables.concat(Tai_const.Createname(make_mangledname('RESOURCESTRINGLIST',current_module.localsymtable,''),AT_DATA,0));
            Inc(Count);
          end;
-        { TableCount }
+        { Insert TableCount at start }
         ResourceStringTables.insert(Tai_const.Create_32bit(count));
-        ResourceStringTables.insert(Tai_symbol.Createname_global('FPC_RESOURCESTRINGTABLES',AT_DATA,0));
-        ResourceStringTables.insert(Tai_align.Create(const_align(4)));
-        ResourceStringTables.concat(Tai_symbol_end.Createname('FPC_RESOURCESTRINGTABLES'));
-        { insert in data segment }
-        maybe_new_object_file(asmlist[al_data]);
-        asmlist[al_data].concatlist(ResourceStringTables);
+        { Add to data segment }
+        maybe_new_object_file(asmlist[al_globals]);
+        new_section(asmlist[al_globals],sec_data,'FPC_RESOURCESTRINGTABLES',sizeof(aint));
+        asmlist[al_globals].concat(Tai_symbol.Createname_global('FPC_RESOURCESTRINGTABLES',AT_DATA,0));
+        asmlist[al_globals].concatlist(ResourceStringTables);
+        asmlist[al_globals].concat(Tai_symbol_end.Createname('FPC_RESOURCESTRINGTABLES'));
         ResourceStringTables.free;
       end;
 
@@ -392,15 +398,15 @@ implementation
             unitinits.concat(Tai_const.Create_sym(nil));
            inc(count);
          end;
-        { TableCount,InitCount }
+        { Insert TableCount,InitCount at start }
         unitinits.insert(Tai_const.Create_32bit(0));
         unitinits.insert(Tai_const.Create_32bit(count));
-        unitinits.insert(Tai_symbol.Createname_global('INITFINAL',AT_DATA,0));
-        unitinits.insert(Tai_align.Create(const_align(4)));
-        unitinits.concat(Tai_symbol_end.Createname('INITFINAL'));
-        { insert in data segment }
-        maybe_new_object_file(asmlist[al_data]);
-        asmlist[al_data].concatlist(unitinits);
+        { Add to data segment }
+        maybe_new_object_file(asmlist[al_globals]);
+        new_section(asmlist[al_globals],sec_data,'INITFINAL',sizeof(aint));
+        asmlist[al_globals].concat(Tai_symbol.Createname_global('INITFINAL',AT_DATA,0));
+        asmlist[al_globals].concatlist(unitinits);
+        asmlist[al_globals].concat(Tai_symbol_end.Createname('INITFINAL'));
         unitinits.free;
       end;
 
@@ -408,11 +414,15 @@ implementation
     procedure insertmemorysizes;
       begin
         { stacksize can be specified and is now simulated }
-        asmlist[al_data].concat(Tai_align.Create(const_align(4)));
-        asmlist[al_data].concat(Tai_symbol.Createname_global('__stklen',AT_DATA,4));
-        asmlist[al_data].concat(Tai_const.Create_32bit(stacksize));
-        asmlist[al_data].concat(Tai_symbol.Createname_global('__heapsize',AT_DATA,4));
-        asmlist[al_data].concat(Tai_const.Create_32bit(heapsize));
+        maybe_new_object_file(asmlist[al_globals]);
+        new_section(asmlist[al_globals],sec_data,'__stklen',4);
+        asmlist[al_globals].concat(Tai_symbol.Createname_global('__stklen',AT_DATA,4));
+        asmlist[al_globals].concat(Tai_const.Create_32bit(stacksize));
+        { Initial heapsize }
+        maybe_new_object_file(asmlist[al_globals]);
+        new_section(asmlist[al_globals],sec_data,'__heapsize',4);
+        asmlist[al_globals].concat(Tai_symbol.Createname_global('__heapsize',AT_DATA,4));
+        asmlist[al_globals].concat(Tai_const.Create_32bit(heapsize));
       end;
 
 
@@ -714,8 +724,9 @@ implementation
        end;
 
       var
-        varal_typestabs : taasmoutput;
+        temptypestabs : taasmoutput;
         storefilepos : tfileposinfo;
+        st : tsymtable;
       begin
         if not (cs_debuginfo in aktmoduleswitches) then
          exit;
@@ -726,21 +737,22 @@ implementation
         if current_module.is_unit then
           begin
             current_module.flags:=current_module.flags or uf_has_debuginfo;
-            asmlist[al_typestabs].concat(tai_symbol.Createname_global(make_mangledname('DEBUGINFO',current_module.globalsymtable,''),AT_DATA,0));
+            st:=current_module.globalsymtable;
           end
         else
-          asmlist[al_typestabs].concat(tai_symbol.Createname_global(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
+          st:=current_module.localsymtable;
+        new_section(asmlist[al_typestabs],sec_data,lower(st.name^),0);
+        asmlist[al_typestabs].concat(tai_symbol.Createname_global(make_mangledname('DEBUGINFO',st,''),AT_DATA,0));
         { first write all global/local symbols again to a temp list. This will flag
           all required tdefs. After that the temp list can be removed since the debuginfo is already
           written to the stabs when the variables/consts were written }
 {$warning Hack to get all needed types}
-        varal_typestabs:=taasmoutput.create;
-        new_section(varal_typestabs,sec_data,'',0);
+        temptypestabs:=taasmoutput.create;
         if assigned(current_module.globalsymtable) then
-          tglobalsymtable(current_module.globalsymtable).concatstabto(varal_typestabs);
+          tglobalsymtable(current_module.globalsymtable).concatstabto(temptypestabs);
         if assigned(current_module.localsymtable) then
-          tstaticsymtable(current_module.localsymtable).concatstabto(varal_typestabs);
-        varal_typestabs.free;
+          tstaticsymtable(current_module.localsymtable).concatstabto(temptypestabs);
+        temptypestabs.free;
         { reset unit type info flag }
         reset_unit_type_info;
         { write used types from the used units }
@@ -958,9 +970,9 @@ implementation
       begin
         is_assembler_generated:=(Errorcount=0) and
           not(
-          asmlist[al_code].empty and
-          asmlist[al_data].empty and
-          asmlist[al_bss].empty and
+          asmlist[al_procedures].empty and
+          asmlist[al_globals].empty and
+//          asmlist[al_bss].empty and
           asmlist[al_threadvars].empty and
           asmlist[al_rtti].empty and
           ((asmlist[al_imports]=nil) or asmlist[al_imports].empty) and
@@ -1295,8 +1307,8 @@ implementation
 {$endif GDB}
 
          { generate wrappers for interfaces }
-         gen_intf_wrappers(asmlist[al_code],current_module.globalsymtable);
-         gen_intf_wrappers(asmlist[al_code],current_module.localsymtable);
+         gen_intf_wrappers(asmlist[al_procedures],current_module.globalsymtable);
+         gen_intf_wrappers(asmlist[al_procedures],current_module.localsymtable);
 
          { generate a list of threadvars }
 {$ifndef segment_threadvars}
@@ -1326,7 +1338,7 @@ implementation
             { create dwarf debuginfo }
             create_dwarf;
             { finish asmlist by adding segment starts }
-            insertsegment;
+//            insertsegment;
             { assemble }
             create_objectfile;
           end;
@@ -1548,7 +1560,7 @@ implementation
          if assigned(exportlib) and
             (target_info.system in [system_i386_win32,system_i386_wdosx]) and
             BinaryContainsExports then
-           asmlist[al_code].concat(tai_const.create_sym(exportlib.edatalabel));
+           asmlist[al_procedures].concat(tai_const.create_sym(exportlib.edatalabel));
 
          If al_resourcestrings.ResStrCount>0 then
           begin
@@ -1616,7 +1628,7 @@ implementation
 {$endif GDB}
 
          { generate wrappers for interfaces }
-         gen_intf_wrappers(asmlist[al_code],current_module.localsymtable);
+         gen_intf_wrappers(asmlist[al_procedures],current_module.localsymtable);
 
 {$ifndef segment_threadvars}
          { generate a list of threadvars }
@@ -1647,7 +1659,7 @@ implementation
          create_dwarf;
 
          { finish asmlist by adding segment starts }
-         insertsegment;
+//         insertsegment;
 
          { insert own objectfile }
          insertobjectfile;

+ 2 - 2
compiler/powerpc/agppcmpw.pas

@@ -800,10 +800,10 @@ var
       if not assigned(p) then
        exit;
       InlineLevel:=0;
-      { lineinfo is only needed for al_code (PFV) }
+      { lineinfo is only needed for al_procedures (PFV) }
       do_line:=((cs_asm_source in aktglobalswitches) or
                 (cs_lineinfo in aktmoduleswitches))
-                 and (p=asmlist[al_code]);
+                 and (p=asmlist[al_procedures]);
       DoNotSplitLine:=false;
       hp:=tai(p.first);
       while assigned(hp) do

+ 1 - 1
compiler/powerpc/nppcset.pas

@@ -91,7 +91,7 @@ implementation
            (af_smartlink_sections in target_asm.flags) then
           jumpsegment:=current_procinfo.aktlocaldata
         else
-          jumpsegment:=asmlist[al_data];
+          jumpsegment:=asmlist[al_globals];
         if not(jumptable_no_range) then
           begin
              { case expr less than min_ => goto elselabel }

+ 5 - 5
compiler/psub.pas

@@ -862,10 +862,10 @@ implementation
                  end;
             end;
 
-            { add the procedure to the al_code }
-            maybe_new_object_file(asmlist[al_code]);
-            new_section(asmlist[al_code],sec_code,lower(procdef.mangledname),aktalignment.procalign);
-            asmlist[al_code].concatlist(aktproccode);
+            { add the procedure to the al_procedures }
+            maybe_new_object_file(asmlist[al_procedures]);
+            new_section(asmlist[al_procedures],sec_code,lower(procdef.mangledname),aktalignment.procalign);
+            asmlist[al_procedures].concatlist(aktproccode);
 
             { only now we can remove the temps }
             tg.resettempgen;
@@ -1301,7 +1301,7 @@ implementation
                    begin
                      s:=proc_get_importname(pd);
                      if s<>'' then
-                       gen_external_stub(asmlist[al_code],pd,s);
+                       gen_external_stub(asmlist[al_procedures],pd,s);
                    end;
 
                  { Import DLL specified? }

+ 15 - 15
compiler/ptconst.pas

@@ -342,8 +342,8 @@ implementation
                     else
                      varalign:=0;
                     varalign:=const_align(varalign);
-                    asmlist[al_rodata].concat(Tai_align.Create(varalign));
-                    asmlist[al_rodata].concat(Tai_label.Create(ll));
+                    asmlist[al_const].concat(Tai_align.Create(varalign));
+                    asmlist[al_const].concat(Tai_label.Create(ll));
                     if p.nodetype=stringconstn then
                       begin
                         len:=tstringconstnode(p).len;
@@ -353,11 +353,11 @@ implementation
                          len:=255;
                         getmem(ca,len+2);
                         move(tstringconstnode(p).value_str^,ca^,len+1);
-                        asmlist[al_rodata].concat(Tai_string.Create_length_pchar(ca,len+1));
+                        asmlist[al_const].concat(Tai_string.Create_length_pchar(ca,len+1));
                       end
                     else
                       if is_constcharnode(p) then
-                        asmlist[al_rodata].concat(Tai_string.Create(char(byte(tordconstnode(p).value))+#0))
+                        asmlist[al_const].concat(Tai_string.Create(char(byte(tordconstnode(p).value))+#0))
                     else
                       message(parser_e_illegal_expression);
                 end
@@ -615,10 +615,10 @@ implementation
                           begin
                             objectlibrary.getdatalabel(ll);
                             asmlist[cural].concat(Tai_const.Create_sym(ll));
-                            asmlist[al_rodata].concat(tai_align.create(const_align(sizeof(aint))));
-                            asmlist[al_rodata].concat(Tai_const.Create_aint(-1));
-                            asmlist[al_rodata].concat(Tai_const.Create_aint(strlength));
-                            asmlist[al_rodata].concat(Tai_label.Create(ll));
+                            asmlist[al_const].concat(tai_align.create(const_align(sizeof(aint))));
+                            asmlist[al_const].concat(Tai_const.Create_aint(-1));
+                            asmlist[al_const].concat(Tai_const.Create_aint(strlength));
+                            asmlist[al_const].concat(Tai_label.Create(ll));
                             getmem(ca,strlength+2);
                             move(strval^,ca^,strlength);
                             { The terminating #0 to be stored in the .data section (JM) }
@@ -626,7 +626,7 @@ implementation
                             { End of the PChar. The memory has to be allocated because in }
                             { tai_string.done, there is a freemem(len+1) (JM)             }
                             ca[strlength+1]:=#0;
-                            asmlist[al_rodata].concat(Tai_string.Create_length_pchar(ca,strlength+1));
+                            asmlist[al_const].concat(Tai_string.Create_length_pchar(ca,strlength+1));
                           end;
                      end;
                    st_widestring:
@@ -638,14 +638,14 @@ implementation
                           begin
                             objectlibrary.getdatalabel(ll);
                             asmlist[cural].concat(Tai_const.Create_sym(ll));
-                            asmlist[al_rodata].concat(tai_align.create(const_align(sizeof(aint))));
-                            asmlist[al_rodata].concat(Tai_const.Create_aint(-1));
-                            asmlist[al_rodata].concat(Tai_const.Create_aint(strlength));
-                            asmlist[al_rodata].concat(Tai_label.Create(ll));
+                            asmlist[al_const].concat(tai_align.create(const_align(sizeof(aint))));
+                            asmlist[al_const].concat(Tai_const.Create_aint(-1));
+                            asmlist[al_const].concat(Tai_const.Create_aint(strlength));
+                            asmlist[al_const].concat(Tai_label.Create(ll));
                             for i:=0 to strlength-1 do
-                              asmlist[al_rodata].concat(Tai_const.Create_16bit(pcompilerwidestring(strval)^.data[i]));
+                              asmlist[al_const].concat(Tai_const.Create_16bit(pcompilerwidestring(strval)^.data[i]));
                             { ending #0 }
-                            asmlist[al_rodata].concat(Tai_const.Create_16bit(0))
+                            asmlist[al_const].concat(Tai_const.Create_16bit(0))
                           end;
                      end;
                    st_longstring:

+ 2 - 2
compiler/raatt.pas

@@ -1106,7 +1106,7 @@ unit raatt;
                commname:=actasmpattern;
                Consume(AS_ID);
                Consume(AS_COMMA);
-               ConcatLocalBss(commname,BuildConstExpression(false,false));
+               curList.concat(Tai_datablock.Create(commname,BuildConstExpression(false,false)));
                if actasmtoken<>AS_SEPARATOR then
                 Consume(AS_SEPARATOR);
              end;
@@ -1117,7 +1117,7 @@ unit raatt;
                commname:=actasmpattern;
                Consume(AS_ID);
                Consume(AS_COMMA);
-               ConcatGlobalBss(commname,BuildConstExpression(false,false));
+               curList.concat(Tai_datablock.Create_global(commname,BuildConstExpression(false,false)));
                if actasmtoken<>AS_SEPARATOR then
                 Consume(AS_SEPARATOR);
              end;

+ 0 - 21
compiler/rautils.pas

@@ -203,8 +203,6 @@ Function SearchIConstant(const s:string; var l:aint): boolean;
   procedure ConcatAlign(p:TAAsmoutput;l:aint);
   Procedure ConcatPublic(p:TAAsmoutput;const s : string);
   Procedure ConcatLocal(p:TAAsmoutput;const s : string);
-  Procedure ConcatGlobalBss(const s : string;size : aint);
-  Procedure ConcatLocalBss(const s : string;size : aint);
 
 
 Implementation
@@ -1568,24 +1566,5 @@ end;
        p.concat(Tai_symbol.Createname(s,AT_FUNCTION,0));
    end;
 
-  Procedure ConcatGlobalBss(const s : string;size : aint);
-  {*********************************************************************}
-  { PROCEDURE ConcatGlobalBss                                           }
-  {  Description: This routine emits an global  datablock   to the      }
-  {  linked list of instructions.                                       }
-  {*********************************************************************}
-   begin
-       asmlist[al_bss].concat(Tai_datablock.Create_global(s,size));
-   end;
-
-  Procedure ConcatLocalBss(const s : string;size : aint);
-  {*********************************************************************}
-  { PROCEDURE ConcatLocalBss                                            }
-  {  Description: This routine emits a local datablcok      to the      }
-  {  linked list of instructions.                                       }
-  {*********************************************************************}
-   begin
-       asmlist[al_bss].concat(Tai_datablock.Create(s,size));
-   end;
 
 end.

+ 1 - 1
compiler/sparc/ncpuset.pas

@@ -91,7 +91,7 @@ unit ncpuset;
            (af_smartlink_sections in target_asm.flags) then
           jumpsegment:=current_procinfo.aktlocaldata
         else
-          jumpsegment:=asmlist[al_data];
+          jumpsegment:=asmlist[al_globals];
         if not(jumptable_no_range) then
           begin
              { case expr less than min_ => goto elselabel }

+ 3 - 3
compiler/systems/i_linux.pas

@@ -25,7 +25,7 @@ unit i_linux;
 
     uses
        systems;
-       
+
     const
        res_elf32_info : tresinfo =
           (
@@ -33,14 +33,14 @@ unit i_linux;
              resbin : 'fpcres';
              rescmd : '-o $OBJ -i $RES'
           );
-          
+
        res_elf64_info : tresinfo =
           (
              id     : res_elf;
              resbin : 'fpcres';
              rescmd : '-o $OBJ -i $RES'
           );
-                                                              
+
        system_i386_linux_info : tsysteminfo =
           (
             system       : system_i386_LINUX;

+ 5 - 5
compiler/systems/t_beos.pas

@@ -164,11 +164,11 @@ begin
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
          begin
 {$ifdef i386}
-           { place jump in al_code }
-           asmlist[al_code].concat(Tai_align.Create_op(4,$90));
-           asmlist[al_code].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
-           asmlist[al_code].concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
-           asmlist[al_code].concat(Tai_symbol_end.Createname(hp2.name^));
+           { place jump in al_procedures }
+           asmlist[al_procedures].concat(Tai_align.Create_op(4,$90));
+           asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
+           asmlist[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
+           asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif i386}
          end;
       end

+ 9 - 9
compiler/systems/t_bsd.pas

@@ -219,17 +219,17 @@ begin
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
          begin
 {$ifdef i386}
-           { place jump in al_code }
-           asmlist[al_code].concat(Tai_align.Create_op(4,$90));
-           asmlist[al_code].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
-           asmlist[al_code].concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
-           asmlist[al_code].concat(Tai_symbol_end.Createname(hp2.name^));
+           { place jump in al_procedures }
+           asmlist[al_procedures].concat(Tai_align.Create_op(4,$90));
+           asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
+           asmlist[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
+           asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif i386}
 {$ifdef powerpc}
-           asmlist[al_code].concat(Tai_align.create(16));
-           asmlist[al_code].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
-           asmlist[al_code].concat(Taicpu.Op_sym(A_B,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
-           asmlist[al_code].concat(Tai_symbol_end.Createname(hp2.name^));
+           asmlist[al_procedures].concat(Tai_align.create(16));
+           asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
+           asmlist[al_procedures].concat(Taicpu.Op_sym(A_B,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
+           asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif powerpc}
          end;
       end

+ 13 - 13
compiler/systems/t_linux.pas

@@ -157,7 +157,7 @@ procedure texportliblinux.generatelib;
 var
   hp2 : texported_item;
 begin
-  new_section(asmlist[al_code],sec_code,'',0);
+  new_section(asmlist[al_procedures],sec_code,'',0);
   hp2:=texported_item(current_module._exports.first);
   while assigned(hp2) do
    begin
@@ -168,11 +168,11 @@ begin
           is declared with cdecl }
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
          begin
-           { place jump in al_code }
-           asmlist[al_code].concat(tai_align.create(target_info.alignment.procalign));
-           asmlist[al_code].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
-           cg.a_jmp_name(asmlist[al_code],tprocsym(hp2.sym).first_procdef.mangledname);
-           asmlist[al_code].concat(Tai_symbol_end.Createname(hp2.name^));
+           { place jump in al_procedures }
+           asmlist[al_procedures].concat(tai_align.create(target_info.alignment.procalign));
+           asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
+           cg.a_jmp_name(asmlist[al_procedures],tprocsym(hp2.sym).first_procdef.mangledname);
+           asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
          end;
       end
      else
@@ -562,7 +562,7 @@ begin
    StaticStr:='-static';
   if (cs_link_strip in aktglobalswitches) then
    StripStr:='-s';
-  if (cs_link_smart in aktglobalswitches) and
+  if (af_smartlink_sections in target_asm.flags) and
      (tf_smartlink_sections in target_info.flags) then
    GCSectionsStr:='--gc-sections';
   If (cs_profile in aktmoduleswitches) or
@@ -592,11 +592,11 @@ begin
 { Remove ReponseFile }
   if (success) and not(cs_link_extern in aktglobalswitches) then
    RemoveFile(outputexedir+Info.ResName);
-   
+
   if (success) then
     success:=PostProcessExecutable(current_module.exefilename^,false);
-    
- 
+
+
   MakeExecutable:=success;   { otherwise a recursive call to link method }
 end;
 
@@ -669,13 +669,13 @@ begin
         Found:=((hp.u.flags and uf_has_resourcefiles)=uf_has_resourcefiles);
         hp:=tused_unit(hp.next);
         end;
-      end;  
+      end;
     if found then
-      begin  
+      begin
       cmdstr:=' -f -i '+maybequoted(fn);
       postprocessexecutable:=DoExec(FindUtil(utilsprefix+'fpcres'),cmdstr,false,false);
       end;
-    end;  
+    end;
 end;
 
 

+ 5 - 5
compiler/systems/t_nwl.pas

@@ -241,11 +241,11 @@ begin
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
          begin
 {$ifdef i386}
-           { place jump in al_code }
-           asmlist[al_code].concat(Tai_align.Create_op(4,$90));
-           asmlist[al_code].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
-           asmlist[al_code].concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
-           asmlist[al_code].concat(Tai_symbol_end.Createname(hp2.name^));
+           { place jump in al_procedures }
+           asmlist[al_procedures].concat(Tai_align.Create_op(4,$90));
+           asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
+           asmlist[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
+           asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif i386}
          end;
       end

+ 5 - 5
compiler/systems/t_nwm.pas

@@ -233,11 +233,11 @@ begin
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
          begin
 {$ifdef i386}
-           { place jump in al_code }
-           asmlist[al_code].concat(Tai_align.Create_op(4,$90));
-           asmlist[al_code].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
-           asmlist[al_code].concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
-           asmlist[al_code].concat(Tai_symbol_end.Createname(hp2.name^));
+           { place jump in al_procedures }
+           asmlist[al_procedures].concat(Tai_align.Create_op(4,$90));
+           asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
+           asmlist[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
+           asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif i386}
          end;
       end

+ 6 - 6
compiler/systems/t_sunos.pas

@@ -169,7 +169,7 @@ procedure texportlibsolaris.generatelib;
 var
   hp2 : texported_item;
 begin
-  new_section(asmlist[al_code],sec_code,'',0);
+  new_section(asmlist[al_procedures],sec_code,'',0);
   hp2:=texported_item(current_module._exports.first);
   while assigned(hp2) do
    begin
@@ -180,11 +180,11 @@ begin
           is declared with cdecl }
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
          begin
-           { place jump in al_code }
-           asmlist[al_code].concat(tai_align.create(target_info.alignment.procalign));
-           asmlist[al_code].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
-           cg.a_jmp_name(asmlist[al_code],tprocsym(hp2.sym).first_procdef.mangledname);
-           asmlist[al_code].concat(Tai_symbol_end.Createname(hp2.name^));
+           { place jump in al_procedures }
+           asmlist[al_procedures].concat(tai_align.create(target_info.alignment.procalign));
+           asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
+           cg.a_jmp_name(asmlist[al_procedures],tprocsym(hp2.sym).first_procdef.mangledname);
+           asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
          end;
       end
      else

+ 3 - 3
compiler/systems/t_win.pas

@@ -316,7 +316,7 @@ implementation
                   {$ifdef ARM}
                     objectlibrary.getlabel(lpcode);
                   {$endif ARM}
-                    { place jump in al_code, insert a code section in the
+                    { place jump in al_procedures, insert a code section in the
                       al_imports to reduce the amount of .s files (PFV) }
                     new_section(asmlist[al_imports],sec_code,'',0);
 {$IfDef GDB}
@@ -437,7 +437,7 @@ implementation
          hp1:=timportlist(current_module.imports.first);
          while assigned(hp1) do
            begin
-              { align al_code for the jumps }
+              { align al_procedures for the jumps }
               new_section(asmlist[al_imports],sec_code,'',sizeof(aint));
               { Get labels for the sections }
               objectlibrary.getlabel(l1);
@@ -487,7 +487,7 @@ implementation
                       objectlibrary.getlabel(l5);
                     {$endif ARM}
                       { create indirect jump and }
-                      { place jump in al_code }
+                      { place jump in al_procedures }
                       new_section(asmlist[al_imports],sec_code,'',0);
 {$IfDef GDB}
                       if (cs_debuginfo in aktmoduleswitches) then

+ 2 - 2
compiler/x86/agx86int.pas

@@ -387,10 +387,10 @@ implementation
     begin
       if not assigned(p) then
        exit;
-      { lineinfo is only needed for al_code (PFV) }
+      { lineinfo is only needed for al_procedures (PFV) }
       do_line:=((cs_asm_source in aktglobalswitches) or
                 (cs_lineinfo in aktmoduleswitches))
-                 and (p=asmlist[al_code]);
+                 and (p=asmlist[al_procedures]);
       InlineLevel:=0;
       DoNotSplitLine:=false;
       hp:=tai(p.first);