FreeBSD kernel kern code
kern_linker.c File Reference
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_kld.h"
#include "opt_hwpmc_hooks.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/boottrace.h>
#include <sys/eventhandler.h>
#include <sys/fcntl.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/libkern.h>
#include <sys/linker.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/sx.h>
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <sys/sysent.h>
#include <sys/sysproto.h>
#include <sys/vnode.h>
#include <net/vnet.h>
#include <security/mac/mac_framework.h>
#include "linker_if.h"
Include dependency graph for kern_linker.c:

Go to the source code of this file.

Macros

#define LINKER_GET_NEXT_FILE_ID(a)
 
#define INT_ALIGN(base, ptr)
 

Typedefs

typedef struct modlist * modlist_t
 

Functions

 __FBSDID ("$FreeBSD$")
 
static const char * linker_basename (const char *path)
 
static linker_file_t linker_find_file_by_name (const char *_filename)
 
static linker_file_t linker_find_file_by_id (int _fileid)
 
 SET_DECLARE (modmetadata_set, struct mod_metadata)
 
 MALLOC_DEFINE (M_LINKER, "linker", "kernel linker")
 
typedef TAILQ_HEAD (modlist)
 
static int linker_file_add_dependency (linker_file_t file, linker_file_t dep)
 
static caddr_t linker_file_lookup_symbol_internal (linker_file_t file, const char *name, int deps)
 
static int linker_load_module (const char *kldname, const char *modname, struct linker_file *parent, const struct mod_depend *verinfo, struct linker_file **lfpp)
 
static modlist_t modlist_lookup2 (const char *name, const struct mod_depend *verinfo)
 
static void linker_init (void *arg)
 
 SYSINIT (linker, SI_SUB_KLD, SI_ORDER_FIRST, linker_init, NULL)
 
static void linker_stop_class_add (void *arg)
 
 SYSINIT (linker_class, SI_SUB_KLD, SI_ORDER_ANY, linker_stop_class_add, NULL)
 
int linker_add_class (linker_class_t lc)
 
static void linker_file_sysinit (linker_file_t lf)
 
static void linker_file_sysuninit (linker_file_t lf)
 
static void linker_file_register_sysctls (linker_file_t lf, bool enable)
 
static void linker_file_enable_sysctls (linker_file_t lf)
 
static void linker_file_unregister_sysctls (linker_file_t lf)
 
static int linker_file_register_modules (linker_file_t lf)
 
static void linker_init_kernel_modules (void)
 
 SYSINIT (linker_kernel, SI_SUB_KLD, SI_ORDER_ANY, linker_init_kernel_modules, NULL)
 
static int linker_load_file (const char *filename, linker_file_t *result)
 
int linker_reference_module (const char *modname, struct mod_depend *verinfo, linker_file_t *result)
 
int linker_release_module (const char *modname, struct mod_depend *verinfo, linker_file_t lf)
 
int linker_file_foreach (linker_predicate_t *predicate, void *context)
 
linker_file_t linker_make_file (const char *pathname, linker_class_t lc)
 
int linker_file_unload (linker_file_t file, int flags)
 
int linker_ctf_get (linker_file_t file, linker_ctf_t *lc)
 
int linker_file_lookup_set (linker_file_t file, const char *name, void *firstp, void *lastp, int *countp)
 
int linker_file_function_listall (linker_file_t lf, linker_function_nameval_callback_t callback_func, void *arg)
 
caddr_t linker_file_lookup_symbol (linker_file_t file, const char *name, int deps)
 
static int linker_debug_search_symbol (caddr_t value, c_linker_sym_t *sym, long *diffp)
 
static int linker_debug_symbol_values (c_linker_sym_t sym, linker_symval_t *symval)
 
static int linker_debug_search_symbol_name (caddr_t value, char *buf, u_int buflen, long *offset)
 
int linker_ddb_search_symbol (caddr_t value, c_linker_sym_t *sym, long *diffp)
 
int linker_ddb_symbol_values (c_linker_sym_t sym, linker_symval_t *symval)
 
int linker_ddb_search_symbol_name (caddr_t value, char *buf, u_int buflen, long *offset)
 
int linker_search_symbol_name_flags (caddr_t value, char *buf, u_int buflen, long *offset, int flags)
 
int linker_search_symbol_name (caddr_t value, char *buf, u_int buflen, long *offset)
 
int linker_kldload_busy (int flags)
 
