mirror of
https://github.com/reactos/reactos.git
synced 2025-06-06 18:00:41 +00:00
[PEFIXUP] Fixup of resource sections in GCC builds. (#3594)
Make resource sections discardable for kernel-mode drivers and DLLs.
This commit is contained in:
parent
0fe7fdbdea
commit
6e33c8ffd3
2 changed files with 12 additions and 6 deletions
|
@ -307,7 +307,7 @@ function(set_module_type_toolchain MODULE TYPE)
|
||||||
# Fixup section characteristics
|
# Fixup section characteristics
|
||||||
# - Remove flags that LD overzealously puts (alignment flag, Initialized flags for code sections)
|
# - Remove flags that LD overzealously puts (alignment flag, Initialized flags for code sections)
|
||||||
# - INIT section is made discardable
|
# - INIT section is made discardable
|
||||||
# - .rsrc is made read-only
|
# - .rsrc is made read-only and discardable
|
||||||
# - PAGE & .edata sections are made pageable.
|
# - PAGE & .edata sections are made pageable.
|
||||||
add_custom_command(TARGET ${MODULE} POST_BUILD
|
add_custom_command(TARGET ${MODULE} POST_BUILD
|
||||||
COMMAND native-pefixup --${TYPE} $<TARGET_FILE:${MODULE}>)
|
COMMAND native-pefixup --${TYPE} $<TARGET_FILE:${MODULE}>)
|
||||||
|
|
|
@ -142,9 +142,15 @@ static int driver_fixup(enum fixup_mode mode, unsigned char *buffer, PIMAGE_NT_H
|
||||||
if (Section->Characteristics & IMAGE_SCN_CNT_CODE)
|
if (Section->Characteristics & IMAGE_SCN_CNT_CODE)
|
||||||
Section->Characteristics &= ~IMAGE_SCN_CNT_INITIALIZED_DATA;
|
Section->Characteristics &= ~IMAGE_SCN_CNT_INITIALIZED_DATA;
|
||||||
|
|
||||||
/* For some reason, .rsrc is made writable by windres */
|
|
||||||
if (strncmp((char*)Section->Name, ".rsrc", 5) == 0)
|
if (strncmp((char*)Section->Name, ".rsrc", 5) == 0)
|
||||||
{
|
{
|
||||||
|
/* .rsrc is discardable for driver images, WDM drivers and Kernel-Mode DLLs */
|
||||||
|
if (mode == MODE_KERNELDRIVER || mode == MODE_WDMDRIVER || mode == MODE_KERNELDLL)
|
||||||
|
{
|
||||||
|
Section->Characteristics |= IMAGE_SCN_MEM_DISCARDABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For some reason, .rsrc is made writable by windres */
|
||||||
Section->Characteristics &= ~IMAGE_SCN_MEM_WRITE;
|
Section->Characteristics &= ~IMAGE_SCN_MEM_WRITE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -356,10 +362,10 @@ print_usage(void)
|
||||||
printf("Usage: %s <options> <filename>\n\n", g_ApplicationName);
|
printf("Usage: %s <options> <filename>\n\n", g_ApplicationName);
|
||||||
printf("<options> can be one of the following options:\n"
|
printf("<options> can be one of the following options:\n"
|
||||||
" --loadconfig Fix the LOAD_CONFIG directory entry;\n"
|
" --loadconfig Fix the LOAD_CONFIG directory entry;\n"
|
||||||
" --kernelmodedriver Fix code and data sections for driver images;\n"
|
" --kernelmodedriver Fix code, data and resource sections for driver images;\n"
|
||||||
" --wdmdriver Fix code and data sections for WDM drivers;\n"
|
" --wdmdriver Fix code, data and resource sections for WDM drivers;\n"
|
||||||
" --kerneldll Fix code and data sections for Kernel-Mode DLLs;\n"
|
" --kerneldll Fix code, data and resource sections for Kernel-Mode DLLs;\n"
|
||||||
" --kernel Fix code and data sections for kernels;\n"
|
" --kernel Fix code, data and resource sections for kernels;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"and/or a combination of the following ones:\n"
|
"and/or a combination of the following ones:\n"
|
||||||
" --section:name[=newname][,[[!]{CDEIKOMPRSUW}][A{1248PTSX}]]\n"
|
" --section:name[=newname][,[[!]{CDEIKOMPRSUW}][A{1248PTSX}]]\n"
|
||||||
|
|
Loading…
Reference in a new issue