Commit Graph

447 Commits

Author SHA1 Message Date
Pete Batard
b74c52f8ba
Fix detection of Ubuntu/MinGW version
For downright incomprehensible reasons the Ubuntu/MinGW folks have decided that MinGW on
Ubuntu should no longer report the compiler's version as '<major>.<minor>', but instead as
'<major>-win32', which of course breaks any script that attempts to read version numbers.

This results in MinGW compilation of gnu-efi on Ubuntu producing the error:
  /bin/sh: 1: [: Illegal number: 10-win32

Fix this by replacing any '-win32' in the -dumpversion report with '.0' so that we get an
approximate version number back again.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-09 12:58:00 +01:00
Pete Batard
630ea144cb
Fix MinGW compilation
Per binutils/docs/as/Section.html, COFF assembly, which is what MinGW uses, does not
allow @type/%type, which is an ELF-only thing. As a result, trying to assemble the
recently modified ctor.S with MinGW produces the error:
  Error: junk at end of line, first unrecognized character is `,'
Fix this by making sure ELF-specifics are only added within ELF-guarded sections.

Note: This fixes the now deleted https://sourceforge.net/p/gnu-efi/bugs/38/

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-09 12:56:57 +01:00
Pete Batard
36d3313805
Clean up Linux/gcc and Windows/VS2022 workflow files
Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-09 12:55:44 +01:00
Pete Batard
399313e148
Allow UEFI shorthands to be specified for the arch
The UEFI shorthands, as used in /efi/boot/boot###.efi, can now be used to specify the arch.
This basically adds 'x64' and 'mips64' as valid arch specifiers.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-09 12:54:49 +01:00
Nigel Croxon
0f2bee2834
Merge pull request #19 from pbatard/master
Fix ‘asm’ undeclared error for MIPS builds
2024-05-08 08:59:57 -04:00
Pete Batard
91cb708816 Fix ‘asm’ undeclared error for MIPS builds
As explained at https://stackoverflow.com/a/49830956/1069307, 'asm' is a GNU
extension that will produce an error when using a non GNU standard like -std=c11.
With recent commit 9b1e06cd0c having fixed our use
of -std=c11, the MIPS build failed with the error above.

With this sorted, we also re-enable the MIPS gcc build in GitHub Actions.
2024-05-08 13:54:10 +01:00
Nigel Croxon
a77c70718d
Merge pull request #18 from pbatard/master
Add GitHub Actions Linux/gcc and Windows/VS2022 CI builds
2024-05-08 08:05:08 -04:00
Nigel Croxon
1cf29645c6
Merge pull request #8 from hughsie/hughsie/Copright
Replace 'Copright' with 'Copyright' in file headers
2024-05-08 08:01:56 -04:00
Pete Batard
c30d23da8f Add GitHub Actions builds 2024-05-08 13:00:08 +01:00
Pete Batard
18fe24f01f Add Visual Studio 2022 solution files
* setjmp is not added as an app as it relies on non MSVC compatible assembly.
2024-05-08 12:16:56 +01:00
Pete Batard
130ebd8f04 Fix MSVC sample compilation 2024-05-08 10:51:58 +01:00
Pete Batard
ac8d6944c2 Use EDK2 compatible names for SMBIOS and AsciiStr functions and GUIDs 2024-05-08 10:51:43 +01:00
Richard Hughes
8272cd905e
Replace 'Copright' with 'Copyright' in file headers
This was hopefully just a typo that has been cargo-culted around the codebase.

It certainly confuses the Red Hat license checker and makes the code copyright
clear.
2024-05-07 13:03:52 +01:00
Nigel Croxon
bfaaec428b
Merge pull request #6 from gmbr3/RuntimeError
Align RTLIB CopyMem/SetMem with normal versions
2024-04-30 07:15:32 -04:00
Nigel Croxon
145c056b83
Merge pull request #5 from gmbr3/fixes
Disable RELRO
2024-04-30 07:14:16 -04:00
Callum Farmer
6b9dae0bef
Fixup string functions for new CopyMem
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-04-27 18:26:21 +01:00
Callum Farmer
f5bb548df5
Align RTLIB CopyMem/SetMem with normal versions
Looks like 699e452654 broke rEFInd
(189e405630/)
2024-04-25 15:27:26 +01:00
Callum Farmer
a0111e0df1
Disable RELRO
No point having PT_GNU_RELRO as ELF data won't exist when merging into PE32+ file

Unbreaks lld usage which complains about linker script
Fixes ncroxon/gnu-efi#4
2024-04-24 12:04:48 +01:00
Nigel Croxon
4dc70fdf45
Merge pull request #3 from gmbr3/eh_frame_hdr
lds: Add eh_frame_hdr section
2024-04-01 11:35:32 -04:00
Callum Farmer
c7ee41c6c4
lds: Add eh_frame_hdr section
A new section has appeared, move it to the correct place
Copy of fwupd/fwupd-efi#59

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-04-01 16:04:02 +01:00
Nigel Croxon
2b0c490219 Bump revision to VERSION = 3.0.18 2024-03-22 10:24:28 -04:00
Peter Jones
31913f8489 Make: make TOPDIR actually work and get rid of unused CDIR
Signed-off-by: Richard Hughes <richard@hughsie.com>
Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-22 10:24:28 -04:00
Peter Jones
95dbde278c make: Make "make clean" use @ and rm -v everywhere
This makes our "make clean" commands show what they've /removed/, rather
than what the shell code that will be run is.

Signed-off-by: Richard Hughes <richard@hughsie.com>
Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-22 10:24:28 -04:00
Soop
13ac2e8b3f Make apps link against the local gnuefi and crt objects
Signed-off-by: Richard Hughes <richard@hughsie.com>
2024-03-22 10:24:28 -04:00
Callum Farmer
e2355ed7fb Remove 64k gap on ARM32
While binutils 2.25 incorrectly changed the page size
to 64K, the second part of that fix prevents the bug
anyways

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:24:28 -04:00
Callum Farmer
792715e5e9 arm64 lds: move 64K gap to reloc
The PE32 header means code ends at end of text, unlike
ELF where its mostly dynamic

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:24:28 -04:00
Callum Farmer
419e257f34 ctors.S: Align with linker scripts
Remove end padding
Change start padding to 16

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:24:23 -04:00
Xiaotian Wu
e5b1a35303 add non-executable GNU stack marking on ELF-linux
Signed-off-by: Xiaotian Wu <wuxiaotian@loongson.cn>
2024-03-22 10:24:23 -04:00
Xiaotian Wu
feedeaa339 Make loongarch64 use efi-app-loongarch64
Binutils 2.41 now supports efi-app-loongarch64, so to use this we must add a
dummy reloc section and remove the PE header definition from crt0 as this will
conflict with the version added by objcopy

Signed-off-by: Xiaotian Wu <wuxiaotian@loongson.cn>
2024-03-22 10:24:23 -04:00
Xiaotian Wu
fe31748c87 Add some definitions for LoongArch
Added CHAR8, CHAR16, WCHAR and VOID type definitions for LoongArch
2024-03-22 10:24:23 -04:00
Callum Farmer
d27431f679 Add EFI_NORETURN for declspec
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:24:23 -04:00
Callum Farmer
593e13f670 Rename ALIGN to EFI_ALIGN
Avoid conflict with other libraries

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:24:23 -04:00
Callum Farmer
2c47753ad3 Update OS Indications to 2.10
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:24:23 -04:00
Callum Farmer
86b8b5ea78 Update memory types to 2.10
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:24:23 -04:00
Callum Farmer
30bf99b81e Update error/warning codes to 2.10
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:24:23 -04:00
Callum Farmer
b084081593 Update table revisions to 2.10
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:24:23 -04:00
Callum Farmer
fb58e92621 ARM32: Only use 4K pages
Turns out some linkers have set page size to 64K on ARM32 aswell
so apply the same fix as ARM64

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:24:19 -04:00
Peter Jones
5df47d3527 Add missing EFI_VARIABLE_... definition.
This adds the definition for EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS.

Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-22 10:24:16 -04:00
Peter Jones
27477ba983 Add some missing definitions for system table revisions
Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-22 10:24:12 -04:00
Peter Jones
699e452654 Make CopyMem() and SetMem() be EFIAPI
For wildly unknown reasons, EFI Boot Services includes CopyMem() and
SetMem() functions, and they are marked as EFIAPI functions.

This patch marks gnu-efi's CopyMem() and SetMem() as EFIAPI functions,
and makes their exposed API match the misguided nonsense in the EFI
spec, so that they can be used there in a test environment.

Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-22 10:24:09 -04:00
Peter Jones
06574e4ecd Add EFI_MEMORY_ATTRIBUTE_PROTOCOL
Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-22 10:24:05 -04:00
Peter Jones
907bf6ce94 Fix some EFI_MEMORY_FOO definitions
Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-22 10:23:56 -04:00
Nigel Croxon
3b137d634d remove superfluous -fno-stack-check
Signed-off-by: David Müller <d.mueller@elsoft.ch>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2024-03-22 10:23:50 -04:00
Callum Farmer
7f8e2d44ed Move OPTNONE macro to eficompiler.h
This is also useful in downstream projects so add it
to public header

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:23:44 -04:00
Nigel Croxon
eab878741a Tail calls break ctors/dtors
Add macro EFI_NO_TAIL_CALL which disables tail call
optimization on a per-function basis

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2024-03-22 10:23:15 -04:00
Callum Farmer
fb3b3f4c66 riscv64: ignore unknown relocs
Sometimes ld emits relocs such as R_RISCV_64 for unwind symbols
these don't need to be handled yet so just can be skipped otherwise
the binary will never load

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:08:37 -04:00
Callum Farmer
4cdcf2a37b riscv64: fix image
- Make it actually work
- Split text/data/reloc/rodata sections
- Move hash sections to past end of image
  (un-needed in PE)
- Correct section & file alignment
- Correct image size

Builds correctly but untested

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:08:24 -04:00
Callum Farmer
eadee98bf0 ARM32: fix image
- Make it actually work
- Split text/data/reloc/rodata sections
- Move hash sections to past end of image
  (un-needed in PE)
- Correct section & file alignment
- Correct image size
- rename .reloc to .areloc within ELF
  as only on ARM32 does this name cause
  it to be marked as REL and subsequently
  mistakenly added to RELSZ

Builds correctly & tested working in QEMU

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:07:56 -04:00
Callum Farmer
0bb329b0bf Merge .plt into .text
ld writes .plt immediately after .text
which corrupts the alignment of .reloc

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:07:53 -04:00
Callum Farmer
262c1f4604 Split out rodata
rodata should be split for security

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:07:49 -04:00