2
0
Эх сурвалжийг харах

* section "fpc" was renamed to ".fpc".
* compiler version string is stored in .fpc.version section.
* debug start/end links are stored in .fpc.links section.
* fixed linking with eVC++ object files by internal linker.
* .fpc.links section is removed by internal linker before writing executable, because it is no longer needed.

git-svn-id: trunk@5305 -

yury 18 жил өмнө
parent
commit
5f484a0f14

+ 10 - 3
compiler/aggas.pas

@@ -258,7 +258,7 @@ implementation
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
           '.eh_frame',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
-          'fpc.resptrs',
+          '.fpc',
           '.toc'
           '.toc'
         );
         );
         secnames_pic : array[TAsmSectiontype] of string[17] = ('',
         secnames_pic : array[TAsmSectiontype] of string[17] = ('',
@@ -274,7 +274,7 @@ implementation
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
           '.eh_frame',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
-          'fpc.resptrs',
+          '.fpc',
           '.toc'
           '.toc'
         );
         );
       var
       var
@@ -286,6 +286,12 @@ implementation
           secname:=secnames_pic[atype]
           secname:=secnames_pic[atype]
         else
         else
           secname:=secnames[atype];
           secname:=secnames[atype];
+          
+        if (atype=sec_fpc) and (Copy(aname,1,3)='res') then
+          begin
+            result:=secname+'.'+aname;
+            exit;
+          end;
 
 
         if (atype=sec_threadvar) and
         if (atype=sec_threadvar) and
           (target_info.system=system_i386_win32) then
           (target_info.system=system_i386_win32) then
@@ -336,7 +342,8 @@ implementation
         AsmWrite(s);
         AsmWrite(s);
         case atype of
         case atype of
           sec_fpc :
           sec_fpc :
-            AsmWrite(', "a", @progbits');
+            if aname = 'resptrs' then
+              AsmWrite(', "a", @progbits');
           sec_stub :
           sec_stub :
             begin
             begin
               case target_info.system of
               case target_info.system of

+ 2 - 2
compiler/dbgstabs.pas

@@ -1529,10 +1529,10 @@ implementation
         hp : tmodule;
         hp : tmodule;
         dbgtable : tai_symbol;
         dbgtable : tai_symbol;
       begin
       begin
-        { Reference all DEBUGINFO sections from the main .text section }
+        { Reference all DEBUGINFO sections from the main .fpc section }
         if (target_info.system=system_powerpc_macos) then
         if (target_info.system=system_powerpc_macos) then
           exit;
           exit;
-        list.concat(Tai_section.create(sec_data,'',0));
+        list.concat(Tai_section.create(sec_fpc,'links',0));
         { make sure the debuginfo doesn't get stripped out }
         { make sure the debuginfo doesn't get stripped out }
         if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
         if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
           begin
           begin

+ 16 - 9
compiler/ogbase.pas

@@ -233,7 +233,7 @@ interface
        function  sectiontype2options(atype:TAsmSectiontype):TObjSectionOptions;virtual;
        function  sectiontype2options(atype:TAsmSectiontype):TObjSectionOptions;virtual;
        function  sectiontype2align(atype:TAsmSectiontype):shortint;virtual;
        function  sectiontype2align(atype:TAsmSectiontype):shortint;virtual;
        function  createsection(atype:TAsmSectionType;const aname:string='';aorder:TAsmSectionOrder=secorder_default):TObjSection;
        function  createsection(atype:TAsmSectionType;const aname:string='';aorder:TAsmSectionOrder=secorder_default):TObjSection;
-       function  createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions):TObjSection;virtual;
+       function  createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions;DiscardDuplicate:boolean=true):TObjSection;virtual;
        procedure CreateDebugSections;virtual;
        procedure CreateDebugSections;virtual;
        function  findsection(const aname:string):TObjSection;
        function  findsection(const aname:string):TObjSection;
        procedure setsection(asec:TObjSection);
        procedure setsection(asec:TObjSection);
@@ -873,9 +873,12 @@ implementation
       end;
       end;
 
 
 
 
-    function TObjData.createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions):TObjSection;
+    function TObjData.createsection(const aname:string;aalign:shortint;aoptions:TObjSectionOptions;DiscardDuplicate:boolean):TObjSection;
       begin
       begin
