]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: GCC: move most AutoGen.obj contents back to .data section
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 23 Feb 2017 18:30:51 +0000 (18:30 +0000)
committerLaszlo Ersek <lersek@redhat.com>
Fri, 24 Feb 2017 10:27:56 +0000 (11:27 +0100)
The generated AutoGen.c files mostly contain read-only data, but due to
lacking annotations, all of it is emitted into the .data section by the
compiler.

Given that GUIDs are UEFI's gaffer tape, having writable GUIDs is a
security hazard, and this was the main rationale for putting AutoGen.obj
in the .text section. However, as it turns out, patchable PCDs are emitted
there as well, which can legally be modified at runtime.

So update the wildcard pattern to only match g...Guid sections, and move
everything else back to .data (Note that this relies on -fdata-sections,
without that option, everything is emitted into .data)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Fixes: 233bd25b000f92fc4bbe181fa48edcd72808de8e
[lersek@redhat.com: add reference to previous commit being fixed up]
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
BaseTools/Scripts/GccBase.lds

index 900848747144dba08a1af4e601c0dbd3917dbef6..41e5c0b4a76942079b99abf5852760c74e993a79 100644 (file)
@@ -32,11 +32,14 @@ SECTIONS {
     *(.got .got.*)\r
 \r
     /*\r
     *(.got .got.*)\r
 \r
     /*\r
-     * The contents of AutoGen.c files are constant from the POV of the program,\r
-     * but most of its contents end up in .data or .bss by default since few of\r
+     * The contents of AutoGen.c files are mostly constant from the POV of the\r
+     * program, but most of it ends up in .data or .bss by default since few of\r
      * the variable definitions that get emitted are declared as CONST.\r
      * the variable definitions that get emitted are declared as CONST.\r
+     * Unfortunately, we cannot pull it into the .text section entirely, since\r
+     * patchable PCDs are also emitted here, but we can at least move all of the\r
+     * emitted GUIDs here.\r
      */\r
      */\r
-    *:AutoGen.obj(.data .data.* .bss .bss.*)\r
+    *:AutoGen.obj(.data.g*Guid)\r
   }\r
 \r
   /*\r
   }\r
 \r
   /*\r