Commit Graph

51 Commits

Author SHA1 Message Date
Callum Farmer
e5b75c4482
Remove unused files
* tpause wasn't included in Makefile and is very basic
(also removed from VS references)
* trivial.S doesn't actually use gnu-efi and wasn't built
* Remove make stuff likely intended for Intel make??

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-09-24 13:28:32 +01:00
Callum Farmer
88f0e1cca8
Update old_ABI test for CompareGuid
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-08-04 19:23:50 +01:00
Callum Farmer
b23462d47c
Add single option to revert to old ABI
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-08-04 19:13:32 +01:00
Callum Farmer
13c46e46a6
Sync FreeBSD
* Always use objcopy -O (--target doesn't make sense)
  and isn't available on freebsd
* No efi-bsdrv target (but has efi-app)(bug in binutils??)
* Sync linker scripts (all features are supported)
* Use clang as HOSTCC (there is no default gcc)

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-08-03 16:21:00 +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
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
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
23c505d548
Merge branch 'master' into Resolve-Conflicts 2024-05-20 15:21:24 +02: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
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
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
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
Pete Batard
130ebd8f04 Fix MSVC sample compilation 2024-05-08 10:51:58 +01: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
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
ba150f34d6 Add test for ctors & dtors with a priority
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-07 16:43:20 +01:00
Peter Jones
4f8b339fac Make ELF constructors and destructors work
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>
2023-03-28 08:59:41 -04:00
Peter Jones
1b94cff100 Fix a minor coverity complaint in some apps
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>
2023-03-28 08:38:37 -04:00
Peter Jones
3d82853ffe lfbgrid: Make pointer size testing not arch name dependent 2023-03-28 07:58:51 -04:00
Callum Farmer
3f9a656929 apps: Fix Makefile install and ordering
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>
2023-03-06 13:36:27 +00:00
b'Nigel Croxon
c2102ae059 Merge /u/mingtaoxt/gnu-efi/ branch master into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/29/
2022-11-16 20:56:17 +00: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
zhoumingtao
e7db4418b1 Add support for LoongArch64 architecture 2021-12-30 15:39:47 +08: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
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
leo
486ba3c3bd Do not include efisetjmp.h on efi.h
People than really want to use efisetjmp implementation can include
the header on their own.

Signed-off-by: leo <leo.sartre@geebol.fr>
2019-05-15 05:32:24 +02:00
Nigel Croxon
5b74db0e15 Redefine jmp_buf to comply with C calling convention.
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2019-03-15 09:32:06 -04:00
Peter Jones
b030bfce35 Add debug helper applications
Add debug helper applications.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2018-03-14 14:50:23 -04:00
Peter Jones
5ec879ace7 apps: Add bltgrid and lfbgrid, and add error checks to modelist
This adds bltgrid and lfbgrid, which draw checkerboards using GOP's
Blt() and linear framebuffer, respectively, and adds some error checks
to modelist.efi.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2018-03-14 14:50:23 -04:00
Peter Jones
25cebcee2a Fix a sign error in the debughook example app
On ISO C90 on i386 4294967294 is a signed integer, and so x can't be
greater (or equal) to that.  Make it an unsigned and choose a better type
for the variable.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2018-03-14 14:50:23 -04:00
Peter Jones
e861bb3861 Work around -Werror=maybe-uninitialized not being very bright.
The compiler doesn't believe the loop always executes at least once,
even though the data in the first array entry doesn't satisfy the exit
condition.  So just initialize the thing to shut it up.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2018-03-14 14:50:23 -04:00
Peter Jones
a46a62b12b Fix some types gcc doesn't like
Most of these come from building on i386 with -Wextra, but they're still
incorrect everywhere else; they just happen to have identical typedefs
at other places, so the compiler doesn't care.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2018-03-14 14:50:22 -04:00
Nigel Croxon
9d0d941591 apps/tcc: tcc marcked ok for non x86-64 archs
Tested on qemu (x86-64 and arm64).

Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-03-10 16:02:03 -05:00
Nigel Croxon
0e808e122a apps/tcc: remove unneeded includes
Signed-off-by: David Decotigny <<ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-03-10 16:00:06 -05:00
Nigel Croxon
049a863e14 Fixed build issue with apps/exit.c
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-17 16:31:39 -05:00
Nigel Croxon
3f8935c3d0 add-Exit - Add Exit() library function which calls BS->Exit()
Signed-off-by: Jonathon Reinhart <jonathon.reinhart@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-17 16:30:28 -05:00
Nigel Croxon
787cb7fcd8 fix clang support.
Tested:
  make all apps + tests apps/ on x86_64
  make CC=clang all apps + tests apps/ on x86_64

Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-17 16:24:26 -05:00
Nigel Croxon
bdb6182f0a don't expect non-x86 compilers to compile x86 asm.
also remove what looks like garbage inside an #if 0 block.

Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-17 16:22:44 -05:00
Nigel Croxon
7b0521df53 remove dead code
Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-17 16:19:16 -05:00
Nigel Croxon
87484730de Restore correct operation of BS driver test
Attaching a patch to fix apps/drv0.efi and apps/drv0_use.efi,
which are both currently not working.

Signed-off-by: David Decotigny <gdaviddecotigny@users.sf.net>
Signed-off-by: Nigel Croxon <noxorc@mac.com>
2017-01-08 06:58:30 -05:00
Nigel Croxon
76206d9ebf This -Wall -Wextra thing actually caught a real bug.
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-03-03 16:55:26 -05:00
Nigel Croxon
fb8f9bfe52 This makes "-Werror=old-style-declaration" work.
Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-03-03 16:27:04 -05:00
Nigel Croxon
11a459ba96 This patch makes the following symbols (relatively) consistent between
all of our linker scripts:

_text
_etext
_text_size
_data
_edata
_data_size

There are various things that are slightly different (positions of
.rela*, .dynamic, and similar in relation to .data), but _text and _data
are now always at the beginning of their respective sections with regard
to how a debuger would reference the debug info, and _etext and _edata
are now always extant and guaranteed to be after any of the respective
kind of data the debugger would look for in that section.

This also adds an application example of how it might be used, and a
makefile target for %.efi.debug which will generate a separate debuginfo
file for that example.

This also enables debugging by default (i.e. -g is in CFLAGS) and adds
.note.gnu.build-id sections to our .so files (i.e. --build-id=sha1 is in
LDFLAGS).

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hp.com>
2015-07-16 12:31:23 -04:00
Nigel Croxon
dae0b4b0b0 Turns out we actually need setjmp in one of gnu-efi's prominent
users, and it seems to make more sense to put it here than in
the application.

All of these are derived from the Tiano code, but I re-wrote the
x86_64 one because we use the ELF psABI calling conventions instead
of the MS ABI calling conventions.  Which is to say you probably
shouldn't setjmp()/longjmp() between functions with EFIAPI (aka
__attribute__((ms_abi))) and those without.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hp.com>
2015-05-14 12:20:51 -04:00