Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/linux/common The internal architecture name of go...



details:   https://anonhg.NetBSD.org/src/rev/c89f33ea7dfd
branches:  trunk
changeset: 1026480:c89f33ea7dfd
user:      ryo <ryo%NetBSD.org@localhost>
date:      Fri Nov 26 09:05:05 2021 +0000

description:
The internal architecture name of golang is "arm" or "arm64", which has
different naming conventions from netbsd's machine[] or machine_arch[]
("earmv7", "aarch64", etc.) and cannot be used as is.
Instead, use define LINUX_GO_RT0_SIGNATURE_ARCH{32,64}.

diffstat:

 sys/compat/linux/arch/aarch64/linux_exec.h |   8 +++++++-
 sys/compat/linux/arch/arm/linux_exec.h     |   7 ++++++-
 sys/compat/linux/common/linux_exec_elf32.c |  12 ++++++++++--
 3 files changed, 23 insertions(+), 4 deletions(-)

diffs (80 lines):

diff -r aefcf1aafeca -r c89f33ea7dfd sys/compat/linux/arch/aarch64/linux_exec.h
--- a/sys/compat/linux/arch/aarch64/linux_exec.h        Fri Nov 26 08:56:28 2021 +0000
+++ b/sys/compat/linux/arch/aarch64/linux_exec.h        Fri Nov 26 09:05:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_exec.h,v 1.2 2021/11/26 08:56:28 ryo Exp $       */
+/*     $NetBSD: linux_exec.h,v 1.3 2021/11/26 09:05:05 ryo Exp $       */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,5 +35,11 @@
 #define linux_exec_setup_stack exec_setup_stack
 
 #define LINUX_GO_RT0_SIGNATURE
+/*
+ * linux/arm golang architecture name and netbsd machine_arch{,32}[] are
+ * different and cannot be used as is.
+ */
+#define LINUX_GO_RT0_SIGNATURE_ARCH32  "arm"
+#define LINUX_GO_RT0_SIGNATURE_ARCH64  "arm64"
 
 #endif /* !_AARCH64_LINUX_EXEC_H */
diff -r aefcf1aafeca -r c89f33ea7dfd sys/compat/linux/arch/arm/linux_exec.h
--- a/sys/compat/linux/arch/arm/linux_exec.h    Fri Nov 26 08:56:28 2021 +0000
+++ b/sys/compat/linux/arch/arm/linux_exec.h    Fri Nov 26 09:05:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_exec.h,v 1.11 2021/11/26 08:56:28 ryo Exp $      */
+/*     $NetBSD: linux_exec.h,v 1.12 2021/11/26 09:05:05 ryo Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -39,6 +39,11 @@
        (LINUX_ELF_AUX_ENTRIES * sizeof(Aux32Info) + LINUX_RANDOM_BYTES)
 
 #define LINUX_GO_RT0_SIGNATURE
+/*
+ * linux/arm golang architecture name and netbsd machine_arch[] are
+ * different and cannot be used as is.
+ */
+#define LINUX_GO_RT0_SIGNATURE_ARCH32  "arm"
 
 #define linux_exec_setup_stack exec_setup_stack
 
diff -r aefcf1aafeca -r c89f33ea7dfd sys/compat/linux/common/linux_exec_elf32.c
--- a/sys/compat/linux/common/linux_exec_elf32.c        Fri Nov 26 08:56:28 2021 +0000
+++ b/sys/compat/linux/common/linux_exec_elf32.c        Fri Nov 26 09:05:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_exec_elf32.c,v 1.101 2021/11/26 08:56:28 ryo Exp $       */
+/*     $NetBSD: linux_exec_elf32.c,v 1.102 2021/11/26 09:05:05 ryo Exp $       */
 
 /*-
  * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.101 2021/11/26 08:56:28 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.102 2021/11/26 09:05:05 ryo Exp $");
 
 #ifndef ELFSIZE
 /* XXX should die */
@@ -337,11 +337,19 @@
                goto out;
 
 #if (ELFSIZE == 32)
+#ifdef LINUX_GO_RT0_SIGNATURE_ARCH32
+       m = LINUX_GO_RT0_SIGNATURE_ARCH32;
+#else
        extern struct netbsd32_machine32_hook_t netbsd32_machine32_hook;
        MODULE_HOOK_CALL(netbsd32_machine32_hook, (), machine, m);
+#endif
+#else /* (ELFSIZE == 32) */
+#ifdef LINUX_GO_RT0_SIGNATURE_ARCH64
+       m = LINUX_GO_RT0_SIGNATURE_ARCH64;
 #else
        m = machine;
 #endif
+#endif /* (ELFSIZE == 32) */
        mlen = snprintf(mbuf, sizeof(mbuf), "_rt0_%s_linux", m);
        if (memmem(tmp, sh[i].sh_size, mbuf, mlen) == NULL)
                error = ENOEXEC;



Home | Main Index | Thread Index | Old Index