Skip to contentSkip to conversation

binutils : enable x86_64-pep for producing EFI binaries on x86-64

PATCH In review Christopher Clark 3 participants 5 messages Jul 30, 2018 – Aug 6, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 binutils : enable x86_64-pep for producing EFI binaries on x86-64

Add x86_64-pep emulation support to the set enabled for x86_64 targets to enable the linker to produce Portable Executables for EFI binaries.

Enables building the x86-64 EFI variant of the Xen hypervisor for the OpenXT Project.

---
Changes in v6: added required "Upstream-Status" field to patch header.

Changes in v5: Apply a patch to extend the set of emulations for x86-64, instead of supplying the "enable-targets" flag via the recipe.

Reasoning: this looks like the least invasive way to add the needed emulation only when required. It will add the extra support to any builds that have x86-64 target enabled and not modify others.

binutils uses autoconf and the AC_ARG_ENABLE macro for handling the "--enable-targets" option to the generated configure script. It doesn't allow for repeating the parameter with additional arguments to extend the list:
it's a one-shot flag. That seems to be standard practice for autoconf.

binutils source contains config files that map from the target identifiers to lists of emulations to enable. This patch extends some of those lists.

Tested with x86-64 build to produce Xen EFI.

 meta/recipes-devtools/binutils/binutils-2.31.inc   |  1 +
 .../0016-add-i386pep-emulation-for-x86_64.patch    | 41 ++++++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 meta/recipes-devtools/binutils/binutils/0016-add-i386pep-emulation-for-x86_64.patch
meta/recipes-devtools/binutils/binutils-2.31.inc +1 -0
index ec9e9c3..02d5bca 100644
@@ -35,6 +35,7 @@ SRC_URI = "\
      file://0013-fix-the-incorrect-assembling-for-ppc-wait-mnemonic.patch \
      file://0014-Detect-64-bit-MIPS-targets.patch \
      file://0015-sync-with-OE-libtool-changes.patch \
+     file://0016-add-i386pep-emulation-for-x86_64.patch \
 "
 S  = "${WORKDIR}/git"
 
meta/recipes-devtools/binutils/binutils/0016-add-i386pep-emulation-for-x86_64.patch new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

Is just passing --enable-targets=all not an option?

Ross

Quoted 94 lines · Christopher Clark

Add x86_64-pep emulation support to the set enabled for x86_64 targets to enable the linker to produce Portable Executables for EFI binaries.

Enables building the x86-64 EFI variant of the Xen hypervisor for the OpenXT Project.

---
Changes in v6: added required "Upstream-Status" field to patch header.

Changes in v5: Apply a patch to extend the set of emulations for x86-64, instead of supplying the "enable-targets" flag via the recipe.

Reasoning: this looks like the least invasive way to add the needed emulation only when required. It will add the extra support to any builds that have x86-64 target enabled and not modify others.

binutils uses autoconf and the AC_ARG_ENABLE macro for handling the "--enable-targets" option to the generated configure script. It doesn't allow for repeating the parameter with additional arguments to extend the list:
it's a one-shot flag. That seems to be standard practice for autoconf.

binutils source contains config files that map from the target identifiers to lists of emulations to enable. This patch extends some of those lists.

Tested with x86-64 build to produce Xen EFI.

 meta/recipes-devtools/binutils/binutils-2.31.inc   |  1 +
 .../0016-add-i386pep-emulation-for-x86_64.patch    | 41 ++++++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 meta/recipes-devtools/binutils/binutils/0016-add-i386pep-emulation-for-x86_64.patch
meta/recipes-devtools/binutils/binutils-2.31.inc +1 -0
index ec9e9c3..02d5bca 100644
@@ -35,6 +35,7 @@ SRC_URI = "\
      file://0013-fix-the-incorrect-assembling-for-ppc-wait-mnemonic.patch \
      file://0014-Detect-64-bit-MIPS-targets.patch \
      file://0015-sync-with-OE-libtool-changes.patch \
+     file://0016-add-i386pep-emulation-for-x86_64.patch \
 "
 S  = "${WORKDIR}/git"
 
