FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_gdb.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/mount.h>
#include <sys/pcpu.h>
#include <sys/proc.h>
#include <sys/namei.h>
#include <sys/fcntl.h>
#include <sys/vnode.h>
#include <sys/linker.h>
#include <machine/elf.h>
#include <net/vnet.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <sys/link_elf.h>
#include "linker_if.h"
#include <kern/kern_ctf.c>
Go to the source code of this file.
Data Structures | |
struct | elf_file |
struct | elf_set |
Macros | |
#define | MAXSEGS 4 |
Typedefs | |
typedef struct elf_file * | elf_file_t |
Functions | |
__FBSDID ("$BSDSUniX$") | |
TAILQ_HEAD (elf_set_head, elf_set) | |
static int | link_elf_link_common_finish (linker_file_t) |
static int | link_elf_link_preload (linker_class_t cls, const char *, linker_file_t *) |
static int | link_elf_link_preload_finish (linker_file_t) |
static int | link_elf_load_file (linker_class_t, const char *, linker_file_t *) |
static int | link_elf_lookup_symbol (linker_file_t, const char *, c_linker_sym_t *) |
static int | link_elf_symbol_values (linker_file_t, c_linker_sym_t, linker_symval_t *) |
static int | link_elf_search_symbol (linker_file_t, caddr_t, c_linker_sym_t *, long *) |
static void | link_elf_unload_file (linker_file_t) |
static void | link_elf_unload_preload (linker_file_t) |
static int | link_elf_lookup_set (linker_file_t, const char *, void ***, void ***, int *) |
static int | link_elf_each_function_name (linker_file_t, int(*)(const char *, void *), void *) |
static int | link_elf_each_function_nameval (linker_file_t, linker_function_nameval_callback_t, void *) |
static void | link_elf_reloc_local (linker_file_t) |
static long | link_elf_symtab_get (linker_file_t, const Elf_Sym **) |
static long | link_elf_strtab_get (linker_file_t, caddr_t *) |
static Elf_Addr | elf_lookup (linker_file_t, Elf_Size, int) |
static int | parse_dynamic (elf_file_t) |
static int | relocate_file (elf_file_t) |
static int | link_elf_preload_parse_symbols (elf_file_t) |
static void | elf_set_add (struct elf_set_head *list, Elf_Addr start, Elf_Addr stop, Elf_Addr base) |
static int | elf_set_find (struct elf_set_head *list, Elf_Addr addr, Elf_Addr *start, Elf_Addr *base) |
static void | elf_set_delete (struct elf_set_head *list, Elf_Addr start) |
static void | link_elf_error (const char *filename, const char *s) |
static void | link_elf_init (void *arg) |
SYSINIT (link_elf, SI_SUB_KLD, SI_ORDER_THIRD, link_elf_init, 0) | |
static int | parse_dpcpu (elf_file_t ef) |
Elf_Addr | elf_relocaddr (linker_file_t lf, Elf_Addr x) |
static const char * | symbol_name (elf_file_t ef, Elf_Size r_info) |
static unsigned long | elf_hash (const char *name) |
const Elf_Sym * | elf_get_sym (linker_file_t lf, Elf_Size symidx) |
const char * | elf_get_symname (linker_file_t lf, Elf_Size symidx) |
Variables | |
static kobj_method_t | link_elf_methods [] |
static struct linker_class | link_elf_class |
static struct elf_set_head | set_pcpu_list |
struct _dynamic | _DYNAMIC |
#define MAXSEGS 4 |
Definition at line 74 of file link_elf.c.
Referenced by link_elf_load_file().
typedef struct elf_file * elf_file_t |
__FBSDID | ( | "$BSDSUniX$" | ) |
const Elf_Sym* elf_get_sym | ( | linker_file_t | lf, |
Elf_Size | symidx | ||
) |
Definition at line 1496 of file link_elf.c.
References elf_file::nchains, and elf_file::symtab.
const char* elf_get_symname | ( | linker_file_t | lf, |
Elf_Size | symidx | ||
) |
Definition at line 1506 of file link_elf.c.
References elf_file::nchains, elf_file::strtab, sym, and elf_file::symtab.
|
static |
Definition at line 1236 of file link_elf.c.
Referenced by link_elf_lookup_symbol().
|
static |
Definition at line 1525 of file link_elf.c.
References elf_file::address, elf_set_find(), linker_file_lookup_symbol(), elf_file::nchains, set_pcpu_list, start, elf_file::strtab, sym, and elf_file::symtab.
Referenced by link_elf_reloc_local(), and relocate_file().
Elf_Addr elf_relocaddr | ( | linker_file_t | lf, |
Elf_Addr | x | ||
) |
Definition at line 1062 of file link_elf.c.
References elf_file::pcpu_base, and elf_file::pcpu_start.
|
static |
Definition at line 199 of file link_elf.c.
References elf_set::es_base, elf_set::es_start, elf_set::es_stop, malloc(), set, start, and stop.
Referenced by parse_dpcpu().
|
static |
Definition at line 245 of file link_elf.c.
References elf_set::es_start, free(), and set.
Referenced by link_elf_unload_file().
|
static |
Definition at line 227 of file link_elf.c.
References elf_set::es_base, elf_set::es_start, and set.
Referenced by elf_lookup().
|
static |
Definition at line 1436 of file link_elf.c.
References callback, elf_file::ddbstrtab, elf_file::ddbsymtab, and symp.
|
static |
Definition at line 1456 of file link_elf.c.
References callback, elf_file::ddbsymtab, link_elf_symbol_values(), and symp.
|
static |
Definition at line 330 of file link_elf.c.
References printf().
Referenced by link_elf_load_file().
|
static |
Definition at line 371 of file link_elf.c.
References __ELF_WORD_SIZE, _DYNAMIC, elf_file::address, elf_file::dynamic, link_elf_link_common_finish(), link_elf_preload_parse_symbols(), linker_add_class(), linker_kernel_file, linker_make_file(), elf_file::modptr, elf_file::object, panic(), parse_dynamic(), preload_search_by_type(), preload_search_info(), elf_file::preloaded, and set_pcpu_list.
|
static |
Definition at line 343 of file link_elf.c.
References elf_file::address, elf_file::dynamic, and malloc().
Referenced by link_elf_init(), link_elf_link_preload_finish(), and link_elf_load_file().
|
static |
Definition at line 639 of file link_elf.c.
References __ELF_WORD_SIZE, elf_file::address, elf_file::dynamic, link_elf_reloc_local(), linker_file_unload(), linker_make_file(), elf_file::modptr, elf_file::object, parse_dpcpu(), parse_dynamic(), preload_search_by_name(), preload_search_info(), elf_file::preloaded, and type.
|
static |
Definition at line 699 of file link_elf.c.
References elf_file::dynamic, link_elf_link_common_finish(), link_elf_preload_parse_symbols(), linker_load_module(), relocate_file(), and elf_file::strtab.
|
static |
Definition at line 724 of file link_elf.c.
References elf_file::address, elf_file::ddbstrcnt, elf_file::ddbstrtab, elf_file::ddbsymcnt, elf_file::ddbsymtab, elf_file::dynamic, free(), Giant, link_elf_error(), link_elf_link_common_finish(), link_elf_reloc_local(), linker_file_unload(), linker_load_dependencies(), linker_load_module(), linker_make_file(), malloc(), MAXSEGS, NDFREE(), elf_file::object, parse_dpcpu(), parse_dynamic(), relocate_file(), elf_file::strbase, elf_file::strtab, elf_file::symbase, vn_close(), vn_open(), and vn_rdwr().
|
static |
Definition at line 1383 of file link_elf.c.
References count, free(), link_elf_lookup_symbol(), link_elf_symbol_values(), malloc(), snprintf(), start, stop, and sym.
Referenced by parse_dpcpu().
|
static |
Definition at line 1252 of file link_elf.c.
References elf_file::buckets, elf_file::chains, elf_file::ddbstrtab, elf_file::ddbsymtab, elf_hash(), elf_file::nbuckets, elf_file::nchains, printf(), elf_file::strtab, symp, and elf_file::symtab.
Referenced by link_elf_lookup_set().
|
static |
Definition at line 435 of file link_elf.c.
References elf_file::ddbstrcnt, elf_file::ddbstrtab, elf_file::ddbsymcnt, elf_file::ddbsymtab, elf_file::modptr, preload_search_info(), printf(), strtab, and symtab.
Referenced by link_elf_init(), and link_elf_link_preload_finish().
|
static |
Definition at line 1574 of file link_elf.c.
References elf_file::address, elf_lookup(), elf_file::rel, elf_file::rela, elf_file::relasize, and elf_file::relsize.
Referenced by link_elf_link_preload(), and link_elf_load_file().
|
static |
Definition at line 1344 of file link_elf.c.
References elf_file::address, elf_file::ddbsymtab, and value.
|
static |
Definition at line 1618 of file link_elf.c.
References elf_file::ddbstrcnt, and elf_file::ddbstrtab.
|
static |
Definition at line 1320 of file link_elf.c.
References elf_file::address, elf_file::ddbstrtab, elf_file::ddbsymcnt, elf_file::ddbsymtab, elf_file::nchains, elf_file::strtab, and elf_file::symtab.
Referenced by link_elf_each_function_nameval(), and link_elf_lookup_set().
|
static |
Definition at line 1605 of file link_elf.c.
References elf_file::ddbsymcnt, and elf_file::ddbsymtab.
|
static |
Definition at line 1078 of file link_elf.c.
References elf_file::address, elf_file::ctfoff, elf_file::ctftab, dpcpu_free(), elf_set_delete(), free(), link_elf_unload_preload(), elf_file::object, elf_file::pcpu_base, elf_file::pcpu_start, elf_file::pcpu_stop, elf_file::preloaded, set_pcpu_list, elf_file::strbase, elf_file::symbase, and elf_file::typoff.
|
static |
Definition at line 1134 of file link_elf.c.
References preload_delete_name().
Referenced by link_elf_unload_file().
|
static |
Definition at line 577 of file link_elf.c.
References count, dpcpu_alloc(), dpcpu_copy(), elf_set_add(), elf_file::lf, link_elf_lookup_set(), elf_file::pcpu_base, elf_file::pcpu_start, elf_file::pcpu_stop, and set_pcpu_list.
Referenced by link_elf_link_preload(), and link_elf_load_file().
|
static |
Definition at line 488 of file link_elf.c.
References elf_file::address, elf_file::buckets, elf_file::chains, elf_file::ddbstrcnt, elf_file::ddbstrtab, elf_file::ddbsymcnt, elf_file::ddbsymtab, elf_file::dynamic, elf_file::got, elf_file::nbuckets, elf_file::nchains, elf_file::pltrel, elf_file::pltrela, elf_file::pltrelasize, elf_file::pltrelsize, elf_file::rel, elf_file::rela, elf_file::relasize, elf_file::relsize, elf_file::strsz, elf_file::strtab, and elf_file::symtab.
Referenced by link_elf_init(), link_elf_link_preload(), and link_elf_load_file().
|
static |
Definition at line 1153 of file link_elf.c.
References elf_file::address, elf_lookup(), elf_file::lf, elf_file::pltrel, elf_file::pltrela, elf_file::pltrelasize, elf_file::pltrelsize, printf(), elf_file::rel, elf_file::rela, elf_file::relasize, elf_file::relsize, and symbol_name().
Referenced by link_elf_link_preload_finish(), and link_elf_load_file().
|
static |
Definition at line 1141 of file link_elf.c.
References elf_file::strtab, and elf_file::symtab.
Referenced by mi_startup(), and relocate_file().
SYSINIT | ( | link_elf | , |
SI_SUB_KLD | , | ||
SI_ORDER_THIRD | , | ||
link_elf_init | , | ||
0 | |||
) |
TAILQ_HEAD | ( | elf_set_head | , |
elf_set | |||
) |
struct _dynamic _DYNAMIC |
Referenced by link_elf_init().
|
static |
Definition at line 180 of file link_elf.c.
|
static |
Definition at line 163 of file link_elf.c.
|
static |
Definition at line 193 of file link_elf.c.
Referenced by elf_lookup(), link_elf_init(), link_elf_unload_file(), and parse_dpcpu().