summaryrefslogtreecommitdiff
path: root/BaseTools/Scripts/Rvct-Align32.sct
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2015-12-18 06:51:36 +0000
committervanjeff <vanjeff@Edk2>2015-12-18 06:51:36 +0000
commit033469d9a9ed257afe3073e9d97ef4a85cbcf366 (patch)
treea5ca76c9f312638da61fcac66f33eab1d9054e1f /BaseTools/Scripts/Rvct-Align32.sct
parentf8ae6c9e4c81bcc2b77e11a79b6bfd45390e0c9f (diff)
downloadedk2-platforms-033469d9a9ed257afe3073e9d97ef4a85cbcf366.tar.xz
BaseTools GCC: avoid the use of COMMON symbols
The default behavior of the GCC compiler is to emit uninitialized globals with external linkage into a COMMON section, where duplicate definitions are merged. This may result in unexpected behavior, since global variables defined under the same name in different C files may not refer to the same logical data item. For instance, the definitions of EFI_EVENT mVirtualAddressChangeEvent that [used to] appear in the following files: CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c will be folded into a single instance of the variable when the latter module includes the former library, which can lead to unexpected results. Even if some may argue that there are legal uses for COMMON allocation, the high modularity of EDK2 combined with the low level of awareness of the intracicies surrounding common allocation and the generally poor EDK2 developer discipline regarding the use of the STATIC keyword* make a strong case for disabling it by default, and re-enabling it explicitly for packages that depend on it. So prevent GCC from emitting variables into the COMMON section, by passing -fno-common to the compiler, and discarding the section in the GNU ld linker script. * Any function or variable that is only referenced from the translation unit that defines it could be made STATIC. This does not only prevent issues like the above, it also allows the compiler to generate better code, e.g., drop out of line function definitions after inlining all invocations or perform constant propagation on variables. (Sync patch r19164 from main trunk.) Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@19381 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Scripts/Rvct-Align32.sct')
0 files changed, 0 insertions, 0 deletions