void linker_kldload_unbusy (int flags)
 
int kern_kldload (struct thread *td, const char *file, int *fileid)
 
int sys_kldload (struct thread *td, struct kldload_args *uap)
 
int kern_kldunload (struct thread *td, int fileid, int flags)
 
int sys_kldunload (struct thread *td, struct kldunload_args *uap)
 
int sys_kldunloadf (struct thread *td, struct kldunloadf_args *uap)
 
int sys_kldfind (struct thread *td, struct kldfind_args *uap)
 
int sys_kldnext (struct thread *td, struct kldnext_args *uap)
 
int sys_kldstat (struct thread *td, struct kldstat_args *uap)
 
int kern_kldstat (struct thread *td, int fileid, struct kld_file_stat *stat)
 
int sys_kldfirstmod (struct thread *td, struct kldfirstmod_args *uap)
 
int sys_kldsym (struct thread *td, struct kldsym_args *uap)
 
static modlist_t modlist_lookup (const char *name, int ver)
 
static modlist_t modlist_newmodule (const char *modname, int version, linker_file_t container)
 
static void linker_addmodules (linker_file_t lf, struct mod_metadata **start, struct mod_metadata **stop, int preload)
 
static void linker_preload (void *arg)
 
 SYSINIT (preload, SI_SUB_KLD, SI_ORDER_MIDDLE, linker_preload, NULL)
 
static void linker_preload_finish (void *arg)
 
 SYSINIT (preload_finish, SI_SUB_KTHREAD_INIT - 100, SI_ORDER_MIDDLE, linker_preload_finish, NULL)
 
 SYSCTL_STRING (_kern, OID_AUTO, module_path, CTLFLAG_RWTUN, linker_path, sizeof(linker_path), "module load search path")
 
 TUNABLE_STR ("module_path", linker_path, sizeof(linker_path))
 
static char * linker_lookup_file (const char *path, int pathlen, const char *name, int namelen, struct vattr *vap)
 
static char * linker_hints_lookup (const char *path, int pathlen, const char *modname, int modnamelen, const struct mod_depend *verinfo)
 
static char * linker_search_module (const char *modname, int modnamelen, const struct mod_depend *verinfo)
 
static char * linker_search_kld (const char *name)
 
static bool linker_root_mounted (void)
 
int linker_load_dependencies (linker_file_t lf)
 
static int sysctl_kern_function_list_iterate (const char *name, void *opaque)
 
static int sysctl_kern_function_list (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern, OID_AUTO, function_list, CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, 0, sysctl_kern_function_list, "", "kernel function list")
 

Variables

const int kld_off_address = offsetof(struct linker_file, address)
 
const int kld_off_filename = offsetof(struct linker_file, filename)
 
const int kld_off_pathname = offsetof(struct linker_file, pathname)
 
const int kld_off_next = offsetof(struct linker_file, link.tqe_next)
 
linker_file_t linker_kernel_file
 
static struct sx kld_sx
 
static u_int kld_busy
 
static struct thread * kld_busy_owner
 
static int loadcnt
 
static linker_class_list_t classes
 
static linker_file_list_t linker_files
 
static int next_file_id = 1
 
static int linker_no_more_classes = 0
 
static modlisthead_t found_modules
 
static char linker_hintfile [] = "linker.hints"
 
static char linker_path [MAXPATHLEN] = "/boot/kernel;/boot/modules"
 
static const char *const linker_ext_list []
 

Macro Definition Documentation

◆ INT_ALIGN

#define INT_ALIGN (   base,
  ptr 
)
Value:
ptr = \
(base) + roundup2((ptr) - (base), sizeof(int))

Definition at line 1900 of file kern_linker.c.

◆ LINKER_GET_NEXT_FILE_ID

#define LINKER_GET_NEXT_FILE_ID (   a)
Value:
do { \
linker_file_t lftmp; \
\
if (!cold) \
sx_assert(&kld_sx, SA_XLOCKED); \
retry: \
TAILQ_FOREACH(lftmp, &linker_files, link) { \
if (next_file_id == lftmp->id) { \
next_file_id++; \
goto retry; \
} \
} \
(a) = next_file_id; \
} while (0)
static struct sx kld_sx
Definition: kern_linker.c:109
static linker_file_list_t linker_files
Definition: kern_linker.c:120
static int next_file_id
Definition: kern_linker.c:121

Definition at line 124 of file kern_linker.c.

Typedef Documentation

◆ modlist_t

typedef struct modlist* modlist_t

Definition at line 147 of file kern_linker.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ kern_kldload()

int kern_kldload ( struct thread *  td,
const char *  file,
int *  fileid 
)

Definition at line 1128 of file kern_linker.c.

References kld_sx, linker_kldload_busy(), linker_kldload_unbusy(), linker_load_module(), priv_check(), and securelevel_gt().

Referenced by sys_kldload(), and vfs_byname_kld().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_kldstat()

int kern_kldstat ( struct thread *  td,
int  fileid,
struct kld_file_stat *  stat 
)

Definition at line 1351 of file kern_linker.c.

References kld_sx, and linker_find_file_by_id().

Referenced by sys_kldstat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_kldunload()

int kern_kldunload ( struct thread *  td,
int  fileid,
int  flags 
)

Definition at line 1197 of file kern_linker.c.

References flags, kld_sx, linker_file_unload(), linker_find_file_by_id(), linker_kldload_busy(), linker_kldload_unbusy(), printf(), priv_check(), and securelevel_gt().

Referenced by sys_kldunload(), sys_kldunloadf(), and vfs_byname_kld().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_add_class()

int linker_add_class ( linker_class_t  lc)

Definition at line 180 of file kern_linker.c.

References classes, kobj_class_compile(), lc, and linker_no_more_classes.

Referenced by link_elf_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_addmodules()

static void linker_addmodules ( linker_file_t  lf,
struct mod_metadata **  start,
struct mod_metadata **  stop,
int  preload 
)
static

Definition at line 1548 of file kern_linker.c.

References modlist_lookup(), modlist_newmodule(), printf(), start, and stop.

Referenced by linker_load_dependencies(), and linker_preload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_basename()

static const char * linker_basename ( const char *  path)
static

Definition at line 2089 of file kern_linker.c.

References filename, and path.

Referenced by linker_load_module(), linker_make_file(), and sys_kldfind().

Here is the caller graph for this function:

◆ linker_ctf_get()

int linker_ctf_get ( linker_file_t  file,
linker_ctf_t *  lc 
)

Definition at line 777 of file kern_linker.c.

References lc.

◆ linker_ddb_search_symbol()

int linker_ddb_search_symbol ( caddr_t  value,
c_linker_sym_t *  sym,
long *  diffp 
)

Definition at line 1017 of file kern_linker.c.

References diffp, linker_debug_search_symbol(), sym, and value.

Referenced by stack_symbol_ddb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_ddb_search_symbol_name()

int linker_ddb_search_symbol_name ( caddr_t  value,
char *  buf,
u_int  buflen,
long *  offset 
)

Definition at line 1031 of file kern_linker.c.

References buf, linker_debug_search_symbol_name(), and value.

Referenced by kmsan_report_hook(), and kmsan_report_inline().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_ddb_symbol_values()

int linker_ddb_symbol_values ( c_linker_sym_t  sym,
linker_symval_t *  symval 
)

Definition at line 1024 of file kern_linker.c.

References linker_debug_symbol_values(), and sym.

Referenced by stack_symbol_ddb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_debug_search_symbol()

static int linker_debug_search_symbol ( caddr_t  value,
c_linker_sym_t *  sym,
long *  diffp 
)
static

Definition at line 938 of file kern_linker.c.

References diffp, linker_files, sym, and value.

Referenced by linker_ddb_search_symbol(), and linker_debug_search_symbol_name().

Here is the caller graph for this function:

◆ linker_debug_search_symbol_name()

static int linker_debug_search_symbol_name ( caddr_t  value,
char *  buf,
u_int  buflen,
long *  offset 
)
static

Definition at line 981 of file kern_linker.c.

References buf, linker_debug_search_symbol(), linker_debug_symbol_values(), sym, and value.

Referenced by linker_ddb_search_symbol_name(), and linker_search_symbol_name_flags().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_debug_symbol_values()

static int linker_debug_symbol_values ( c_linker_sym_t  sym,
linker_symval_t *  symval 
)
static

Definition at line 969 of file kern_linker.c.

References linker_files, and sym.

Referenced by linker_ddb_symbol_values(), and linker_debug_search_symbol_name().

Here is the caller graph for this function:

◆ linker_file_add_dependency()

static int linker_file_add_dependency ( linker_file_t  file,
linker_file_t  dep 
)
static

Definition at line 783 of file kern_linker.c.

