Also add EXEC_PREFIX and INCLUDEDIR variables
This was requested by fwupd-efi, to be able
to retrieve the version number of gnu-efi
so we can detect features
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Right now whenever we have shell commands with loops, errors in the
middle are accidentally ignored, and make continues to process commands.
This adds 'set -e' to all of those, so they'll propagate back up.
Signed-off-by: Peter Jones <pjones@redhat.com>
This makes us use CFLAGS when trying to find libgcc, so we don't get the
one with the wrong endian or float ABI.
Signed-off-by: Peter Jones <pjones@redhat.com>
This makes the normal DESTDIR= variable work on the command line, and
makes relative paths always relative to the top-level directory.
Signed-off-by: Peter Jones <pjones@redhat.com>
This makes setup and teardown functions defined with
__attribute__((__constructor__) and __attribute__((__destructor__)) work
in normal circumstances in EFI binaries.
A couple of notes:
- it implements both the old-style .ctors/.dtors methods and the newer
style .init_array/.fini_array ELF constructor and destructor arrays,
processed in the order:
.init_array[]
.ctors[]
efi_main()
.dtors[]
.fini_array[]
- Destructors will only be called if efi_main() exits using "return";
any call to Exit() will still longjmp() past them.
- InitializeLib() has already been called before constructors run, so
they don't need to call it (and neither does anything else.) For
compatibility, it has been altered so calling it more than once is
safe.
- No attempt is made to handle any constructor or destructor with a
prototype other than "void func(void);", but note that InitializeLib
has been called, so LibImageHandle, ST, BS, and RT are set.
- The init_array/ctor/dtor/fini_array lists aren't the using the GNU
"CONSTRUCTOR" output section command, so they don't start with a size.
- The lists are individually sorted during the link stage via
SORT_BY_NAME() in the linker script.
- The default (empty) init_array/ctor/dtor/fini_array lists are padded
out to 8-byte alignment with ".p2align 3, 0", and each list always has
at least one ".long 0" at the end of it (even if it's completely
empty). As a result, they can have NULLs that need to be skipped.
The sections they're in are mergeable, so the NULLs don't have to be
exclusively at the end.
- The ia64 and mips64el arches have not been tested.
Signed-off-by: Peter Jones <pjones@redhat.com>
This is ascii order but with upper and lower case letters mixed, so
things like 'X' and 'x' that use fallthrough still stay together.
Signed-off-by: Peter Jones <pjones@redhat.com>
Coverity added a new kind of check, and it noticed some minor errors
with some types in two of the apps here, both of the same form:
1. gnu-efi-3.0.6/apps/lfbgrid.c:91: overflow_before_widen: Potentially
overflowing expression "info->VerticalResolution *
info->PixelsPerScanLine" with type "unsigned int" (32 bits, unsigned) is
evaluated using 32-bit arithmetic, and then used in a context that
expects an expression of type "UINTN" (64 bits, unsigned).
1. gnu-efi-3.0.6/apps/bltgrid.c:67: overflow_before_widen: Potentially
overflowing expression "info->VerticalResolution *
info->HorizontalResolution" with type "unsigned int" (32 bits, unsigned)
is evaluated using 32-bit arithmetic, and then used in a context that
expects an expression of type "UINTN" (64 bits, unsigned).
This resolves both issues.
Signed-off-by: Peter Jones <pjones@redhat.com>
The whole gnu-efi project is licensed under BSD license, see [1].
However some of the RISC-V codes have conflict license identifiers:
- Some mention GPL-2.0+ in the SPDX license part, but the long license
header indicates it's actually BSD and GPL-2.0+ dual-licensed
- Some mention GPL-2.0+ in the SPDX license part only
- Some do not have any license indication
To have a matching license with the whole project, this commit updates
all RISC-V codes to have the correct SPDX license identifiers
(GPL-2.0+ or BSD dual-license).
Link: https://sourceforge.net/p/gnu-efi/ [1]
Signed-off-by: Bin Meng <bmeng@tinylab.org>
Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Create a new directory called $APPSDIR
which is the default install location of
these examples. apps must be ordered after
gnuefi target.
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
When using function/data sections option from
gcc, some additional un-packed sections get created
move these to there correct placement if not already
included
sections seen on x86/x86_64/aarch64:
.gcc_except_table.efi_main
.bss.debugging
.gcc_except_table.* only appears on objcopy archs
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Objcopy sometimes generates .rela.plt and .rela.data
sections for which their names are longer than the 8
characters limit of PE32
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Date: Tue Feb 7 21:48:27 2023 +0000
ARM32/x86_64 lds: Force data segment align to 4KiB
Some newer versions of binutils can set invalid COMMONPAGESIZE
and MAXPAGESIZE values on these architectures
git fetch git.code.sf.net/u/gmbr3/gnu-efi arm-pagesize
git merge 89d55b364d
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Some newer versions of binutils can set invalid COMMONPAGESIZE
and MAXPAGESIZE values on these architectures
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Binutils 2.38 now supports efi-app-aarch64 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: Callum Farmer <gmbr3@opensuse.org>
Use ld commands DATA_SEGMENT_ALIGN and DATA_SEGMENT_END
Fixes binutils 2.39 warning:
/usr/bin/ld: warning: efi/fwup.so has a LOAD segment with RWX
permissions
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
The current ld script places .dynamic section right after .text, which
results in that one LOAD segment contains both data and code. Binutils
2.39 and later will throw a warning if RWX segments exist. Code and
data should be placed in different LOAD segments with different
permissions. This patch adds a gap between data and code sections which
is taken from the default ld script in riscv64.
Co-developed-by: Moody Liu <mooodyhunter@outlook.com>
Signed-off-by: Moody Liu <mooodyhunter@outlook.com>
Signed-off-by: Letu Ren <fantasquex@gmail.com>
According to README.gnuefi,
To build the sample EFI applications provided in subdirectory "apps",
simply invoke "make" in the toplevel directory (the directory
containing this README file). This should build lib/libefi.a and
gnuefi/libgnuefi.a first and then all the EFI applications such as a
apps/t6.efi.
The default target of top directory Makefile should be all instead of
gnuefi.
Signed-off-by: Letu Ren <fantasquex@gmail.com>