meta/recipes-devtools/binutils/binutils/0016-add-i386pep-emulation-for-x86_64.patch new file +41 -1
new file mode 100644
index 0000000..9f20784
@@ -0,0 +1,41 @@
+binutils : enable x86_64-pep for producing EFI binaries on x86-64
+
+Add x86_64-pep emulation support to the set enabled for x86_64 targets
+to enable the linker to produce Portable Executables for EFI binaries.
+
+Enables building the x86-64 EFI variant of the Xen hypervisor for
+the OpenXT Project.
+
+Signed-off-by: Christopher Clark <[email protected]>
+
+Upstream-Status: Inappropriate [OE configuration specific]
+---
+diff --git a/bfd/config.bfd b/bfd/config.bfd
+index c882421..dc705b6 100644
+--- a/bfd/config.bfd
++++ b/bfd/config.bfd
+@@ -688,7 +688,7 @@ case "${targ}" in
+     ;;
+   x86_64-*-linux-*)
+     targ_defvec=x86_64_elf64_vec
+-    targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec i386_pei_vec x86_64_pei_vec l1om_elf64_vec k1om_elf64_vec"
++    targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec i386_pei_vec x86_64_pei_vec l1om_elf64_vec k1om_elf64_vec x86_64_pe_vec x86_64_pe_be_vec i386_pe_vec"
+     want64=true
+     ;;
+   x86_64-*-nacl*)
+diff --git a/ld/configure.tgt b/ld/configure.tgt
+index a1db7ad..65a984a 100644
+--- a/ld/configure.tgt
++++ b/ld/configure.tgt
+@@ -253,8 +253,9 @@ x86_64-*-linux-gnux32)     targ_emul=elf32_x86_64
+                       tdir_elf_iamcu=`echo ${targ_alias} | sed -e 's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'`
+                       tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'` ;;
+ x86_64-*-linux-*)     targ_emul=elf_x86_64
+-                      targ_extra_emuls="elf32_x86_64 elf_i386 elf_iamcu elf_l1om elf_k1om"
+-                      targ_extra_libpath="elf_i386 elf32_x86_64 elf_l1om elf_k1om"
++                      targ_extra_emuls="elf32_x86_64 elf_i386 elf_iamcu elf_l1om elf_k1om i386pe i386pep"
++                      targ_extra_libpath="elf_i386 elf32_x86_64 elf_l1om elf_k1om i386pep"
++                      targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o"
+                       tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` ;;
+ i[3-7]86-*-redox*)    targ_emul=elf_i386
+                       targ_extra_emuls=elf_x86_64 ;;
--

2.7.4

#2 lore raw
Quoted 11 lines · Ross
Quoted 6 lines · Christopher Clark

Add x86_64-pep emulation support to the set enabled for x86_64 targets to enable the linker to produce Portable Executables for EFI binaries.

Enables building the x86-64 EFI variant of the Xen hypervisor for the OpenXT Project.

Is just passing --enable-targets=all not an option?

It is a possible option, but I prefer not to. Here's why:

This binutils software, and definitely the cross variant that is built, is one that a lot of trust ends up being placed in. It runs on the build servers (typically a privileged environment, eg. on the internal intranet, with access to proprietary source code, sometimes signature keys, shared network storage, etc.) and processes a _lot_ of input data (source code) obtained from third parties.

In addition to that, it then produces the binaries that are run on the target systems.

Since it is difficult to fully audit every version of all of the input, always, it does make sense to take additional care with the tools that process it.

I think it's reasonable, and advisable, to want the default to be to minimize the build for this component, and narrow its functionality to that required to produce executables for the target architecture that the build is for.

Christopher

#3 lore raw
In reply to Burton, Ross

We can and many toolchains do that especially in embedded targets but it will cause more compile time to build binutils and size will grow a lot and since we do not use universal binutils which can be shared across architectures we will not benefit from this although it does mean our binutils will be able to inspect objects of many different kinds weather that’s valuable or not I can’t say much it’s not my usecase at least

Quoted 121 lines · Ross

Is just passing --enable-targets=all not an option?

Ross

Quoted 6 lines · Christopher Clark

Add x86_64-pep emulation support to the set enabled for x86_64 targets to enable the linker to produce Portable Executables for EFI binaries.

Enables building the x86-64 EFI variant of the Xen hypervisor for the OpenXT Project.

Quoted 8 lines

---
Changes in v6: added required "Upstream-Status" field to patch header.

Changes in v5: Apply a patch to extend the set of emulations for x86-64, instead of supplying the "enable-targets" flag via the recipe.

Reasoning: this looks like the least invasive way to add the needed

emulation

Quoted 5 lines

only when required. It will add the extra support to any builds that have x86-64 target enabled and not modify others.

binutils uses autoconf and the AC_ARG_ENABLE macro for handling the "--enable-targets" option to the generated configure script. It doesn't

allow

Quoted 4 lines

for repeating the parameter with additional arguments to extend the list:
it's a one-shot flag. That seems to be standard practice for autoconf.

binutils source contains config files that map from the target

identifiers

Quoted 6 lines

to lists of emulations to enable. This patch extends some of those lists.

Tested with x86-64 build to produce Xen EFI.

 meta/recipes-devtools/binutils/binutils-2.31.inc   |  1 +
 .../0016-add-i386pep-emulation-for-x86_64.patch    | 41

++++++++++++++++++++++

Quoted 2 lines
 2 files changed, 42 insertions(+)
 create mode 100644

meta/recipes-devtools/binutils/binutils/0016-add-i386pep-emulation-for-x86_64.patch

Review

Quoted 2 lines
(quoted diff) +0 -0

b/meta/recipes-devtools/binutils/binutils-2.31.inc

meta/recipes-devtools/binutils/binutils-2.31.inc SRC_URI = "\ · line 35

Quoted 5 lines

index ec9e9c3..02d5bca 100644

meta/recipes-devtools/binutils/binutils-2.31.inc +0 -0
@@ -35,6 +35,7 @@ SRC_URI = "\
 

file://0013-fix-the-incorrect-assembling-for-ppc-wait-mnemonic.patch \

Quoted 7 lines
meta/recipes-devtools/binutils/binutils-2.31.inc +1 -0
      file://0014-Detect-64-bit-MIPS-targets.patch \
      file://0015-sync-with-OE-libtool-changes.patch \
+     file://0016-add-i386pep-emulation-for-x86_64.patch \
 "
 S  = "${WORKDIR}/git"
 

diff --git

a/meta/recipes-devtools/binutils/binutils/0016-add-i386pep-emulation-for-x86_64.patch b/meta/recipes-devtools/binutils/binutils/0016-add-i386pep-emulation-for-x86_64.patch

Quoted 4 lines

new file mode 100644
index 0000000..9f20784
--- /dev/null
+++

b/meta/recipes-devtools/binutils/binutils/0016-add-i386pep-emulation-for-x86_64.patch

Quoted 12 lines
meta/recipes-devtools/binutils/binutils-2.31.inc +11 -0
@@ -0,0 +1,41 @@
+binutils : enable x86_64-pep for producing EFI binaries on x86-64
+
+Add x86_64-pep emulation support to the set enabled for x86_64 targets
+to enable the linker to produce Portable Executables for EFI binaries.
+
+Enables building the x86-64 EFI variant of the Xen hypervisor for
+the OpenXT Project.
+
+Signed-off-by: Christopher Clark <[email protected]>
+
+Upstream-Status: Inappropriate [OE configuration specific]

meta/recipes-devtools/binutils/binutils-2.31.inc line 21

Quoted 10 lines
meta/recipes-devtools/binutils/binutils-2.31.inc +10 -0
+---
+diff --git a/bfd/config.bfd b/bfd/config.bfd
+index c882421..dc705b6 100644
+--- a/bfd/config.bfd
++++ b/bfd/config.bfd
+@@ -688,7 +688,7 @@ case "${targ}" in
+     ;;
+   x86_64-*-linux-*)
+     targ_defvec=x86_64_elf64_vec
+-    targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec

i386_pei_vec x86_64_pei_vec l1om_elf64_vec k1om_elf64_vec"

meta/recipes-devtools/binutils/binutils-2.31.inc line 22

Quoted 1 line
meta/recipes-devtools/binutils/binutils-2.31.inc +1 -0
++    targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec

i386_pei_vec x86_64_pei_vec l1om_elf64_vec k1om_elf64_vec x86_64_pe_vec x86_64_pe_be_vec i386_pe_vec"

meta/recipes-devtools/binutils/binutils-2.31.inc line 31

Quoted 9 lines
meta/recipes-devtools/binutils/binutils-2.31.inc +9 -0
+     want64=true
+     ;;
+   x86_64-*-nacl*)
+diff --git a/ld/configure.tgt b/ld/configure.tgt
+index a1db7ad..65a984a 100644
+--- a/ld/configure.tgt
++++ b/ld/configure.tgt
+@@ -253,8 +253,9 @@ x86_64-*-linux-gnux32)     targ_emul=elf32_x86_64
+                       tdir_elf_iamcu=`echo ${targ_alias} | sed -e