References kld_sx, and realloc().

Referenced by linker_load_dependencies(), linker_load_module(), and linker_preload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_file_enable_sysctls()

static void linker_file_enable_sysctls ( linker_file_t  lf)
static

Definition at line 335 of file kern_linker.c.

References kld_sx, linker_file_lookup_set(), start, stop, sysctl_enable_oid(), sysctl_wlock(), and sysctl_wunlock().

Referenced by linker_load_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_file_foreach()

int linker_file_foreach ( linker_predicate_t *  predicate,
void *  context 
)

Definition at line 601 of file kern_linker.c.

References kld_sx, and linker_files.

◆ linker_file_function_listall()

int linker_file_function_listall ( linker_file_t  lf,
linker_function_nameval_callback_t  callback_func,
void *  arg 
)

Definition at line 817 of file kern_linker.c.

◆ linker_file_lookup_set()

int linker_file_lookup_set ( linker_file_t  file,
const char *  name,
void *  firstp,
void *  lastp,
int *  countp 
)

◆ linker_file_lookup_symbol()

caddr_t linker_file_lookup_symbol ( linker_file_t  file,
const char *  name,
int  deps 
)

Definition at line 824 of file kern_linker.c.

References kld_sx, linker_file_lookup_symbol_internal(), name, and sym.

Referenced by elf_lookup(), and elf_obj_lookup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_file_lookup_symbol_internal()

static caddr_t linker_file_lookup_symbol_internal ( linker_file_t  file,
const char *  name,
int  deps 
)
static

Definition at line 839 of file kern_linker.c.

References kld_sx, linker_file_lookup_symbol_internal(), malloc(), name, and sym.

Referenced by linker_file_lookup_symbol(), and linker_file_lookup_symbol_internal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_file_register_modules()

static int linker_file_register_modules ( linker_file_t  lf)
static

Definition at line 378 of file kern_linker.c.

References kld_sx, linker_file_lookup_set(), linker_kernel_file, module_register(), printf(), start, and stop.

Referenced by linker_init_kernel_modules(), linker_load_file(), and linker_preload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_file_register_sysctls()

static void linker_file_register_sysctls ( linker_file_t  lf,
bool  enable 
)
static

Definition at line 309 of file kern_linker.c.

References kld_sx, linker_file_lookup_set(), start, stop, sysctl_register_disabled_oid(), sysctl_register_oid(), sysctl_wlock(), and sysctl_wunlock().

Referenced by linker_load_file(), and linker_preload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_file_sysinit()

static void linker_file_sysinit ( linker_file_t  lf)
static

Definition at line 197 of file kern_linker.c.

References Giant, kld_sx, linker_file_lookup_set(), start, stop, and sysinit.

Referenced by linker_load_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_file_sysuninit()

static void linker_file_sysuninit ( linker_file_t  lf)
static

Definition at line 252 of file kern_linker.c.

References Giant, kld_sx, linker_file_lookup_set(), start, stop, and sysinit.

Referenced by linker_file_unload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_file_unload()

◆ linker_file_unregister_sysctls()

static void linker_file_unregister_sysctls ( linker_file_t  lf)
static

Definition at line 357 of file kern_linker.c.

References kld_sx, linker_file_lookup_set(), start, stop, sysctl_unregister_oid(), sysctl_wlock(), and sysctl_wunlock().

Referenced by linker_file_unload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_find_file_by_id()

static linker_file_t linker_find_file_by_id ( int  _fileid)
static

Definition at line 589 of file kern_linker.c.

References kld_sx, and linker_files.

Referenced by kern_kldstat(), kern_kldunload(), sys_kldfirstmod(), sys_kldnext(), and sys_kldsym().

Here is the caller graph for this function:

◆ linker_find_file_by_name()

static linker_file_t linker_find_file_by_name ( const char *  _filename)
static

Definition at line 569 of file kern_linker.c.

References filename, free(), kld_sx, linker_files, malloc(), and sprintf().

Referenced by linker_load_file(), linker_load_module(), and sys_kldfind().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_hints_lookup()

static char * linker_hints_lookup ( const char *  path,
int  pathlen,
const char *  modname,
int  modnamelen,
const struct mod_depend *  verinfo 
)
static

Definition at line 1909 of file kern_linker.c.

References flags, free(), INT_ALIGN, linker_hintfile, linker_lookup_file(), malloc(), NDFREE(), path, printf(), result, snprintf(), vn_close(), vn_open(), and vn_rdwr().

