Commit Graph

451 Commits

Author SHA1 Message Date
Callum Farmer
b6f99c7ac5
Add substitute elf.h for macOS
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-14 18:50:39 +01:00
Callum Farmer
f19216bf87
Add macOS toolchain
Fixes ncroxon/gnu-efi#36

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-14 18:50:17 +01:00
Nigel Croxon
33727c2abe
Merge pull request #34 from gmbr3/riscv
Toolchain fixes + RISCV64 objcopy move + AARCH64 non-objcopy restore
2024-07-06 20:48:55 -04:00
Callum Farmer
2765122e67
X86_64: We use RELA not REL
Weird huh? GNU ld uses RELA but no addends, as soon as
you get an addend from LLD, this code breaks

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:44:02 +01:00
Callum Farmer
9c953ddf27
Make old ABI func static
Otherwise, LLVM will emit an extern symbol if -O0 is used
which will break the build

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:44:02 +01:00
Callum Farmer
f77e4e8a8e
Force DWARF 4 on LLVM
Otherwise readelf just throws an absolute blowup :(

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:44:01 +01:00
Callum Farmer
0c0b91b9f9
PC file missing from clean
The pkgconfig file was not being removed
by clean, add the missing statement

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:44:01 +01:00
Callum Farmer
21f87c2b1e
Fixup riscv64 objcopy move
Detect new enough objcopy

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:44:01 +01:00
Callum Farmer
353984bb97
Move riscv64 default to objcopy
Fixes ncroxon/gnu-efi#11

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:44:01 +01:00
Callum Farmer
23715d6389
Restore non-objcopy ARM64 crt0/lds
* An up-to-date version of it anyways
* Useful for systems without objcopy 2.38+

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:44:01 +01:00
Callum Farmer
9fb0825a6b
Output ELF data file on Linux CI/CD
* Useful for checking moved/new ELF sections

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:44:00 +01:00
Callum Farmer
771b632092
Add Linux musl-libc toolchain
* Use gcc as compiler and bfd as linker
* Use musl toolchain prefixes
* musl doesn't have any Ubuntu cross toolchains
  so x86_64 only

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:43:42 +01:00
Callum Farmer
16c9eedafb
Add Linux LLVM toolchain
* Use clang as compiler and LLD as linker

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:29:04 +01:00
Callum Farmer
d9b395ac03
Make CopyMemC call CopyMem
* The last part of this: I hope :)
* ISO C permits overwriting of Src even if it marks Src as CONST
* UEFI marks Src as NON CONST, so forward calls via this function
* Allows us to keep in-line with shim without causing Werror havoc with other downstreams

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:29:04 +01:00
Callum Farmer
c03d395571
Disable uninitialized error on GCC
Gives error on 'Red' in bltgrid.c which is initialized
by the looks of it?

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:29:04 +01:00
Callum Farmer
f8ebcfc077
Use char16_t literals
Add char16_t('u') literals
Remove wchar_t('L') literals

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-06-24 19:34:51 +01:00
Callum Farmer
ce1ec9d27b
Make CHAR8 use unsigned char
* Means we don't have to switch the implementation of char to unsigned char
* Matches the underlying type of char8_t from C++20

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-06-24 19:34:51 +01:00
Callum Farmer
edfda7c396
Make CHAR16 use uint16_t
musl-libc doesn't like fshort-wchar so remove wchar_t usage
Use uint16_t as char16_t can be up to 32bits
Fixes ncroxon/gnu-efi#16

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-06-24 19:34:18 +01:00
Nigel Croxon
9e479726ed
Merge pull request #33 from pbatard/msvc
Apply stdbool/stdint MSVC fixes
2024-06-04 08:45:42 -04:00
Pete Batard
96e3b8469c
Apply stdbool/stdint MSVC fixes
It seems that while Visual Studio can support the C23 standard, Microsoft didn't get the memo
about no longer requiring stdbool.h for true/false, so add an exception for that.

Also harmonize the inclusion of stdint.h for IA32 and IA64 so that, just like for other archs,
it is not limited to GNU-like compilers only.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-06-03 21:13:41 +01:00
Nigel Croxon
2a44cea3f3
Merge pull request #31 from pbatard/drv0
Fix driver EFI subsystem for VS and RISCV64 and add driver testing
2024-05-28 08:40:32 -04:00
Pete Batard
0248433f2c
Add driver testing to the test list
Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-24 10:29:50 +01:00
Pete Batard
eeb0e6a830
Fix RISCV64 not setting the subsystem according to EFI_SUBSYSTEM
The RISCV64 toolchain does not support 16-bit variable relocation from assembly,
and even if it did support relocations, it would not properly set the subsystem
from --defsym. So we add an extra step on RISCV64, post objcopy, to set the field
manually (using dd and /bin/echo to output the relevant byte, as GNU Make's echo
does not support -ne).
Closes ncroxon/gnu-efi#27.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-24 10:29:49 +01:00
Pete Batard
5d0de491f1
Fix drv0 not being properly set to Boot Service Driver for Visual Studio
Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-24 10:29:35 +01:00
Nigel Croxon
4ecd540d46
Merge pull request #28 from pbatard/pbatard
Add RISCV64 testing support and default to clean compiler output
2024-05-21 13:29:24 -04:00
Nigel Croxon
dee84a8948
Merge pull request #30 from pbatard/fixes
Fix double reference to route80h.efi in apps
2024-05-21 13:27:58 -04:00
Pete Batard
0cdd5584a0
Fix double reference to route80h.efi in apps
Commit 625bdb6368 reorganized the apps list but
also duplicated route80h.efi so remove the extra one, as having two instances
produces an error when running 'make install'.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-21 13:55:09 +01:00
Pete Batard
b50b0a0a2c
Add RISCV64 testing support
Requires a recent QEMU (for the pflash0 options) and therefore Ubuntu 24.04.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-21 11:46:42 +01:00
Pete Batard
2d6d426b8c
Enable silent rules for compiler output
This is similar to using automake's silent rules and, just as with automake,
can be disabled by invoking 'make V=1'.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-21 11:45:20 +01:00
Nigel Croxon
7440e5ebb7
Merge pull request #26 from pbatard/Resolve-Conflicts
Add build time QEMU/UEFI tests
2024-05-20 09:24:38 -04:00
Pete Batard
23c505d548
Merge branch 'master' into Resolve-Conflicts 2024-05-20 15:21:24 +02:00
Nigel Croxon
34754d941f
Merge pull request #25 from gmbr3/RuntimeError
Multiple fixes
2024-05-20 09:02:57 -04:00
Callum Farmer
39681d7a0f
Add test for old ABIs of ReallocatePool and CopyMem
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-05-20 12:15:20 +01:00
Callum Farmer
e3c7731bcc
Fixup functions for new ReallocatePool
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-05-20 12:15:20 +01:00
Callum Farmer
eaa624e71d
Add legacy defines for CopyMem
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-05-20 12:15:19 +01:00
Callum Farmer
f3656c8800
Move ReallocatePool to EDK2 ABI
Fixes ncroxon/gnu-efi#9

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-05-20 12:14:01 +01:00
Callum Farmer
1e8900a92b
Switch everything to Unix line endings
I wondered why a patch didn't apply :(

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-05-19 14:22:26 +01:00
Callum Farmer
8ad6c33424
PC: Add useful variables
* Add efi_machine_type_name and gnu_efi_arch from fwupd-efi

