Browse Source

* Excluded oso_executable from attributes of user sections. User sections may currently be specified only for variables and typed consts, which are not executable.
* Fixed TLS directory size written to PE header when cross-compiling. It must be the value for target, not for host.

git-svn-id: trunk@18024 -

sergei 14 years ago
parent
commit
c9f92c0323
2 changed files with 6 additions and 2 deletions
  1. 1 1
      compiler/ogbase.pas
  2. 5 1
      compiler/ogcoff.pas

+ 1 - 1
compiler/ogbase.pas

@@ -913,7 +913,7 @@ implementation
     function TObjData.sectiontype2options(atype:TAsmSectiontype):TObjSectionOptions;
     function TObjData.sectiontype2options(atype:TAsmSectiontype):TObjSectionOptions;
       const
       const
         secoptions : array[TAsmSectiontype] of TObjSectionOptions = ([],
         secoptions : array[TAsmSectiontype] of TObjSectionOptions = ([],
-          {user} [oso_Data,oso_load,oso_write,oso_executable,oso_keep],
+          {user} [oso_Data,oso_load,oso_write,oso_keep],
           {code} [oso_Data,oso_load,oso_readonly,oso_executable,oso_keep],
           {code} [oso_Data,oso_load,oso_readonly,oso_executable,oso_keep],
           {Data} [oso_Data,oso_load,oso_write,oso_keep],
           {Data} [oso_Data,oso_load,oso_write,oso_keep],
 { TODO: Fix sec_rodata be read-only-with-relocs}
 { TODO: Fix sec_rodata be read-only-with-relocs}

+ 5 - 1
compiler/ogcoff.pas

@@ -282,14 +282,17 @@ interface
 {$ifdef i386}
 {$ifdef i386}
        COFF_MAGIC       = $14c;
        COFF_MAGIC       = $14c;
        COFF_OPT_MAGIC   = $10b;
        COFF_OPT_MAGIC   = $10b;
+       TLSDIR_SIZE      = $18;
 {$endif i386}
 {$endif i386}
 {$ifdef arm}
 {$ifdef arm}
        COFF_MAGIC       = $1c0;
        COFF_MAGIC       = $1c0;
        COFF_OPT_MAGIC   = $10b;
        COFF_OPT_MAGIC   = $10b;
+       TLSDIR_SIZE      = $18;
 {$endif arm}
 {$endif arm}
 {$ifdef x86_64}
 {$ifdef x86_64}
        COFF_MAGIC       = $8664;
        COFF_MAGIC       = $8664;
        COFF_OPT_MAGIC   = $20b;
        COFF_OPT_MAGIC   = $20b;
+       TLSDIR_SIZE      = $28;
 {$endif x86_64}
 {$endif x86_64}
     function ReadDLLImports(const dllname:string;readdllproc:Treaddllproc):boolean;
     function ReadDLLImports(const dllname:string;readdllproc:Treaddllproc):boolean;
 
 
@@ -2324,7 +2327,8 @@ const pemagic : array[0..3] of byte = (
             begin
             begin
               tlssymbol:=tlsexesymbol.ObjSymbol;
               tlssymbol:=tlsexesymbol.ObjSymbol;
               peoptheader.DataDirectory[PE_DATADIR_TLS].vaddr:=tlssymbol.address;
               peoptheader.DataDirectory[PE_DATADIR_TLS].vaddr:=tlssymbol.address;
-              peoptheader.DataDirectory[PE_DATADIR_TLS].size:=Sizeof(tlsdirectory);
+              { sizeof(TlsDirectory) is different on host and target when cross-compiling }
+              peoptheader.DataDirectory[PE_DATADIR_TLS].size:=TLSDIR_SIZE;
               if IsSharedLibrary then
               if IsSharedLibrary then
                 begin
                 begin
                   { Here we should reset __FPC_tls_callbacks value to nil }
                   { Here we should reset __FPC_tls_callbacks value to nil }