Subject: [alpine-aports] [PATCH 1/3] testing/binutils-cross-embedded: New aport

From: Marian Buschsieweke <[email-masked]>
Date: Mon, 28 May 2018 18:49:28 +0200

Tools necessary to build programs for embedded targets
http://www.gnu.org/software/binutils

This package creates binutils-arm-none-eabi, binutils-avr and
binutils-xtensa-lx106-elf as subpackages.
---
 testing/binutils-cross-embedded/APKBUILD      | 88 +++++++++++++++++++
 .../binutils-ld-fix-static-linking.patch      | 46 ++++++++++
 2 files changed, 134 insertions(+)
 create mode 100644 testing/binutils-cross-embedded/APKBUILD
 create mode 100644 testing/binutils-cross-embedded/binutils-ld-fix-static-linking.patch

diff --git a/testing/binutils-cross-embedded/APKBUILD b/testing/binutils-cross-embedded/APKBUILD
new file mode 100644
index 0000000000..9cc286fd9b
--- /dev/null
+++ b/testing/binutils-cross-embedded/APKBUILD
@@ -0,0 +1,88 @@
+# Maintainer: Marian Buschsieweke <[email-masked]>
+# Based on binutils-avr
+_pkgbase=binutils
+_targets="arm-none-eabi avr xtensa-lx106-elf"
+pkgname="$_pkgbase-cross-embedded"
+pkgver=2.30
+pkgrel=0
+pkgdesc="Tools necessary to build programs for embedded targets"
+url="http://www.gnu.org/software/${_pkgbase}/"
+makedepends="gettext libtool autoconf automake bison zlib-dev"
+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"
+
+builddir="$srcdir/${_pkgbase}-$pkgver"
+_workingdir="$srcdir/${_pkgbase}-build"
+
+build() {
+	for target in $_targets; do
+		workingdir="${srcdir}/build-${target}"
+		mkdir "$workingdir"
+		cd "$workingdir"
+		"$builddir"/configure \
+			--target=${target} \
+			--build="$CBUILD" \
+			--host="$CHOST" \
+			--prefix=/usr/ \
+			--bindir=/usr/bin \
+			--infodir=/deleteme/info \
+			--htmldir=/deleteme/html \
+			--pdfdir=/deleteme/pdf \
+			--mandir=/deleteme/man \
+			--disable-nls \
+			--enable-plugins \
+			--enable-interwork \
+			--with-system-zlib \
+			|| 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 install DESTDIR="$subpkgdir"
+	rm -rf "$subpkgdir"/deleteme
+	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 ${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="c3ce91aa20f058ec589bf18c722bf651331b394db6378900cc813cc0eea3a331a96584d5ae090630b627369510397dccc9edfcd43d4aeefc99579f277a05c72c  binutils-2.30.tar.bz2
+ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49  binutils-ld-fix-static-linking.patch"
diff --git a/testing/binutils-cross-embedded/binutils-ld-fix-static-linking.patch b/testing/binutils-cross-embedded/binutils-ld-fix-static-linking.patch
new file mode 100644
index 0000000000..bc5d762656
--- /dev/null
+++ b/testing/binutils-cross-embedded/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}}
-- 
2.17.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Leonardo Arena <[email-masked]>
Date: Mon, 15 Oct 2018 08:29:53 +0200

Hi,

On Mon, May 28, 2018 at 6:49 PM Marian Buschsieweke <
[email-masked]> wrote:

>  create mode 100644
> testing/binutils-cross-embedded/binutils-ld-fix-static-linking.patch
>
> diff --git a/testing/binutils-cross-embedded/APKBUILD
> b/testing/binutils-cross-embedded/APKBUILD
> new file mode 100644

License IDs, aren't correct. Please see https://spdx.org/licenses/

> +                       --mandir=/deleteme/man \

This can be omitted.

> +       pkgdesc="Tools necessary to build programs for platform ${target}"
Thanks!

/eo