From 5996efe5589192ba327f05fd5c91f48b52e5ae61 Mon Sep 17 00:00:00 2001 From: pgoyette Date: Sat, 21 Mar 2020 04:48:37 +0000 Subject: [PATCH] Teach rump how to process __link_set_sysctl_funcs so it can handle modules the same as a real kernel. Partly addresses PR kern/55088 - __link_set_evcnts not yet handled (that will happen later) --- lib/librumpuser/rumpuser_dl.c | 37 +++++++++++++++++++++++++++++++++-- sys/rump/ldscript.rump | 16 ++++++++++++++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/lib/librumpuser/rumpuser_dl.c b/lib/librumpuser/rumpuser_dl.c index 017b0cbd09a6..e8f25ad445e9 100644 --- a/lib/librumpuser/rumpuser_dl.c +++ b/lib/librumpuser/rumpuser_dl.c @@ -1,4 +1,4 @@ -/* $NetBSD: rumpuser_dl.c,v 1.31 2019/12/26 04:53:11 msaitoh Exp $ */ +/* $NetBSD: rumpuser_dl.c,v 1.32 2020/03/21 04:48:37 pgoyette Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -40,11 +40,16 @@ #include "rumpuser_port.h" #if !defined(lint) -__RCSID("$NetBSD: rumpuser_dl.c,v 1.31 2019/12/26 04:53:11 msaitoh Exp $"); +__RCSID("$NetBSD: rumpuser_dl.c,v 1.32 2020/03/21 04:48:37 pgoyette Exp $"); #endif /* !lint */ #include #include + +#ifdef NOTYET +#include +#endif + #include #include @@ -353,6 +358,14 @@ process_object(void *handle, const struct modinfo *const *mi_start, *const *mi_end; struct rump_component *const *rc, *const *rc_end; + struct sysctllog; + typedef void sysctl_setup_func(struct sysctllog **); + sysctl_setup_func *const *sfp, *const *sfp_end; + +#ifdef NOTYET /* We don't yet handle link_set_evcnts */ + struct evcnt *const *evp, *const *evp_end; +#endif + mi_start = dlsym(handle, "__start_link_set_modules"); mi_end = dlsym(handle, "__stop_link_set_modules"); if (mi_start && mi_end) @@ -365,6 +378,26 @@ process_object(void *handle, docompload(*rc); assert(rc == rc_end); } + + /* handle link_set_sysctl_funcs */ + sfp = dlsym(handle, "__start_link_set_sysctl_funcs"); + sfp_end = dlsym(handle, "__stop_link_set_sysctl_funcs"); + if (sfp && sfp_end) { + for (; sfp < sfp_end; sfp++) + (**sfp)(NULL); + assert(sfp == sfp_end); + } + +#ifdef NOTYET + /* handle link_set_evcnts */ + evp = dlsym(handle, "__start_link_set_evcnts"); + evp_end = dlsym(handle, "__stop_link_set_evcnts"); + if (evp && evp_end) { + for (; evp < evp_end; evp++) + evcnt_attach_static(*evp); + assert(evp == evp_end); + } +#endif } /* diff --git a/sys/rump/ldscript.rump b/sys/rump/ldscript.rump index 348ac43b998d..d441b63968ae 100644 --- a/sys/rump/ldscript.rump +++ b/sys/rump/ldscript.rump @@ -1,4 +1,4 @@ -/* $NetBSD: ldscript.rump,v 1.3 2014/04/23 17:05:18 pooka Exp $ */ +/* $NetBSD: ldscript.rump,v 1.4 2020/03/21 04:48:38 pgoyette Exp $ */ /* * From binutils 2.19 onwards (in NetBSD) binutils ld PROVIDEs @@ -24,5 +24,19 @@ SECTIONS *(link_set_rump_components); __stop_link_set_rump_components = .; } + + link_set_sysctl_funcs : + { + __start_link_set_sysctl_funcs = .; + *(link_set_sysctl_funcs); + __stop_link_set_sysctl_funcs = .; + } + + link_set_rump_components : + { + __start_link_set_evcnts = .; + *(link_set_evcnts); + __stop_link_set_evcnts = .; + } } INSERT AFTER .data;