binutils : enable x86_64-pep for producing EFI binaries on x86/x86-64
PATCH v3 1/1 binutils : enable x86_64-pep for producing EFI binaries on x86/x86-64
On x86 and x86_64 architectures, add the x86_64-pep emulation support to the linker to enable production of Portable Executables for EFI binaries.
Enables building the x86-64 EFI variant of the Xen hypervisor.
---
Changes in v3:
* Use overrides rather than a function to add the configure flags.
I've used a construction that should allow other layers to override a single variable to provide different extra targets if needed.
* Only make this change for x86 and x86-64.
The linker flag for x86-64 EFI binaries is known: x86_64-pep. Make this available on both x86-64 and x86, so multiarch is covered.
The linker flag for constructing 32-bit x86 EFI binaries is not known by me, and is not easily discoverable via inspecting the binutils source or queries of the internet. 32-bit x86 UEFI appears to be very uncommon.
* No change for the ARM architectures in this patch.
I have no data on what linker flags are required for EFI on ARM, and again I'm drawing a blank via source inspection and internet query. If additional lines for arm and aarch64 are added later, they will fit well with the structure added by this patch.
The ARM64 build of the Xen hypervisor does not need additional toolchain support for construction an EFI image as its PE/COFF header is coded in assembly.
* Using gmail 'From'/'Author' address as it is preferred for contact. S-o-b address as provided is required for attribution. Unchanged from v2.
meta/recipes-devtools/binutils/binutils.inc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
meta/recipes-devtools/binutils/binutils.inc +6 -1
@@ -74,12 +74,17 @@ EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \ --enable-deterministic-archives \ --enable-plugins \ ${LDGOLD} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}" + ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)} \ + ${ENABLE_EXTRA_TARGETS}" LDGOLD_class-native = "" LDGOLD_class-crosssdk = "" LDGOLD ?= "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default --enable-threads', '--enable-gold --enable-ld=default --enable-threads', d)}" +ARCH_EFI_EMULATION_x86-64 = "x86_64-pep" +ARCH_EFI_EMULATION_x86 = "x86_64-pep" +ENABLE_EXTRA_TARGETS ?= "--enable-targets=${ARCH_EFI_EMULATION}" + # This is necessary due to a bug in the binutils Makefiles # EXTRA_OEMAKE = "configure-build-libiberty all"
Signature · 1 line
2.7.4
LGTM
Quoted 68 lines · Christopher Clark
On x86 and
x86_64architectures, add the x86_64-pep emulation support to the linker to enable production of Portable Executables for EFI binaries.Enables building the x86-64 EFI variant of the Xen hypervisor.
Signed-off-by Christopher Clark <[email protected]>---
Changes in v3:* Use overrides rather than a function to add the configure flags.
I've used a construction that should allow other layers to override a single variable to provide different extra targets if needed.
* Only make this change for x86 and x86-64.
The linker flag for x86-64 EFI binaries is known: x86_64-pep. Make this available on both x86-64 and x86, so multiarch is covered.
The linker flag for constructing 32-bit x86 EFI binaries is not known by me, and is not easily discoverable via inspecting the binutils source or queries of the internet. 32-bit x86 UEFI appears to be very uncommon.
* No change for the ARM architectures in this patch.
I have no data on what linker flags are required for EFI on ARM, and again I'm drawing a blank via source inspection and internet query. If additional lines for arm and aarch64 are added later, they will fit well with the structure added by this patch.
The ARM64 build of the Xen hypervisor does not need additional toolchain support for construction an EFI image as its PE/COFF header is coded in assembly.
* Using gmail 'From'/'Author' address as it is preferred for contact. S-o-b address as provided is required for attribution. Unchanged from v2.
meta/recipes-devtools/binutils/binutils.inc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)meta/recipes-devtools/binutils/binutils.inc +6
-2@@ -74,12 +74,17 @@ EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \ --enable-deterministic-archives \ --enable-plugins \ ${LDGOLD} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}" + ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)} \ + ${ENABLE_EXTRA_TARGETS}" LDGOLD_class-native = "" LDGOLD_class-crosssdk = "" LDGOLD ?= "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default --enable-threads', '--enable-gold --enable-ld=default --enable-threads', d)}" +ARCH_EFI_EMULATION_x86-64 = "x86_64-pep" +ARCH_EFI_EMULATION_x86 = "x86_64-pep" +ENABLE_EXTRA_TARGETS ?= "--enable-targets=${ARCH_EFI_EMULATION}" + # This is necessary due to a bug in the binutils Makefiles # EXTRA_OEMAKE = "configure-build-libiberty all" --2.7.4
Quoted 5 lines · Christopher Clark
meta/recipes-devtools/binutils/binutils.inc +0
-1@@ -74,12 +74,17 @@ EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \ --enable-deterministic-archives \ --enable-plugins \ ${LDGOLD} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
meta/recipes-devtools/binutils/binutils.inc EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \ · line 86
Quoted 10 lines
meta/recipes-devtools/binutils/binutils.inc +5
-0+ ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)} \ + ${ENABLE_EXTRA_TARGETS}" LDGOLD_class-native = "" LDGOLD_class-crosssdk = "" LDGOLD ?= "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default --enable-threads', '--enable-gold --enable-ld=default --enable-threads', d)}" +ARCH_EFI_EMULATION_x86-64 = "x86_64-pep" +ARCH_EFI_EMULATION_x86 = "x86_64-pep" +ENABLE_EXTRA_TARGETS ?= "--enable-targets=${ARCH_EFI_EMULATION}"
Can't believe I didn't spot this when reviewing by hand but:
| checking for archiver @FILE support... configure: error:
--enable-targets option must specify target names or 'all'
Under non-x86, this passes --enable-targets=
Ross
Quoted 24 lines · Ross
meta/recipes-devtools/binutils/binutils.inc EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \ · line 77
Quoted 5 lines · Christopher Clark
meta/recipes-devtools/binutils/binutils.inc +0
-1@@ -74,12 +74,17 @@ EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \ --enable-deterministic-archives \ --enable-plugins \ ${LDGOLD} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch','--enable-64-bit-bfd', '', d)}"
Review EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \ · line 77
Quoted 1 line
(quoted diff) +1
-0+ ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch','--enable-64-bit-bfd', '', d)} \
meta/recipes-devtools/binutils/binutils.inc EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \
Quoted 5 lines
meta/recipes-devtools/binutils/binutils.inc +1
-0+ ${ENABLE_EXTRA_TARGETS}" LDGOLD_class-native = "" LDGOLD_class-crosssdk = "" LDGOLD ?= "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold','--enable-gold=default --enable-threads', '--enable-gold --enable-ld=default --enable-threads', d)}"
meta/recipes-devtools/binutils/binutils.inc EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \ · line 86
Quoted 4 lines
meta/recipes-devtools/binutils/binutils.inc +3
-0+ARCH_EFI_EMULATION_x86-64 = "x86_64-pep" +ARCH_EFI_EMULATION_x86 = "x86_64-pep" +ENABLE_EXTRA_TARGETS ?= "--enable-targets=${ARCH_EFI_EMULATION}"Can't believe I didn't spot this when reviewing by hand but:
Quoted 6 lines
| checking for archiver @FILE support... configure: error:
--enable-targets option must specify target names or 'all'Under non-x86, this passes --enable-targets=
Groan, oops - that makes sense. Will repin with a fix.
thanks
Christopher
Quoted 1 line · Christopher Clark
+ENABLE_EXTRA_TARGETS ?= "--enable-targets=${ARCH_EFI_EMULATION}"
This has an interesting implication in that it's not building support for all targets now, specifically buildhistory-diff shows that large chunks are no longer being built:
--rw-r--r-- root root 15269./usr/src/debug/binutils/2.31-r0/git/elfcpp/mips.h
--rw-r--r-- root root 9539./usr/src/debug/binutils/2.31-r0/git/elfcpp/powerpc.h
--rw-r--r-- root root 5994./usr/src/debug/binutils/2.31-r0/git/elfcpp/s390.h
--rw-r--r-- root root 8243./usr/src/debug/binutils/2.31-r0/git/elfcpp/sparc.h
--rw-r--r-- root root 5654./usr/src/debug/binutils/2.31-r0/git/elfcpp/tilegx.h
--rw-r--r-- root root 329045./usr/src/debug/binutils/2.31-r0/git/gold/powerpc.cc
--rw-r--r-- root root 136896./usr/src/debug/binutils/2.31-r0/git/gold/sparc.cc etc
(that's a diff, so the leading - is a removal marker)
So binutils on x86 only support x86, but binutils for ARM supports all architectures. Inconsistency doesn't seem right. Can we *add* x86_64-pep to the target list? Or can we make all binutils just build their native formats?
Ross