summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2002-05-20 14:42:48 +0000
committerru <ru@FreeBSD.org>2002-05-20 14:42:48 +0000
commit531943a766cf8c4c616513e850124e60fec019b2 (patch)
tree42405b4300067951c84b39d4f2e941325655b209
parent13ebb01c0e1e246560d0d27ac3ec141fa0a4dd94 (diff)
downloadFreeBSD-src-531943a766cf8c4c616513e850124e60fec019b2.zip
FreeBSD-src-531943a766cf8c4c616513e850124e60fec019b2.tar.gz
Bootstrap elf2aout(1) for sparc64; used to build sys/boot/sparc64/boot1.
-rw-r--r--Makefile.inc16
-rw-r--r--usr.bin/elf2aout/elf2aout.c30
-rw-r--r--usr.sbin/elf2aout/elf2aout.c30
3 files changed, 63 insertions, 3 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1
index 5e11cc3..f2443c6 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -632,10 +632,14 @@ _elf2exe= usr.sbin/elf2exe
_btxld= usr.sbin/btxld
.endif
+.if ${TARGET_ARCH} == "sparc64"
+_elf2aout= usr.bin/elf2aout
+.endif
+
_xlint= usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint
cross-tools:
-.for _tool in ${_btxld} ${_elf2exe} \
+.for _tool in ${_btxld} ${_elf2aout} ${_elf2exe} \
gnu/usr.bin/binutils usr.bin/objformat usr.sbin/crunch/crunchide \
gnu/usr.bin/cc ${_xlint}
cd ${.CURDIR}/${_tool}; \
diff --git a/usr.bin/elf2aout/elf2aout.c b/usr.bin/elf2aout/elf2aout.c
index f087880..e35dcd3 100644
--- a/usr.bin/elf2aout/elf2aout.c
+++ b/usr.bin/elf2aout/elf2aout.c
@@ -27,9 +27,37 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/elf64.h>
+#if __FreeBSD_version >= 500034
#include <sys/endian.h>
+#else
+#include <machine/endian.h>
+#if BYTE_ORDER == LITTLE_ENDIAN
+
+#define bswap16(x) \
+ ((x >> 8) | (x << 8))
+
+#define bswap32(x) \
+ ((x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24))
+
+#define bswap64(x) \
+ ((x >> 56) | ((x >> 40) & 0xff00) | ((x >> 24) & 0xff0000) | \
+ ((x >> 8) & 0xff000000) | ((x << 8) & ((u_int64_t)0xff << 32)) | \
+ ((x << 24) & ((u_int64_t)0xff << 40)) | \
+ ((x << 40) & ((u_int64_t)0xff << 48)) | ((x << 56)))
+
+#define be16toh(x) bswap16((x))
+#define be32toh(x) bswap32((x))
+#define be64toh(x) bswap64((x))
+#define htobe32(x) bswap32((x))
+#else
+#define be16toh(x) (x)
+#define be32toh(x) (x)
+#define be64toh(x) (x)
+#define htobe32(x) (x)
+#endif
+#endif
#include <sys/mman.h>
#include <sys/stat.h>
diff --git a/usr.sbin/elf2aout/elf2aout.c b/usr.sbin/elf2aout/elf2aout.c
index f087880..e35dcd3 100644
--- a/usr.sbin/elf2aout/elf2aout.c
+++ b/usr.sbin/elf2aout/elf2aout.c
@@ -27,9 +27,37 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/elf64.h>
+#if __FreeBSD_version >= 500034
#include <sys/endian.h>
+#else
+#include <machine/endian.h>
+#if BYTE_ORDER == LITTLE_ENDIAN
+
+#define bswap16(x) \
+ ((x >> 8) | (x << 8))
+
+#define bswap32(x) \
+ ((x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24))
+
+#define bswap64(x) \
+ ((x >> 56) | ((x >> 40) & 0xff00) | ((x >> 24) & 0xff0000) | \
+ ((x >> 8) & 0xff000000) | ((x << 8) & ((u_int64_t)0xff << 32)) | \
+ ((x << 24) & ((u_int64_t)0xff << 40)) | \
+ ((x << 40) & ((u_int64_t)0xff << 48)) | ((x << 56)))
+
+#define be16toh(x) bswap16((x))
+#define be32toh(x) bswap32((x))
+#define be64toh(x) bswap64((x))
+#define htobe32(x) bswap32((x))
+#else
+#define be16toh(x) (x)
+#define be32toh(x) (x)
+#define be64toh(x) (x)
+#define htobe32(x) (x)
+#endif
+#endif
#include <sys/mman.h>
#include <sys/stat.h>
OpenPOWER on IntegriCloud