Commit graph

236 commits

Author SHA1 Message Date
Peter Jones
f2b183d7d4 CFLAGS: add -Wno-pointer-sign
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
d8410a74a8 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-09-02 13:47:14 -04:00
Peter Jones
f05d80c0cf Fix the arch subdirs in .gitignore.
Currently they'll exclude e.g. inc/x64/ by accident; this makes it only
apply to the top level.

Also adds vim temp files to the ignore list.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
b5d49caed2 lfbgrid: Make pointer size testing not arch name dependent.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
7d3e816a07 Switch to -fPIE
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
e3119e8a97 Implement Print(L"%p", ptr);
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
deab218bed Semi-asciibetize _Print()'s formatters.
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>
2021-09-02 13:47:14 -04:00
Peter Jones
bcb85a073a Supply makefile templates.
This supplies template makefiles for applications consuming gnu-efi to
use as:

include efi.mk

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
224c1d56d7 Rename our installed .o and linker scripts.
Since crt0 and our linker scripts are now in a subdirectory, there's no
need to make them named differently in the installed machine.  This
renames them to crt0.o and efi.lds .

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
f1e3fc0174 Install all headers for all arches.
This further enables cross-builds by installing all the arches headers.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
b60f503ac2 Install our libraries in $(LIBDIR)/gnuefi/$(ARCH)
This makes it possible to install all the output on the same machine for
cross-builds.  This also adds "install_compat", which uses the previous
paths.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
0874e84f35 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-09-02 13:47:14 -04:00
Peter Jones
5c8b8170cd Make: make TOPDIR actually work and get rid of unused CDIR
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
ecc69d3f55 Make CHAR8 and similar be defined the same way edk2 does it.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
cd1fcf8210 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-09-02 13:47:14 -04:00
Peter Jones
3be3bf05aa 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-09-02 13:47:14 -04:00
Peter Jones
0ccddd751d 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-09-02 13:47:14 -04:00
Peter Jones
9062404f06 gitignore: add our build directories.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
f4d3336a6d Remove the accidental lib/Makefile.orig
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
574f225511 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>
2021-09-02 13:47:14 -04:00
Peter Jones
8de6d921b0 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-09-02 13:47:14 -04:00
Peter Jones
4c8b33b0c2 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-09-02 13:47:14 -04:00
Peter Jones
cf1061931d 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-09-02 13:47:14 -04:00
Peter Jones
226946c5f1 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-09-02 13:47:14 -04:00
Peter Jones
8a4f5c3a1a Use EFI canonical names everywhere the compiler doesn't care.
Always use x64/X64 and aa64/AA64 unless the toolchain cares about
"x86_64" or whatnot.

Note that we still have mips64el as an arch name, which is not actually
defined in the UEFI specs.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Peter Jones
5b5e069876 Add .travis.yml
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-02 13:47:14 -04:00
Soop
aa4fc266e3 Make apps link against the local gnuefi and crt objects 2021-09-02 13:47:14 -04:00
Rick Mark
3557f8b17f Support for building on macOS systems 2021-09-02 13:47:14 -04:00
sgerwk
0bfb651dd5 make parameter to compile apps + add example output directory 2021-09-02 13:47:14 -04:00
Soop
c506a20970 Add elf.h for cross-building without a system libelf installed. 2021-09-02 13:47:14 -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
Esben Haabendal
1a53d8f88a Fix for problem with undeclared intptr_t type
When building gnu-efi with old compilers with pre C90 compilers:

In file included from gnu-efi-3.0.9/lib/../inc/efilib.h:25:0,
                 from gnu-efi-3.0.9/lib/lib.h:24,
                 from gnu-efi-3.0.9/lib/dpath.c:25:
gnu-efi-3.0.9/lib/dpath.c: In function 'FileDevicePath':
gnu-efi-3.0.9/lib/../inc/efilink.h:145:47: error: 'intptr_t' undeclared (first use in this function)
 #define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(intptr_t)(&(((TYPE *) 0)->Field)))

Problem introduced with commit a46a62b12b
(Fix some types gcc doesn't like).

Avoid this by adding intptr_t (and uintptr_t) typedefs for builds that does
not include stdint.h.

Signed-off-by: Esben Haabendal <esben@esben1.localdomain>
2019-03-15 12:09:50 +01:00
Fabrice Fontaine
6335e5c697 efilink: fix build with gcc 4.8
intptr_t is undefined without an include on stdint.h

Fixes:
 - http://autobuild.buildroot.org/results/a0ca37b5ed27af445344e3ac49dc87bb17512c50

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2019-01-18 22:12:38 +01:00
Nigel Croxon
d34132e62f * Fixed typeo lib/error.c EFI_WARN_UNKNOWN_GLYPH definition.
On couple of locations in runtime string library (rtstr.c)
there are calls to non-runtime variant of StrLen function.
* Another issue is with formatting 1394 paths.
The F1394_DEVICE_PATH::Guid is formatted as %g, but 1394
GUID is 8 byte integer, not EFI_GUID and therefore should
be formatted as e.g. %016lx (as edk2 does).
* Beyond what's mentioned above, changed the format of the
harddrive path, so it's in line with edk2 format and spec
(2.7 errata A, chapter 10.6.1.6, table 102).

Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
Signed-off-by: manison <manison@users.sf.net>
2019-01-09 07:03:46 -05:00
Nigel Croxon
5d0d538c25 Fix typeo in efierr.h EFI_WARN_UNKNOWN_GLYPH definition.
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
Signed-off-by: manison <manison@users.sf.net>
2019-01-08 11:19:25 -05:00
Gary Lin
5bb5032fda Set '\0' properly in StrnCpy()
The arguments to SetMem() were wrong. Besides, SetMem() should start at
"Dest + Size" since "Size" will be smaller than "Len" if they are not
equal.

Signed-off-by: Gary Lin <glin@suse.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2018-10-12 08:17:20 -04:00
Nigel Croxon
183ec634ee Bump revision to VERSION = 3.0.9 2018-10-11 08:46:29 -04:00