Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Replace weak symbol definition for machine32 w...



details:   https://anonhg.NetBSD.org/src/rev/a99a75880dad
branches:  pgoyette-compat
changeset: 447787:a99a75880dad
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu Jan 24 03:27:23 2019 +0000

description:
Replace weak symbol definition for machine32 with a hook.  Our in-kernel
linker doesn't handle weak symbols, so this prevented us from loading the
compat_linux32 module.

XXX There don't seem to be any other consumers of machine32 (nor does
XXX there seem to be any consumers of machine_arch32), even though it
XXX is defined for aarch64, arm32, and riscv).

diffstat:

 sys/arch/amd64/amd64/netbsd32_machdep.c     |  15 +++++++++---
 sys/arch/mips/mips/netbsd32_machdep.c       |  33 ++++++++++++++++++----------
 sys/arch/sparc64/sparc64/netbsd32_machdep.c |  30 +++++++++++++++----------
 sys/compat/linux/common/linux_exec_elf32.c  |  11 +++------
 sys/kern/compat_stub.c                      |   6 ++++-
 sys/sys/compat_stub.h                       |   7 +++++-
 6 files changed, 65 insertions(+), 37 deletions(-)

diffs (225 lines):

diff -r 5dcb5393f23d -r a99a75880dad sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c   Thu Jan 24 02:09:56 2019 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c   Thu Jan 24 03:27:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.115.2.16 2019/01/22 07:42:40 pgoyette Exp $     */
+/*     $NetBSD: netbsd32_machdep.c,v 1.115.2.17 2019/01/24 03:27:23 pgoyette Exp $     */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.115.2.16 2019/01/22 07:42:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.115.2.17 2019/01/24 03:27:23 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -969,16 +969,23 @@
                return VM_DEFAULT_ADDRESS32_BOTTOMUP(base, sz);
 }
 
+static const char *
+netbsd32_machine32(void)
+{
+
+       return machine32;
+}
+
 void
 netbsd32_machdep_md_init(void)
 {
 
-       /* nothing to do */
+       MODULE_SET_HOOK(netbsd32_machine32_hook, "mach32", netbsd32_machine32);
 }
 
 void
 netbsd32_machdep_md_fini(void)
 {
 
-       /* nothing to do */
+       MODULE_UNSET_HOOK(netbsd32_machine32_hook);
 }
diff -r 5dcb5393f23d -r a99a75880dad sys/arch/mips/mips/netbsd32_machdep.c
--- a/sys/arch/mips/mips/netbsd32_machdep.c     Thu Jan 24 02:09:56 2019 +0000
+++ b/sys/arch/mips/mips/netbsd32_machdep.c     Thu Jan 24 03:27:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.15.2.12 2019/01/22 07:42:40 pgoyette Exp $      */
+/*     $NetBSD: netbsd32_machdep.c,v 1.15.2.13 2019/01/24 03:27:23 pgoyette Exp $      */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.15.2.12 2019/01/22 07:42:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.15.2.13 2019/01/24 03:27:23 pgoyette Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_coredump.h"
@@ -317,16 +317,25 @@
            netbsd32_sendsig_siginfo(ksi, mask));
 }
 
-void    
-netbsd32_machdep_md_init(void)
-{       
-                
-       /* nothing to do */
-}               
-                
-void            
+static const char *
+netbsd32_machine32(void)
+{
+
+       return machine32;
+}
+
+void 
+netbsd32_machdep_md_init(void) 
+{
+
+       MODULE_SET_HOOK(netbsd32_machine32_hook, "mach32", netbsd32_machine32);
+}
+
+void
 netbsd32_machdep_md_fini(void)