Referenced by linker_search_module().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_init()

static void linker_init ( void *  arg)
static

Definition at line 160 of file kern_linker.c.

References classes, kld_sx, and linker_files.

◆ linker_init_kernel_modules()

static void linker_init_kernel_modules ( void  )
static

Definition at line 420 of file kern_linker.c.

References kld_sx, linker_file_register_modules(), and linker_kernel_file.

Here is the call graph for this function:

◆ linker_kldload_busy()

int linker_kldload_busy ( int  flags)

Definition at line 1073 of file kern_linker.c.

References flags, kld_busy, kld_busy_owner, and kld_sx.

Referenced by kern_kldload(), and kern_kldunload().

Here is the caller graph for this function:

◆ linker_kldload_unbusy()

void linker_kldload_unbusy ( int  flags)

Definition at line 1104 of file kern_linker.c.

References flags, kld_busy, kld_busy_owner, kld_sx, panic(), and wakeup().

Referenced by kern_kldload(), and kern_kldunload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_load_dependencies()

int linker_load_dependencies ( linker_file_t  lf)

Definition at line 2232 of file kern_linker.c.

References kld_sx, linker_addmodules(), linker_file_add_dependency(), linker_file_lookup_set(), linker_kernel_file, linker_load_module(), modlist_lookup(), modlist_lookup2(), printf(), start, and stop.

Referenced by link_elf_load_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_load_file()

static int linker_load_file ( const char *  filename,
linker_file_t *  result 
)
static

Definition at line 432 of file kern_linker.c.

References classes, filename, kld_sx, lc, linker_file_enable_sysctls(), linker_file_register_modules(), linker_file_register_sysctls(), linker_file_sysinit(), linker_file_unload(), linker_find_file_by_name(), printf(), prison0, and result.

Referenced by linker_load_module().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_load_module()

static int linker_load_module ( const char *  kldname,
const char *  modname,
struct linker_file *  parent,
const struct mod_depend *  verinfo,
struct linker_file **  lfpp 
)
static

◆ linker_lookup_file()

static char * linker_lookup_file ( const char *  path,
int  pathlen,
const char *  name,
int  namelen,
struct vattr *  vap 
)
static

Definition at line 1854 of file kern_linker.c.

References flags, free(), linker_ext_list, malloc(), name, NDFREE(), path, result, snprintf(), type, vn_close(), and vn_open().

Referenced by linker_hints_lookup(), and linker_search_kld().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_make_file()

linker_file_t linker_make_file ( const char *  pathname,
linker_class_t  lc 
)

Definition at line 617 of file kern_linker.c.

References filename, kld_sx, kobj_create(), lc, linker_basename(), linker_files, LINKER_GET_NEXT_FILE_ID, and loadcnt.

Referenced by link_elf_init(), link_elf_link_preload(), and link_elf_load_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_preload()

◆ linker_preload_finish()

static void linker_preload_finish ( void *  arg)
static

Definition at line 1788 of file kern_linker.c.

References kld_sx, linker_file_unload(), and linker_files.

Here is the call graph for this function:

◆ linker_reference_module()

int linker_reference_module ( const char *  modname,
struct mod_depend *  verinfo,
linker_file_t *  result 
)

Definition at line 524 of file kern_linker.c.

References kld_sx, linker_load_module(), modlist_lookup2(), and result.

Referenced by loadimage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_release_module()

int linker_release_module ( const char *  modname,
struct mod_depend *  verinfo,
linker_file_t  lf 
)

Definition at line 544 of file kern_linker.c.

References kld_sx, linker_file_unload(), and modlist_lookup2().

Referenced by loadimage(), and unloadentry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_root_mounted()

static bool linker_root_mounted ( void  )
static

Definition at line 2141 of file kern_linker.c.

References pwd_drop(), pwd_hold(), and rootvnode.

Referenced by linker_load_module().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_search_kld()

static char * linker_search_kld ( const char *  name)
static

Definition at line 2066 of file kern_linker.c.

References linker_lookup_file(), linker_path, name, and result.

Referenced by linker_load_module().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_search_module()

static char * linker_search_module ( const char *  modname,
int  modnamelen,
const struct mod_depend *  verinfo 
)
static

Definition at line 2041 of file kern_linker.c.

References linker_hints_lookup(), linker_path, and result.

