Commit Graph

460 Commits

Author SHA1 Message Date
Dwight Engen
4a566dd746 aarch64: fix setjmp overrun
The assembly code uses fixed offsets into the jmp_buf and leaves an 8 byte
gap between the GPRs and the FPRs, but the jmp_buf structure was not laid
out to account for this so the code would overrun the jmp_buf by 8 bytes.

Found-by: Oskar Engen <oskar.engen@gmail.com>
Signed-off-by: Dwight Engen <dwight.engen@gmail.com>
2022-09-28 12:01:29 -04:00
Nigel Croxon
8b018e6721 Bump revision to VERSION = 3.0.15 2022-08-08 11:38:33 -04:00
Sergei Trofimovich
803b49c40b */*.S: add non-executable GNU stack marking on ELF-linux
binutils-2.39 enabed a few warning by default
(https://sourceware.org/pipermail/binutils/2022-August/122246.html):

> The ELF linker will now generate a warning message if the stack is made executable.

Let's suppress the warnings in assembly files by adding non-executables
stack markings. This fixes at least systemd build which uses '-Wl,--fatal-warnings':

    https://github.com/systemd/systemd/issues/24226
2022-08-08 11:35:10 -04:00
Sergei Trofimovich
2ed6486834 lib/Makefile: add .o file dependency on libsubdirs targets
Without the change there is no guarantee that .o files will be built
after directories are created for them and build fails as:

    gcc -I/build/gnu-efi-code//lib ... -c lib/runtime/rtstr.c -o runtime/rtstr.o
    Assembler messages:
    Fatal error: can't create runtime/rtstr.o: No such file or directory
2022-07-25 10:39:43 -04:00
Fabrice Fontaine
6b28563584 Handle __mips64
Handle __mips64 to avoid a build failure since
b1c7a1c5f2

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2022-07-25 10:36:14 -04:00
zhoumingtao
5849eacdce use jr instead of jirl
jirl -> jr
2022-07-07 15:16:10 +08:00
zhoumingtao
e7db4418b1 Add support for LoongArch64 architecture 2021-12-30 15:39:47 +08:00
Nigel Croxon
af773c779d Bump revision to VERSION = 3.0.14 2021-08-19 12:25:25 -04:00
Pete Batard
b136460925 riscv64: finalize efibind.h
There's little reason not to derive the RISCV64 version of efibind.h
from the AARCH64 version, especially as the current version is missing
required macros such as EFI_DRIVER_ENTRY_POINT() which breaks the
compilation of some drivers.

The only major difference we introduce from AARCH64 is to consider
that any toolchain that supports RISCV64 is modern enough to support
<stdint.h>. Also, as we preserve the added definition for BOOLEAN,
we guard it with an ifndef in anticipation of MSVC RISCV64 support.

We validated these changes by confirming that they now allow gnu-efi
to be used to compile a set of UEFI drivers for RISCV64.
2021-08-19 12:21:14 -04:00
Alfonso Sánchez-Beato
31a6aab44c Set NumberOfSymbols to zero
Acoording to what the spec says about the number of sybols [1]:

"This value should be zero for an image because COFF debugging
information is deprecated."

Changing as if not zero it causes problems to llvm-objcopy. This
affects only the architectures where COFF is not supported by objcopy
and where we build the PE header via assembly code.

[1] https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
2021-07-29 11:38:16 +02:00
b'Nigel Croxon
269ef9dbc7 Merge /u/abeato/gnu-efi/ branch add-guids into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/26/
2021-07-16 16:48:28 +00:00
Pete Batard
4ef183353c Fix VS2019 Code Analysis warnings
When compiling for x64, Visual Studio 2019's Code Analysis produces the following warnings:

C:\Projects\gnu-efi\lib\print.c(1380): warning C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2).
C:\Projects\gnu-efi\lib\smbios.c(47): warning C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2).
C:\Projects\gnu-efi\lib\str.c(289): warning C26451: Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2).

Fix these by adding an explicit cast to UINTN.
2021-07-16 12:43:24 -04:00
Alfonso Sánchez-Beato
fbbbf47e5c Add definitions for the EFI device tree table
Add definitions for the EFI device tree table, as specified in UEFI
specification 2.9 (March 2021).

Signed-off-by: Alfonso Sánchez-Beato <alfonso.sanchez-beato@canonical.com>
2021-07-16 16:36:46 +02:00
b'Nigel Croxon
40160210a7 Merge /u/xypron/gnu-efi/ branch misc_fixes into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/25/
2021-06-24 12:16:12 +00:00
Heinrich Schuchardt
4fe83e1026 apps: memory leak in draw_boxes()
Free the buffer allocated to draw boxes.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-23 23:22:41 +02:00
Heinrich Schuchardt
58124a7fea apps: define FrameBufferAddr for riscv64
The size of FrameBufferAddr is architecture dependent. Add the missing
definition for the riscv64 architecture.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-23 22:56:29 +02:00
Heinrich Schuchardt
df31239ac5 riscv64: provide efisetjmp_arch.h
efisetjmp_arch.h is required for 'make apps'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-23 22:56:29 +02:00
Heinrich Schuchardt
b5f98d40fe riscv64: missing EFI_FUNCTION
Add missing definition. It is needed for 'make apps'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-23 22:56:29 +02:00
Heinrich Schuchardt
01a8d3bb00 apps: simplify logical constraints
EFI_ERROR(EFI_NOT_STARTED) is true. So we can simplify

    (EFI_ERROR(rc) && rc == EFI_NOT_STARTED)

to

    (rc == EFI_NOT_STARTED)

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-23 22:53:26 +02:00
b'Nigel Croxon
2a7829c50b Merge /u/xypron/gnu-efi/ branch misc_fixes into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/22/
2021-06-23 15:18:12 +00:00
Nigel Croxon
860b1c8cbe efiapi.h: add RISC-V machine type definitions
These values are from the UEFI specification version 2.9.

Signed-off-by: David Michael <fedora.dm0@...>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2021-06-23 09:37:54 -04:00
Heinrich Schuchardt
e2fc15ae0e lib/str: simplify Atoi()
Checking that str is non-zero is superfluous in

	(*str && *str == ' ')

0x20 is always non-zero.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-22 00:17:00 +02:00
Heinrich Schuchardt
500c10f191 lib/misc: avoid NULL dereference in LibInsertToTailOfBootOrder
AllocatePool() may return NULL. We must check the return value before
dereferencing it.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-22 00:17:00 +02:00
Heinrich Schuchardt
70402aa91d lib/hand: missing va_end() in LibReinstallProtocolInterfaces()
For each va_start() there must be a call to va_end().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-22 00:17:00 +02:00
b'Nigel Croxon
9e7e6822b7 Merge /u/xypron/gnu-efi/ branch GCC_visibility into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/20/
2021-05-17 14:20:24 +00:00
Ard Biesheuvel
fa506bd242 ARM: hide 'hidden' pragma for hosted build
The hidden visibility #pragma in inc/arm/efibind.h was meant to inform
the compiler that symbols with external linkage are never exported from
shared libraries [and thus never preempted] when executing in UEFI context
(since UEFI does not support shared libraries). This allows the compiler to
generate relative symbol references instead of GOT entries, which is much more
efficient since the latter need to be relocated before invoking the entry
point of the UEFI app.

However, as it turns out, this pragma is leaking into other code that does
not run in UEFI context, but simply needs to access data structures that
UEFI defines. So make the pragma dependent on whether we are building with
-ffreestanding, which is only used for bare metal code such as UEFI.

Last-Update: 2018-08-24

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Elder versions of sbsigntool failed to build on armhf without the patch,
cf. https://launchpad.net/ubuntu/+source/gnu-efi/3.0.8-0ubuntu1~16.04.1
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-08 11:40:21 +00:00
Peter Jones
69df7422b1 Add EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID.
Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-08 11:07:25 +00:00
Marvin Häuser
b916d1e54e Fix dummy relocation block alignment
As per the PE format specification, relocation blocks must be aligned on 32-bit boundaries. Fix the dummy relocations to obey the alignment constraints.
2021-04-06 22:35:03 +02:00
b'Nigel Croxon
3676bc353c Merge /u/xypron/gnu-efi/ branch riscv64 into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/17/
2021-04-05 14:13:03 +00:00
b'Nigel Croxon
ea4c77ffc5 Merge /u/xypron/gnu-efi/ branch va_args into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/16/
2021-04-05 14:12:39 +00:00
b'Nigel Croxon
e686743ba6 Merge /u/xypron/gnu-efi/ branch xtoi into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/15/
2021-04-05 14:11:53 +00:00
b'Nigel Croxon
2a1200f36f Merge /u/kagurazakakotor/gnu-efi/ branch shell-protocol into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/13/
2021-04-05 14:11:15 +00:00
b'Nigel Croxon
2cdf05814d Merge /u/kagurazakakotor/gnu-efi/ branch protocol-header into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/12/
2021-04-05 14:10:15 +00:00
Heinrich Schuchardt
0ec661b389 lib/hand: missing va_end
For each va_start() there must be a va_end().

Correct LibInstallProtocolInterfaces() and
LibUninstallProtocolInterfaces().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-04 11:06:05 +02:00
Heinrich Schuchardt
1771b6e779 lisb/str.c: simplify xtoi()
If str == ' ', str has to be non-zero. No extra check is needed.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-04 10:51:08 +02:00
Heinrich Schuchardt
b95f138fa1 Initial support for RISCV64
Add the RISCV64 architecture

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-01 17:17:33 +02:00
Heinrich Schuchardt
dfdcd7eff3 Undefined Status in LibGetVariableAndSize()
GrowBuffer() expects that parameter Status is initialized.
LibGetVariableAndSize() currently passes random data from the stack.

Initialize variable Status.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-19 17:14:48 +01:00
Nigel Croxon
59fd1e9d1d Bump revision to VERSION = 3.0.13 2021-03-08 15:05:36 -05:00
Pete Batard
b39be0d5a9 Define UnicodeSPrint/UnicodeVSPrint as our main SPrint/VSPrint calls
Per https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/PrintLib.h
those are the names used by EDK2, so make these our official names as well.

For compatibility with older gnu-efi versions, also keep SPrint and VSPrint defined.
2021-03-08 15:00:14 -05:00
Pete Batard
2458595367 Use EFI_FILE_SYSTEM_VOLUME_LABEL rather than EFI_FILE_SYSTEM_VOLUME_LABEL_INFO
Per https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Guid/FileSystemVolumeLabelInfo.h
the EDK2 uses EFI_FILE_SYSTEM_VOLUME_LABEL and EFI_FILE_SYSTEM_VOLUME_LABEL_ID rather
than EFI_FILE_SYSTEM_VOLUME_LABEL_INFO and EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID.

We redefine those to the proper EDK2 names, while also adding defines for compatibility.
2021-03-08 14:59:46 -05:00
Pete Batard
6c77f27793 Define BASE_CR as a duplicate of the _CR macro
Per https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Base.h#L867
the EDK2 uses BASE_CR and not _CR, so make sure gnu-efi defines it too.
2021-03-08 14:59:02 -05:00
Pete Batard
41e4d11d11 Fix CopyMem() not handling overlaps
Per https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/BaseMemoryLib.h
"(CopyMem) must handle the case where SourceBuffer overlaps DestinationBuffer".

Having the gnu-efi version of CopyMem differ from the EDK2 version can lead to
extremely hard to troubleshoot issues as well as very unexpected results. So
make sure our version follows the same guidelines.
2021-03-08 14:58:21 -05:00
Pete Batard
b1c7a1c5f2 Remove the need for other include paths besides <gnu-efi>/inc
Having to add specific arch include paths and then <gnu-efi>/lib
to be able to use gnu-efi in an application is annoying.

This patch ensures that the library itself takes care of including
the relevant headers, and that one needs only to add <gnu-efi>/inc
in their include path to be able to use gnu-efi.
2021-02-18 10:15:22 -05:00
Pete Batard
70bced02ed Always define HAVE_USE_MS_ABI for MSVC compilers
Obviously, it makes little sense not to have it unconditionally defined there.
2021-02-18 10:13:46 -05:00
Pete Batard
0247cb7cd4 Add AsciiPrint and AsciiVSPrint
Per https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/PrintLib.h
AsciiPrint() is the official name of APrint() so declare it as such and define
an APrint alias for compatibility.

Also add an AsciiVSPrint() to print a formatted ASCII string to a buffer using
a va_list. AsciiPrint() too is defined in EDK2's PrintLib.h, though our implementation
just invokes the Unicode version and then converts the buffer to ASCII.
2021-02-18 10:11:44 -05:00
Pete Batard
ebdde0bc4b Always prefer the external <stdarg.h> for MSVC compilation
The __builtin_va_###() intrinsics apply only to GCC-like compilers and
MSVC's <stdarg.h> works just fine with gnu-efi.
Without this patch, one has to define GNU_EFI_USE_EXTERNAL_STDARG to
make gnu-efi work with a Microsoft toolchain, which is annoying...
2021-02-18 10:09:07 -05:00
Jiaqing Zhao
6c04004f63
Add EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL definitions
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2020-11-15 15:26:19 +08:00
Jiaqing Zhao
773f30af29
Move EFI_SHELL_PARAMETERS_PROTOCOL related definitions to efishell.h
As EFI_SHELL_PARAMETERS_PROTOCOL is also defined in UEFI Shell Spec,
put it together with EFI_SHELL_PROTOCOL.

Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2020-11-15 15:15:18 +08:00
Jiaqing Zhao
2b26c8112f
Add EFI_SHELL_PROTOCOL definitions
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2020-11-15 15:12:25 +08:00
Kagurazaka Kotori
ce0bd62f5c
Add Device Path Utilities Protocol support
Signed-off-by: Kagurazaka Kotori <kagurazakakotori@gmail.com>
2020-07-23 15:44:12 +08:00