Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ksyms/ksyms.c
Show All 35 Lines | |||||
#include <sys/elf.h> | #include <sys/elf.h> | ||||
#include <sys/linker.h> | #include <sys/linker.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/mman.h> | #include <sys/mman.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/resourcevar.h> | #include <sys/resourcevar.h> | ||||
#include <sys/rwlock.h> | |||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <sys/sx.h> | #include <sys/sx.h> | ||||
#include <sys/uio.h> | #include <sys/uio.h> | ||||
#include <machine/elf.h> | #include <machine/elf.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
#include <vm/vm_object.h> | #include <vm/vm_object.h> | ||||
#include <vm/vm_page.h> | |||||
#include <vm/vm_pager.h> | |||||
#include "linker_if.h" | #include "linker_if.h" | ||||
#define SHDR_NULL 0 | #define SHDR_NULL 0 | ||||
#define SHDR_SYMTAB 1 | #define SHDR_SYMTAB 1 | ||||
#define SHDR_STRTAB 2 | #define SHDR_STRTAB 2 | ||||
#define SHDR_SHSTRTAB 3 | #define SHDR_SHSTRTAB 3 | ||||
▲ Show 20 Lines • Show All 375 Lines • ▼ Show 20 Lines | ksyms_open(struct cdev *dev, int flags, int fmt __unused, struct thread *td) | ||||
* snapshot of the kernel symbol table. This should work fine in the | * snapshot of the kernel symbol table. This should work fine in the | ||||
* rare case of a kernel module being loaded/unloaded at the same | * rare case of a kernel module being loaded/unloaded at the same | ||||
* time. | * time. | ||||
*/ | */ | ||||
for (try = 0; try < 3; try++) { | for (try = 0; try < 3; try++) { | ||||
ksyms_size_calc(&ts); | ksyms_size_calc(&ts); | ||||
elfsz = sizeof(struct ksyms_hdr) + ts.ts_symsz + ts.ts_strsz; | elfsz = sizeof(struct ksyms_hdr) + ts.ts_symsz + ts.ts_strsz; | ||||
object = vm_object_allocate(OBJT_PHYS, | object = vm_pager_allocate(OBJT_PHYS, NULL, round_page(elfsz), | ||||
OFF_TO_IDX(round_page(elfsz))); | VM_PROT_ALL, 0, td->td_ucred); | ||||
sc->sc_obj = object; | sc->sc_obj = object; | ||||
sc->sc_objsz = elfsz; | sc->sc_objsz = elfsz; | ||||
error = ksyms_snapshot(sc, &ts); | error = ksyms_snapshot(sc, &ts); | ||||
if (error == 0) | if (error == 0) | ||||
break; | break; | ||||
vm_object_deallocate(sc->sc_obj); | vm_object_deallocate(sc->sc_obj); | ||||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |