1

[alpine-aports] [PATCH] testing/binutils-cross-bare-metal: New aport

Marian Buschsieweke
Details
Message ID
<20170919082916.31421-1-marian.buschsieweke@ovgu.de>
Sender timestamp
1505809756
DKIM signature
missing
Download raw message
Patch: +166 -0
Tools necessary to build programs for embedded targets
http://www.gnu.org/software/binutils

This package contains binutils-arm-none-eabi, binutils-arm-avr and
binutils-xtensa-lx106-elf. It is an attempt to create embedded
toolchains for different targets using a single maintainable
APKGBUILD.
---
 testing/binutils-cross-bare-metal/APKBUILD         | 89 ++++++++++++++++++++++
 .../binutils-ld-fix-static-linking.patch           | 46 +++++++++++
 .../binutils-cross-bare-metal/hash-style-gnu.patch | 31 ++++++++
 3 files changed, 166 insertions(+)
 create mode 100644 testing/binutils-cross-bare-metal/APKBUILD
 create mode 100644 testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch
 create mode 100644 testing/binutils-cross-bare-metal/hash-style-gnu.patch

diff --git a/testing/binutils-cross-bare-metal/APKBUILD b/testing/binutils-cross-bare-metal/APKBUILD
new file mode 100644
index 0000000000..3ecad2d212
--- /dev/null
+++ b/testing/binutils-cross-bare-metal/APKBUILD
@@ -0,0 +1,89 @@
+# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
+# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
+# Based on binutils-avr
+_pkgbase=binutils
+_targets="arm-none-eabi avr xtensa-lx106-elf"
+pkgname="$_pkgbase-cross-bare-metal"
+pkgver=2.28
+pkgrel=0
+pkgdesc="Tools necessary to build programs for embedded targets"
+url="http://www.gnu.org/software/${_pkgbase}/"
+makedepends="gettext libtool autoconf automake bison"
+arch="all"
+license="GPL2 GPL3+ LGPL2 BSD"
+for target in $_targets; do
+	targetnorm="${target//-/_}"
+	subpackages="${_pkgbase}-${target}:${targetnorm} ${subpackages}"
+done
+source="http://ftp.gnu.org/gnu/${_pkgbase}/${_pkgbase}-${pkgver}.tar.bz2
+	binutils-ld-fix-static-linking.patch
+	hash-style-gnu.patch"
+
+builddir="$srcdir/${_pkgbase}-$pkgver"
+_workingdir="$srcdir/${_pkgbase}-build"
+
+build() {
+	for target in $_targets; do
+		workingdir="${srcdir}/build-${target}"
+		mkdir "$workingdir"
+		cd "$workingdir"
+		"$builddir"/configure \
+			--build="$CBUILD" \
+			--target=${target} \
+			--with-lib-path=/usr/lib \
+			--prefix=/usr \
+			--enable-ld=default \
+			--enable-gold=yes \
+			--enable-plugins \
+			--disable-multilib \
+			--disable-werror \
+			--disable-nls \
+			|| return 1
+		make tooldir=/usr
+	done
+}
+
+check() {
+	for target in $_targets; do
+		workingdir="${srcdir}/build-${target}"
+		cd "$workingdir"
+		make check
+	done
+}
+
+package() {
+	mkdir -p "${pkgdir}"
+}
+
+install_subpkg() {
+	workingdir="${srcdir}/build-${target}"
+	cd "$workingdir"
+	make tooldir=/usr install DESTDIR="$subpkgdir"
+	rm -rf "$subpkgdir"/usr/share/info
+	rm -rf "$subpkgdir"/usr/share/man
+	for bin in ar as nm objcopy objdump ranlib strip readelf; do
+		rm -f "$subpkgdir"/usr/bin/"$bin"
+	done
+}
+
+arm_none_eabi() {
+	target="${subpkgname#${_pkgbase}-}"
+	pkgdesc="Tools necessary to build programs for platform ${target}"
+	install_subpkg
+}
+
+avr() {
+	target="${subpkgname#${_pkgbase}-}"
+	pkgdesc="Tools necessary to build programs for platform ${target}"
+	install_subpkg
+}
+
+xtensa_lx106_elf() {
+	target="${subpkgname#${_pkgbase}-}"
+	pkgdesc="Tools necessary to build programs for platform ${target}"
+	install_subpkg
+}
+
+sha512sums="ede2e4e59a800260eea8c14eafbaee94e30abadafd5c419a3370f9f62213cf027d6400a1d4970b6958bd4d220e675dcd483a708107016e7abd5c99d7392ba8fd  binutils-2.28.tar.bz2
+ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49  binutils-ld-fix-static-linking.patch
+24e853bf4b58621a77921087e599da2ace47ba3079e2d50fb5d08ae399be5f060c5fdd7f65257bcc0526aebc66e68b98aafd45d714c035da8ea2bdc3d8d4e375  hash-style-gnu.patch"
diff --git a/testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch b/testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch
new file mode 100644
index 0000000000..bc5d762656
--- /dev/null
+++ b/testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch
@@ -0,0 +1,46 @@
+This fixes static linking for our hardened toolchain
+diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
+index e8126cb..9532bfb 100644
+--- a/ld/scripttempl/elf.sc
+@@ -235,8 +235,8 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
+ if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then
+   SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))"
+   SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))"
+-  CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors"
+-  DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors"
++  CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .ctors"
++  DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .dtors"
+ else
+   SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))"
+   SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))"
+@@ -270,15 +270,14 @@ CTOR=".ctors        ${CONSTRUCTING-0} :
+        doesn't matter which directory crtbegin.o
+        is in.  */
+ 
+-    KEEP (*crtbegin.o(.ctors))
+-    KEEP (*crtbegin?.o(.ctors))
++    KEEP (*crtbegin*.o(.ctors))
+ 
+     /* We don't want to include the .ctor section from
+        the crtend.o file until after the sorted ctors.
+        The .ctor section from the crtend file contains the
+        end of ctors marker and it must be last */
+ 
+-    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
++    KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
+     KEEP (*(SORT(.ctors.*)))
+     KEEP (*(.ctors))
+     ${CONSTRUCTING+${CTOR_END}}
+@@ -286,9 +285,8 @@ CTOR=".ctors        ${CONSTRUCTING-0} :
+ DTOR=".dtors        ${CONSTRUCTING-0} :
+   {
+     ${CONSTRUCTING+${DTOR_START}}
+-    KEEP (*crtbegin.o(.dtors))
+-    KEEP (*crtbegin?.o(.dtors))
+-    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
++    KEEP (*crtbegin*.o(.dtors))
++    KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
+     KEEP (*(SORT(.dtors.*)))
+     KEEP (*(.dtors))
+     ${CONSTRUCTING+${DTOR_END}}
diff --git a/testing/binutils-cross-bare-metal/hash-style-gnu.patch b/testing/binutils-cross-bare-metal/hash-style-gnu.patch
new file mode 100644
index 0000000000..2e6c01972e
--- /dev/null
+++ b/testing/binutils-cross-bare-metal/hash-style-gnu.patch
@@ -0,0 +1,31 @@
+# DP: Default to --hash-style=gnu in ld.bfd and ld.gold.
+
+--- a/ld/ldmain.c
+@@ -287,6 +288,15 @@
+   emulation = get_emulation (argc, argv);
+   ldemul_choose_mode (emulation);
+   default_target = ldemul_choose_target (argc, argv);
++
++  /* Default to --hash-style=gnu */
++  if (strcmp (default_target, "elf32-tradbigmips") != 0
++      && strcmp (default_target, "elf32-tradlittlemips") != 0)
++    {
++      link_info.emit_gnu_hash = TRUE;
++      link_info.emit_hash = FALSE;
++    }
++
+   config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
+   config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
+   lang_init ();
+--- a/gold/options.h
+@@ -794,7 +794,7 @@
+ 		N_("Min fraction of empty buckets in dynamic hash"),
+ 		N_("FRACTION"));
+ 
+-  DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "sysv",
++  DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "gnu",
+ 	      N_("Dynamic hash style"), N_("[sysv,gnu,both]"),
+ 	      {"sysv", "gnu", "both"});
+ 
-- 
2.14.1



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---

[alpine-aports] Re: [PATCH] testing/binutils-cross-bare-metal: New aport

Marian Buschsieweke
Details
Message ID
<20170920143008.1184b3c1@notebook-marian>
In-Reply-To
<20170919082916.31421-1-marian.buschsieweke@ovgu.de> (view parent)
Sender timestamp
1505910608
DKIM signature
missing
Download raw message
Hi,

I rejected this patch, because the source was given via FTP. For good reasons,
the FTP source is no longer available and I updated the APKGBUILD accordingly.
Also I removed two flags to configure which I believed to be required, but were
not.

The new APKBUILD can be found at: https://patchwork.alpinelinux.org/patch/3583/

Kind regards,
Marian

On Tue, 19 Sep 2017 10:29:16 +0200
Marian Buschsieweke <marian.buschsieweke@ovgu.de> wrote:

> Tools necessary to build programs for embedded targets
> http://www.gnu.org/software/binutils
> 
> This package contains binutils-arm-none-eabi, binutils-arm-avr and
> binutils-xtensa-lx106-elf. It is an attempt to create embedded
> toolchains for different targets using a single maintainable
> APKGBUILD.
> ---
>  testing/binutils-cross-bare-metal/APKBUILD         | 89 ++++++++++++++++++++++
>  .../binutils-ld-fix-static-linking.patch           | 46 +++++++++++
>  .../binutils-cross-bare-metal/hash-style-gnu.patch | 31 ++++++++
>  3 files changed, 166 insertions(+)
>  create mode 100644 testing/binutils-cross-bare-metal/APKBUILD
>  create mode 100644 testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch
>  create mode 100644 testing/binutils-cross-bare-metal/hash-style-gnu.patch
> 
> diff --git a/testing/binutils-cross-bare-metal/APKBUILD b/testing/binutils-cross-bare-metal/APKBUILD
> new file mode 100644
> index 0000000000..3ecad2d212
> --- /dev/null
> +++ b/testing/binutils-cross-bare-metal/APKBUILD
> @@ -0,0 +1,89 @@
> +# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
> +# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
> +# Based on binutils-avr
> +_pkgbase=binutils
> +_targets="arm-none-eabi avr xtensa-lx106-elf"
> +pkgname="$_pkgbase-cross-bare-metal"
> +pkgver=2.28
> +pkgrel=0
> +pkgdesc="Tools necessary to build programs for embedded targets"
> +url="http://www.gnu.org/software/${_pkgbase}/"
> +makedepends="gettext libtool autoconf automake bison"
> +arch="all"
> +license="GPL2 GPL3+ LGPL2 BSD"
> +for target in $_targets; do
> +	targetnorm="${target//-/_}"
> +	subpackages="${_pkgbase}-${target}:${targetnorm} ${subpackages}"
> +done
> +source="http://ftp.gnu.org/gnu/${_pkgbase}/${_pkgbase}-${pkgver}.tar.bz2
> +	binutils-ld-fix-static-linking.patch
> +	hash-style-gnu.patch"
> +
> +builddir="$srcdir/${_pkgbase}-$pkgver"
> +_workingdir="$srcdir/${_pkgbase}-build"
> +
> +build() {
> +	for target in $_targets; do
> +		workingdir="${srcdir}/build-${target}"
> +		mkdir "$workingdir"
> +		cd "$workingdir"
> +		"$builddir"/configure \
> +			--build="$CBUILD" \
> +			--target=${target} \
> +			--with-lib-path=/usr/lib \
> +			--prefix=/usr \
> +			--enable-ld=default \
> +			--enable-gold=yes \
> +			--enable-plugins \
> +			--disable-multilib \
> +			--disable-werror \
> +			--disable-nls \
> +			|| return 1
> +		make tooldir=/usr
> +	done
> +}
> +
> +check() {
> +	for target in $_targets; do
> +		workingdir="${srcdir}/build-${target}"
> +		cd "$workingdir"
> +		make check
> +	done
> +}
> +
> +package() {
> +	mkdir -p "${pkgdir}"
> +}
> +
> +install_subpkg() {
> +	workingdir="${srcdir}/build-${target}"
> +	cd "$workingdir"
> +	make tooldir=/usr install DESTDIR="$subpkgdir"
> +	rm -rf "$subpkgdir"/usr/share/info
> +	rm -rf "$subpkgdir"/usr/share/man
> +	for bin in ar as nm objcopy objdump ranlib strip readelf; do
> +		rm -f "$subpkgdir"/usr/bin/"$bin"
> +	done
> +}
> +
> +arm_none_eabi() {
> +	target="${subpkgname#${_pkgbase}-}"
> +	pkgdesc="Tools necessary to build programs for platform ${target}"
> +	install_subpkg
> +}
> +
> +avr() {
> +	target="${subpkgname#${_pkgbase}-}"
> +	pkgdesc="Tools necessary to build programs for platform ${target}"
> +	install_subpkg
> +}
> +
> +xtensa_lx106_elf() {
> +	target="${subpkgname#${_pkgbase}-}"
> +	pkgdesc="Tools necessary to build programs for platform ${target}"
> +	install_subpkg
> +}
> +
> +sha512sums="ede2e4e59a800260eea8c14eafbaee94e30abadafd5c419a3370f9f62213cf027d6400a1d4970b6958bd4d220e675dcd483a708107016e7abd5c99d7392ba8fd  binutils-2.28.tar.bz2
> +ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49  binutils-ld-fix-static-linking.patch
> +24e853bf4b58621a77921087e599da2ace47ba3079e2d50fb5d08ae399be5f060c5fdd7f65257bcc0526aebc66e68b98aafd45d714c035da8ea2bdc3d8d4e375  hash-style-gnu.patch"
> diff --git a/testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch b/testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch
> new file mode 100644
> index 0000000000..bc5d762656
> --- /dev/null
> +++ b/testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch
> @@ -0,0 +1,46 @@
> +This fixes static linking for our hardened toolchain
> +diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
> +index e8126cb..9532bfb 100644
> +--- a/ld/scripttempl/elf.sc
> ++++ b/ld/scripttempl/elf.sc
> +@@ -235,8 +235,8 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
> + if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then
> +   SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))"
> +   SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))"
> +-  CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors"
> +-  DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors"
> ++  CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .ctors"
> ++  DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .dtors"
> + else
> +   SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))"
> +   SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))"
> +@@ -270,15 +270,14 @@ CTOR=".ctors        ${CONSTRUCTING-0} :
> +        doesn't matter which directory crtbegin.o
> +        is in.  */
> + 
> +-    KEEP (*crtbegin.o(.ctors))
> +-    KEEP (*crtbegin?.o(.ctors))
> ++    KEEP (*crtbegin*.o(.ctors))
> + 
> +     /* We don't want to include the .ctor section from
> +        the crtend.o file until after the sorted ctors.
> +        The .ctor section from the crtend file contains the
> +        end of ctors marker and it must be last */
> + 
> +-    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
> ++    KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
> +     KEEP (*(SORT(.ctors.*)))
> +     KEEP (*(.ctors))
> +     ${CONSTRUCTING+${CTOR_END}}
> +@@ -286,9 +285,8 @@ CTOR=".ctors        ${CONSTRUCTING-0} :
> + DTOR=".dtors        ${CONSTRUCTING-0} :
> +   {
> +     ${CONSTRUCTING+${DTOR_START}}
> +-    KEEP (*crtbegin.o(.dtors))
> +-    KEEP (*crtbegin?.o(.dtors))
> +-    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
> ++    KEEP (*crtbegin*.o(.dtors))
> ++    KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
> +     KEEP (*(SORT(.dtors.*)))
> +     KEEP (*(.dtors))
> +     ${CONSTRUCTING+${DTOR_END}}
> diff --git a/testing/binutils-cross-bare-metal/hash-style-gnu.patch b/testing/binutils-cross-bare-metal/hash-style-gnu.patch
> new file mode 100644
> index 0000000000..2e6c01972e
> --- /dev/null
> +++ b/testing/binutils-cross-bare-metal/hash-style-gnu.patch
> @@ -0,0 +1,31 @@
> +# DP: Default to --hash-style=gnu in ld.bfd and ld.gold.
> +
> +--- a/ld/ldmain.c
> ++++ b/ld/ldmain.c
> +@@ -287,6 +288,15 @@
> +   emulation = get_emulation (argc, argv);
> +   ldemul_choose_mode (emulation);
> +   default_target = ldemul_choose_target (argc, argv);
> ++
> ++  /* Default to --hash-style=gnu */
> ++  if (strcmp (default_target, "elf32-tradbigmips") != 0
> ++      && strcmp (default_target, "elf32-tradlittlemips") != 0)
> ++    {
> ++      link_info.emit_gnu_hash = TRUE;
> ++      link_info.emit_hash = FALSE;
> ++    }
> ++
> +   config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
> +   config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
> +   lang_init ();
> +--- a/gold/options.h
> ++++ b/gold/options.h
> +@@ -794,7 +794,7 @@
> + 		N_("Min fraction of empty buckets in dynamic hash"),
> + 		N_("FRACTION"));
> + 
> +-  DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "sysv",
> ++  DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "gnu",
> + 	      N_("Dynamic hash style"), N_("[sysv,gnu,both]"),
> + 	      {"sysv", "gnu", "both"});
> + 



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---