* Add gnu_efi_default_is_objcopy so downstreams know if the crt0 goes objcopy

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-05-19 14:22:11 +01:00
Callum Farmer
c339e077c8
Restore old CopyMem as CopyMemC
CopyMemC cos CONST Src

Reverts 6b9dae0bef

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-05-19 13:56:07 +01:00
Pete Batard
46aca420cc
Add build time QEMU UEFI tests
Use OVMF/AVMF and the UEFI Shell in a QEMU environment to validate that the
UEFI executables we build do run and produce the expected output.

The tests to run are flexibly defined is test_list.txt and can be expanded.

At this stage, only x64, ia32, aa64 and arm are run, which rely on the UEFI
firmwares found at https://github.com/pbatard/EfiFs/tree/gh-pages/AAVMF and
https://github.com/pbatard/EfiFs/tree/gh-pages/OVMF as well as Shell builds
from https://github.com/pbatard/UEFI-Shell.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-18 16:12:11 +01:00
Pete Batard
da5fe74408
Create GitHub Actions artifacts
This makes the apps/*.efi files available for download and testing after each build.
Also clean up the GitHub Actions workflows a little bit.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-18 16:11:25 +01:00
Pete Batard
9e2483ab62
Fix output of test apps to produce CRLF rather than LFCR
LFCR results in unwanted blank lines being added on serial output.
CRLF is what UEFI actually uses.
Also fix unneeded CR added to Print() optput in tcc.c.

These fixes are needed to to use these application for build time tests.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-18 16:11:13 +01:00
Pete Batard
5dee8b0339
Fix MinGW EFI applications
The EFI subsystem and application entrypoint were not being set for MinGW builds
and we don't need to go through objcopy either, so fix that.
Also make sure that the link options can be understood by the compiler, which
is what we use for linking, and remove the extra GNU_EFI_USE_MS_ABI, that was
already automatically added.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-18 15:37:16 +01:00
Nigel Croxon
52c3c36e34
Merge pull request #24 from pbatard/master
Actually make the apps build with MinGW
2024-05-16 14:44:42 -04:00
Pete Batard
625bdb6368
Actually make the apps build with MinGW
To builds the apps with MinGW, the CRT0 library must be ignored because
it is ELF specific and we don't need to go through ELF relocations.
We also apply the GNU_EFI_USE_MS_ABI (since we have it), remove the -z
flags, that are invalid in MinGW, and clean up the apps Makefile.

Note that setjump and debughook are excluded from MinGW builds as they
use constructs that are not available there.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-16 17:50:10 +01:00
Nigel Croxon
ccfe18558c
Merge pull request #23 from pbatard/master
Actually define STATIC as static
2024-05-16 08:55:38 -04:00
Pete Batard
f719f7d838
Actually define STATIC as static
Should be the same as EDK2, per:
https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Base.h#L264

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-16 13:01:13 +01:00
Nigel Croxon
e1024aba22
Merge pull request #22 from pbatard/master
Fix exception on ARM32 with VS2022 when Print() is invoked
2024-05-14 16:20:26 -04:00
Pete Batard
0c7af72ba8
Fix exception on ARM32 with VS2022 when Print() is invoked
On ARM32 only, it appears that whenever Visual Studio inlines the FloatToString()
call (which it does for Release builds), the resulting executable produces an
"Undefined OpCode Exception" on Print() invocation, regardless of whether there
is an actual float to string conversion occurring there.

To work around this, add an explicit clause to prevent inlining, and do so on all
platform just in case.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-14 13:56:03 +01:00
Pete Batard
f2f17bfb16
Add a new EFI_NOINLINE macro and clean up eficompiler.h
Guard the macros by the compilers they should explicitly apply to and
add a #error in case the compiler has no alignment directive defined,
as ignoring alignment is likely to produce runtime errors.
Also prefer _MSC_VER to _MSC_EXTENSIONS, as _MSC_EXTENSIONS may not
always be defined by the MSVC compiler.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-14 13:55:59 +01:00