's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'`

meta/recipes-devtools/binutils/binutils-2.31.inc line 32

Quoted 1 line
meta/recipes-devtools/binutils/binutils-2.31.inc +1 -0
+                       tdir_elf_i386=`echo ${targ_alias} | sed -e

's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'` ;;

meta/recipes-devtools/binutils/binutils-2.31.inc line 34

Quoted 2 lines
meta/recipes-devtools/binutils/binutils-2.31.inc +2 -0
+ x86_64-*-linux-*)     targ_emul=elf_x86_64
+-                      targ_extra_emuls="elf32_x86_64 elf_i386

elf_iamcu elf_l1om elf_k1om"

meta/recipes-devtools/binutils/binutils-2.31.inc line 35

Quoted 1 line
meta/recipes-devtools/binutils/binutils-2.31.inc +1 -0
+-                      targ_extra_libpath="elf_i386 elf32_x86_64

elf_l1om elf_k1om"

meta/recipes-devtools/binutils/binutils-2.31.inc line 36

Quoted 1 line
meta/recipes-devtools/binutils/binutils-2.31.inc +1 -0
++                      targ_extra_emuls="elf32_x86_64 elf_i386

elf_iamcu elf_l1om elf_k1om i386pe i386pep"

meta/recipes-devtools/binutils/binutils-2.31.inc line 37

Quoted 1 line
meta/recipes-devtools/binutils/binutils-2.31.inc +1 -0
++                      targ_extra_libpath="elf_i386 elf32_x86_64

elf_l1om elf_k1om i386pep"

meta/recipes-devtools/binutils/binutils-2.31.inc line 39

Quoted 2 lines
meta/recipes-devtools/binutils/binutils-2.31.inc +2 -0
++                      targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o"
+                       tdir_elf_i386=`echo ${targ_alias} | sed -e

