소스 검색

* 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;
         inusedlist:=false;
         pass:=255;
         pass:=255;
         ppuidx:=-1;
         ppuidx:=-1;
-        { mainly used to remove unused labels from the al_code }
+        { mainly used to remove unused labels from the al_procedures }
         refs:=0;
         refs:=0;
       end;
       end;
 
 

+ 34 - 10
compiler/aasmtai.pas

@@ -587,10 +587,9 @@ interface
          before they can be referenced and therefor they need to be written
          before they can be referenced and therefor they need to be written
          first (PFV) }
          first (PFV) }
        Tasmlist=(al_typestabs,
        Tasmlist=(al_typestabs,
-                 al_code,
-                 al_bss,
-                 al_data,
-                 al_rodata,
+                 al_procedures,
+                 al_globals,
+                 al_const,
                  al_typedconsts,
                  al_typedconsts,
                  al_rotypedconsts,
                  al_rotypedconsts,
                  al_threadvars,
                  al_threadvars,
@@ -605,10 +604,9 @@ interface
     const
     const
        TasmlistStr : array[tasmlist] of string[24] =(
        TasmlistStr : array[tasmlist] of string[24] =(
            'al_typestabs',
            'al_typestabs',
-           'al_code',
-           'al_bss',
-           'al_data',
-           'al_rodata',
+           'al_procedures',
+           'al_globals',
+           'al_const',
            'al_typedconsts',
            'al_typedconsts',
            'al_rotypedconsts',
            'al_rotypedconsts',
            'al_threadvars',
            'al_threadvars',
@@ -644,8 +642,12 @@ interface
 
 
     function  use_smartlink_section:boolean;
     function  use_smartlink_section:boolean;
     function  maybe_smartlink_symbol:boolean;
     function  maybe_smartlink_symbol:boolean;
+
     procedure maybe_new_object_file(list:taasmoutput);
     procedure maybe_new_object_file(list:taasmoutput);
     procedure new_section(list:taasmoutput;Asectype:TAsmSectionType;Aname:string;Aalign:byte);
     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;
     function ppuloadai(ppufile:tcompilerppufile):tai;
     procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
     procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
@@ -710,8 +712,7 @@ implementation
     function use_smartlink_section:boolean;
     function use_smartlink_section:boolean;
       begin
       begin
         result:=(af_smartlink_sections in target_asm.flags) and
         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;
       end;
 
 
 
 
@@ -737,6 +738,26 @@ implementation
       end;
       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
                              TAI
  ****************************************************************************}
  ****************************************************************************}
@@ -821,6 +842,9 @@ implementation
         typ:=ait_section;
         typ:=ait_section;
         sectype:=asectype;
         sectype:=asectype;
         secalign:=Aalign;
         secalign:=Aalign;
+        if (Aname='') and
+           use_smartlink_section then
+          internalerror(200509131);
         name:=stringdup(Aname);
         name:=stringdup(Aname);
         sec:=nil;
         sec:=nil;
       end;
       end;

+ 42 - 46
compiler/aggas.pas

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

+ 21 - 9
compiler/assemble.pas

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

+ 14 - 14
compiler/cresstr.pas

@@ -149,16 +149,16 @@ procedure Tal_resourcestrings.CreateResourceStringList;
          begin
          begin
             objectlibrary.getdatalabel(l1);
             objectlibrary.getdatalabel(l1);
             asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_sym(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);
             getmem(s,len+1);
             move(value^,s^,len);
             move(value^,s^,len);
             s[len]:=#0;
             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;
          end;
        { append Current value (nil) and hash...}
        { append Current value (nil) and hash...}
        asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_sym(nil));
        asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_sym(nil));
