diff --git a/sys/compat/linux/arch/aarch64/linux_exec.h b/sys/compat/linux/arch/aarch64/linux_exec.h index cfe5c9f7e4fa..08a07270f6c7 100644 --- a/sys/compat/linux/arch/aarch64/linux_exec.h +++ b/sys/compat/linux/arch/aarch64/linux_exec.h @@ -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 --git a/sys/compat/linux/arch/arm/linux_exec.h b/sys/compat/linux/arch/arm/linux_exec.h index eb277ab02deb..b9f95f03566f 100644 --- a/sys/compat/linux/arch/arm/linux_exec.h +++ b/sys/compat/linux/arch/arm/linux_exec.h @@ -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 --git a/sys/compat/linux/common/linux_exec_elf32.c b/sys/compat/linux/common/linux_exec_elf32.c index 4712199f74e3..e39e37a4282e 100644 --- a/sys/compat/linux/common/linux_exec_elf32.c +++ b/sys/compat/linux/common/linux_exec_elf32.c @@ -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 -__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 @@ ELFNAME2(linux,go_rt0_signature)(struct lwp *l, struct exec_package *epp, Elf_Eh 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;