Commit graph

242 commits

Author SHA1 Message Date
Peter Jones
193ae1aeac Fix ARCH setting on the cross-compilation cases.
This makes it possible to pass ARCH in correctly when cross compiling.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-21 13:06:19 -04:00
Gary Lin
5e07f70b08 arm and aarch64: calculate the VirtualSize of .sbat separately
Use _sbat_vsize from shim's linker script as the VirtualSize of .sbat.

Signed-off-by: Gary Lin <glin@suse.com>
2021-03-18 22:43:40 -04:00
Peter Jones
e32d8c84a5 arm and aarch64: fix some PE headers.
This fixes the SizeOfImage and SizeOfInitializedData fields on arm and
aa64.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-15 18:34:32 -04:00
Peter Jones
f922aec7d6 Be more forceful about which va_* ABI we get on x86_64.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-11 22:17:46 -05:00
Peter Jones
4444de49c6 arm/aarch64: include .sbat in section headers.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-11 10:09:11 -05:00
Peter Jones
d7e183a351 Don't implement standard string.h functions. 2021-03-09 11:31:12 -05:00
Peter Jones
2f7e898b7b Use libc string function declarations
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-09 09:59:54 -05:00
Peter Jones
9aa86c7526 Honor OPTIMIZATIONS, WARNFLAGS, and WERRFLAGS when built with a sub-make
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 14:52:46 -05:00
Peter Jones
66af5a5b7d Honor CCACHE_DISABLE when built with a sub-make
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 14:52:46 -05:00
Peter Jones
7cfefa0919 Fix strcmpa() and friends and CompareMem() and friends
Back in the past, I re-defined CHAR8 the same way UEFI defined it (on some
platforms, some of the time, in an accidentally compiler-dependent way).

This turns out to have some bad side effects in code written without
thinking about integer promotion :/.  Meanwhile, some issues were
discovered with some of the string comparison functions here.

This patch addresses all of those issue, whichever types you've got.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 13:04:49 -05:00
Peter Jones
4f0643e91f CFLAGS: add -Wno-pointer-sign
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 13:04:49 -05:00
Peter Jones
ca395d9ecd Use CFLAGS with "gcc -print-libgcc-file-name" to get the right one.
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>
2021-03-05 13:04:49 -05:00
Peter Jones
b499899c9c Add EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID. 2021-03-05 13:04:49 -05:00
Peter Jones
deabf8f3d3 Make: make "make DESTDIR=../foo install" work right.
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>
2021-03-05 13:04:49 -05:00
Peter Jones
0f19d03810 Make: make TOPDIR actually work and get rid of unused CDIR
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 13:04:49 -05:00
Peter Jones
bacef83960 Make CHAR8 be *unambiguously* defined the way edk2 does it.
Back in the past, I made CHAR8 and CHAR16 work the way it does in
edk2... well, in some edk2 tree, for some arch, and accidentally
dependent on some compiler-defined types that depend on runtime choices
more than intended.

This patch makes it /always/ the same thing edk2 defines it as, without
depending on __CHAR16_TYPE__ or __WCHAR_TYPE__, and also uses CHAR16
everywhere instead of sometimes using WCHAR.  We still need
-fshort-wchar, of course, for L'' and L"".

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 12:23:00 -05:00
Peter Jones
9fb55dee2b Make our dummy .reloc sections not depend on section order.
Currently on x64 we manually build a dummy .reloc table entry by using a
symbol in .text and subtracting its address from another symbol that's
inside the .reloc section.  On ia32 we just use its location.  In either
case, if the linker puts either section in a location we're not
expecting, the .reloc table winds up having invalid values, and the PE
loader will fail to load the binary.

This changes it to be two symbols that are both in .text, making the
result unrelated to the section order or location.

It's not clear to me that these .reloc entries are actually necessary at
all, but I'm going to leave them in place for now, in case they are.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 12:19:00 -05:00
Peter Jones
832f871bca 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.

It also consolidates our list of arches into an ARCHES variable defined
in Make.defaults

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 12:19:00 -05:00
Peter Jones
71566d5e35 make: Fix shell exit status handling.
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>
2021-03-05 12:19:00 -05:00
Peter Jones
7344b05c67 gitignore: add our build directories.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 12:18:55 -05:00
Peter Jones
9d6666de4a Get rid of unused make-like files from yore.
These files are all edk2-like makefile snippets, and we don't use any of
them for anything.  They've also got DOS line endings and things like
that.

This patch just gets rid of them.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 12:10:50 -05:00
Peter Jones
ca63d4c169 Get rid of some unused junk that has the BSD 4-clause license.
We don't need any of this, and its license is not GPL compatible.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 12:10:50 -05:00
Peter Jones
791842e222 Add stuff that's got weird characters to .gitattributes
Some of these files will be removed in a later patch, but they need to
stay in .gitattributes until after the next release, because they make
patch application break in weird ways.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-05 12:10:50 -05:00
Peter Jones
f81b6b895d 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>
2021-03-05 12:10:50 -05:00
Soop
14aa561f56 Make apps link against the local gnuefi and crt objects 2021-03-05 12:10:50 -05:00
Rick Mark
b3e136f052 Support for building on macOS systems 2021-03-05 12:10:50 -05:00
sgerwk
b0e70341ef make parameter to compile apps + add example output directory 2021-03-05 12:10:50 -05:00
Soop
e696ef2f13 Add elf.h for cross-building without a system libelf installed. 2021-03-05 12:10:50 -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
Kagurazaka Kotori
7cc4f3a20c
Replace Pause() macro with new library function
Key input should be consumed to prevent WaitForKey event from being
always triggered and potential buffer overflow.
This fixes issue #26.