@@ -167,16 +167,16 @@ procedure Tal_resourcestrings.CreateResourceStringList;
        objectlibrary.getdatalabel(l1);
        objectlibrary.getdatalabel(l1);
        l:=length(name);
        l:=length(name);
        asmlist[aasmtai.al_resourcestrings].concat(tai_const.create_sym(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(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);
        getmem(s,l+1);
        move(Name[1],s^,l);
        move(Name[1],s^,l);
        s[l]:=#0;
        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;
   end;
   end;
 
 

+ 2 - 2
compiler/i386/ag386nsm.pas

@@ -399,10 +399,10 @@ interface
       if not assigned(p) then
       if not assigned(p) then
        exit;
        exit;
       InlineLevel:=0;
       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
       do_line:=(cs_asm_source in aktglobalswitches) or
                ((cs_lineinfo in aktmoduleswitches)
                ((cs_lineinfo in aktmoduleswitches)
-                 and (p=asmlist[al_code]));
+                 and (p=asmlist[al_procedures]));
       hp:=tai(p.first);
       hp:=tai(p.first);
       while assigned(hp) do
       while assigned(hp) do
        begin
        begin

+ 1 - 1
compiler/i386/n386set.pas

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

+ 36 - 25
compiler/ncgutil.pas

@@ -121,7 +121,7 @@ interface
 implementation
 implementation
 
 
   uses
   uses
-    strings,
+    strings,version,
     cutils,cclasses,
     cutils,cclasses,
     globals,systems,verbose,
     globals,systems,verbose,
     ppu,defutil,
     ppu,defutil,
@@ -1566,11 +1566,8 @@ implementation
 
 
     procedure gen_entry_code(list:TAAsmoutput);
     procedure gen_entry_code(list:TAAsmoutput);
       var
       var
-        href : treference;
         paraloc1,
         paraloc1,
-        paraloc2,
-        paraloc3 : tcgpara;
-        hp   : tused_unit;
+        paraloc2 : tcgpara;
       begin
       begin
         paraloc1.init;
         paraloc1.init;
         paraloc2.init;
         paraloc2.init;
@@ -1606,23 +1603,6 @@ implementation
            cg.allocallcpuregisters(list);
            cg.allocallcpuregisters(list);
            cg.a_call_name(list,'FPC_INITIALIZEUNITS');
            cg.a_call_name(list,'FPC_INITIALIZEUNITS');
            cg.deallocallcpuregisters(list);
            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;
          end;
 
 
 {$ifdef GDB}
 {$ifdef GDB}
@@ -1700,9 +1680,40 @@ implementation
         stabsendlabel : tasmlabel;
         stabsendlabel : tasmlabel;
         mangled_length : longint;
         mangled_length : longint;
         p : pchar;
         p : pchar;
+        hp   : tused_unit;
 {$endif GDB}
 {$endif GDB}
       begin
       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));
         list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname));
+
 {$ifdef GDB}
 {$ifdef GDB}
         if (cs_debuginfo in aktmoduleswitches) then
         if (cs_debuginfo in aktmoduleswitches) then
           begin
           begin
@@ -1891,7 +1902,7 @@ implementation
 
 
     procedure gen_external_stub(list:taasmoutput;pd:tprocdef;const externalname:string);
     procedure gen_external_stub(list:taasmoutput;pd:tprocdef;const externalname:string);
       begin
       begin
-        { add the procedure to the al_code }
+        { add the procedure to the al_procedures }
         maybe_new_object_file(list);
         maybe_new_object_file(list);
         new_section(list,sec_code,lower(pd.mangledname),aktalignment.procalign);
         new_section(list,sec_code,lower(pd.mangledname),aktalignment.procalign);
         list.concat(Tai_align.create(aktalignment.procalign));
         list.concat(Tai_align.create(aktalignment.procalign));
@@ -1919,7 +1930,7 @@ implementation
      {$ifndef segment_threadvars}
      {$ifndef segment_threadvars}
         if (vo_is_thread_var in sym.varoptions) then
         if (vo_is_thread_var in sym.varoptions) then
           inc(l,sizeof(aint));
           inc(l,sizeof(aint));
