Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lib/libsa Add SA_ENABLE_BIENDIAN option, which enable us...



details:   https://anonhg.NetBSD.org/src/rev/fa2697704ce2
branches:  trunk
changeset: 461983:fa2697704ce2
user:      rin <rin%NetBSD.org@localhost>
date:      Sun Jul 21 16:53:17 2019 +0000

description:
Add SA_ENABLE_BIENDIAN option, which enable us to load kernel image of
opposite byte order (for arm EFI bootloader).

XXX
Currently, it is restricted to load_elf*.c. It would be nice if we can
recognize disklabel and filesystem of opposite byte order.

diffstat:

 sys/lib/libsa/Makefile         |   9 ++++++++-
 sys/lib/libsa/loadfile_elf32.c |  28 +++++++++++++++++-----------
 2 files changed, 25 insertions(+), 12 deletions(-)

diffs (119 lines):

diff -r 1fb3c73b5e5c -r fa2697704ce2 sys/lib/libsa/Makefile
--- a/sys/lib/libsa/Makefile    Sun Jul 21 16:19:45 2019 +0000
+++ b/sys/lib/libsa/Makefile    Sun Jul 21 16:53:17 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.90 2019/04/02 22:25:10 christos Exp $
+#      $NetBSD: Makefile,v 1.91 2019/07/21 16:53:17 rin Exp $
 
 LIB=   sa
 LIBISPRIVATE?= yes
@@ -7,6 +7,8 @@
 SA_INCLUDE_NET?= yes           # Netboot via TFTP, NFS
 SA_USE_LOADFILE?= no           # Generic executable loading support
 SA_ENABLE_LS_OP?= no           # Filesystems ls operation
+SA_ENABLE_BIENDIAN?= no                # Biendian support
+                               # (currently only for loadfile_elf*)
 
 #DEBUGCPPFLAGS= -DBOOTP_DEBUG -DNETIF_DEBUG -DETHER_DEBUG -DNFS_DEBUG -DRPC_DEBUG -DRARP_DEBUG -DARP_DEBUG -DNET_DEBUG -DDEBUG -DPARANOID
 CPPFLAGS=      -I${SADIR} ${SACPPFLAGS} ${SAMISCCPPFLAGS} \
@@ -73,6 +75,11 @@
 SRCS+= nfs.c tftp.c
 .endif
 
+.if (${SA_ENABLE_BIENDIAN} == "yes")
+CPPFLAGS+=     -DLIBSA_BIENDIAN_SUPPORT
+SRCS+=         byteorder.c
+.endif
+
 SRCS+= ffsv1.c ffsv2.c
 SRCS+= lfsv1.c lfsv2.c
 SRCS+= cd9660.c
diff -r 1fb3c73b5e5c -r fa2697704ce2 sys/lib/libsa/loadfile_elf32.c
--- a/sys/lib/libsa/loadfile_elf32.c    Sun Jul 21 16:19:45 2019 +0000
+++ b/sys/lib/libsa/loadfile_elf32.c    Sun Jul 21 16:53:17 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: loadfile_elf32.c,v 1.54 2019/06/20 17:33:30 maxv Exp $ */
+/* $NetBSD: loadfile_elf32.c,v 1.55 2019/07/21 16:53:17 rin Exp $ */
 
 /*
  * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc.
@@ -59,12 +59,18 @@
 #define        ELFROUND        (ELFSIZE / 8)
 
 #ifndef _STANDALONE
-#include "byteorder.h"
-
 /*
  * Byte swapping may be necessary in the non-_STANDLONE case because
  * we may be built with a host compiler.
  */
+#ifndef LIBSA_BIENDIAN_SUPPORT
+#define LIBSA_BIENDIAN_SUPPORT
+#endif
+#endif
+
+#ifdef LIBSA_BIENDIAN_SUPPORT
+#include "byteorder.h"
+
 #define        E16(f)                                                          \
        f = (bo == ELFDATA2LSB) ? sa_htole16(f) : sa_htobe16(f)
 #define        E32(f)                                                          \
@@ -241,10 +247,10 @@
 #error ELFSIZE is not 32 or 64
 #endif
 }
-#else /* _STANDALONE */
+#else /* LIBSA_BIENDIAN_SUPPORT */
 /*
- * Byte swapping is never necessary in the _STANDALONE case because
- * we are being built with the target compiler.
+ * Byte swapping is never necessary in the !LIBSA_BIENDIAN_SUPPORT case
+ * because we are being built with the target compiler.
  */
 #define        internalize_ehdr(bo, ehdr)      /* nothing */
 #define        externalize_ehdr(bo, ehdr)      /* nothing */
@@ -253,7 +259,7 @@
 
 #define        internalize_shdr(bo, shdr)      /* nothing */
 #define        externalize_shdr(bo, shdr)      /* nothing */
-#endif /* _STANDALONE */
+#endif /* LIBSA_BIENDIAN_SUPPORT */
 
 #define IS_TEXT(p)     (p.p_flags & PF_X)
 #define IS_DATA(p)     ((p.p_flags & PF_X) == 0)
@@ -379,7 +385,7 @@
        internalize_ehdr(elf->e_ident[EI_DATA], elf);
        maxp += sizeof(Elf_Ehdr);
 
-#ifndef _STANDALONE
+#ifdef LIBSA_BIENDIAN_SUPPORT
        for (i = 0; i < elf->e_shnum; i++)
                internalize_shdr(elf->e_ident[EI_DATA], &shdr[i]);
 #endif
@@ -472,7 +478,7 @@
        /*
         * Finally, load the SECTION HEADERS.
         */
-#ifndef _STANDALONE
+#ifdef LIBSA_BIENDIAN_SUPPORT
        for (i = 0; i < elf->e_shnum; i++)
                externalize_shdr(elf->e_ident[EI_DATA], &shdr[i]);
 #endif
@@ -526,7 +532,7 @@
        shpp = maxp;
        maxp += roundup(sz, ELFROUND);
 
-#ifndef _STANDALONE
+#ifdef LIBSA_BIENDIAN_SUPPORT
        for (i = 0; i < elf->e_shnum; i++)
                internalize_shdr(elf->e_ident[EI_DATA], &shp[i]);
 #endif
@@ -636,7 +642,7 @@
                }
        }
        if (flags & LOAD_SYM) {
-#ifndef _STANDALONE
+#ifdef LIBSA_BIENDIAN_SUPPORT
                for (i = 0; i < elf->e_shnum; i++)
                        externalize_shdr(elf->e_ident[EI_DATA], &shp[i]);
 #endif



Home | Main Index | Thread Index | Old Index