summaryrefslogtreecommitdiff
path: root/MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf
diff options
context:
space:
mode:
authorTaylor Beebe <taylor.d.beebe@gmail.com>2024-08-28 00:31:48 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-09-13 06:58:46 +0300
commitac43bbacdef18a6fea6d978e096326ec0805885d (patch)
treeb7df070aa9c31205f5d123eff6542680094f968f /MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf
parent3a9da5f329ab9683bffc451502a2f0680568a71f (diff)
downloadedk2-ac43bbacdef18a6fea6d978e096326ec0805885d.tar.xz
MdePkg: Create Stack Check Null Libs
Add Null libs for Stack Check and Stack Check Failure Hook Lib that allow a platform to opt out of stack checks and the stack check failure hook lib. StackCheckLib allows implementation (or in this case null implementation) of stack checks on binaries. There is a Host Application specific version of this null lib because MSVC host applications must not be linked against our lib (so the file here is a no-op but that doesn't cause the build system to fail the build for not building a file for MSVC) as it links against the MSVC C runtime lib that provides the stack cookie definitions. GCC host applications do not link against such a C runtime lib and must be linked against our version. StackCheckFailureHookLib lets a platform do custom functionality when a stack check failure occurs (such as log it to a platform defined mechanism). The null lib simply returns. Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
Diffstat (limited to 'MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf')
-rw-r--r--MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf41
1 files changed, 41 insertions, 0 deletions
diff --git a/MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf b/MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf
new file mode 100644
index 0000000000..bb42833d02
--- /dev/null
+++ b/MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf
@@ -0,0 +1,41 @@
+## @file
+# Null library instance for StackCheckLib which can be included
+# when a build needs to include stack check functions but does
+# not want to generate stack check failures.
+#
+# Copyright (c) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 1.29
+ BASE_NAME = StackCheckLibNull
+ FILE_GUID = f6ef2763-ca3b-4c6f-a931-2a48de3ce352
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = StackCheckLib
+
+[Sources]
+ StackCheckLibNullGcc.c | GCC
+ StackCheckLibNullMsvc.c | MSFT
+
+[Sources.IA32]
+ IA32/StackCheckFunctionsMsvc.nasm | MSFT
+
+[Sources.X64]
+ X64/StackCheckFunctionsMsvc.nasm | MSFT
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[BuildOptions]
+ # We cannot build the MSVC version with /GL (whole program optimization) because we run into linker error
+ # LNK1237, which is a failure to link against a symbol from a library compiled with /GL. The whole program
+ # optimization tries to do away with references to this symbol. The solution is to not compile the stack
+ # check libs with /GL
+ MSFT:*_*_*_CC_FLAGS = /GL-
+
+ # We cannot build the GCC version with LTO (link time optimization) because we run into linker errors where
+ # the stack cookie variable has been optimized away, as it looks to GCC like the variable is not used, because
+ # the compiler inserts the usage.
+ GCC:*_*_*_CC_FLAGS = -fno-lto