-        list:=asmlist[al_bss];
+        list:=asmlist[al_globals];
         sectype:=sec_bss;
         sectype:=sec_bss;
      {$else}
      {$else}
         if (vo_is_thread_var in sym.varoptions) then
         if (vo_is_thread_var in sym.varoptions) then
@@ -1929,7 +1940,7 @@ implementation
           end
           end
         else
         else
           begin
           begin
-            list:=asmlist[al_bss];
+            list:=asmlist[al_globals];
             sectype:=sec_bss;
             sectype:=sec_bss;
           end;
           end;
      {$endif}
      {$endif}

+ 84 - 86
compiler/nobj.pas

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

+ 14 - 5
compiler/ogelf.pas

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

+ 1 - 1
compiler/parser.pas

@@ -253,7 +253,7 @@ implementation
       begin
       begin
          exprasmlist:=taasmoutput.create;
          exprasmlist:=taasmoutput.create;
          { Create assembler output lists for CG }
          { 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];
                      al_threadvars,al_withdebug,al_typedconsts,al_rotypedconsts,al_rtti,al_picdata];
          for i:=low(Tasmlist) to high(Tasmlist) do
          for i:=low(Tasmlist) to high(Tasmlist) do
            if i in to_create then
            if i in to_create then

+ 1 - 1
compiler/pdecvar.pas

@@ -1117,7 +1117,7 @@ implementation
                    if vs.typ=globalvarsym then
                    if vs.typ=globalvarsym then
                      begin
                      begin
                        tglobalvarsym(vs).set_mangledname(C_Name);
                        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
                        if (not extern_var) then
                          insertbssdata(tglobalvarsym(vs));
                          insertbssdata(tglobalvarsym(vs));
                        { now we can insert it in the import lib if its a dll, or
                        { 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}
 {$endif GDB}
        scanner,pbase,pexpr,psystem,psub,pdecsub;
        scanner,pbase,pexpr,psystem,psub,pdecsub;
 
 
+(*
     procedure fixseg(p:TAAsmoutput; sec:TAsmSectionType; secname: string);
     procedure fixseg(p:TAAsmoutput; sec:TAsmSectionType; secname: string);
       begin
       begin
         maybe_new_object_file(p);
         maybe_new_object_file(p);
@@ -55,7 +56,7 @@ implementation
         else
         else
           p.insert(Tai_section.Create(sec,secname,0));
           p.insert(Tai_section.Create(sec,secname,0));
       end;
       end;
-
+*)
 
 
     procedure create_objectfile;
     procedure create_objectfile;
       var
       var
@@ -103,7 +104,8 @@ implementation
         GenerateAsm(false);
         GenerateAsm(false);
 
 
         { Also create a smartlinked version ? }
         { 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
          begin
            { regenerate the importssection for win32 }
            { regenerate the importssection for win32 }
            if assigned(asmlist[al_imports]) and
            if assigned(asmlist[al_imports]) and
@@ -129,7 +131,8 @@ implementation
         current_module.linkunitofiles.add(current_module.objfilename^,link_static);
         current_module.linkunitofiles.add(current_module.objfilename^,link_static);
         current_module.flags:=current_module.flags or uf_static_linked;
         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
          begin
            current_module.linkunitstaticlibs.add(current_module.staticlibfilename^,link_smart);
            current_module.linkunitstaticlibs.add(current_module.staticlibfilename^,link_smart);
            current_module.flags:=current_module.flags or uf_smart_linked;
            current_module.flags:=current_module.flags or uf_smart_linked;
@@ -147,6 +150,7 @@ implementation
       end;
       end;
 
 
 
 
+(*
     procedure insertsegment;
     procedure insertsegment;
       var
       var
         oldaktfilepos : tfileposinfo;
         oldaktfilepos : tfileposinfo;
@@ -160,17 +164,17 @@ implementation
            then
            then
          begin
          begin
            { align the first data }
            { 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));
              ' ['+date_string+'] for '+target_cpu_string+' - '+target_info.shortname));
          end;
          end;
         { align code segment }
         { 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 }
         { 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');
         fixseg(asmlist[al_threadvars],sec_bss,'____seg_tbss');
         { we should use .rdata section for these two no ?
         { we should use .rdata section for these two no ?
           .rdata is a read only data section (PM) }
           .rdata is a read only data section (PM) }
@@ -187,11 +191,12 @@ implementation
             aktfilepos.line:=0;
             aktfilepos.line:=0;
             asmlist[al_typestabs].insert(Tai_symbol.Createname('gcc2_compiled',AT_DATA,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));
             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;
             aktfilepos:=oldaktfilepos;
           end;
           end;
 {$endif GDB}
 {$endif GDB}
       end;
       end;
+*)
 
 
 {$ifndef segment_threadvars}
 {$ifndef segment_threadvars}
     procedure InsertThreadvarTablesTable;
     procedure InsertThreadvarTablesTable;