Signed-off-by: Kagurazaka Kotori <kagurazakakotori@gmail.com>
2020-07-22 17:49:07 +08:00
Kagurazaka Kotori
b82e6b6f5b
Add Simple Text Input Ex Protocol support
Signed-off-by: Kagurazaka Kotori <kagurazakakotori@gmail.com>
2020-07-21 16:05:43 +08:00
Nigel Croxon
39137210cb Bump revision to VERSION = 3.0.12 2020-05-11 11:05:20 -04:00
Pete Batard
d857a968f4 Add SMBIOS 3.0 table support
Also fix some small whitespace issues.
2020-05-11 11:03:35 -04:00
Nigel Croxon
9b63de7db6 Re-add back the original symbol, typeo.
Fix breaking code by restoring original typeo in efierr.h
EFI_WARN_UNKOWN_GLYPH definition.

Fixes: commit 5d0d538c25

Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2020-01-16 14:35:56 -05:00
Ben Wolsieffer
44267b59d8 Fix ARCH on ARMv6.
Extends the armv7 ARCH sed expression to work correctly on armv6.

Signed-off-by: Ben Wolsieffer <benwolsieffer@gmail.com>
2019-12-04 11:47:40 -05:00
Alexander von Gluck IV
6685cd0002 efibind: Fix usage of efi headers from C++ code
* __STDC_VERSION__ is undefined when headers are called from C++
  code resulting in not using stdint.h and efibind.h
  "making a guess" on what they are. extern "C" will not define
  __STDC_VERSION__.
* Always leverage stdint.h on C++.
* Honestly, gnu-efi should always use stdint.h, or find a better
  way to detect it. (or platforms without it need to catch up to 2007)
2019-11-27 17:03:49 -06:00
Nigel Croxon
2ab1abfd26 Bump revision to VERSION = 3.0.11 2019-10-28 07:48:52 -04:00
Nigel Croxon
8b2da2c224 Revert "efilink: fix build with gcc 4.8"
Breaks gcc builds with '-nostdinc' flag.

The fix in 1a53d8f88a
(Fix for problem with undeclared intptr_t type), which is also merged
fixes the same problem, without causing breakage.

This reverts commit 6335e5c697.
2019-10-28 07:45:38 -04:00
Nigel Croxon
9b14e7dab0 Bump revision to VERSION = 3.0.10 2019-10-03 12:05:00 -04:00
Nigel Croxon
3e4d5c7990 Merge /u/lslrt/gnu-efi/ branch exclude_efisetjmp into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/8/
2019-05-16 20:31:59 +00: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
leo
238358c6df efiapi.h: fix EventGroup parameter of EFI_CREATE_EVENT_EX prototype
From UEFI specifications, this parameter is a pointer, see
https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
page 148 for reference.

Signed-off-by: leo <leo.sartre@geebol.fr>
2019-05-14 07:44:28 +02:00
Nigel Croxon
230c36c6aa gnuefi/Makefile uses a strange rule to create libgnuefi.a, which only works
because of a "make" builtin rule. This breaks make -r, and it is an
inefficient way to build, at least for multiple files.

I have made a git tree which includes a patch for this problem,
and also forces -r by adding it to MAKEFLAGS:

git://git.zytor.com/users/hpa/gnu-efi.git make-r-fixes

Signed-off-by: H. Peter Anvin <hpa@users.sourceforge.net>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2019-04-02 09:47:24 -04:00
Nigel Croxon
7604ff2629 Merge /u/esben/gnu-efi/ branch intptr-t-fix into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/5/
2019-03-22 18:02:34 +00:00
Nigel Croxon
99c1436dc9 Merge /u/ffontaine35/gnu-efi/ branch master into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/3/
2019-03-22 18:01:07 +00:00
Nigel Croxon
de4e5e4e3b Make.rules incomplete/wrong; make -r failure
Make.rules is not complete; in particular it lacks a %.o: %.S rule.
This happens to work due to the builtin make rule to that effect. but
building with make -r, or building as a sub-make of an environment that
uses make -r (or MAKEFLAGS += -r) causes it to break.

In general, make -r is strongly preferred, and Make.rules seems to have
been created explicitly to support this.

To further complicate things, the rule %.S: %.c causes a completely
incomprehensible error message. This rule is wrong, it should be %.s:
%.c not %.S: %.c.

Finally, the rule %.E: %.c is normally %.i: %.c; .i is the normal
extension for preprocessed C source. The equivalent rule for assembly is
%.s: %.S.

Signed-off-by: H. Peter Anvin <hpa@users.sf.net>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2019-03-15 09:48:10 -04: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