Referenced by linker_load_module().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_search_symbol_name()

int linker_search_symbol_name ( caddr_t  value,
char *  buf,
u_int  buflen,
long *  offset 
)

Definition at line 1064 of file kern_linker.c.

References buf, linker_search_symbol_name_flags(), and value.

Referenced by run_interrupt_driven_config_hooks_warning().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_search_symbol_name_flags()

int linker_search_symbol_name_flags ( caddr_t  value,
char *  buf,
u_int  buflen,
long *  offset,
int  flags 
)

Definition at line 1043 of file kern_linker.c.

References buf, flags, kld_sx, linker_debug_search_symbol_name(), and value.

Referenced by linker_search_symbol_name(), and stack_symbol().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linker_stop_class_add()

static void linker_stop_class_add ( void *  arg)
static

Definition at line 171 of file kern_linker.c.

References linker_no_more_classes.

◆ MALLOC_DEFINE()

MALLOC_DEFINE ( M_LINKER  ,
"linker"  ,
"kernel linker  
)

◆ modlist_lookup()

static modlist_t modlist_lookup ( const char *  name,
int  ver 
)
static

Definition at line 1497 of file kern_linker.c.

References found_modules, and name.

Referenced by linker_addmodules(), linker_load_dependencies(), linker_preload(), and modlist_lookup2().

Here is the caller graph for this function:

◆ modlist_lookup2()

static modlist_t modlist_lookup2 ( const char *  name,
const struct mod_depend *  verinfo 
)
static

Definition at line 1510 of file kern_linker.c.

References found_modules, modlist_lookup(), and name.

Referenced by linker_load_dependencies(), linker_load_module(), linker_preload(), linker_reference_module(), and linker_release_module().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modlist_newmodule()

static modlist_t modlist_newmodule ( const char *  modname,
int  version,
linker_file_t  container 
)
static

Definition at line 1533 of file kern_linker.c.

References found_modules, malloc(), and panic().

Referenced by linker_addmodules(), and linker_preload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SET_DECLARE()

SET_DECLARE ( modmetadata_set  ,
struct mod_metadata   
)

◆ sys_kldfind()

int sys_kldfind ( struct thread *  td,
struct kldfind_args *  uap 
)

Definition at line 1257 of file kern_linker.c.

References filename, free(), kld_sx, linker_basename(), linker_find_file_by_name(), and malloc().

Here is the call graph for this function:

◆ sys_kldfirstmod()

int sys_kldfirstmod ( struct thread *  td,
struct kldfirstmod_args *  uap 
)

Definition at line 1408 of file kern_linker.c.

References kld_sx, linker_find_file_by_id(), and module_getid().

Here is the call graph for this function:

◆ sys_kldload()

int sys_kldload ( struct thread *  td,
struct kldload_args *  uap 
)

Definition at line 1178 of file kern_linker.c.

References free(), kern_kldload(), and malloc().

Here is the call graph for this function:

◆ sys_kldnext()

int sys_kldnext ( struct thread *  td,
struct kldnext_args *  uap 
)

Definition at line 1290 of file kern_linker.c.

References kld_sx, linker_files, and linker_find_file_by_id().

Here is the call graph for this function:

◆ sys_kldstat()

int sys_kldstat ( struct thread *  td,
struct kldstat_args *  uap 
)

Definition at line 1327 of file kern_linker.c.

References free(), kern_kldstat(), and malloc().

Here is the call graph for this function:

◆ sys_kldsym()

int sys_kldsym ( struct thread *  td,
struct kldsym_args *  uap 
)

Definition at line 1437 of file kern_linker.c.

References free(), kld_sx, linker_files, linker_find_file_by_id(), malloc(), and sym.

Here is the call graph for this function:

◆ sys_kldunload()

int sys_kldunload ( struct thread *  td,
struct kldunload_args *  uap 
)

Definition at line 1240 of file kern_linker.c.

References kern_kldunload().

Here is the call graph for this function:

◆ sys_kldunloadf()

int sys_kldunloadf ( struct thread *  td,
struct kldunloadf_args *  uap 
)

Definition at line 1247 of file kern_linker.c.

References kern_kldunload().

Here is the call graph for this function:

◆ sysctl_kern_function_list()

static int sysctl_kern_function_list ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2324 of file kern_linker.c.

References kld_sx, linker_files, sysctl_kern_function_list_iterate(), and sysctl_wire_old_buffer().

Here is the call graph for this function:

