Commit Graph

54 Commits

Author SHA1 Message Date
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 939dffb06f
Allow forcefully ignoring glibc headers on Linux
* Sometimes it may not be available so allow use of the substitute version

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-28 15:43:32 +01:00
Callum Farmer 644e03821e
Tune for new MacOS toolchains
* Doesn't seem to like nocombreloc
* i686 doesn't have the efi-app-ia32 target (bug in binutils??)
* Set float manually on ARM32 due to generic toolchain
* Ensure _DYNAMIC symbol exists

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-16 14:49:52 +01:00
Callum Farmer 8f5c321507
Better detect the correct MacOS toolchain
* We need ELF not Mach-O

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-16 14:49:52 +01:00
Callum Farmer 16a913e01c
Disable norelro on macOS
The no platform GNU ELF linker rejects it

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-14 18:50:40 +01:00
Callum Farmer b6f99c7ac5
Add substitute elf.h for macOS
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-14 18:50:39 +01:00
Callum Farmer f77e4e8a8e
Force DWARF 4 on LLVM
Otherwise readelf just throws an absolute blowup :(

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:44:01 +01:00
Callum Farmer 21f87c2b1e
Fixup riscv64 objcopy move
Detect new enough objcopy

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:44:01 +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 c03d395571
Disable uninitialized error on GCC
Gives error on 'Red' in bltgrid.c which is initialized
by the looks of it?

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-07-04 15:29:04 +01:00
Callum Farmer ce1ec9d27b
Make CHAR8 use unsigned char
* Means we don't have to switch the implementation of char to unsigned char
* Matches the underlying type of char8_t from C++20

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-06-24 19:34:51 +01:00
Callum Farmer edfda7c396
Make CHAR16 use uint16_t
musl-libc doesn't like fshort-wchar so remove wchar_t usage
Use uint16_t as char16_t can be up to 32bits
Fixes ncroxon/gnu-efi#16

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-06-24 19:34:18 +01:00
Pete Batard 2d6d426b8c
Enable silent rules for compiler output
This is similar to using automake's silent rules and, just as with automake,
can be disabled by invoking 'make V=1'.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-21 11:45:20 +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 b74c52f8ba
Fix detection of Ubuntu/MinGW version
For downright incomprehensible reasons the Ubuntu/MinGW folks have decided that MinGW on
Ubuntu should no longer report the compiler's version as '<major>.<minor>', but instead as
'<major>-win32', which of course breaks any script that attempts to read version numbers.

This results in MinGW compilation of gnu-efi on Ubuntu producing the error:
  /bin/sh: 1: [: Illegal number: 10-win32

Fix this by replacing any '-win32' in the -dumpversion report with '.0' so that we get an
approximate version number back again.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-09 12:58:00 +01:00
Pete Batard 399313e148
Allow UEFI shorthands to be specified for the arch
The UEFI shorthands, as used in /efi/boot/boot###.efi, can now be used to specify the arch.
This basically adds 'x64' and 'mips64' as valid arch specifiers.

Signed-off-by: Pete Batard <pete@akeo.ie>
2024-05-09 12:54:49 +01:00
Callum Farmer a0111e0df1
Disable RELRO
No point having PT_GNU_RELRO as ELF data won't exist when merging into PE32+ file

Unbreaks lld usage which complains about linker script
Fixes ncroxon/gnu-efi#4
2024-04-24 12:04:48 +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
Xiaotian Wu feedeaa339 Make loongarch64 use efi-app-loongarch64
Binutils 2.41 now supports efi-app-loongarch64, 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: Xiaotian Wu <wuxiaotian@loongson.cn>
2024-03-22 10:24:23 -04:00
Callum Farmer fb58e92621 ARM32: Only use 4K pages
Turns out some linkers have set page size to 64K on ARM32 aswell
so apply the same fix as ARM64

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:24:19 -04:00
Nigel Croxon 3b137d634d remove superfluous -fno-stack-check
Signed-off-by: David Müller <d.mueller@elsoft.ch>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2024-03-22 10:23:50 -04:00
Callum Farmer bbb501833d X86_64: fix clang
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:06:43 -04:00
Callum Farmer 486b1c20c1 Enforce nocombreloc
It is needed to avoid ELF reloc (rela) issues and
to find un-merged reloc sections

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-04 13:59:02 +01:00
Callum Farmer 9b1e06cd0c Use -std instead of --std
--std isn't standardised. lol.

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-04 13:59:02 +01:00
b'Nigel Croxon d9275e2a70 Merge /u/gmbr3/gnu-efi/ branch unsigned-char into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/47/
2023-04-17 11:38:06 +00:00
b'Nigel Croxon e0e1f53ce2 Merge /u/gmbr3/gnu-efi/ branch pkgconf2 into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/45/
2023-04-17 11:36:22 +00:00
Callum Farmer e398748032 ISO-Latin-1 requires unsigned char
It has characters from 0 to 256 so this requires
an unsigned 8 bit value

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-04-08 19:16:26 +01:00
Callum Farmer 63a9a4d4c0 Add pkgconfig file
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>
2023-04-07 13:51:28 +01:00
Peter Jones 98ef7f9f5f 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>
2023-04-04 09:28:42 -04:00
Peter Jones 4ee8cf5610 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>
2023-04-04 09:28:42 -04:00
Peter Jones b9c4b23d90 CFLAGS: add -Wno-pointer-sign
Signed-off-by: Peter Jones <pjones@redhat.com>
2023-03-28 08:39:19 -04:00
Peter Jones 368cdf1265 Switch to -fPIE
Signed-off-by: Peter Jones <pjones@redhat.com>
2023-03-28 08:38:58 -04:00
Nigel Croxon 637b3bdb9b Author: 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>
2023-02-08 09:25:01 -05:00
Callum Farmer 04e6df709d Make.defaults: Force 4K page size on ARM64
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-02-07 21:18:41 +00:00
Callum Farmer a90c2f16fa Make.defaults: Enable objcopy on aarch64
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-02-07 16:38:05 +00:00
zhoumingtao e7db4418b1 Add support for LoongArch64 architecture 2021-12-30 15:39:47 +08: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
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
Peter Jones 656e495d51 Call ar in deterministic mode.
We need the x86_64 and i686 builds of .a's to be the same, and that
means we need to not have timestamps.  Also force the timestamps on disk
just in case that doesn't work, because RHEL's ar /silently ignores -D/.

v2: use "ar rvD" not "ar rv -D".

It's a wonder anybody ever gets these command line options right, if
"ar rv -D libfoo.a foo.o" doesn't use deterministic mode (or
complain), but "ar rvD libfoo.a foo.o" does.

v3: Add a bunch of junk to try to set timestamps to 0 manually

For some reason I'm still getting timestamps in the .a even though ar seems to
be invoked correctly.  When I do "mock -r rhel-7-build --shell" and run make
manually, they're fine.  Very strange.

v4: go back to v2, the problem isn't in the make process.

"ar rDv" works just fine, but /usr/lib/rpm/redhat/brp-strip-static-archive is
calling "%{__strip} -g $for_each.a", and it's rewriting our binary from
ts/uid/gid of 0/0/0 to $epoch/$UID/$GID.  Awesomely /usr/bin/strip it seems to
have 3 modes of operation:
-U: the default, which adds $epoch/$UID/$GID to your binary archive
    instead of just removing stuff.  Clearly the Principle of Least
    Surprise is strong here.
-p: preserve the timestamp from the original .a, but add UID and GID,
    because this is 1980 and people use ar(1) for archiving stuff they
    might want that out of.
-D: Condescend at you in a command line error and explain that -D both
    is and is not a valid option:
      /usr/bin/strip: invalid option -- 'D'
      Usage: /usr/bin/strip <option(s)> in-file(s)
      Removes symbols and sections from files
      The options are:
      ...
      -D --enable-deterministic-archives
                  Produce deterministic output when stripping archives
    So I agree that it's invalid, but I think we may be pronouncing that
    second vowel differently.  They say in-VAL-id, I say IN-vuh-lid.

Nobody should ever have to run "strace -ttt -v -f -o make.strace make all",
just to discover the problem isn't even in there.

Related: rhbz#1310782

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 be57aadba6 Nerf -Werror=pragma away
Nerf -Werror=-pragma away

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 2c624c22fe Make ARCH overrideable on the command line
Make ARCH overrideable on the command line.

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 f0bf464a37 make clang not complain about -fno-merge-all-constants
Make clang not complain about -fno-merge-all-constants

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 5fa13d4609 Fix arm build paths in the makefile
Previous work was apparently done with arm-linux-gnueabi-gcc as a
cross-builder, but our armv7 builders have native gcc with the target as
armv7hl-linux-gnueabi, so we need to munge the arch there to get our arm
path.

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 99d94682de [PATCH] Disable AVX instruction set on IA32 and x86_64 platforms
If gnu-efi is compiled with "-march=native" on a host that supports AVX, both
gcc and clang will use AVX instructions freely which is currently not supported
and will result in a non-functional gnu-efi build (e.g. black screen, hangs).

For now, disable AVX on IA32 and x86_64 by checking first if the compiler does
actually support the appropriate flag (-mno-avx) and use it if possible.

Credit for the compiler command line to check if a flag is supported goes to
Gentoo's awesome flag-o-matic eclass, where it is taken from. Thanks.

Signed-off-by: Matthias Dahl <matthias.dahl@binary-island.eu>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-07-13 08:43:16 -04: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 3f234f5b6f Add support for 64 bit MIPS
This is a patch to add support for 64-bit MIPS.

Signed-off-by: Hev heiher <heiher@users.sf.net>
Signed-off-by: Nigel Croxon <noxorc@mac.com>
2017-01-08 07:04:52 -05:00
Nigel Croxon bd38ba4b6b GNU ar warning about deterministic mode
GNU ar currently produces the following string of warnings:
Warning: Archive 'libefi.a' seems to have been created in
deterministic mode.
'<file>.o' will always be updated. Please consider passing
the U flag to ar to avoid the problem. This patch fixes the issue.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <noxorc@users.sf.net>
2016-11-21 10:59:13 -05:00
Nigel Croxon b2c4db065f I did a quick review of the MS x86_64 calling convention for floating
point and as far as I can tell it agrees with the UEFI spec.
The attached patch removes -mno-mmx and -mno-sse for x86_64 and adds
a new Print target, "%f", to print float and double types.

It seems to compile for ia32, although I'm not sure why - shouldn't
it be throwing errors because the new function FloatToStr() in print.c
accepts a float, yet I left -no-sse for ARCH=ia32? A better solution
might be to add -msoft-float for targets where the floating point
calling convention doesn't match the UEFI spec. As I'm not familiar
with UEFI on ia32, I didn't make any changes to it.

Signed-off-by: Nathan Blythe <nblythe@lgsinnovations.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-06-17 10:07:25 -04:00
Nigel Croxon 50b883773f -fpic is not needed for MinGW, and MinGW32 issues a warning as a
result, which breaks gnu-efi compilation due to -Werror:
gnu-efi/lib/boxdraw.c:1:0: error: -fpic ignored for target
(all code is position independent) [-Werror]

This patch ensures that -fpic is disabled when MinGW is used.

Signed-off-by: Pete Batard <pbatard@users.sf.net>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-03-29 10:16:21 -04:00