Browse Source

* .init section support

git-svn-id: trunk@5835 -
florian 18 years ago
parent
commit
c238bb15d1

+ 3 - 2
compiler/aasmbase.pas

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

+ 5 - 3
compiler/aggas.pas

@@ -259,7 +259,8 @@ implementation
           '.eh_frame',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.fpc',
-          '.toc'
+          '.toc',
+          '.init'
         );
         secnames_pic : array[TAsmSectiontype] of string[17] = ('',
           '.text',
@@ -275,7 +276,8 @@ implementation
           '.eh_frame',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           '.fpc',
-          '.toc'
+          '.toc',
+          '.init'
         );
       var
         sep     : string[3];
@@ -332,7 +334,7 @@ implementation
         AsmLn;
         case target_info.system of
          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_linux: ;
          system_powerpc_darwin,

+ 2 - 1
compiler/i386/ag386nsm.pas

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

+ 4 - 2
compiler/ogbase.pas

@@ -799,7 +799,8 @@ implementation
           'eh_frame',
           'debug_frame','debug_info','debug_line','debug_abbrev',
           'fpc',
-          'toc'
+          'toc',
+          'init'
         );
       var
         sep : string[3];
@@ -846,7 +847,8 @@ implementation
           {debug_line} [oso_Data,oso_noload,oso_debug],
           {debug_abbrev} [oso_Data,oso_noload,oso_debug],
           {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
         result:=secoptions[atype];

+ 2 - 1
compiler/ogcoff.pas

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

+ 5 - 3
compiler/ogelf.pas

@@ -582,7 +582,8 @@ implementation
           '.eh_frame',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
           'fpc',
-          ''
+          '.toc',
+          '.init'
         );
         secnames_pic : array[TAsmSectiontype] of string[17] = ('',
           '.text',
@@ -597,8 +598,9 @@ implementation
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
           '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
-          '.fpc',
-          '.toc'
+          'fpc',
+          '.toc',
+          '.init'
         );
       var
         sep : string[3];

+ 1 - 1
compiler/powerpc/agppcmpw.pas

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

+ 10 - 3
compiler/raatt.pas

@@ -52,7 +52,7 @@ unit raatt;
         AS_DB,AS_DW,AS_DD,AS_DQ,AS_GLOBAL,
         AS_ALIGN,AS_BALIGN,AS_P2ALIGN,AS_ASCII,
         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  --------------------}
         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);
@@ -74,7 +74,7 @@ unit raatt;
         '.byte','.word','.long','.quad','.globl',
         '.align','.balign','.p2align','.ascii',
         '.asciz','.lcomm','.comm','.single','.double','.tfloat',
-        '.data','.text','END',
+        '.data','.text','.init','END',
         'TYPE','SIZEOF','%','<<','>>','!','&','|','^','~','@','lo','hi');
 
     type
@@ -600,7 +600,7 @@ unit raatt;
                  c:=current_scanner.asmgetchar;
                  exit;
                end;
-               
+
              '}' :
                begin
                  actasmtoken:=AS_RSBRACKET;
@@ -987,6 +987,13 @@ unit raatt;
                Consume(AS_TEXT);
              end;
 
+           AS_INIT:
+             Begin
+               new_section(curList,sec_init,lower(current_procinfo.procdef.mangledname),0);
+               lasTSec:=sec_init;
+               Consume(AS_INIT);
+             end;
+
            AS_DB:
              Begin
                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;
         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
             reference_reset_symbol(href,ref.symbol,0);
             hreg:=getaddressregister(list);
@@ -402,7 +402,7 @@ unit cgx86;
           end;
 {$else x86_64}
         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
             reference_reset_symbol(href,ref.symbol,0);
             hreg:=getaddressregister(list);