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

* .init section support

git-svn-id: trunk@5835 -
florian 18 жил өмнө
parent
commit
c238bb15d1

+ 3 - 2
compiler/aasmbase.pas

@@ -41,7 +41,7 @@ interface
 
 
        TAsmsymtype=(
        TAsmsymtype=(
          AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
          AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
-         { 
+         {
            the address of this code label is taken somewhere in the code
            the address of this code label is taken somewhere in the code
            so it must be taken care of it when creating pic
            so it must be taken care of it when creating pic
          }
          }
@@ -81,7 +81,8 @@ interface
          { ELF resources }
          { ELF resources }
          sec_fpc,
          sec_fpc,
          { Table of contents section }
          { Table of contents section }
-         sec_toc
+         sec_toc,
+         sec_init
        );
        );
 
 
        TAsmSectionOrder = (secorder_begin,secorder_default,secorder_end);
        TAsmSectionOrder = (secorder_begin,secorder_default,secorder_end);

+ 5 - 3
compiler/aggas.pas

@@ -259,7 +259,8 @@ implementation
           '.eh_frame',
           '.eh_frame',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.fpc',
           '.fpc',
-          '.toc'
+          '.toc',
+          '.init'
         );
         );
         secnames_pic : array[TAsmSectiontype] of string[17] = ('',
         secnames_pic : array[TAsmSectiontype] of string[17] = ('',
           '.text',
           '.text',
@@ -275,7 +276,8 @@ implementation
           '.eh_frame',
           '.eh_frame',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.fpc',
           '.fpc',
-          '.toc'
+          '.toc',
+          '.init'
         );
         );
       var
       var
         sep     : string[3];
         sep     : string[3];
@@ -332,7 +334,7 @@ implementation
         AsmLn;
         AsmLn;
         case target_info.system of
         case target_info.system of
          system_i386_OS2,
          system_i386_OS2,
-         system_i386_EMX, 
+         system_i386_EMX,
          system_m68k_amiga,  { amiga has old GNU AS (2.14), which blews up from .section (KB) }
          system_m68k_amiga,  { amiga has old GNU AS (2.14), which blews up from .section (KB) }
          system_m68k_linux: ;
          system_m68k_linux: ;
          system_powerpc_darwin,
          system_powerpc_darwin,

+ 2 - 1
compiler/i386/ag386nsm.pas

@@ -364,7 +364,8 @@ interface
           '.eh_frame',
           '.eh_frame',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.fpc',
           '.fpc',
-          ''
+          '',
+          '.init'
         );
         );
       begin
       begin
         AsmLn;
         AsmLn;

+ 4 - 2
compiler/ogbase.pas

@@ -799,7 +799,8 @@ implementation
           'eh_frame',
           'eh_frame',
           'debug_frame','debug_info','debug_line','debug_abbrev',
           'debug_frame','debug_info','debug_line','debug_abbrev',
           'fpc',
           'fpc',
-          'toc'
+          'toc',
+          'init'
         );
         );
       var
       var
         sep : string[3];
         sep : string[3];
@@ -846,7 +847,8 @@ implementation
           {debug_line} [oso_Data,oso_noload,oso_debug],
           {debug_line} [oso_Data,oso_noload,oso_debug],
           {debug_abbrev} [oso_Data,oso_noload,oso_debug],
           {debug_abbrev} [oso_Data,oso_noload,oso_debug],
           {fpc} [oso_Data,oso_load,oso_write,oso_keep],
           {fpc} [oso_Data,oso_load,oso_write,oso_keep],
-          {toc} [oso_Data,oso_load,oso_readonly]
+          {toc} [oso_Data,oso_load,oso_readonly],
+          {init} [oso_Data,oso_load,oso_readonly,oso_executable,oso_keep]
         );
         );
       begin
       begin
         result:=secoptions[atype];
         result:=secoptions[atype];

+ 2 - 1
compiler/ogcoff.pas

@@ -477,7 +477,8 @@ implementation
           '.eh_frame',
           '.eh_frame',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.fpc',
           '.fpc',
-          ''
+          '',
+          '.init'
         );
         );
 
 
 const go32v2stub : array[0..2047] of byte=(
 const go32v2stub : array[0..2047] of byte=(

+ 5 - 3
compiler/ogelf.pas

@@ -582,7 +582,8 @@ implementation
           '.eh_frame',
           '.eh_frame',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           'fpc',
           'fpc',
-          ''
+          '.toc',
+          '.init'
         );
         );
         secnames_pic : array[TAsmSectiontype] of string[17] = ('',
         secnames_pic : array[TAsmSectiontype] of string[17] = ('',
           '.text',
           '.text',
@@ -597,8 +598,9 @@ 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',
-          '.toc'
+          'fpc',
+          '.toc',
+          '.init'
         );
         );
       var
       var
         sep : string[3];
         sep : string[3];

+ 1 - 1
compiler/powerpc/agppcmpw.pas

@@ -74,7 +74,7 @@ interface
         'csect', {read only data}
         'csect', {read only data}
         'csect', {bss} 'csect', '',
         'csect', {bss} 'csect', '',
         'csect','csect','csect','csect',
         'csect','csect','csect','csect',
