From 9dc5b07a6805b7f3c72bbc1a8f313568359e286d Mon Sep 17 00:00:00 2001 From: sergei Date: Wed, 17 Apr 2013 19:51:38 +0000 Subject: [PATCH] * 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 - --- compiler/ogcoff.pas | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/compiler/ogcoff.pas b/compiler/ogcoff.pas index ab232f5454..e87b273061 100644 --- a/compiler/ogcoff.pas +++ b/compiler/ogcoff.pas @@ -734,24 +734,20 @@ const pemagic : array[0..3] of byte = ( function peencodesechdrflags(aoptions:TObjSectionOptions;aalign:shortint):longword; begin - result:=0; - if (oso_load in aoptions) then - begin - if oso_executable in aoptions then - result:=result or PE_SCN_CNT_CODE or PE_SCN_MEM_EXECUTE - 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 + if oso_executable in aoptions then + result:=PE_SCN_CNT_CODE or PE_SCN_MEM_EXECUTE else + begin + if (oso_data in aoptions) then + result:=PE_SCN_CNT_INITIALIZED_DATA + else + 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 + result:=result or PE_SCN_MEM_READ; + if not (oso_load in aoptions) then result:=result or PE_SCN_MEM_DISCARDABLE; case aalign of 1 : result:=result or PE_SCN_ALIGN_1BYTES; @@ -2742,7 +2738,7 @@ const pemagic : array[0..3] of byte = ( exesec:=FindExeSection('.reloc'); if exesec=nil then exit; - objsec:=internalObjData.createsection('.reloc',0,[oso_data,oso_load,oso_keep]); + objsec:=internalObjData.createsection('.reloc',0,[oso_data,oso_keep]); exesec.AddObjSection(objsec); pgaddr:=longword(-1); hdrpos:=longword(-1);