's/x86_64/i386/'` ;;

Quoted 5 lines
meta/recipes-devtools/binutils/binutils-2.31.inc +2 -1
+ i[3-7]86-*-redox*)    targ_emul=elf_i386
+                       targ_extra_emuls=elf_x86_64 ;;
--

2.7.4

#4 lore raw

Khem, are you OK with this v6 patch for binutils to add build support for EFI on x86-64?

Christopher

Quoted 136 lines · Khem Raj

We can and many toolchains do that especially in embedded targets but it will cause more compile time to build binutils and size will grow a lot and since we do not use universal binutils which can be shared across architectures we will not benefit from this although it does mean our binutils will be able to inspect objects of many different kinds weather that’s valuable or not I can’t say much it’s not my usecase at least

Quoted 125 lines · Ross

Is just passing --enable-targets=all not an option?

Ross

Quoted 6 lines · Christopher Clark

Add x86_64-pep emulation support to the set enabled for x86_64 targets to enable the linker to produce Portable Executables for EFI binaries.

Enables building the x86-64 EFI variant of the Xen hypervisor for the OpenXT Project.

Quoted 8 lines

---
Changes in v6: added required "Upstream-Status" field to patch header.

Changes in v5: Apply a patch to extend the set of emulations for x86-64, instead of supplying the "enable-targets" flag via the recipe.

Reasoning: this looks like the least invasive way to add the needed

emulation

Quoted 1 line

only when required. It will add the extra support to any builds that

have

Quoted 4 lines

x86-64 target enabled and not modify others.

binutils uses autoconf and the AC_ARG_ENABLE macro for handling the "--enable-targets" option to the generated configure script. It doesn't

allow

Quoted 1 line

for repeating the parameter with additional arguments to extend the

list:

Quoted 3 lines

it's a one-shot flag. That seems to be standard practice for autoconf.

binutils source contains config files that map from the target

identifiers

Quoted 1 line

to lists of emulations to enable. This patch extends some of those

lists.

Quoted 5 lines

Tested with x86-64 build to produce Xen EFI.

 meta/recipes-devtools/binutils/binutils-2.31.inc   |  1 +
 .../0016-add-i386pep-emulation-for-x86_64.patch    | 41

++++++++++++++++++++++

Quoted 2 lines
 2 files changed, 42 insertions(+)
 create mode 100644 meta/recipes-devtools/binutils/binutils/0016-add-

i386pep-emulation-for-x86_64.patch

Review

Quoted 2 lines
(quoted diff) +0 -0

b/meta/recipes-devtools/binutils/binutils-2.31.inc

meta/recipes-devtools/binutils/binutils-2.31.inc SRC_URI = "\ · line 35

Quoted 5 lines

index ec9e9c3..02d5bca 100644

meta/recipes-devtools/binutils/binutils-2.31.inc +0 -0
@@ -35,6 +35,7 @@ SRC_URI = "\
      file://0013-fix-the-incorrect-assembling-for-ppc-wait-mnemonic.patch

\

Review

Quoted 7 lines
meta/recipes-devtools/binutils/binutils-2.31.inc +1 -0
      file://0014-Detect-64-bit-MIPS-targets.patch \
      file://0015-sync-with-OE-libtool-changes.patch \
+     file://0016-add-i386pep-emulation-for-x86_64.patch \
 "
 S  = "${WORKDIR}/git"
 
(quoted diff) +0 -0

i386pep-emulation-for-x86_64.patch b/meta/recipes-devtools/ binutils/binutils/0016-add-i386pep-emulation-for-x86_64.patch

meta/recipes-devtools/binutils/binutils/0016-add-

Quoted 4 lines

new file mode 100644
index 0000000..9f20784

meta/recipes-devtools/binutils/binutils/0016-add- new file +0 -0

i386pep-emulation-for-x86_64.patch

Quoted 12 lines
meta/recipes-devtools/binutils/binutils/0016-add- new file +11 -0
@@ -0,0 +1,41 @@
+binutils : enable x86_64-pep for producing EFI binaries on x86-64
+
+Add x86_64-pep emulation support to the set enabled for x86_64 targets
+to enable the linker to produce Portable Executables for EFI binaries.
+
+Enables building the x86-64 EFI variant of the Xen hypervisor for
+the OpenXT Project.
+
+Signed-off-by: Christopher Clark <[email protected]>
+
+Upstream-Status: Inappropriate [OE configuration specific]

meta/recipes-devtools/binutils/binutils/0016-add- line 21

Quoted 10 lines
meta/recipes-devtools/binutils/binutils/0016-add- new file +10 -0
+---
+diff --git a/bfd/config.bfd b/bfd/config.bfd
+index c882421..dc705b6 100644
+--- a/bfd/config.bfd
++++ b/bfd/config.bfd
+@@ -688,7 +688,7 @@ case "${targ}" in
+     ;;
+   x86_64-*-linux-*)
+     targ_defvec=x86_64_elf64_vec
+-    targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec

i386_pei_vec x86_64_pei_vec l1om_elf64_vec k1om_elf64_vec"

meta/recipes-devtools/binutils/binutils/0016-add- line 22

Quoted 1 line
meta/recipes-devtools/binutils/binutils/0016-add- new file +1 -0
++    targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec

i386_pei_vec x86_64_pei_vec l1om_elf64_vec k1om_elf64_vec x86_64_pe_vec x86_64_pe_be_vec i386_pe_vec"

meta/recipes-devtools/binutils/binutils/0016-add- line 31

Quoted 9 lines
meta/recipes-devtools/binutils/binutils/0016-add- new file +9 -0
+     want64=true
+     ;;
+   x86_64-*-nacl*)
+diff --git a/ld/configure.tgt b/ld/configure.tgt
+index a1db7ad..65a984a 100644
+--- a/ld/configure.tgt
++++ b/ld/configure.tgt
+@@ -253,8 +253,9 @@ x86_64-*-linux-gnux32)     targ_emul=elf32_x86_64
+                       tdir_elf_iamcu=`echo ${targ_alias} | sed -e

