diff options
author | Taylor Beebe <taylor.d.beebe@gmail.com> | 2024-02-28 10:47:23 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-04-15 19:04:08 +0000 |
commit | 5ba3602e4580d6b65dacf4292a031627f93e1167 (patch) | |
tree | 831459ddd4f2628cd4f24500f0cde731eab9915a /BaseTools/Source/Python/Workspace | |
parent | d77efa2ebef9a0feca97df787138d132393e1130 (diff) | |
download | edk2-5ba3602e4580d6b65dacf4292a031627f93e1167.tar.gz edk2-5ba3602e4580d6b65dacf4292a031627f93e1167.tar.bz2 edk2-5ba3602e4580d6b65dacf4292a031627f93e1167.zip |
BaseTools: Use Stronger Matching for NULL Linked Libraries
To prevent the possibility that a library with a name like
NULLTestLib is interpreted as a NULL linked library, use
more explicit pattern matching to ensure that the library
name follows the pattern NULL%d.
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Taylor Beebe <taylor.d.beebe@gmail.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'BaseTools/Source/Python/Workspace')
-rw-r--r-- | BaseTools/Source/Python/Workspace/WorkspaceCommon.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py index 8bb6553c6f..6ad7a3b940 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -102,12 +102,12 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha #
if Module.ModuleType != SUP_MODULE_USER_DEFINED:
for LibraryClass in Platform.LibraryClasses.GetKeys():
- if LibraryClass.startswith("NULL") and Platform.LibraryClasses[LibraryClass, Module.ModuleType]:
+ if LibraryClass.startswith("NULL") and LibraryClass[4:].isdigit() and Platform.LibraryClasses[LibraryClass, Module.ModuleType]:
Module.LibraryClasses[LibraryClass] = Platform.LibraryClasses[LibraryClass, Module.ModuleType]
# add forced library instances (specified in module overrides)
for LibraryClass in Platform.Modules[str(Module)].LibraryClasses:
- if LibraryClass.startswith("NULL"):
+ if LibraryClass.startswith("NULL") and LibraryClass[4:].isdigit():
Module.LibraryClasses[LibraryClass] = Platform.Modules[str(Module)].LibraryClasses[LibraryClass]
# EdkII module
@@ -123,7 +123,7 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha while len(LibraryConsumerList) > 0:
M = LibraryConsumerList.pop()
for LibraryClassName in M.LibraryClasses:
- if LibraryClassName.startswith("NULL") and bool(M.LibraryClass):
+ if LibraryClassName.startswith("NULL") and LibraryClassName[4:].isdigit() and bool(M.LibraryClass):
continue
if LibraryClassName not in LibraryInstance:
# override library instance for this module
@@ -141,7 +141,7 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha LibraryModule = BuildDatabase[LibraryPath, Arch, Target, Toolchain]
# for those forced library instance (NULL library), add a fake library class
- if LibraryClassName.startswith("NULL"):
+ if LibraryClassName.startswith("NULL") and LibraryClassName[4:].isdigit():
LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, [ModuleType]))
elif LibraryModule.LibraryClass is None \
or len(LibraryModule.LibraryClass) == 0 \
|