@@ -218,14 +223,14 @@ implementation
            ltvTables.concat(Tai_const.Createname(make_mangledname('THREADVARLIST',current_module.localsymtable,''),AT_DATA,0));
            ltvTables.concat(Tai_const.Createname(make_mangledname('THREADVARLIST',current_module.localsymtable,''),AT_DATA,0));
            inc(count);
            inc(count);
          end;
          end;
-        { TableCount }
+        { Insert TableCount at start }
         ltvTables.insert(Tai_const.Create_32bit(count));
         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 }
         { 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;
         ltvTables.free;
       end;
       end;
 
 
@@ -257,13 +262,14 @@ implementation
          if ltvTable.first<>nil then
          if ltvTable.first<>nil then
           begin
           begin
             s:=make_mangledname('THREADVARLIST',current_module.localsymtable,'');
             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;
             current_module.flags:=current_module.flags or uf_threadvars;
           end;
           end;
          ltvTable.Free;
          ltvTable.Free;
@@ -311,8 +317,8 @@ implementation
           ResourceInfo.concat(Tai_symbol.Createname_global('FPC_RESLOCATION',AT_DATA,0));
           ResourceInfo.concat(Tai_symbol.Createname_global('FPC_RESLOCATION',AT_DATA,0));
           ResourceInfo.Concat(Tai_const.Create_32bit(0));
           ResourceInfo.Concat(Tai_const.Create_32bit(0));
           end;
           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;
         ResourceInfo.free;
         end;
         end;
     end;
     end;
@@ -341,14 +347,14 @@ implementation
            ResourceStringTables.concat(Tai_const.Createname(make_mangledname('RESOURCESTRINGLIST',current_module.localsymtable,''),AT_DATA,0));
            ResourceStringTables.concat(Tai_const.Createname(make_mangledname('RESOURCESTRINGLIST',current_module.localsymtable,''),AT_DATA,0));
            Inc(Count);
            Inc(Count);
          end;
          end;
-        { TableCount }
+        { Insert TableCount at start }
         ResourceStringTables.insert(Tai_const.Create_32bit(count));
         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;
         ResourceStringTables.free;
       end;
       end;
 
 
@@ -392,15 +398,15 @@ implementation
             unitinits.concat(Tai_const.Create_sym(nil));
             unitinits.concat(Tai_const.Create_sym(nil));
            inc(count);
            inc(count);
          end;
          end;
-        { TableCount,InitCount }
+        { Insert TableCount,InitCount at start }
         unitinits.insert(Tai_const.Create_32bit(0));
         unitinits.insert(Tai_const.Create_32bit(0));
         unitinits.insert(Tai_const.Create_32bit(count));
         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;
         unitinits.free;
       end;
       end;
 
 
@@ -408,11 +414,15 @@ implementation
     procedure insertmemorysizes;
     procedure insertmemorysizes;
       begin
       begin
         { stacksize can be specified and is now simulated }
         { 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;
       end;
 
 
 
 
@@ -714,8 +724,9 @@ implementation
        end;
        end;
 
 
       var
       var
-        varal_typestabs : taasmoutput;
+        temptypestabs : taasmoutput;
         storefilepos : tfileposinfo;
         storefilepos : tfileposinfo;
+        st : tsymtable;
       begin
       begin
         if not (cs_debuginfo in aktmoduleswitches) then
         if not (cs_debuginfo in aktmoduleswitches) then
          exit;
          exit;
@@ -726,21 +737,22 @@ implementation
         if current_module.is_unit then
         if current_module.is_unit then
           begin
           begin
             current_module.flags:=current_module.flags or uf_has_debuginfo;
             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
           end
         else
         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
         { 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
           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 }
           written to the stabs when the variables/consts were written }
 {$warning Hack to get all needed types}
 {$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
         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
         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 flag }
         reset_unit_type_info;
         reset_unit_type_info;
         { write used types from the used units }
         { write used types from the used units }
@@ -958,9 +970,9 @@ implementation
       begin
       begin
         is_assembler_generated:=(Errorcount=0) and
         is_assembler_generated:=(Errorcount=0) and
           not(
           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_threadvars].empty and
           asmlist[al_rtti].empty and
           asmlist[al_rtti].empty and
           ((asmlist[al_imports]=nil) or asmlist[al_imports].empty) and
           ((asmlist[al_imports]=nil) or asmlist[al_imports].empty) and
@@ -1295,8 +1307,8 @@ implementation
 {$endif GDB}
 {$endif GDB}
 
 
          { generate wrappers for interfaces }
          { 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 }
          { generate a list of threadvars }
 {$ifndef segment_threadvars}
 {$ifndef segment_threadvars}
@@ -1326,7 +1338,7 @@ implementation
             { create dwarf debuginfo }
             { create dwarf debuginfo }
             create_dwarf;
             create_dwarf;
             { finish asmlist by adding segment starts }
             { finish asmlist by adding segment starts }
-            insertsegment;
+//            insertsegment;
             { assemble }
             { assemble }
             create_objectfile;
             create_objectfile;
           end;
           end;
@@ -1548,7 +1560,7 @@ implementation
          if assigned(exportlib) and
          if assigned(exportlib) and
             (target_info.system in [system_i386_win32,system_i386_wdosx]) and
             (target_info.system in [system_i386_win32,system_i386_wdosx]) and
             BinaryContainsExports then
             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
          If al_resourcestrings.ResStrCount>0 then
           begin
           begin
@@ -1616,7 +1628,7 @@ implementation
 {$endif GDB}
 {$endif GDB}
 
 
          { generate wrappers for interfaces }
          { 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}
 {$ifndef segment_threadvars}
          { generate a list of threadvars }
          { generate a list of threadvars }
@@ -1647,7 +1659,7 @@ implementation
          create_dwarf;
          create_dwarf;
 
 
          { finish asmlist by adding segment starts }
          { finish asmlist by adding segment starts }
-         insertsegment;
+//         insertsegment;
 
 
          { insert own objectfile }
          { insert own objectfile }
          insertobjectfile;
          insertobjectfile;

+ 2 - 2
compiler/powerpc/agppcmpw.pas

@@ -800,10 +800,10 @@ var
       if not assigned(p) then
       if not assigned(p) then
        exit;
        exit;
       InlineLevel:=0;
       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
       do_line:=((cs_asm_source in aktglobalswitches) or
                 (cs_lineinfo in aktmoduleswitches))
                 (cs_lineinfo in aktmoduleswitches))
