public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: sys-boot/gnu-efi/files/, sys-boot/gnu-efi/
@ 2018-01-28 22:59 Sergei Trofimovich
  0 siblings, 0 replies; 2+ messages in thread
From: Sergei Trofimovich @ 2018-01-28 22:59 UTC (permalink / raw
  To: gentoo-commits

commit:     c62fc5c0068b7cf27a79700cf9f0e7f20a625641
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 28 22:54:24 2018 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sun Jan 28 22:58:41 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c62fc5c0

sys-boot/gnu-efi: fix linker script on .gnu.hash systems, bug #575300

Two patches here:
- gnu-hash.patch: fix linker script to work on .gnu.hash-only systems
- ia64-setjmp.patch: fix build breakage on ia64 systems

Reported-by: Émeric Maschino
Closes: https://bugs.gentoo.org/575300
Package-Manager: Portage-2.3.20, Repoman-2.3.6

 .../files/gnu-efi-3.0.6-ia64-gnu-hash.patch        | 149 +++++++++++++++++++
 .../gnu-efi/files/gnu-efi-3.0.6-ia64-setjmp.patch  | 163 +++++++++++++++++++++
 sys-boot/gnu-efi/gnu-efi-3.0.6-r2.ebuild           |  93 ++++++++++++
 3 files changed, 405 insertions(+)

diff --git a/sys-boot/gnu-efi/files/gnu-efi-3.0.6-ia64-gnu-hash.patch b/sys-boot/gnu-efi/files/gnu-efi-3.0.6-ia64-gnu-hash.patch
new file mode 100644
index 00000000000..9487ba4c673
--- /dev/null
+++ b/sys-boot/gnu-efi/files/gnu-efi-3.0.6-ia64-gnu-hash.patch
@@ -0,0 +1,149 @@
+https://sourceforge.net/p/gnu-efi/code/merge-requests/1/
+
+From 2cc0b085fb82e80d43cc08c8376dff9f9532a72d Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sat, 27 Jan 2018 20:29:05 +0000
+Subject: [PATCH] gnuefi: preserve .gnu.hash sections (unbreaks elilo on IA-64)
+
+Gentoo has slightly modified linker defaults: --hash-style=gnu
+This means all ELF files in system have '.gnu.hash' section
+but no '.hash' section.
+
+gnuefi's ldscript did not account for it and as a result
+one symbol 'ImageBase' did not resolve locally for elilo.so
+and caused 'elilo' to fail to load by ia64 EFI:
+  Loading.: Gentoo (try new elilo)
+  ImageAddress: pointer is outside of image
+  ImageAddress: pointer is outside of image
+
+Those two relocations come from crt0-efi-ia64.S PE32 entry point
+fdescr:
+
+```
+    #define IMAGE_REL_BASED_DIR64<->10
+    .section .reloc, "a"
+    data4   _start_plabel // Page RVA
+    data4   12            // Block Size (2*4+2*2)
+    data2   (IMAGE_REL_BASED_DIR64<<12) +  0 // reloc for plabel's entry point
+    data2   (IMAGE_REL_BASED_DIR64<<12) +  8 // reloc for plabel's global pointer
+```
+
+These refer ImageBase.
+
+The change adds '.gnu.hash' collection (follows existing '.hash'
+collection).
+
+Tested on IA-64 by successfully booting elilo-3.16.
+
+Bug: https://bugs.gentoo.org/575300
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+---
+ README.gnuefi                  | 8 +++++++-
+ gnuefi/elf_ia32_efi.lds        | 4 +++-
+ gnuefi/elf_ia32_fbsd_efi.lds   | 4 +++-
+ gnuefi/elf_ia64_efi.lds        | 4 +++-
+ gnuefi/elf_x86_64_efi.lds      | 4 +++-
+ gnuefi/elf_x86_64_fbsd_efi.lds | 4 +++-
+ 6 files changed, 22 insertions(+), 6 deletions(-)
+
+diff --git a/README.gnuefi b/README.gnuefi
+index a7feec0..512698c 100644
+--- a/README.gnuefi
++++ b/README.gnuefi
+@@ -231,11 +231,17 @@ and page sized.These eight sections are used to group together the much
+ greater number of sections that are typically present in ELF object files.
+ Specifically:
+ 
+- .hash
++ .hash (and/or .gnu.hash)
+ 	Collects the ELF .hash info (this section _must_ be the first
+ 	section in order to build a shared object file; the section is
+ 	not actually loaded or used at runtime).
+ 
++	GNU binutils provides a mechanism to generate different hash info
++	via --hash-style=<sysv|gnu|both> option. In this case output
++	shared object will contain .hash section, .gnu.hash section or
++	both. In order to generate correct output linker script preserves
++	both types of hash sections.
++
+  .text
+ 	Collects all sections containing executable code.
+ 
+diff --git a/gnuefi/elf_ia32_efi.lds b/gnuefi/elf_ia32_efi.lds
+index 6cc4ce1..f27fe5f 100644
+--- a/gnuefi/elf_ia32_efi.lds
++++ b/gnuefi/elf_ia32_efi.lds
+@@ -5,7 +5,9 @@ SECTIONS
+ {
+   . = 0;
+   ImageBase = .;
+-  .hash : { *(.hash) }	/* this MUST come first! */
++  /* .hash and/or .gnu.hash MUST come first! */
++  .hash : { *(.hash) }
++  .gnu.hash : { *(.gnu.hash) }
+   . = ALIGN(4096);
+   .text :
+   {
+diff --git a/gnuefi/elf_ia32_fbsd_efi.lds b/gnuefi/elf_ia32_fbsd_efi.lds
+index 77d6fad..cd309e2 100644
+--- a/gnuefi/elf_ia32_fbsd_efi.lds
++++ b/gnuefi/elf_ia32_fbsd_efi.lds
+@@ -5,7 +5,9 @@ SECTIONS
+ {
+   . = 0;
+   ImageBase = .;
+-  .hash : { *(.hash) }	/* this MUST come first! */
++  /* .hash and/or .gnu.hash MUST come first! */
++  .hash : { *(.hash) }
++  .gnu.hash : { *(.gnu.hash) }
+   . = ALIGN(4096);
+   .text :
+   {
+diff --git a/gnuefi/elf_ia64_efi.lds b/gnuefi/elf_ia64_efi.lds
+index baca962..190792a 100644
+--- a/gnuefi/elf_ia64_efi.lds
++++ b/gnuefi/elf_ia64_efi.lds
+@@ -5,7 +5,9 @@ SECTIONS
+ {
+   . = 0;
+   ImageBase = .;
+-  .hash : { *(.hash) }	/* this MUST come first! */
++  /* .hash and/or .gnu.hash MUST come first! */
++  .hash : { *(.hash) }
++  .gnu.hash : { *(.gnu.hash) }
+   . = ALIGN(4096);
+   .text :
+   {
+diff --git a/gnuefi/elf_x86_64_efi.lds b/gnuefi/elf_x86_64_efi.lds
+index 942d1f3..7be5902 100644
+--- a/gnuefi/elf_x86_64_efi.lds
++++ b/gnuefi/elf_x86_64_efi.lds
+@@ -6,7 +6,9 @@ SECTIONS
+ {
+   . = 0;
+   ImageBase = .;
+-  .hash : { *(.hash) }	/* this MUST come first! */
++  /* .hash and/or .gnu.hash MUST come first! */
++  .hash : { *(.hash) }
++  .gnu.hash : { *(.gnu.hash) }
+   . = ALIGN(4096);
+   .eh_frame : 
+   { 
+diff --git a/gnuefi/elf_x86_64_fbsd_efi.lds b/gnuefi/elf_x86_64_fbsd_efi.lds
+index 6fd2031..fe1f334 100644
+--- a/gnuefi/elf_x86_64_fbsd_efi.lds
++++ b/gnuefi/elf_x86_64_fbsd_efi.lds
+@@ -6,7 +6,9 @@ SECTIONS
+ {
+   . = 0;
+   ImageBase = .;
+-  .hash : { *(.hash) }	/* this MUST come first! */
++  /* .hash and/or .gnu.hash MUST come first! */
++  .hash : { *(.hash) }
++  .gnu.hash : { *(.gnu.hash) }
+   . = ALIGN(4096);
+   .eh_frame : 
+   { 
+-- 
+2.16.1
+

diff --git a/sys-boot/gnu-efi/files/gnu-efi-3.0.6-ia64-setjmp.patch b/sys-boot/gnu-efi/files/gnu-efi-3.0.6-ia64-setjmp.patch
new file mode 100644
index 00000000000..b0964426500
--- /dev/null
+++ b/sys-boot/gnu-efi/files/gnu-efi-3.0.6-ia64-setjmp.patch
@@ -0,0 +1,163 @@
+https://sourceforge.net/p/gnu-efi/code/merge-requests/2/
+
+From 0e6995a96b0f5867c8d85fbd251cfbc295a3fc4d Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sun, 28 Jan 2018 16:44:21 +0000
+Subject: [PATCH] gnu-efi: fix lib/ia64/setjmp.S IA-64 build failure
+
+The build failed as:
+  lib/ia64/setjmp.S:171: Error: Unknown opcode `ldf.nt1 f26=[r10],8'
+  lib/ia64/setjmp.S:178: Error: Operand 1 of `ldf.fill.nt1' should be a floating-point register
+
+The change syncs longjmp definition with
+    edk2/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/setjmp.s
+pulling in:
+- branch in the end of function
+- registers used wrong instruction for float restore
+
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+---
+ lib/ia64/setjmp.S | 61 +++++++++++++++++++++++++++----------------------------
+ 1 file changed, 30 insertions(+), 31 deletions(-)
+
+diff --git a/lib/ia64/setjmp.S b/lib/ia64/setjmp.S
+index c806fbc..bbb29d8 100644
+--- a/lib/ia64/setjmp.S
++++ b/lib/ia64/setjmp.S
+@@ -16,11 +16,11 @@ BASIS,
+ 	.globl	setjmp
+ 	.type	setjmp, @function
+ setjmp:
+-	alloc	loc = ar.pfs, 1, 2, 1, 0
++	alloc	loc0 = ar.pfs, 1, 2, 1, 0
+ 	;;
+ 	mov	r14 = ar.unat
+ 	mov	r15 = ar.bsp
+-	add	r10 = 0x10 * 20, in0
++	add	r10 = 0x10*20, in0
+ 	;;
+ 	stf.spill.nta	[in0] = f2, 0x10 
+ 	st8.spill.nta	[r10] = r4, 8
+@@ -98,29 +98,25 @@ setjmp:
+ 
+ 	.globl	longjmp
+ 	.type	longjmp, @function
+-	.regstk
++	.regstk 2, 0, 0, 0
+ longjmp:
+-	add		r10 = 0x10 * 20 + 8*14, in0
+-	movl		r2 = ~(((1<<14) - 1) << 16) | 3)
++	add		r10 = 0x10*20 + 8*14, in0
++	movl		r2  = ~((((1<<14) - 1) << 16) | 3)
+ 	;;
+ 	ld8.nt1		r14 = [r10], -8*2
+ 	mov		r15 = ar.bspstore
+ 	;;
+ 	ld8.nt1		r17 = [r10], -8
+ 	mov		r16 = ar.rsc
+-	cmp.leu		p6 = r14, r15
++	cmp.leu		p6  = r14, r15
+ 	;;
+ 	ld8.nt1		r18 = [r10], -8
+ 	ld8.nt1		r25 = [r10], -8
+-	and		r2 = r16, r2
++	and		r2  = r16, r2
+ 	;;
+-	ldf.fill.nt1	f2 = [in0], 0x10
++	ldf.fill.nt1	f2  = [in0], 0x10
+ 	ld8.nt1		r24 = [r10], -8
+-	mov		b5 = r25
+-	;;
+-	mov		ar.rsc = r2
+-	ld8.nt1		r23 = [r10], -8
+-	mov		b5 = r25
++	mov		b5  = r25
+ 	;;
+ 	mov		ar.rsc = r2
+ 	ld8.nt1		r23 = [r10], -8
+@@ -137,51 +133,51 @@ _skip_flushrs:
+ 	mov		r31 = ar.rnat
+ 	loadrs
+ 	;;
+-	ldf.fill.nt1	f4 = [in0], 0x10
++	ldf.fill.nt1	f4  = [in0], 0x10
+ 	ld8.nt1		r22 = [r10], -8
+-	dep		r2 = -1, r14, 3, 6
++	dep		r2  = -1, r14, 3, 6
+ 	;;
+-	ldf.fill.nt1	f5 = [in0], 0x10
+-	ld8.nt1		f21 = [r10], -8
+-	cmp		p6 = r2, r15
++	ldf.fill.nt1	f5  = [in0], 0x10
++	ld8.nt1		r21 = [r10], -8
++	cmp.ltu		p6  = r2, r15
+ 	;;
+ 	ld8.nt1		r20 = [r10], -0x10
+ (p6)	ld8.nta		r31 = [r2]
+-	mov		b3 = r23
++	mov		b3  = r23
+ 	;;
+ 	ldf.fill.nt1	f16 = [in0], 0x10
+-	ld8.fill.nt1	r7 = [r10], -8
+-	mov		b2 = r22
++	ld8.fill.nt1	r7  = [r10], -8
++	mov		b2  = r22
+ 	;;
+ 	ldf.fill.nt1	f17 = [in0], 0x10
+-	ld8.fill.nt1	r6 = [r10], -8
+-	mov		b1 = r21
++	ld8.fill.nt1	r6  = [r10], -8
++	mov		b1  = r21
+ 	;;
+ 	ldf.fill.nt1	f18 = [in0], 0x10
+-	ld8.fill.nt1	r5 = [r10], -8
+-	mov		b0 = r20
++	ld8.fill.nt1	r5  = [r10], -8
++	mov		b0  = r20
+ 	;;
+ 	ldf.fill.nt1	f19 = [in0], 0x10
+-	ld8.fill.nt1	r4 = [r10], 8*13
++	ld8.fill.nt1	r4  = [r10], 8*13
+ 	;;
+ 	ldf.fill.nt1	f20 = [in0], 0x10
+ 	ld8.nt1		r19 = [r10], 0x10
+ 	;;
+ 	ldf.fill.nt1	f21 = [in0], 0x10
+-	ldf.nt1		f26 = [r10], 8
++	ld8.nt1		r26 = [r10], 8
+ 	mov		ar.pfs = r19
+ 	;;
+ 	ldf.fill.nt1	f22 = [in0], 0x10
+ 	ld8.nt1		r27 = [r10], 8
+-	mov		pr = r26, -1
++	mov		pr  = r26, -1
+ 	;;
+-	ldf.fill.nt1	r23 = [in0], 0x10
++	ldf.fill.nt1	f23 = [in0], 0x10
+ 	ld8.nt1		r28 = [r10], -17*8 - 0x10
+ 	mov		ar.lc = r27
+ 	;;
+ 	ldf.fill.nt1	f24 = [in0], 0x10
+ 	ldf.fill.nt1	f25 = [in0], 0x10
+-	mov		r8 = in1
++	mov		r8  = in1
+ 	;;
+ 	ldf.fill.nt1	f26 = [in0], 0x10
+ 	ldf.fill.nt1	f31 = [r10], -0x10
+@@ -192,9 +188,12 @@ _skip_flushrs:
+ 	ldf.fill.nt1	f28 = [in0]
+ 	ldf.fill.nt1	f29 = [r10], 0x10*3 + 8*4
+ 	;;
+-	ld8.fill.nt1	sp = [r10]
++	ld8.fill.nt1	sp  = [r10]
+ 	mov		ar.unat = r18
+ 	;;
+ 	mov		ar.bspstore = r14
+ 	mov		ar.rnat = r31
+ 	;;
++	invala
++	mov		ar.rsc = r16
++	br.ret.sptk	b0
+-- 
+2.16.1
+

diff --git a/sys-boot/gnu-efi/gnu-efi-3.0.6-r2.ebuild b/sys-boot/gnu-efi/gnu-efi-3.0.6-r2.ebuild
new file mode 100644
index 00000000000..d30fd4771bd
--- /dev/null
+++ b/sys-boot/gnu-efi/gnu-efi-3.0.6-r2.ebuild
@@ -0,0 +1,93 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit flag-o-matic toolchain-funcs
+
+DESCRIPTION="Library for build EFI Applications"
+HOMEPAGE="http://gnu-efi.sourceforge.net/"
+SRC_URI="mirror://sourceforge/gnu-efi/${P}.tar.bz2"
+
+# inc/, lib/ dirs (README.efilib)
+# - BSD-2
+# gnuefi dir:
+# - BSD (3-cluase): crt0-efi-ia32.S
+# - GPL-2+ : setjmp_ia32.S
+LICENSE="GPL-2+ BSD BSD-2"
+SLOT="0"
+KEYWORDS="-* ~amd64 ~arm ~arm64 ~ia64 ~x86"
+IUSE="abi_x86_32 abi_x86_64 -custom-cflags"
+
+DEPEND="sys-apps/pciutils"
+RDEPEND=""
+
+# These objects get run early boot (i.e. not inside of Linux),
+# so doing these QA checks on them doesn't make sense.
+QA_EXECSTACK="usr/*/lib*efi.a:* usr/*/crt*.o"
+RESTRICT="strip"
+
+PATCHES=(
+	"${FILESDIR}"/${P}-ia64-gnu-hash.patch
+	"${FILESDIR}"/${P}-ia64-setjmp.patch
+)
+
+src_prepare() {
+	sed -i -e "s/-Werror//" Make.defaults || die
+	default
+}
+
+efimake() {
+	local arch=
+	case ${CHOST} in
+		arm*) arch=arm ;;
+		aarch64*) arch=aarch64 ;;
+		ia64*) arch=ia64 ;;
+		i?86*) arch=ia32 ;;
+		x86_64*) arch=x86_64 ;;
+		*) die "Unknown CHOST" ;;
+	esac
+
+	local args=(
+		ARCH="${arch}"
+		HOSTCC="${BUILD_CC}"
+		CC="${CC}"
+		AS="${AS}"
+		LD="${LD}"
+		AR="${AR}"
+		PREFIX="${EPREFIX}/usr"
+		LIBDIR='$(PREFIX)'/$(get_libdir)
+	)
+	emake -j1 "${args[@]}" "$@"
+}
+
+src_compile() {
+	tc-export BUILD_CC AR AS CC LD
+
+	if use custom-cflags; then
+		# https://bugs.gentoo.org/607992
+		filter-mfpmath sse
+
+		# https://bugs.gentoo.org/619628
+		append-flags $(test-flags-CC -mno-avx)
+	else
+		unset CFLAGS CPPFLAGS LDFLAGS
+	fi
+
+	if [[ ${CHOST} == x86_64* ]]; then
+		use abi_x86_32 && CHOST=i686 ABI=x86 efimake
+		use abi_x86_64 && efimake
+	else
+		efimake
+	fi
+}
+
+src_install() {
+	if [[ ${CHOST} == x86_64* ]]; then
+		use abi_x86_32 && CHOST=i686 ABI=x86 efimake INSTALLROOT="${D}" install
+		use abi_x86_64 && efimake INSTALLROOT="${D}" install
+	else
+		efimake INSTALLROOT="${D}" install
+	fi
+	einstalldocs
+}


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: sys-boot/gnu-efi/files/, sys-boot/gnu-efi/
@ 2024-11-23  9:48 Viorel Munteanu
  0 siblings, 0 replies; 2+ messages in thread
From: Viorel Munteanu @ 2024-11-23  9:48 UTC (permalink / raw
  To: gentoo-commits

commit:     b9b6b79955981a40ff0b582f6015e9b077fea135
Author:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 23 08:55:18 2024 +0000
Commit:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
CommitDate: Sat Nov 23 09:48:03 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b9b6b799

sys-boot/gnu-efi: add 4.0.0

Signed-off-by: Viorel Munteanu <ceamac <AT> gentoo.org>

 sys-boot/gnu-efi/Manifest                          |   1 +
 .../files/gnu-efi-4.0.0-remove-linux-headers.patch |  14 ++
 sys-boot/gnu-efi/gnu-efi-4.0.0.ebuild              | 144 +++++++++++++++++++++
 3 files changed, 159 insertions(+)

diff --git a/sys-boot/gnu-efi/Manifest b/sys-boot/gnu-efi/Manifest
index eedf75385f78..2947d3d66990 100644
--- a/sys-boot/gnu-efi/Manifest
+++ b/sys-boot/gnu-efi/Manifest
@@ -2,3 +2,4 @@ DIST gnu-efi-3.0.15.tar.bz2 159399 BLAKE2B 0df93d8cacfa1e6d4b7731e32287d4386da93
 DIST gnu-efi-3.0.17.tar.bz2 165568 BLAKE2B 27f8171b411a6a8a138d44d91c7e4e4291aa399562825d51a398913572119482ffeb303d7508ae13eacd2cd10b8f5098405ab16eb56243587efe93235f661285 SHA512 0893ca234272584f889b1ae1c75341a9ceee60acfd32765daa5d704191ba00450536a287b949304c6d055d1bf125cc29e24fc41df8e5230e0da4f9d944876512
 DIST gnu-efi-3.0.18.tar.bz2 167567 BLAKE2B e080fa4c57a281452a6473304871304d1b5c30d42ee728b4c0c084258ed2f6f2099c068ec5841cee81ecf664dd658dee3b94d68324ebaa498cb49cec4f7f7df9 SHA512 39f9fa14b880441a94a04400ff8850efdd9474929e5501dfd05af06e7747b4d0f7cb742ac811c7026cf52d00508efb73018be4d61d63a1211de0cd931cbc473d
 DIST gnu-efi-3.0.19.tar.gz 218588 BLAKE2B 78db87904e644406ce2eb1a0ef0f325e7ad0f004dd56199e319985c5d035b4755d545c1a6bcf749da08c7670132de28a3e53ba059956b841034c6b059e39042b SHA512 78a79f51bd271043edbf534427d8fbba3d8099e831a9643019899453e8363ebd4d43f6e5448cdde31d43a6bdb94ec32e73425138bfb614617b8886df90fc1665
+DIST gnu-efi-4.0.0.tar.gz 228852 BLAKE2B 30a22785b43b586596e9b4cfd281815715529185fbfdb800947ee08a94b3dac80ee13e9f2a8f5cf4acc46b7844cef9e92de97e97801d085249dce3afb2b0fcf0 SHA512 737fda41a45a63ab652f3e8dd5c035bc40dd66e839218c33478fe2ce81346f004b1bed79a5ec29cc282f0d699ad21256e0915482a3fa04b880dea21cae9e2b7f

diff --git a/sys-boot/gnu-efi/files/gnu-efi-4.0.0-remove-linux-headers.patch b/sys-boot/gnu-efi/files/gnu-efi-4.0.0-remove-linux-headers.patch
new file mode 100644
index 000000000000..858200e3010f
--- /dev/null
+++ b/sys-boot/gnu-efi/files/gnu-efi-4.0.0-remove-linux-headers.patch
@@ -0,0 +1,14 @@
+https://bugs.gentoo.org/888829
+
+--- a/apps/Makefile
++++ b/apps/Makefile
+@@ -41,9 +41,7 @@
+ 
+ include $(SRCDIR)/../Make.defaults
+ 
+-LINUX_HEADERS	= /usr/src/sys/build
+ APPSDIR		= $(LIBDIR)/gnuefi/apps
+-CPPFLAGS	+= -D__KERNEL__ -I$(LINUX_HEADERS)/include
+ 
+ ifneq ($(HAVE_EFI_OBJCOPY),)
+ ifeq ($(SYSTEM_HAS_EFI_OBJCOPY),0)

diff --git a/sys-boot/gnu-efi/gnu-efi-4.0.0.ebuild b/sys-boot/gnu-efi/gnu-efi-4.0.0.ebuild
new file mode 100644
index 000000000000..991d495bd8d8
--- /dev/null
+++ b/sys-boot/gnu-efi/gnu-efi-4.0.0.ebuild
@@ -0,0 +1,144 @@
+# Copyright 2004-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit flag-o-matic toolchain-funcs
+
+DESCRIPTION="Library for build EFI Applications"
+HOMEPAGE="https://sourceforge.net/projects/gnu-efi/"
+SRC_URI="https://github.com/ncroxon/gnu-efi/archive/${PV}.tar.gz -> ${P}.tar.gz"
+
+# inc/, lib/ dirs (README.efilib)
+# - BSD-2
+# gnuefi dir:
+# - BSD (3-cluase): crt0-efi-ia32.S
+# - GPL-2+ : setjmp_ia32.S
+LICENSE="GPL-2+ BSD BSD-2"
+SLOT="0"
+KEYWORDS="-* ~amd64 ~arm ~arm64 ~riscv ~x86"
+IUSE="abi_x86_32 abi_x86_64 custom-cflags"
+REQUIRED_USE="
+	amd64? ( || ( abi_x86_32 abi_x86_64 ) )
+	x86? ( || ( abi_x86_32 abi_x86_64 ) )
+"
+
+# for ld.bfd and objcopy
+BDEPEND="sys-devel/binutils"
+
+# These objects get run early boot (i.e. not inside of Linux),
+# so doing these QA checks on them doesn't make sense.
+QA_EXECSTACK="usr/*/lib*efi.a:* usr/*/crt*.o"
+RESTRICT="strip"
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-4.0.0-remove-linux-headers.patch
+)
+
+DOCS="README* SECURITY* docs/*"
+
+check_and_set_objcopy() {
+	if [[ ${MERGE_TYPE} != "binary" ]]; then
+		# bug #931792
+		# llvm-objcopy does not support EFI target, try to use binutils objcopy or fail
+		tc-export OBJCOPY
+		OBJCOPY="${OBJCOPY/llvm-/}"
+		# Test OBJCOPY to see if it supports EFI targets, and return if it does
+		LC_ALL=C "${OBJCOPY}" --help | grep -q '\<pei-' && return 0
+		# If OBJCOPY does not support EFI targets, it is possible that the 'objcopy' on our path is
+		# still LLVM if the 'binutils-plugin' USE flag is set. In this case, we check to see if the
+		# '(prefix)/usr/bin/objcopy' binary is available (it should be, it's a dependency), and if
+		# so, we use the absolute path explicitly.
+		local binutils_objcopy="${EPREFIX}"/usr/bin/"${OBJCOPY}"
+		if [[ -e "${binutils_objcopy}" ]]; then
+			OBJCOPY="${binutils_objcopy}"
+		fi
+		if ! use arm && ! use riscv; then
+			# bug #939338
+			# objcopy does not understand PE/COFF on these arches: arm32, riscv64 and mips64le
+			# gnu-efi containes a workaround
+			LC_ALL=C "${OBJCOPY}" --help | grep -q '\<pei-' || die "${OBJCOPY} (objcopy) does not support EFI target"
+		fi
+	fi
+}
+
+check_compiler() {
+	if [[ ${MERGE_TYPE} != "binary" ]]; then
+		tc-is-gcc || tc-is-clang || die "Unsupported compiler"
+	fi
+}
+
+pkg_pretend() {
+	check_compiler
+}
+
+pkg_setup() {
+	check_compiler
+	check_and_set_objcopy
+}
+
+src_prepare() {
+	default
+	sed -i -e "s/-Werror//" Make.defaults || die
+}
+
+efimake() {
+	local arch=
+	case ${CHOST} in
+		arm*) arch=arm ;;
+		aarch64*) arch=aarch64 ;;
+		ia64*) arch=ia64 ;;
+		i?86*) arch=ia32 ;;
+		riscv64*) arch=riscv64;;
+		x86_64*) arch=x86_64 ;;
+		*) die "Unknown CHOST" ;;
+	esac
+
+	local args=(
+		ARCH="${arch}"
+		HOSTCC="${BUILD_CC}"
+		CC="${CC}"
+		AS="${AS}"
+		LD="${LD}"
+		AR="${AR}"
+		OBJCOPY="${OBJCOPY}"
+		PREFIX="${EPREFIX}/usr"
+		LIBDIR='$(PREFIX)'/$(get_libdir)
+	)
+	emake -j1 "${args[@]}" "$@"
+}
+
+src_compile() {
+	tc-export BUILD_CC AR AS CC LD OBJCOPY
+
+	if ! use custom-cflags; then
+		unset CFLAGS CPPFLAGS LDFLAGS
+	fi
+
+	# work around musl: include first the compiler include dir, then the system one
+	# bug #933080, #938012
+	local CPPINCLUDEDIR
+	if tc-is-gcc; then
+		CPPINCLUDEDIR=$(LC_ALL=C ${CC} -print-search-dirs 2> /dev/null | grep ^install: | cut -f2 -d' ')/include
+	elif tc-is-clang; then
+		CPPINCLUDEDIR=$(LC_ALL=C ${CC} -print-resource-dir 2> /dev/null)/include
+	fi
+	append-cflags "-nostdinc -isystem ${CPPINCLUDEDIR} -isystem ${ESYSROOT}/usr/include"
+
+	if use amd64 || use x86; then
+		use abi_x86_32 && CHOST=i686 ABI=x86 efimake
+		use abi_x86_64 && CHOST=x86_64 ABI=amd64 efimake
+	else
+		efimake
+	fi
+}
+
+src_install() {
+	if use amd64 || use x86; then
+		use abi_x86_32 && CHOST=i686 ABI=x86 efimake INSTALLROOT="${D}" install
+		use abi_x86_64 && CHOST=x86_64 ABI=amd64 efimake INSTALLROOT="${D}" install
+	else
+		efimake INSTALLROOT="${D}" install
+	fi
+	einstalldocs
+}


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-23  9:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-23  9:48 [gentoo-commits] repo/gentoo:master commit in: sys-boot/gnu-efi/files/, sys-boot/gnu-efi/ Viorel Munteanu
  -- strict thread matches above, loose matches on Subject: below --
2018-01-28 22:59 Sergei Trofimovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox