From: Ard Biesheuvel Date: Mon, 3 Aug 2015 08:22:50 +0000 (+0000) Subject: BaseTools GCC: move AutoGen.obj contents to .text section X-Git-Tag: edk2-stable201903~9144 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=233bd25b000f92fc4bbe181fa48edcd72808de8e BaseTools GCC: move AutoGen.obj contents to .text section All AutoGen.obj files consist of global GUID definitions, fixed and patchable PCDs and other data that is essentially read-only at runtime but has not been declared as such for various reasons. By moving these contents to .text we achieve two things: - global GUIDs and other data items which must be constant for correct program operation can no longer be modified, for instance, when running a DXE_RUNTIME_MODULE binary under the OS with the Properties Table feature for memory protection enabled; - the .data section becomes smaller, and may be dropped completely for many XIP modules, which reduces wasted FV space if the PE/COFF section alignment is large. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Jordan Justen Tested-by: Liming Gao Tested-by: Leif Lindholm git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18137 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds index 3d99f01db2..4ee6d99853 100644 --- a/BaseTools/Scripts/GccBase.lds +++ b/BaseTools/Scripts/GccBase.lds @@ -29,6 +29,13 @@ SECTIONS { *(.text .text.* .stub .gnu.linkonce.t.*) *(.rodata .rodata.* .gnu.linkonce.r.*) *(.got .got.*) + + /* + * The contents of AutoGen.c files are constant from the POV of the program, + * but most of its contents end up in .data or .bss by default since few of + * the variable definitions that get emitted are declared as CONST. + */ + *:AutoGen.obj(.data .data.* .bss .bss.*) } /*