-                 and (p=asmlist[al_code]);
+                 and (p=asmlist[al_procedures]);
       DoNotSplitLine:=false;
       DoNotSplitLine:=false;
       hp:=tai(p.first);
       hp:=tai(p.first);
       while assigned(hp) do
       while assigned(hp) do

+ 1 - 1
compiler/powerpc/nppcset.pas

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

+ 5 - 5
compiler/psub.pas

@@ -862,10 +862,10 @@ implementation
                  end;
                  end;
             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 }
             { only now we can remove the temps }
             tg.resettempgen;
             tg.resettempgen;
@@ -1301,7 +1301,7 @@ implementation
                    begin
                    begin
                      s:=proc_get_importname(pd);
                      s:=proc_get_importname(pd);
                      if s<>'' then
                      if s<>'' then
-                       gen_external_stub(asmlist[al_code],pd,s);
+                       gen_external_stub(asmlist[al_procedures],pd,s);
                    end;
                    end;
 
 
                  { Import DLL specified? }
                  { Import DLL specified? }

+ 15 - 15
compiler/ptconst.pas

@@ -342,8 +342,8 @@ implementation
                     else
                     else
                      varalign:=0;
                      varalign:=0;
                     varalign:=const_align(varalign);
                     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
                     if p.nodetype=stringconstn then
                       begin
                       begin
                         len:=tstringconstnode(p).len;
                         len:=tstringconstnode(p).len;