's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'`

meta/recipes-devtools/binutils/binutils/0016-add- line 32

Quoted 1 line
meta/recipes-devtools/binutils/binutils/0016-add- new file +1 -0
+                       tdir_elf_i386=`echo ${targ_alias} | sed -e

's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'` ;;

meta/recipes-devtools/binutils/binutils/0016-add- line 34

Quoted 2 lines
meta/recipes-devtools/binutils/binutils/0016-add- new file +2 -0
+ x86_64-*-linux-*)     targ_emul=elf_x86_64
+-                      targ_extra_emuls="elf32_x86_64 elf_i386

elf_iamcu elf_l1om elf_k1om"

meta/recipes-devtools/binutils/binutils/0016-add- line 35

Quoted 1 line
meta/recipes-devtools/binutils/binutils/0016-add- new file +1 -0
+-                      targ_extra_libpath="elf_i386 elf32_x86_64

elf_l1om elf_k1om"

meta/recipes-devtools/binutils/binutils/0016-add- line 36

Quoted 1 line
meta/recipes-devtools/binutils/binutils/0016-add- new file +1 -0
++                      targ_extra_emuls="elf32_x86_64 elf_i386

elf_iamcu elf_l1om elf_k1om i386pe i386pep"

meta/recipes-devtools/binutils/binutils/0016-add- line 37

Quoted 1 line
meta/recipes-devtools/binutils/binutils/0016-add- new file +1 -0
++                      targ_extra_libpath="elf_i386 elf32_x86_64

elf_l1om elf_k1om i386pep"

meta/recipes-devtools/binutils/binutils/0016-add- line 38

Quoted 1 line
meta/recipes-devtools/binutils/binutils/0016-add- new file +1 -0
++                      targ_extra_ofiles="deffilep.o pep-dll.o

pe-dll.o"

meta/recipes-devtools/binutils/binutils/0016-add- line 39

Quoted 1 line
meta/recipes-devtools/binutils/binutils/0016-add- new file +1 -0
+                       tdir_elf_i386=`echo ${targ_alias} | sed -e

's/x86_64/i386/'` ;;

Quoted 5 lines
meta/recipes-devtools/binutils/binutils/0016-add- new file +2 -1
+ i[3-7]86-*-redox*)    targ_emul=elf_i386
+                       targ_extra_emuls=elf_x86_64 ;;
--

2.7.4