| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: rumpuser_dl.c,v 1.31 2019/12/26 04:53:11 msaitoh Exp $ */ | | 1 | /* $NetBSD: rumpuser_dl.c,v 1.32 2020/03/21 04:48:37 pgoyette Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2009 Antti Kantee. All Rights Reserved. | | 4 | * Copyright (c) 2009 Antti Kantee. All Rights Reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -30,31 +30,36 @@ | | | @@ -30,31 +30,36 @@ |
30 | * Called during rump bootstrap. | | 30 | * Called during rump bootstrap. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | /* | | 33 | /* |
34 | * Solaris libelf.h doesn't support _FILE_OFFSET_BITS=64. Luckily, | | 34 | * Solaris libelf.h doesn't support _FILE_OFFSET_BITS=64. Luckily, |
35 | * for this module it doesn't matter. | | 35 | * for this module it doesn't matter. |
36 | */ | | 36 | */ |
37 | #if defined(__sun__) | | 37 | #if defined(__sun__) |
38 | #define RUMPUSER_NO_FILE_OFFSET_BITS | | 38 | #define RUMPUSER_NO_FILE_OFFSET_BITS |
39 | #endif | | 39 | #endif |
40 | #include "rumpuser_port.h" | | 40 | #include "rumpuser_port.h" |
41 | | | 41 | |
42 | #if !defined(lint) | | 42 | #if !defined(lint) |
43 | __RCSID("$NetBSD: rumpuser_dl.c,v 1.31 2019/12/26 04:53:11 msaitoh Exp $"); | | 43 | __RCSID("$NetBSD: rumpuser_dl.c,v 1.32 2020/03/21 04:48:37 pgoyette Exp $"); |
44 | #endif /* !lint */ | | 44 | #endif /* !lint */ |
45 | | | 45 | |
46 | #include <sys/types.h> | | 46 | #include <sys/types.h> |
47 | #include <sys/time.h> | | 47 | #include <sys/time.h> |
| | | 48 | |
| | | 49 | #ifdef NOTYET |
| | | 50 | #include <sys/evcnt.h> |
| | | 51 | #endif |
| | | 52 | |
48 | #include <assert.h> | | 53 | #include <assert.h> |
49 | | | 54 | |
50 | #include <dlfcn.h> | | 55 | #include <dlfcn.h> |
51 | #include <errno.h> | | 56 | #include <errno.h> |
52 | #include <fcntl.h> | | 57 | #include <fcntl.h> |
53 | #include <stdint.h> | | 58 | #include <stdint.h> |
54 | #include <stdio.h> | | 59 | #include <stdio.h> |
55 | #include <stdlib.h> | | 60 | #include <stdlib.h> |
56 | #include <string.h> | | 61 | #include <string.h> |
57 | #include <unistd.h> | | 62 | #include <unistd.h> |
58 | | | 63 | |
59 | #include <rump/rumpuser.h> | | 64 | #include <rump/rumpuser.h> |
60 | | | 65 | |
| @@ -343,38 +348,66 @@ getsymbols(struct link_map *map, int ism | | | @@ -343,38 +348,66 @@ getsymbols(struct link_map *map, int ism |
343 | strtaboff += strlen(cursymname)+1; | | 348 | strtaboff += strlen(cursymname)+1; |
344 | } | | 349 | } |
345 | | | 350 | |
346 | return 0; | | 351 | return 0; |
347 | } | | 352 | } |
348 | | | 353 | |
349 | static void | | 354 | static void |
350 | process_object(void *handle, | | 355 | process_object(void *handle, |
351 | rump_modinit_fn domodinit, rump_compload_fn docompload) | | 356 | rump_modinit_fn domodinit, rump_compload_fn docompload) |
352 | { | | 357 | { |
353 | const struct modinfo *const *mi_start, *const *mi_end; | | 358 | const struct modinfo *const *mi_start, *const *mi_end; |
354 | struct rump_component *const *rc, *const *rc_end; | | 359 | struct rump_component *const *rc, *const *rc_end; |
355 | | | 360 | |
| | | 361 | struct sysctllog; |
| | | 362 | typedef void sysctl_setup_func(struct sysctllog **); |
| | | 363 | sysctl_setup_func *const *sfp, *const *sfp_end; |
| | | 364 | |
| | | 365 | #ifdef NOTYET /* We don't yet handle link_set_evcnts */ |
| | | 366 | struct evcnt *const *evp, *const *evp_end; |
| | | 367 | #endif |
| | | 368 | |
356 | mi_start = dlsym(handle, "__start_link_set_modules"); | | 369 | mi_start = dlsym(handle, "__start_link_set_modules"); |
357 | mi_end = dlsym(handle, "__stop_link_set_modules"); | | 370 | mi_end = dlsym(handle, "__stop_link_set_modules"); |
358 | if (mi_start && mi_end) | | 371 | if (mi_start && mi_end) |
359 | domodinit(mi_start, (size_t)(mi_end-mi_start)); | | 372 | domodinit(mi_start, (size_t)(mi_end-mi_start)); |
360 | | | 373 | |
361 | rc = dlsym(handle, "__start_link_set_rump_components"); | | 374 | rc = dlsym(handle, "__start_link_set_rump_components"); |
362 | rc_end = dlsym(handle, "__stop_link_set_rump_components"); | | 375 | rc_end = dlsym(handle, "__stop_link_set_rump_components"); |
363 | if (rc && rc_end) { | | 376 | if (rc && rc_end) { |
364 | for (; rc < rc_end; rc++) | | 377 | for (; rc < rc_end; rc++) |
365 | docompload(*rc); | | 378 | docompload(*rc); |
366 | assert(rc == rc_end); | | 379 | assert(rc == rc_end); |
367 | } | | 380 | } |
| | | 381 | |
| | | 382 | /* handle link_set_sysctl_funcs */ |
| | | 383 | sfp = dlsym(handle, "__start_link_set_sysctl_funcs"); |
| | | 384 | sfp_end = dlsym(handle, "__stop_link_set_sysctl_funcs"); |
| | | 385 | if (sfp && sfp_end) { |
| | | 386 | for (; sfp < sfp_end; sfp++) |
| | | 387 | (**sfp)(NULL); |
| | | 388 | assert(sfp == sfp_end); |
| | | 389 | } |
| | | 390 | |
| | | 391 | #ifdef NOTYET |
| | | 392 | /* handle link_set_evcnts */ |
| | | 393 | evp = dlsym(handle, "__start_link_set_evcnts"); |
| | | 394 | evp_end = dlsym(handle, "__stop_link_set_evcnts"); |
| | | 395 | if (evp && evp_end) { |
| | | 396 | for (; evp < evp_end; evp++) |
| | | 397 | evcnt_attach_static(*evp); |
| | | 398 | assert(evp == evp_end); |
| | | 399 | } |
| | | 400 | #endif |
368 | } | | 401 | } |
369 | | | 402 | |
370 | /* | | 403 | /* |
371 | * Get the linkmap from the dynlinker. Try to load kernel modules | | 404 | * Get the linkmap from the dynlinker. Try to load kernel modules |
372 | * from all objects in the linkmap. | | 405 | * from all objects in the linkmap. |
373 | */ | | 406 | */ |
374 | void | | 407 | void |
375 | rumpuser_dl_bootstrap(rump_modinit_fn domodinit, | | 408 | rumpuser_dl_bootstrap(rump_modinit_fn domodinit, |
376 | rump_symload_fn symload, rump_compload_fn compload) | | 409 | rump_symload_fn symload, rump_compload_fn compload) |
377 | { | | 410 | { |
378 | struct link_map *map, *origmap, *mainmap; | | 411 | struct link_map *map, *origmap, *mainmap; |
379 | void *mainhandle; | | 412 | void *mainhandle; |
380 | int error; | | 413 | int error; |