◆ sysctl_kern_function_list_iterate()

static int sysctl_kern_function_list_iterate ( const char *  name,
void *  opaque 
)
static

Definition at line 2311 of file kern_linker.c.

References name, and opaque.

Referenced by sysctl_kern_function_list().

Here is the caller graph for this function:

◆ SYSCTL_PROC()

SYSCTL_PROC ( _kern  ,
OID_AUTO  ,
function_list  ,
CTLTYPE_OPAQUE|CTLFLAG_RD|  CTLFLAG_MPSAFE,
NULL  ,
,
sysctl_kern_function_list  ,
""  ,
"kernel function list"   
)

◆ SYSCTL_STRING()

SYSCTL_STRING ( _kern  ,
OID_AUTO  ,
module_path  ,
CTLFLAG_RWTUN  ,
linker_path  ,
sizeof(linker_path ,
"module load search path  
)

◆ SYSINIT() [1/5]

SYSINIT ( linker  ,
SI_SUB_KLD  ,
SI_ORDER_FIRST  ,
linker_init  ,
NULL   
)

◆ SYSINIT() [2/5]

SYSINIT ( linker_class  ,
SI_SUB_KLD  ,
SI_ORDER_ANY  ,
linker_stop_class_add  ,
NULL   
)

◆ SYSINIT() [3/5]

SYSINIT ( linker_kernel  ,
SI_SUB_KLD  ,
SI_ORDER_ANY  ,
linker_init_kernel_modules  ,
NULL   
)

◆ SYSINIT() [4/5]

SYSINIT ( preload  ,
SI_SUB_KLD  ,
SI_ORDER_MIDDLE  ,
linker_preload  ,
NULL   
)

◆ SYSINIT() [5/5]

SYSINIT ( preload_finish  ,
SI_SUB_KTHREAD_INIT -  100,
SI_ORDER_MIDDLE  ,
linker_preload_finish  ,
NULL   
)

◆ TAILQ_HEAD()

typedef TAILQ_HEAD ( modlist  )

Definition at line 140 of file kern_linker.c.

References name.

◆ TUNABLE_STR()

TUNABLE_STR ( "module_path"  ,
linker_path  ,
sizeof(linker_path  
)

Variable Documentation

◆ classes

linker_class_list_t classes
static

◆ found_modules

modlisthead_t found_modules
static

◆ kld_busy

u_int kld_busy
static

Definition at line 110 of file kern_linker.c.

Referenced by linker_kldload_busy(), and linker_kldload_unbusy().

◆ kld_busy_owner

struct thread* kld_busy_owner
static

Definition at line 111 of file kern_linker.c.

Referenced by linker_kldload_busy(), and linker_kldload_unbusy().

◆ kld_off_address

const int kld_off_address = offsetof(struct linker_file, address)

Definition at line 81 of file kern_linker.c.

◆ kld_off_filename

const int kld_off_filename = offsetof(struct linker_file, filename)

Definition at line 82 of file kern_linker.c.

◆ kld_off_next

const int kld_off_next = offsetof(struct linker_file, link.tqe_next)

Definition at line 84 of file kern_linker.c.

◆ kld_off_pathname

const int kld_off_pathname = offsetof(struct linker_file, pathname)

Definition at line 83 of file kern_linker.c.

◆ kld_sx

◆ linker_ext_list

const char* const linker_ext_list[]
static
Initial value:
= {
"",
".ko",
NULL
}

Definition at line 1842 of file kern_linker.c.

Referenced by linker_lookup_file().

◆ linker_files

◆ linker_hintfile

char linker_hintfile[] = "linker.hints"
static

Definition at line 1834 of file kern_linker.c.

Referenced by linker_hints_lookup().

◆ linker_kernel_file

linker_file_t linker_kernel_file

◆ linker_no_more_classes

int linker_no_more_classes = 0
static

Definition at line 122 of file kern_linker.c.

Referenced by linker_add_class(), and linker_stop_class_add().

◆ linker_path

char linker_path[MAXPATHLEN] = "/boot/kernel;/boot/modules"
static

Definition at line 1835 of file kern_linker.c.

Referenced by linker_search_kld(), and linker_search_module().

◆ loadcnt

int loadcnt
static

Definition at line 117 of file kern_linker.c.

Referenced by linker_make_file().

◆ next_file_id

int next_file_id = 1
static

Definition at line 121 of file kern_linker.c.