Browse Source

* COFF: fixed setting section flags. Content type and access bits must be set for non-loadable sections as well.
* Changed .reloc sections to be non-loadable, all Windows DLLs have it that way (and ld produces the same as well).

git-svn-id: trunk@24262 -

sergei 12 years ago
parent
commit
9dc5b07a68
1 changed files with 12 additions and 16 deletions
  1. 12 16
      compiler/ogcoff.pas

+ 12 - 16
compiler/ogcoff.pas

@@ -734,24 +734,20 @@ const pemagic : array[0..3] of byte = (
 
 
     function peencodesechdrflags(aoptions:TObjSectionOptions;aalign:shortint):longword;
     function peencodesechdrflags(aoptions:TObjSectionOptions;aalign:shortint):longword;
       begin
       begin
-        result:=0;
-        if (oso_load in aoptions) then
+        if oso_executable in aoptions then
+          result:=PE_SCN_CNT_CODE or PE_SCN_MEM_EXECUTE
+        else
           begin
           begin
-            if oso_executable in aoptions then
-              result:=result or PE_SCN_CNT_CODE or PE_SCN_MEM_EXECUTE
+            if (oso_data in aoptions) then
+              result:=PE_SCN_CNT_INITIALIZED_DATA
             else
             else
-              begin
-                if (oso_data in aoptions) then
-                  result:=result or PE_SCN_CNT_INITIALIZED_DATA
-                else
-                  result:=result or PE_SCN_CNT_UNINITIALIZED_DATA;
-              end;
-            if oso_write in aoptions then
-              result:=result or PE_SCN_MEM_WRITE or PE_SCN_MEM_READ
-            else
-              result:=result or PE_SCN_MEM_READ;
-          end
+              result:=PE_SCN_CNT_UNINITIALIZED_DATA;
+          end;
+        if oso_write in aoptions then
+          result:=result or PE_SCN_MEM_WRITE or PE_SCN_MEM_READ
         else
         else
+          result:=result or PE_SCN_MEM_READ;
+        if not (oso_load in aoptions) then
           result:=result or PE_SCN_MEM_DISCARDABLE;
           result:=result or PE_SCN_MEM_DISCARDABLE;
         case aalign of
         case aalign of
            1 : result:=result or PE_SCN_ALIGN_1BYTES;
            1 : result:=result or PE_SCN_ALIGN_1BYTES;
@@ -2742,7 +2738,7 @@ const pemagic : array[0..3] of byte = (
         exesec:=FindExeSection('.reloc');
         exesec:=FindExeSection('.reloc');
         if exesec=nil then
         if exesec=nil then
           exit;
           exit;
-        objsec:=internalObjData.createsection('.reloc',0,[oso_data,oso_load,oso_keep]);
+        objsec:=internalObjData.createsection('.reloc',0,[oso_data,oso_keep]);
         exesec.AddObjSection(objsec);
         exesec.AddObjSection(objsec);
         pgaddr:=longword(-1);
         pgaddr:=longword(-1);
         hdrpos:=longword(-1);
         hdrpos:=longword(-1);