-{       
+{
 
-       /* nothing to do */
+       MODULE_UNSET_HOOK(netbsd32_machine32_hook);
 }
+
+
diff -r 5dcb5393f23d -r a99a75880dad sys/arch/sparc64/sparc64/netbsd32_machdep.c
--- a/sys/arch/sparc64/sparc64/netbsd32_machdep.c       Thu Jan 24 02:09:56 2019 +0000
+++ b/sys/arch/sparc64/sparc64/netbsd32_machdep.c       Thu Jan 24 03:27:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.110.14.5 2019/01/22 07:42:40 pgoyette Exp $     */
+/*     $NetBSD: netbsd32_machdep.c,v 1.110.14.6 2019/01/24 03:27:24 pgoyette Exp $     */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.110.14.5 2019/01/22 07:42:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.110.14.6 2019/01/24 03:27:24 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1016,17 +1016,23 @@
        return round_page((vaddr_t)(base) + (vsize_t)MAXDSIZ32);
 }
 
-void    
-netbsd32_machdep_md_init(void)
+static const char *
+netbsd32_machine32(void)
 {
-                    
-       /* nothing to do */
-}               
- 
-void    
+
+       return machine32;
+}
+
+void 
+netbsd32_machdep_md_init(void) 
+{
+
+       MODULE_SET_HOOK(netbsd32_machine32_hook, "mach32", netbsd32_machine32);
+}
+
+void
 netbsd32_machdep_md_fini(void)
 {
-        
-       /* nothing to do */
+
+       MODULE_UNSET_HOOK(netbsd32_machine32_hook);
 }
-
diff -r 5dcb5393f23d -r a99a75880dad sys/compat/linux/common/linux_exec_elf32.c
--- a/sys/compat/linux/common/linux_exec_elf32.c        Thu Jan 24 02:09:56 2019 +0000
+++ b/sys/compat/linux/common/linux_exec_elf32.c        Thu Jan 24 03:27:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_exec_elf32.c,v 1.94.12.1 2018/07/28 04:37:43 pgoyette Exp $      */
+/*     $NetBSD: linux_exec_elf32.c,v 1.94.12.2 2019/01/24 03:27:24 pgoyette 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.94.12.1 2018/07/28 04:37:43 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.94.12.2 2019/01/24 03:27:24 pgoyette Exp $");
 
 #ifndef ELFSIZE
 /* XXX should die */
@@ -55,6 +55,7 @@
 #include <sys/stat.h>
 #include <sys/kauth.h>
 #include <sys/cprng.h>
+#include <sys/compat_stub.h>
 
 #include <sys/mman.h>
 #include <sys/syscallargs.h>
@@ -334,11 +335,7 @@
                goto out;
 
 #if (ELFSIZE == 32)
-       extern const char machine32[] __weak;
-       if (machine32 != NULL)
-               m = machine32;
-       else
-               m = machine;
+       MODULE_HOOK_CALL(netbsd32_machine32_hook, (), machine, m);
 #else
        m = machine;
 #endif
diff -r 5dcb5393f23d -r a99a75880dad sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Thu Jan 24 02:09:56 2019 +0000
+++ b/sys/kern/compat_stub.c    Thu Jan 24 03:27:23 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.39 2019/01/15 22:01:26 pgoyette Exp $        */
+/* $NetBSD: compat_stub.c,v 1.1.2.40 2019/01/24 03:27:24 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -248,3 +248,7 @@
  */
 struct sysvipc50_sysctl_hook_t sysvipc50_sysctl_hook;
 
+/* 
+ * Hook for compat32_machine32
+ */
+struct netbsd32_machine32_hook_t netbsd32_machine32_hook;
diff -r 5dcb5393f23d -r a99a75880dad sys/sys/compat_stub.h
--- a/sys/sys/compat_stub.h     Thu Jan 24 02:09:56 2019 +0000
+++ b/sys/sys/compat_stub.h     Thu Jan 24 03:27:23 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.52 2019/01/22 07:42:42 pgoyette Exp $        */
+/* $NetBSD: compat_stub.h,v 1.1.2.53 2019/01/24 03:27:24 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -308,4 +308,9 @@
 #include <sys/sysctl.h>
 MODULE_HOOK(sysvipc50_sysctl_hook, int, (SYSCTLFN_PROTO));
 
+/*
+ * Hook for compat32_machine32
+ */
+MODULE_HOOK(netbsd32_machine32_hook, const char *, (void));
+
 #endif /* _SYS_COMPAT_STUB_H */



Home | Main Index | Thread Index | Old Index