]> git.draconx.ca Git - gentoo-draconx.git/commitdiff
dev-util/elftoaout: New package.
authorNick Bowler <nbowler@draconx.ca>
Mon, 11 Jul 2022 01:05:37 +0000 (21:05 -0400)
committerNick Bowler <nbowler@draconx.ca>
Mon, 11 Jul 2022 01:06:47 +0000 (21:06 -0400)
This utility is extracted from sparc-utils which is not installable on
non-SPARC platforms; needed for cross-building Linux for SPARC netboot.

dev-util/elftoaout/Manifest [new file with mode: 0644]
dev-util/elftoaout/elftoaout-2.3.ebuild [new file with mode: 0644]
dev-util/elftoaout/files/elftoaout-build-rules.patch [new file with mode: 0644]
dev-util/elftoaout/files/elftoaout-lp64-fixes.patch [new file with mode: 0644]
dev-util/elftoaout/files/elftoaout-no-linux-elf.patch [new file with mode: 0644]

diff --git a/dev-util/elftoaout/Manifest b/dev-util/elftoaout/Manifest
new file mode 100644 (file)
index 0000000..a110482
--- /dev/null
@@ -0,0 +1,5 @@
+AUX elftoaout-build-rules.patch 455 BLAKE2B 3fa35c4165dc2ccab1019d5d47cae44b3c39c56650300c0fe5bfcbd8a45bea0417414d24553b581d43ad16613b0b1d7b4447d5e40bb85eae29e1474acdae8eba SHA512 da31e08081c468f6c1fcb417832bfd6f20288839bd397bc81160fe71798466087218fc86fad719e50b2d955e101ea32cb14d4be74a8a187fbb4d5a9091da4603
+AUX elftoaout-lp64-fixes.patch 2765 BLAKE2B cbc9f0dcb77cb0ed7391554e4dd9a821b28b1472aedcfd4a3a52368487d7bdb409ea4c19490e28600e685f7a18e1a342e8392b9213c7e05f2f9c26ee696a01dc SHA512 0c8f43831a0ad5dcdd0352d4c5391db72b3d5b3f4d8f0e651cdaadcdf1de0f5caec25b047337417d4b41745795534e5bb22e1c3a0d5752800f96c8d6741f68fa
+AUX elftoaout-no-linux-elf.patch 401 BLAKE2B 0287e84f6f6e8a508cd8a924845081c4c70953fd64405c93d91dc1b04609d9544cc30ea5b5901ad7010a8c6f8f8365e2dfb75dd81b20454d5de2e53d994a45b7 SHA512 4a6a2d65f950bbe40a1b3cf6449d7e50b11bfa4296153092a605b0d870880cb272c67ae3b8434c972dc8abb8c8150cd8770cfb9f7b6e8ef4c20151937030dede
+DIST sparc-utils_1.9.orig.tar.gz 110080 BLAKE2B 52f47c130fb8e24b0340589c846292fb2e4e9b211a10cddf52a7a63edd70673e2b7d05c2415e558c5f2d1235f33f4ae65b777d3f8b2cf2c50a601d1f0a7a941a SHA512 bde05f1a98211aaf502be6dfd757ddfb21c136cedbb46ca84a4539706c71901815c9d8bedfebc3800c7340634b32276197c75f92f9cc829e4f50c37d203e9358
+EBUILD elftoaout-2.3.ebuild 841 BLAKE2B 00f9a2c455b0410ec9f66f66417da296dd0b3bde63f6967ebf91c931dc85a215b269c41170b58321a8adf506e0410b8b796d6900808594e9c8715df614305d3b SHA512 85d0cc70be267587a712ec1d4055b97a58be9118d2b27b1a0a4ccc4f03f2ddb12e175a68e827472852abf97832bbb59973f313c9179db60e45a6f2671bdce7ae
diff --git a/dev-util/elftoaout/elftoaout-2.3.ebuild b/dev-util/elftoaout/elftoaout-2.3.ebuild
new file mode 100644 (file)
index 0000000..0ab1737
--- /dev/null
@@ -0,0 +1,37 @@
+# Copyright © 2022 Nick Bowler
+# License GPLv3+: GNU General Public License version 3 or any later version.
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+EAPI=8
+
+inherit toolchain-funcs
+
+MY_PN=sparc-utils
+MY_P=${MY_PN}_1.9
+
+DESCRIPTION="ELF to a.out convertor for SPARC and SPARC64 bootstraps"
+SRC_URI="http://archive.debian.org/debian-archive/debian/pool/main/s/$MY_PN/$MY_P.orig.tar.gz"
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS="~amd64"
+
+RDEPEND="!sys-apps/sparc-utils"
+
+PATCHES=(
+       "$FILESDIR/$PN-build-rules.patch"
+       "$FILESDIR/$PN-lp64-fixes.patch"
+       "$FILESDIR/$PN-no-linux-elf.patch"
+)
+
+S=$WORKDIR/${MY_P/_/-}.orig
+
+src_compile () {
+       emake -C $P CC=$(tc-getCC) CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
+}
+
+src_install () {
+       dobin $P/elftoaout
+       doman $P/elftoaout.1
+}
diff --git a/dev-util/elftoaout/files/elftoaout-build-rules.patch b/dev-util/elftoaout/files/elftoaout-build-rules.patch
new file mode 100644 (file)
index 0000000..e7ec46d
--- /dev/null
@@ -0,0 +1,18 @@
+diff --git a/elftoaout-2.3/Makefile b/elftoaout-2.3/Makefile
+index 7dc3529..64d8ff6 100644
+--- a/elftoaout-2.3/Makefile
++++ b/elftoaout-2.3/Makefile
+@@ -3,8 +3,11 @@ CFLAGS = -O2 -Wall
+ all: elftoaout
+-elftoaout: elftoaout.c
+-      $(CC) $(CFLAGS) -o elftoaout elftoaout.c
++elftoaout: elftoaout.o
++      $(CC) $(CFLAGS) $(LDFLAGS) -o elftoaout elftoaout.o
++
++.c.o:
++      $(CC) $(CFLAGS) -c $<
+ install: elftoaout
+       install -m 0755 -s elftoaout /usr/bin/elftoaout
diff --git a/dev-util/elftoaout/files/elftoaout-lp64-fixes.patch b/dev-util/elftoaout/files/elftoaout-lp64-fixes.patch
new file mode 100644 (file)
index 0000000..57fd11d
--- /dev/null
@@ -0,0 +1,81 @@
+diff --git a/elftoaout-2.3/elftoaout.c b/elftoaout-2.3/elftoaout.c
+index 943c9ef..1f9b4c0 100644
+--- a/elftoaout-2.3/elftoaout.c
++++ b/elftoaout-2.3/elftoaout.c
+@@ -20,6 +20,7 @@
+  */
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <stdint.h>
+ #ifdef linux
+ #include <linux/elf.h>
+ #define ELFDATA2MSB   2
+@@ -27,9 +28,20 @@
+ #include <sys/elf.h>
+ #endif
+-#define swab16(x)  (((x)<<8&0xFF00)|((x)>>8&0x00FF))
+-#define swab32(x)  (((x)<<24&0xFF000000)|((x)<<8&0x00FF0000)|((x)>>24&0x000000FF)|((x)>>8&0x0000FF00))
+-#define swab64(x)  ((((unsigned long long)(swab32((unsigned int)x))) << 32) | (swab32(((unsigned long long)x)>>32)))
++static uint16_t swab16(uint16_t x)
++{
++      return (((x)<<8&0xFF00)|((x)>>8&0x00FF));
++}
++
++static uint32_t swab32(uint32_t x)
++{
++      return (((x)<<24&0xFF000000)|((x)<<8&0x00FF0000)|((x)>>24&0x000000FF)|((x)>>8&0x0000FF00));
++}
++
++static uint64_t swab64(uint64_t x)
++{
++      return ((((unsigned long long)(swab32(x))) << 32) | (swab32(x>>32)));
++}
+ /* We carry a.out header here in order to compile the thing on Solaris */
+@@ -37,14 +49,14 @@
+ #define       CMAGIC      0x01030108
+ typedef struct {
+-      unsigned long   a_magic;        /* magic number */
+-      unsigned long   a_text;         /* size of text segment */
+-      unsigned long   a_data;         /* size of initialized data */
+-      unsigned long   a_bss;          /* size of uninitialized data */
+-      unsigned long   a_syms;         /* size of symbol table || checksum */
+-      unsigned long   a_entry;        /* entry point */
+-      unsigned long   a_trsize;       /* size of text relocation */
+-      unsigned long   a_drsize;       /* size of data relocation */
++      uint32_t        a_magic;        /* magic number */
++      uint32_t        a_text;         /* size of text segment */
++      uint32_t        a_data;         /* size of initialized data */
++      uint32_t        a_bss;          /* size of uninitialized data */
++      uint32_t        a_syms;         /* size of symbol table || checksum */
++      uint32_t        a_entry;        /* entry point */
++      uint32_t        a_trsize;       /* size of text relocation */
++      uint32_t        a_drsize;       /* size of data relocation */
+ } Exec;
+@@ -75,7 +87,7 @@ void print_ptab(ProgTable *t);
+ void print_ptab64(ProgTable64 *t);
+ typedef struct {
+-      char *buf;                /* Image data */
++      unsigned char *buf;       /* Image data */
+       unsigned len;             /* Length of buffer */
+       unsigned bss;             /* Length of extra data */
+ } Segment;
+@@ -386,9 +398,9 @@ void print_ptab64(ProgTable64 *t) {
+                       printf("NULL");
+                       break;
+               case PT_LOAD:
+-                      printf("Loadable to 0x%Lx[0x%Lx] from 0x%Lx[0x%Lx] align 0x%Lx",
+-                              p->p_vaddr, p->p_memsz, p->p_offset, p->p_filesz,
+-                              p->p_align);
++                      printf("Loadable to 0x%jx[0x%jx] from 0x%jx[0x%jx] align 0x%jx",
++                              (uintmax_t)p->p_vaddr, (uintmax_t)p->p_memsz, (uintmax_t)p->p_offset, (uintmax_t)p->p_filesz,
++                              (uintmax_t)p->p_align);
+                       break;
+               case PT_DYNAMIC:
+                       printf("Dynamic");
diff --git a/dev-util/elftoaout/files/elftoaout-no-linux-elf.patch b/dev-util/elftoaout/files/elftoaout-no-linux-elf.patch
new file mode 100644 (file)
index 0000000..32b23be
--- /dev/null
@@ -0,0 +1,18 @@
+diff --git a/elftoaout-2.3/elftoaout.c b/elftoaout-2.3/elftoaout.c
+index 1f9b4c0..2b87e2e 100644
+--- a/elftoaout-2.3/elftoaout.c
++++ b/elftoaout-2.3/elftoaout.c
+@@ -21,12 +21,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stdint.h>
+-#ifdef linux
+-#include <linux/elf.h>
+-#define ELFDATA2MSB   2
+-#else
+-#include <sys/elf.h>
+-#endif
++#include <elf.h>
+ static uint16_t swab16(uint16_t x)
+ {