-        result:=TObjSection(FObjSectionList.Find(aname));
+        if DiscardDuplicate then
+          result:=TObjSection(FObjSectionList.Find(aname))
+        else
+          result:=nil;
         if not assigned(result) then
         if not assigned(result) then
           begin
           begin
             result:=CObjSection.create(FObjSectionList,aname,aalign,aoptions);
             result:=CObjSection.create(FObjSectionList,aname,aalign,aoptions);
@@ -2204,12 +2207,12 @@ implementation
           begin
           begin
             exesec:=TExeSection(ExeSections[i]);
             exesec:=TExeSection(ExeSections[i]);
             if not(oso_keep in exesec.SecOptions) and
             if not(oso_keep in exesec.SecOptions) and
-               (
-                (exesec.ObjSectionlist.count=0) or
                 (
                 (
-                 (cs_link_strip in current_settings.globalswitches) and
-                 (oso_debug in exesec.SecOptions)
-                )
+                 (exesec.ObjSectionlist.count=0) or
+                 (
+                  (cs_link_strip in current_settings.globalswitches) and
+                  (oso_debug in exesec.SecOptions)
+                 )
                ) then
                ) then
               begin
               begin
                 Comment(V_Debug,'Deleting empty section '+exesec.name);
                 Comment(V_Debug,'Deleting empty section '+exesec.name);
@@ -2316,7 +2319,11 @@ implementation
                 if oso_debug in objsec.secoptions then
                 if oso_debug in objsec.secoptions then
                   objsec.Used:=true;
                   objsec.Used:=true;
                 if (oso_keep in objsec.secoptions) then
                 if (oso_keep in objsec.secoptions) then
-                  AddToObjSectionWorkList(objsec);
+                  begin
+                    AddToObjSectionWorkList(objsec);
+                    if objsec.name='.fpc.n_links' then
+                      objsec.Used:=false;
+                  end;
               end;
               end;
           end;
           end;
         AddToObjSectionWorkList(entrysym.exesymbol.objsymbol.objsection);
         AddToObjSectionWorkList(entrysym.exesymbol.objsymbol.objsection);

+ 3 - 2
compiler/ogcoff.pas