-         '','','','','','','','','','','',''
+         '','','','','','','','','','','','',''
       );
       );
 
 
     type
     type

+ 10 - 3
compiler/raatt.pas

@@ -52,7 +52,7 @@ unit raatt;
         AS_DB,AS_DW,AS_DD,AS_DQ,AS_GLOBAL,
         AS_DB,AS_DW,AS_DD,AS_DQ,AS_GLOBAL,
         AS_ALIGN,AS_BALIGN,AS_P2ALIGN,AS_ASCII,
         AS_ALIGN,AS_BALIGN,AS_P2ALIGN,AS_ASCII,
         AS_ASCIIZ,AS_LCOMM,AS_COMM,AS_SINGLE,AS_DOUBLE,AS_EXTENDED,
         AS_ASCIIZ,AS_LCOMM,AS_COMM,AS_SINGLE,AS_DOUBLE,AS_EXTENDED,
-        AS_DATA,AS_TEXT,AS_END,
+        AS_DATA,AS_TEXT,AS_INIT,AS_END,
         {------------------ Assembler Operators  --------------------}
         {------------------ Assembler Operators  --------------------}
         AS_TYPE,AS_SIZEOF,AS_MOD,AS_SHL,AS_SHR,AS_NOT,AS_AND,AS_OR,AS_XOR,AS_NOR,AS_AT,
         AS_TYPE,AS_SIZEOF,AS_MOD,AS_SHL,AS_SHR,AS_NOT,AS_AND,AS_OR,AS_XOR,AS_NOR,AS_AT,
         AS_LO,AS_HI);
         AS_LO,AS_HI);
@@ -74,7 +74,7 @@ unit raatt;
         '.byte','.word','.long','.quad','.globl',
         '.byte','.word','.long','.quad','.globl',
         '.align','.balign','.p2align','.ascii',
         '.align','.balign','.p2align','.ascii',
         '.asciz','.lcomm','.comm','.single','.double','.tfloat',
         '.asciz','.lcomm','.comm','.single','.double','.tfloat',
-        '.data','.text','END',
+        '.data','.text','.init','END',
         'TYPE','SIZEOF','%','<<','>>','!','&','|','^','~','@','lo','hi');
         'TYPE','SIZEOF','%','<<','>>','!','&','|','^','~','@','lo','hi');
 
 
     type
     type
@@ -600,7 +600,7 @@ unit raatt;
                  c:=current_scanner.asmgetchar;
                  c:=current_scanner.asmgetchar;
                  exit;
                  exit;
                end;
                end;
-               
+
              '}' :
              '}' :
                begin
                begin
                  actasmtoken:=AS_RSBRACKET;
                  actasmtoken:=AS_RSBRACKET;
@@ -987,6 +987,13 @@ unit raatt;
                Consume(AS_TEXT);
                Consume(AS_TEXT);
              end;
              end;
 
 
+           AS_INIT:
+             Begin
+               new_section(curList,sec_init,lower(current_procinfo.procdef.mangledname),0);
+               lasTSec:=sec_init;
+               Consume(AS_INIT);
+             end;
+
            AS_DB:
            AS_DB:
              Begin
              Begin
                Consume(AS_DB);
                Consume(AS_DB);

+ 2 - 0
compiler/x86/agx86int.pas

@@ -66,6 +66,7 @@ implementation
         '',
         '',
         '','','','',
         '','','','',
         '',
         '',
+        '',
         ''
         ''
       );
       );
 
 
@@ -76,6 +77,7 @@ implementation
         '',
         '',
         '','','','',
         '','','','',
         '',
         '',
+        '',
         ''
         ''
       );
       );
 
 

+ 2 - 2
compiler/x86/cgx86.pas

@@ -377,7 +377,7 @@ unit cgx86;
                end;
                end;
           end;
           end;
         if (cs_create_pic in current_settings.moduleswitches) and
         if (cs_create_pic in current_settings.moduleswitches) and
-         assigned(ref.symbol) then
+         assigned(ref.symbol) and not((ref.symbol.bind=AB_LOCAL) and (ref.symbol.typ in [AT_LABEL,AT_FUNCTION])) then
           begin
           begin
             reference_reset_symbol(href,ref.symbol,0);
             reference_reset_symbol(href,ref.symbol,0);
             hreg:=getaddressregister(list);
             hreg:=getaddressregister(list);
@@ -402,7 +402,7 @@ unit cgx86;
           end;
           end;
 {$else x86_64}
 {$else x86_64}
         if (cs_create_pic in current_settings.moduleswitches) and
         if (cs_create_pic in current_settings.moduleswitches) and
-          assigned(ref.symbol) then
+          assigned(ref.symbol) and not((ref.symbol.bind=AB_LOCAL) and (ref.symbol.typ in [AT_LABEL,AT_FUNCTION])) then
           begin
           begin
             reference_reset_symbol(href,ref.symbol,0);
             reference_reset_symbol(href,ref.symbol,0);
             hreg:=getaddressregister(list);
             hreg:=getaddressregister(list);