3086 Commits

Author SHA1 Message Date
vit9696
6f0af031d7 BaseTools: Disable cast-function-type-mismatch for Xcode
Currently DxeCore and PeiCore rely on type cast violation too heavily.
2025-04-07 15:08:42 +03:00
Mikhail Krichanov
709984a981 Fixed compilation of all packages tracked by CI after rebasing upon edk2-stable202502 tag. 2025-04-07 13:54:15 +03:00
Mike Beaton
b89875486a BaseTools: Enable symbolic debugging with LTO in XCODE toolchain (#64) 2025-04-07 12:32:50 +03:00
vit9696
0146e644f0 BaseTools: Provide fat Mach-O binaries on Darwin
Merge pull request #63 from acidanthera/vit9696-fattools-20240327
2025-04-07 12:32:50 +03:00
Mikhail Krichanov
0d9d6f987b Fixed compilation of all packages tracked by CI after rebasing upon edk2-stable202311. 2025-04-07 12:32:50 +03:00
Mikhail Krichanov
992385e15e SecurePE: Defined new PcdImageProtectionPolicy. 2025-04-07 12:30:28 +03:00
Mikhail Krichanov
4d3a62c2e7 BaseTools: Fixed '-D EDK2_REDUCE_FW_SIZE' build option. 2025-04-07 12:24:28 +03:00
Mikhail Krichanov
48b806f46f UE: Support UE generation and consumption. 2025-04-07 12:24:28 +03:00
Mikhail Krichanov
d13d798fdd BaseTools/tools_def: Deduplicate DLINK_FLAGS from CC_FLAGS 2025-04-07 12:24:27 +03:00
Marvin Häuser
577c44620c BaseTools/build_rule: Always pass CC_FLAGS to DLINK 2025-04-07 12:24:27 +03:00
Marvin Häuser
8171958c4e BaseTools/CommonLib: Replace aligned_alloc with posix_memalign 2025-04-07 12:24:27 +03:00
Mikhail Krichanov
1fef202932 MdePkg/UefiImageLib: Introduce DebugAddress
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2025-04-07 12:24:27 +03:00
Mikhail Krichanov
ba9aad0b56 ImageTool: Rework PeEmit with dynamically-growing buffers 2025-04-07 12:24:27 +03:00
Mikhail Krichanov
e46d356fc9 MdePkg/UefiImageLib: Support multi-format and multi-source architecture
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2025-04-07 12:24:27 +03:00
Mikhail Krichanov
c041043886 BaseTools/Conf: Added EDK2_GCC_NOLTO build option. 2025-04-07 12:24:27 +03:00
Mikhail Krichanov
63b9e567e5 Build: Replaced GCC5 toolchain with GCC. 2025-04-07 12:24:27 +03:00
Mikhail Krichanov
a759ddb400 BaseTools/Conf/tools_def.template: Added -Wno-maybe-uninitialized to fix
gcc-12.3.0 compilation.
2025-04-07 12:20:19 +03:00
Mikhail Krichanov
7193c4e313 BaseTools: Introduce new HII section design 2025-04-07 12:18:23 +03:00
Mikhail Krichanov
54c0f644f9 BaseTools/C: Consume UefiImageLib and ImageToolEmit 2025-04-07 12:18:23 +03:00
Marvin Häuser
4c392eb104 BaseTools/GenFv: Remove .text and .data from FV map 2025-04-07 12:18:23 +03:00
Marvin Häuser
544c7bdda8 BaseTools/build_rule: Drop deprecated ASM16 definition 2025-04-07 12:18:22 +03:00
Mikhail Krichanov
bc87d7b430 Drop support for the TE format 2025-04-07 12:18:22 +03:00
Mikhail Krichanov
f60f34fabf BaseTools/CommonLib: Consume MemoryAllocationLib 2025-04-07 12:18:22 +03:00
Marvin Häuser
473ab07302 BaseTools/GenFvInternalLib: Remove unused BaseOfCode parameter 2025-04-07 12:13:58 +03:00
Marvin Häuser
607095f8f4 BaseTools/GenFv: Remove duplicated alignment macros 2025-04-07 12:13:58 +03:00
Marvin Häuser
48e9d4282c BaseTools/DevicePath: Consume MdePkg/UefiDevicePathLib
BaseTools has been duplicating and adapting code that is defined in
MdePkg and MdeModulePkg. This leads to desync issues where the same
symbols may be backed by different functions with slightly different
semantics and also fixes that apply only to BaseTools or only to MdePkg
and MdeModulePkg.

To address these issues, update BaseTools/Source/C to utilize the code
from MdePkg and MdeModulePkg.

Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2025-04-07 12:13:58 +03:00
Marvin Häuser
2f61ab9f51 BaseTools/CommonLib: Consume MdePkg and MdeModulePkg
BaseTools has been duplicating and adapting code that is defined in
MdePkg and MdeModulePkg. This leads to desync issues where the same
symbols may be backed by different functions with slightly different
semantics and also fixes that apply only to BaseTools or only to MdePkg
and MdeModulePkg.

To address these issues, update BaseTools/Source/C to utilize the code
from MdePkg and MdeModulePkg.

Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2025-04-07 12:13:58 +03:00
Mike Beaton
850cf3b628 GenSec: Support TianoCompress
Allows .fdf files to define a compressed .ffs section which can be read
by legacy EFI firmware (such as found on Apple Mac).
Use `COMPRESS TIANO`.
2025-04-07 12:13:58 +03:00
Mikhail Krichanov
7b30f78411 Build: Renamed XIPFLAGS as SECPEIFLAGS, added comment in build_rule.template on its usage. 2025-04-07 12:13:58 +03:00
Mikhail Krichanov
4d4dcbe71f BaseTools: Removed GCC48/49 toolchains, refactored tools_def.template. 2025-04-07 12:13:58 +03:00
Mikhail Krichanov
011411a38e BaseTools, MdeModulePkg: Update brotli submodule
Update the brotli submodule to the latest commit (ed1995b6bda1)
so that the build isn't broken in GCC 12 compilers.

Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com>
2025-04-07 12:13:57 +03:00
Mikhail Krichanov
5d894921a3 BaseTools: Replaced GenFw with ImageTool and MicroTool. 2025-04-07 12:13:57 +03:00
Mikhail Krichanov
09a0c067d0 SecurePE: Replaced old PE loader with Secure one. 2025-04-07 12:12:35 +03:00
Mikhail Krichanov
7a0cf5389b Build: Fixed missing HII for X64, IA32 CLANGDWARF DEBUG, NOOPT. 2025-04-07 12:02:07 +03:00
Vitaly Cheptsov
c46ec15ff3 BaseTools: Allow .text relocations in CLANGDWARF toolchain
UefiCpuPkg modules like ExceptionHandlerAsm.nasm require relocations
to .text or PIC as they use instructions like mov or bt against
external symbols:

1. mov     rax, ASM_PFX(CommonInterruptEntry)
2. mov     rax, HookAfterStubHeaderEnd
3. bt      [ASM_PFX(mErrorCodeFlag)], ecx
4. mov     [rcx + (@VectorNum - HookAfterStubHeaderBegin)], al

It is not easily possible to rewrite 3/4 cases without involving
more registers or more commands, and EDK II has never targeted
read-only .text at load time, only at runtime.

Change the defaults to let OVMF compile by CLANGDWARF as per:
https://lists.llvm.org/pipermail/llvm-dev/2017-March/111441.html

Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>
2025-04-07 12:02:07 +03:00
Rebecca Cran
259e1f04c6 BaseTools: Add @verbatim as allowed Doxygen tag
Per the discussion in https://github.com/tianocore/edk2/pull/6476,
update Ecc code to allow the @verbatim Doxygen tag.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2025-02-04 00:12:00 +00:00
Dionna Glaze
cd87106d26 BaseTools: Add /DRIVER to CLANGPDB link flags
This quiets the warning reported in Issue #10637.

Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
2025-02-03 02:03:45 +00:00
Michael D Kinney
62b0698309 BaseTools/AutoGen: GenMake response file quotes strings
If command line options are moved into a response file
of a GCC family build, then the file path separators are
converted from '\' to '/'. However, this can corrupt
command line options that are quoted strings.

Update GenMake to no convert '\' to '/' in quoted strings.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-02-02 19:22:42 +00:00
Ard Biesheuvel
15a7d311a8 BaseTools/tools_def: Remove no-warn-rwx-segments linker options
The linker option 'no-warn-rwx-segments' breaks both the LLVM linker and
versions of the binutils ld.bfd linker prior to 2.39.

Now that the ELF image is made up of separate R-X and RW- segments, this
warning is no longer emitted and so there is no longer a need to
suppress it either.

While at it, move GCC_DLINK_FLAGS_COMMON (which is not common but only
used by Ia32 and X64) into its only user so it can be dropped.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-02-02 09:20:53 +00:00
Ard Biesheuvel
f2b42c83dd BaseTools/Scripts/GccBase.lds: Use separate R-W and RW- ELF segments
To prevent the ELF linkers from complaining about emitted ELF segments
that require both writable and executable permissions, define two
separate R-X and RW- ELF segments, and emit the output sections
explicitly into those segments as appropriate.

Note that this has no bearing on the PE image, and using a single RW-
segment would probably be fine too.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-02-02 09:20:53 +00:00
Ard Biesheuvel
e5d95c786b BaseTools/Scripts: Merge GCC and Clang ELF linker scripts
The original reason for creating a separate version of the ELF linker
script for Clang was the difference between COMMONPAGESIZE and
MAXPAGESIZE, which can we provided on the command line to the respective
linkers (ld.bfd versus lld). That difference no longer exists, and both
use COMMONPAGE_SIZE. So there is no longer a need to maintain a fork,
which has already been going out of sync with the original for no good
reason.

So merge the two and call it GccBase.lds

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-02-02 09:20:53 +00:00
Ard Biesheuvel
f5d585b46b BaseTools/Scripts/ClangBase.lds: Move .entry into .text section
The GccBase.lds and ClangBase.lds ELF linker scripts have been laid out
very carefully to ensure that the memory mappings of .text and .data are
such that they can be preserved in the PE/COFF memory image. This
removes the need to update any place-relative ELF relocations when
generating the PE/COFF image, making its job much easier, and
potentially allowing it to disregard static ELF relocations altogether,
and rely solely on dynamic ELF relocations.

Adding an arbitrary .entry section before .text breaks those
assumptions, so instead of emitting it as a separate section, move its
payload to the start of .text.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-02-02 09:20:53 +00:00
Ard Biesheuvel
d844a7eab5 BaseTools/tools_def: Use no-warn-rwx-segments only for GCC5
The command line option --no-warn-rwx-segments was added to the linker
command line for all GCC family builds on ARM and AARCH64, including
CLANGDWARF and GCC49 and older, none of which are intended for use with
linkers that actually understand this option.

So instead, move it to the GCC5 DLINK FLAGS definitions for ARM and
AARCH64 (which are inherited by the versionless GCC which is intended to
replace GCC5 at some point).

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-02-01 18:22:48 +01:00
Gerd Hoffmann
e063f8b8a5 BaseTools/Pccts: set C standard
The prehistoric code base doesn't build with ISO C23.  Set the C
standard to C11 (for both clang and gcc) so it continues to build with
gcc 15 (which uses C23 by default).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-01-31 05:23:39 +00:00
Ashraf Ali S
6d2143f685 BaseTools: Fix NoneType parent reference in FMMT operations
This patch addresses an issue in the FMMT operations where the parent
reference is not checked for NoneType. This oversight can lead to an
AttributeError: 'NoneType' object has no attribute 'Name' when
attempting to access the parent reference. The fix involves adding a
check for NoneType before accessing the parent reference to ensure that
the operations handle such cases gracefully.

The affected functions include:
- AddNewFfs
- ReplaceFfs
- ExtractFfs

These functions now include proper checks to prevent the AttributeError.

Signed-off-by: Ashraf Ali S <ashraf.ali.s@intel.com>
2025-01-27 16:26:18 +00:00
Oliver Smith-Denny
14cb48b0a0 BaseTools: Break Build on Linker Warnings
Today VS2022 and GCC are set to treat all compiler warnings as
errors and break the build. However, linker warnings for both
do not break the build. There are critical errors that can be
treated as warnings as the linker, such as not finding the
module entry point and use a default address as the entry
point. This will cause a runtime crash for something that
should be caught at build time.

This commit adds /WX to VS2022's DLINK_FLAGS and --fatal-warnings
to GCC's DLINK_FLAGS for IA32, X64, ARM, and AARCH64 in order to
break the build on linker warnings.

VS2022 linker warning 4210 is ignored for all builds because it
checks for static initializers and the linking of the VCRuntime.
edk2 never links the VCRuntime (except for HOST_APPLICATIONs) and
so the presence of static initializers will always cause this
warning, even when the edk2 code calls these initializers that
would otherwise be called in the _CRT_INIT function of the
VCRuntime. At the time of this commit, it only fails in CryptoPkg
for building OpenSSL, but could fail anywhere a static initializer
is used.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2025-01-22 19:47:20 +00:00
Michael D Kinney
139cbb266b BaseTools/Plugin/HostBasedUnitTestRunner: Set ASAN env vars
The environment variable `GTEST_CATCH_EXCEPTION` must be
set to `0` for so all exceptions are handled by the
address sanitizer and not GoogleTest. This allows stack
back trace and other details to be logged by the address
sanitizer so the source of the issue identified address
sanitizer can be determined.

The environment variable `ASAN_OPTIONS` must be set to
`detect_leaks=0` to disable memory leak detection. The
unit test frameworks may have memory leaks and some
firmware code under test use cases may perform a memory
allocation without a matching memory free as their
expected behavior.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-01-21 05:02:38 +00:00
Michael D Kinney
8d0e23d998 BaseTools/Conf: Simplify VS20xx HOST_APPLICATION builds
Add Empty_C_File_Host_Application_Build.c to BaseTools/Conf
that is a C source file with only comments that is used to
compile into an OBJ file using CC_FLAGS for a HOST_APPLICATION
module and the OBJ is passed into the VS20xx DLINK action to
provide the context required to select the correct default
windows application libraries.

Update build_rule.template to compile the empty C file and
generate OBJ in the OUTPUT_DIR of the HOST_APPLICATION
component and use the OBJ in the DLINK action.

This simplifies CC_FLAGS and DLINK_FLAGS for all modules
of type HOST_APPLICATION.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-01-21 05:02:38 +00:00
Aaron Pop
ac9a6eed02 BaseTools: build_rule.template generate a different dll for wholearchive.
When running the /wholearchive test build, generate the test .dll as a
different filename to prevent the system holding onto the dll file too
long and generating a build error that the actual dll cannot be found.
Remove the temporary file after it was generated because the successful
completion of the link command is the test case.

Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2025-01-15 04:36:14 +00:00
Yang Gang
3ac092cf72 BaseTools: Clean up os.path.normcase and os.path.normpath usage
Refer to the docs of python, `os.path.normcase(path)` function:
"Normalize the case of a pathname. On Windows, convert all characters in
the pathname to lowercase, and also convert forward slashes to backward
slashes. On other operating systems, return the path unchanged."

`os.path.normpath(path)` also convert forward slashes to backward slashes.

So call `os.path.normcase` after `os.path.normpath` just convert path to
lowercase on Windows(only).

And Windows is case-insensitive but case-preserving.

So the usage of `os.path.normcase(os.path.normpath(path))` can be
simplified to `os.path.normpath(path)`. Then we can use case-preserving
paths rather than lowercase paths in compile_commands.json file
or build log.

But this patch continue to use `os.path.normcase`
when comparing/searching paths.

Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2025-01-09 07:25:45 +00:00