@@ -1795,9 +1795,10 @@ const pemagic : array[0..3] of byte = (
                if (Copy(secname,1,6)='.idata') or
                if (Copy(secname,1,6)='.idata') or
                   (Copy(secname,1,6)='.edata') or
                   (Copy(secname,1,6)='.edata') or
                   (Copy(secname,1,5)='.rsrc') or
                   (Copy(secname,1,5)='.rsrc') or
-                  (Copy(secname,1,6)='.pdata') then
+                  (Copy(secname,1,6)='.pdata') or
+                  (Copy(secname,1,4)='.fpc') then
                  include(secoptions,oso_keep);
                  include(secoptions,oso_keep);
-               objsec:=TCoffObjSection(createsection(secname,secalign,secoptions));
+               objsec:=TCoffObjSection(createsection(secname,secalign,secoptions,false));
                FSecTbl^[i]:=objsec;
                FSecTbl^[i]:=objsec;
                if not win32 then
                if not win32 then
                  objsec.mempos:=sechdr.rvaofs;
                  objsec.mempos:=sechdr.rvaofs;

+ 3 - 3
compiler/pmodules.pas

@@ -378,8 +378,8 @@ implementation
 {$ENDIF POWERPC}
 {$ENDIF POWERPC}
       begin
       begin
         maybe_new_object_file(current_asmdata.asmlists[al_globals]);
         maybe_new_object_file(current_asmdata.asmlists[al_globals]);
-        { Insert Ident of the compiler in the main .data section }
-        current_asmdata.asmlists[al_globals].concat(Tai_section.create(sec_data,'',0));
+        { Insert Ident of the compiler in the .fpc.version section }
+        current_asmdata.asmlists[al_globals].concat(Tai_section.create(sec_fpc,'version',0));
         current_asmdata.asmlists[al_globals].concat(Tai_align.Create(const_align(32)));
         current_asmdata.asmlists[al_globals].concat(Tai_align.Create(const_align(32)));
         current_asmdata.asmlists[al_globals].concat(Tai_string.Create('FPC '+full_version_string+
         current_asmdata.asmlists[al_globals].concat(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));
@@ -1451,7 +1451,7 @@ implementation
          if islibrary or (target_info.system in system_unit_program_exports) then
          if islibrary or (target_info.system in system_unit_program_exports) then
            exportlib.generatelib;
            exportlib.generatelib;
 
 
-         { Reference all DEBUGINFO sections from the main .text section }
+         { Reference all DEBUGINFO sections from the main .fpc section }
          if (cs_debuginfo in current_settings.moduleswitches) then
          if (cs_debuginfo in current_settings.moduleswitches) then
            debuginfo.referencesections(current_asmdata.asmlists[al_procedures]);
            debuginfo.referencesections(current_asmdata.asmlists[al_procedures]);
 
 

+ 1 - 0
compiler/systems/t_gba.pas

@@ -366,6 +366,7 @@ begin
       add('*(.data)');
       add('*(.data)');
       add('*(.data.*)');
       add('*(.data.*)');
       add('*(.gnu.linkonce.d*)');
       add('*(.gnu.linkonce.d*)');
+      add('*(.fpc*)');
       add('CONSTRUCTORS');
       add('CONSTRUCTORS');
       add('. = ALIGN(4);');
       add('. = ALIGN(4);');
       add('} >iwram = 0xff');
       add('} >iwram = 0xff');

+ 1 - 0
compiler/systems/t_go32v2.pas

@@ -190,6 +190,7 @@ begin
   ScriptRes.Add('      *(.dtor)');
   ScriptRes.Add('      *(.dtor)');
   ScriptRes.Add('      djgpp_last_dtor = . ;');
   ScriptRes.Add('      djgpp_last_dtor = . ;');
   ScriptRes.Add('      *(.data)');
   ScriptRes.Add('      *(.data)');
+  ScriptRes.Add('      *(.fpc*)');
   ScriptRes.Add('      *(.gcc_exc)');
   ScriptRes.Add('      *(.gcc_exc)');
   ScriptRes.Add('      ___EH_FRAME_BEGIN__ = . ;');
   ScriptRes.Add('      ___EH_FRAME_BEGIN__ = . ;');
   ScriptRes.Add('      *(.eh_fram)');
   ScriptRes.Add('      *(.eh_fram)');

+ 1 - 0
compiler/systems/t_linux.pas

@@ -574,6 +574,7 @@ begin
       add('  .data           :');
       add('  .data           :');
       add('  {');
       add('  {');
       add('    *(.data .data.* .gnu.linkonce.d.*)');
       add('    *(.data .data.* .gnu.linkonce.d.*)');
+      add('    KEEP (*(.fpc .fpc.version .fpc.links))');
       add('    KEEP (*(.gnu.linkonce.d.*personality*))');
       add('    KEEP (*(.gnu.linkonce.d.*personality*))');
       add('  }');
       add('  }');
       add('  _edata = .;');
       add('  _edata = .;');

+ 2 - 1
compiler/systems/t_win.pas

@@ -958,6 +958,7 @@ implementation
             Concat('EXESECTION .data');
             Concat('EXESECTION .data');
             Concat('  SYMBOL __data_start__');
             Concat('  SYMBOL __data_start__');
             Concat('  OBJSECTION .data*');
             Concat('  OBJSECTION .data*');
+            Concat('  OBJSECTION .fpc*');
             Concat('  SYMBOL edata');
             Concat('  SYMBOL edata');
             Concat('  SYMBOL __data_end__');
             Concat('  SYMBOL __data_end__');
             Concat('ENDEXESECTION');
             Concat('ENDEXESECTION');
@@ -1158,7 +1159,7 @@ implementation
             Add('  .data BLOCK(__section_alignment__) :');
             Add('  .data BLOCK(__section_alignment__) :');
             Add('  {');
             Add('  {');
             Add('    __data_start__ = . ;');
             Add('    __data_start__ = . ;');
-            add('    *(.data .data.* .gnu.linkonce.d.*)');
+            add('    *(.data .data.* .gnu.linkonce.d.* .fpc*)');
             Add('    *(.data2)');
             Add('    *(.data2)');
             Add('    *(SORT(.data$*))');
             Add('    *(SORT(.data$*))');
             Add('    __data_end__ = . ;');
             Add('    __data_end__ = . ;');

+ 17 - 17
utils/fpcres/elfres.pas

@@ -27,7 +27,7 @@ though.
 
 
 Format used for the various resource sections:
 Format used for the various resource sections:
 
 
- fpc.resptrs:   This section is contained in resptrs.o and always linked to the executable by
+ .fpc.resptrs:  This section is contained in resptrs.o and always linked to the executable by
                 FPC. It containes an exported label fpcrespointers, which is used at runtime
                 FPC. It containes an exported label fpcrespointers, which is used at runtime
                 to find the resptrs section in memory. The resptrs contains pointers to all the
                 to find the resptrs section in memory. The resptrs contains pointers to all the
                 sections and their sizes. These are updated in a post-precessing step by the
                 sections and their sizes. These are updated in a post-precessing step by the
@@ -38,15 +38,15 @@ Format used for the various resource sections:
                 The second integer (32/64 Bit) value in this section contains the number of
                 The second integer (32/64 Bit) value in this section contains the number of
                 resources.
                 resources.
                 After this follows a version-defined number of TFPCResourceSectionInfo entries.
                 After this follows a version-defined number of TFPCResourceSectionInfo entries.
- fpc.ressym:    Contains the resource names. This simply is a stream of zero-terminated strings.
+ .fpc.ressym:   Contains the resource names. This simply is a stream of zero-terminated strings.
                 Only textual names are supported, numeric IDs get autoconverted to #ID's.
                 Only textual names are supported, numeric IDs get autoconverted to #ID's.
                 The reshash table has got a byte index into ressym to quickly get that data if needed
                 The reshash table has got a byte index into ressym to quickly get that data if needed
- fpc.reshash:   n TFPCResourceInfo records. (number of entries is defined in fpc.resptrs)
- fpc.resdata:   Contains the plain resource data stream. A byte index into the data stream
+ .fpc.reshash:  n TFPCResourceInfo records. (number of entries is defined in fpc.resptrs)
+ .fpc.resdata:  Contains the plain resource data stream. A byte index into the data stream
                 is given for each resource entry in TResourceInfo
                 is given for each resource entry in TResourceInfo
- fpc.resspare:  An empty section which is resized to make room if the size of any of the previous
+ .fpc.resspare: An empty section which is resized to make room if the size of any of the previous
                 sections gets changed. NOT USED IN VERSION 1 (SIZE WILL BE 0)
                 sections gets changed. NOT USED IN VERSION 1 (SIZE WILL BE 0)
- fpc.resstr:    This section is completely seperated from the rest and contains a block of
+ .fpc.resstr:   This section is completely seperated from the rest and contains a block of
                 resourcestrings in internal FPC format.
                 resourcestrings in internal FPC format.
 
 
 resptr TFPCResourceSectionInfo list for FPC resources version 1:
 resptr TFPCResourceSectionInfo list for FPC resources version 1:
@@ -78,8 +78,8 @@ const fpcres2elf_version=1;
 
 
 // Do not change the following consts, they are dummy tables to generate an .o that makes ld happy
 // Do not change the following consts, they are dummy tables to generate an .o that makes ld happy
 const shstrtab = #0+'.symtab'+#0+'.strtab'+#0+'.shstrtab'+#0+'.text'+#0+'.data'+#0+
 const shstrtab = #0+'.symtab'+#0+'.strtab'+#0+'.shstrtab'+#0+'.text'+#0+'.data'+#0+
-                 '.bss'+#0+'fpc.ressym'+#0+'fpc.resstr'+#0+'fpc.reshash'+#0+
-                 'fpc.resdata'+#0+'fpc.resspare'+#0+#0;
+                 '.bss'+#0+'.fpc.ressym'+#0+'.fpc.resstr'+#0+'.fpc.reshash'+#0+
+                 '.fpc.resdata'+#0+'.fpc.resspare'+#0+#0;
       symtab =   #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00+
       symtab =   #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00+
                  #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$03#$00#$01#$00+
                  #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$03#$00#$01#$00+
                  #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$03#$00#$02#$00+
                  #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$03#$00#$02#$00+
@@ -545,7 +545,7 @@ begin
   SectionHeader.sh_entsize:=0;
   SectionHeader.sh_entsize:=0;
   FSectionStream.Write(SectionHeader,sizeOf(SectionHeader));
   FSectionStream.Write(SectionHeader,sizeOf(SectionHeader));
 
 
-  // fpc.ressym
+  // .fpc.ressym
   SectionHeader.sh_name:=$2C;
   SectionHeader.sh_name:=$2C;
   SectionHeader.sh_type:=1; // PROGBITS
   SectionHeader.sh_type:=1; // PROGBITS
   SectionHeader.sh_flags:=2; // A
   SectionHeader.sh_flags:=2; // A
@@ -558,8 +558,8 @@ begin
   SectionHeader.sh_entsize:=0;
   SectionHeader.sh_entsize:=0;
   FSectionStream.Write(SectionHeader,sizeOf(SectionHeader));
   FSectionStream.Write(SectionHeader,sizeOf(SectionHeader));
 
 
-  // fpc.resstr
-  SectionHeader.sh_name:=$37;
+  // .fpc.resstr
+  SectionHeader.sh_name:=$38;
   SectionHeader.sh_type:=1; // PROGBITS
   SectionHeader.sh_type:=1; // PROGBITS
   SectionHeader.sh_flags:=2; // A
   SectionHeader.sh_flags:=2; // A
   SectionHeader.sh_addr:=0;
   SectionHeader.sh_addr:=0;
@@ -571,8 +571,8 @@ begin
   SectionHeader.sh_entsize:=0;
   SectionHeader.sh_entsize:=0;
   FSectionStream.Write(SectionHeader,sizeOf(SectionHeader));
   FSectionStream.Write(SectionHeader,sizeOf(SectionHeader));
 
 
-  // fpc.reshash
-  SectionHeader.sh_name:=$42;
+  // .fpc.reshash
+  SectionHeader.sh_name:=$44;
   SectionHeader.sh_type:=1; // PROGBITS
   SectionHeader.sh_type:=1; // PROGBITS
   SectionHeader.sh_flags:=2; // A
   SectionHeader.sh_flags:=2; // A
   SectionHeader.sh_addr:=0;
   SectionHeader.sh_addr:=0;
@@ -584,8 +584,8 @@ begin
   SectionHeader.sh_entsize:=0;
   SectionHeader.sh_entsize:=0;
   FSectionStream.Write(SectionHeader,sizeOf(SectionHeader));
   FSectionStream.Write(SectionHeader,sizeOf(SectionHeader));
 
 
-  // fpc.resdata
-  SectionHeader.sh_name:=$4e;
+  // .fpc.resdata
+  SectionHeader.sh_name:=$51;
   SectionHeader.sh_type:=1; // PROGBITS
   SectionHeader.sh_type:=1; // PROGBITS
   SectionHeader.sh_flags:=2; // A
   SectionHeader.sh_flags:=2; // A
   SectionHeader.sh_addr:=0;
   SectionHeader.sh_addr:=0;
@@ -597,9 +597,9 @@ begin
   SectionHeader.sh_entsize:=0;
   SectionHeader.sh_entsize:=0;
   FSectionStream.Write(SectionHeader,sizeOf(SectionHeader));
   FSectionStream.Write(SectionHeader,sizeOf(SectionHeader));
 
 
-  // fpc.resspare
+  // .fpc.resspare
   // Not used in V1
   // Not used in V1
-  SectionHeader.sh_name:=$5a;
+  SectionHeader.sh_name:=$5f;
   SectionHeader.sh_type:=8; // NOBITS
   SectionHeader.sh_type:=8; // NOBITS
   SectionHeader.sh_flags:=2; // A
   SectionHeader.sh_flags:=2; // A
   SectionHeader.sh_addr:=0;
   SectionHeader.sh_addr:=0;

+ 4 - 4
utils/fpcres/elfresfix.pas

@@ -16,7 +16,7 @@
 { *********************************************************************** }
 { *********************************************************************** }
 
 
 {
 {
-This tool will update the fpc.resptrs section of an ELF executable to point
+This tool will update the .fpc.resptrs section of an ELF executable to point
 to the various resource sections in the file. This is done so that the FPC
 to the various resource sections in the file. This is done so that the FPC
 RTL at runtime is able to get pointers to these sections.
 RTL at runtime is able to get pointers to these sections.
 
 
@@ -206,12 +206,12 @@ begin
     SectionName:=copy(strtab,SectionHeaders[i].sh_name+1,32);
     SectionName:=copy(strtab,SectionHeaders[i].sh_name+1,32);
     SectionName:=copy(SectionName,1,pos(#0,SectionName)-1);
     SectionName:=copy(SectionName,1,pos(#0,SectionName)-1);
     DoVerbose(SProcessingSection+SectionName);
     DoVerbose(SProcessingSection+SectionName);
-    sn:=Copy(SectionName,1,4);
+    sn:=Copy(SectionName,1,5);
     // FPC section ?
     // FPC section ?
-    if (sn='fpc.') then
+    if (sn='.fpc.') then
       begin
       begin
       sn:=SectionName;
       sn:=SectionName;
-      Delete(SN,1,4);
+      Delete(SN,1,5);
       if SN='resptrs' then
       if SN='resptrs' then
         begin
         begin
         ResPtrsSection:=i;
         ResPtrsSection:=i;