@@ -353,11 +353,11 @@ implementation
                          len:=255;
                          len:=255;
                         getmem(ca,len+2);
                         getmem(ca,len+2);
                         move(tstringconstnode(p).value_str^,ca^,len+1);
                         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
                       end
                     else
                     else
                       if is_constcharnode(p) then
                       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
                     else
                       message(parser_e_illegal_expression);
                       message(parser_e_illegal_expression);
                 end
                 end
@@ -615,10 +615,10 @@ implementation
                           begin
                           begin
                             objectlibrary.getdatalabel(ll);
                             objectlibrary.getdatalabel(ll);
                             asmlist[cural].concat(Tai_const.Create_sym(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);
                             getmem(ca,strlength+2);
                             move(strval^,ca^,strlength);
                             move(strval^,ca^,strlength);
                             { The terminating #0 to be stored in the .data section (JM) }
                             { 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 }
                             { End of the PChar. The memory has to be allocated because in }
                             { tai_string.done, there is a freemem(len+1) (JM)             }
                             { tai_string.done, there is a freemem(len+1) (JM)             }
                             ca[strlength+1]:=#0;
                             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;
                      end;
                      end;
                    st_widestring:
                    st_widestring:
@@ -638,14 +638,14 @@ implementation
                           begin
                           begin
                             objectlibrary.getdatalabel(ll);
                             objectlibrary.getdatalabel(ll);
                             asmlist[cural].concat(Tai_const.Create_sym(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
                             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 }
                             { ending #0 }
-                            asmlist[al_rodata].concat(Tai_const.Create_16bit(0))
+                            asmlist[al_const].concat(Tai_const.Create_16bit(0))
                           end;
                           end;
                      end;
                      end;
                    st_longstring:
                    st_longstring:

+ 2 - 2
compiler/raatt.pas

@@ -1106,7 +1106,7 @@ unit raatt;
                commname:=actasmpattern;
                commname:=actasmpattern;
                Consume(AS_ID);
                Consume(AS_ID);
                Consume(AS_COMMA);
                Consume(AS_COMMA);
-               ConcatLocalBss(commname,BuildConstExpression(false,false));
+               curList.concat(Tai_datablock.Create(commname,BuildConstExpression(false,false)));
                if actasmtoken<>AS_SEPARATOR then
                if actasmtoken<>AS_SEPARATOR then
                 Consume(AS_SEPARATOR);
                 Consume(AS_SEPARATOR);
              end;
              end;
@@ -1117,7 +1117,7 @@ unit raatt;
                commname:=actasmpattern;
                commname:=actasmpattern;
                Consume(AS_ID);
                Consume(AS_ID);
                Consume(AS_COMMA);
                Consume(AS_COMMA);
-               ConcatGlobalBss(commname,BuildConstExpression(false,false));
+               curList.concat(Tai_datablock.Create_global(commname,BuildConstExpression(false,false)));
                if actasmtoken<>AS_SEPARATOR then
                if actasmtoken<>AS_SEPARATOR then
                 Consume(AS_SEPARATOR);
                 Consume(AS_SEPARATOR);
              end;
              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 ConcatAlign(p:TAAsmoutput;l:aint);
   Procedure ConcatPublic(p:TAAsmoutput;const s : string);
   Procedure ConcatPublic(p:TAAsmoutput;const s : string);
   Procedure ConcatLocal(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
 Implementation
@@ -1568,24 +1566,5 @@ end;
        p.concat(Tai_symbol.Createname(s,AT_FUNCTION,0));
        p.concat(Tai_symbol.Createname(s,AT_FUNCTION,0));
    end;
    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.
 end.

+ 1 - 1
compiler/sparc/ncpuset.pas

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

+ 3 - 3
compiler/systems/i_linux.pas

@@ -25,7 +25,7 @@ unit i_linux;
 
 
     uses
     uses
        systems;
        systems;
-       
+
     const
     const
        res_elf32_info : tresinfo =
        res_elf32_info : tresinfo =
           (
           (
@@ -33,14 +33,14 @@ unit i_linux;
              resbin : 'fpcres';
              resbin : 'fpcres';
              rescmd : '-o $OBJ -i $RES'
              rescmd : '-o $OBJ -i $RES'
           );
           );
-          
+
        res_elf64_info : tresinfo =
        res_elf64_info : tresinfo =
           (
           (
              id     : res_elf;
              id     : res_elf;
              resbin : 'fpcres';
              resbin : 'fpcres';
              rescmd : '-o $OBJ -i $RES'
              rescmd : '-o $OBJ -i $RES'
           );
           );
-                                                              
+
        system_i386_linux_info : tsysteminfo =
        system_i386_linux_info : tsysteminfo =
           (
           (
             system       : system_i386_LINUX;
             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
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
          begin
          begin
 {$ifdef i386}
 {$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}
 {$endif i386}
          end;
          end;
       end
       end

+ 9 - 9
compiler/systems/t_bsd.pas

@@ -219,17 +219,17 @@ begin
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
          begin
          begin
 {$ifdef i386}
 {$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}
 {$endif i386}
 {$ifdef powerpc}
 {$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}
 {$endif powerpc}
          end;
          end;
       end
       end

+ 13 - 13
compiler/systems/t_linux.pas

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

+ 5 - 5
compiler/systems/t_nwm.pas

@@ -233,11 +233,11 @@ begin
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
          begin
          begin
 {$ifdef i386}
 {$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}
 {$endif i386}
          end;
          end;
       end
       end

+ 6 - 6
compiler/systems/t_sunos.pas

@@ -169,7 +169,7 @@ procedure texportlibsolaris.generatelib;
 var
 var
   hp2 : texported_item;
   hp2 : texported_item;
 begin
 begin
-  new_section(asmlist[al_code],sec_code,'',0);
+  new_section(asmlist[al_procedures],sec_code,'',0);
   hp2:=texported_item(current_module._exports.first);
   hp2:=texported_item(current_module._exports.first);
   while assigned(hp2) do
   while assigned(hp2) do
    begin
    begin
@@ -180,11 +180,11 @@ begin
           is declared with cdecl }
           is declared with cdecl }
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
          begin
          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;
       end
       end
      else
      else

+ 3 - 3
compiler/systems/t_win.pas

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

+ 2 - 2
compiler/x86/agx86int.pas

@@ -387,10 +387,10 @@ implementation
     begin
     begin
       if not assigned(p) then
       if not assigned(p) then
        exit;
        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
       do_line:=((cs_asm_source in aktglobalswitches) or
                 (cs_lineinfo in aktmoduleswitches))
                 (cs_lineinfo in aktmoduleswitches))
-                 and (p=asmlist[al_code]);
+                 and (p=asmlist[al_procedures]);
       InlineLevel:=0;
       InlineLevel:=0;
       DoNotSplitLine:=false;
       DoNotSplitLine:=false;
       hp:=tai(p.first);
       hp:=tai(p.first);