diff options
author | markj <markj@FreeBSD.org> | 2014-08-07 18:36:47 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2014-08-07 18:36:47 +0000 |
commit | 95576e5070819ac5bc80e16b237dc5a0061ed9a4 (patch) | |
tree | 41a88f5d1dfb9a03b88de120fe2dbb615db03792 | |
parent | 50af577d2958463bdeba4a96c7de9bad571fed80 (diff) | |
download | FreeBSD-src-95576e5070819ac5bc80e16b237dc5a0061ed9a4.zip FreeBSD-src-95576e5070819ac5bc80e16b237dc5a0061ed9a4.tar.gz |
MFC r265456, r265578:
Add a postinit debugger hook to rtld. This will be used by dtrace(1) to halt
the victim process before its entry point is called, at which point probes
and DOF data are registered with the kernel. The r_debug_state hook cannot
be used for this purpose, as it is called before the program's init routines
are invoked and in particular before DOF data is registered (via drti.o).
-rw-r--r-- | libexec/rtld-elf/Symbol.map | 1 | ||||
-rw-r--r-- | libexec/rtld-elf/rtld.c | 17 |
2 files changed, 17 insertions, 1 deletions
diff --git a/libexec/rtld-elf/Symbol.map b/libexec/rtld-elf/Symbol.map index 9ad6251..5ea7d7e 100644 --- a/libexec/rtld-elf/Symbol.map +++ b/libexec/rtld-elf/Symbol.map @@ -30,4 +30,5 @@ FBSDprivate_1.0 { _rtld_atfork_post; _rtld_addr_phdr; _rtld_get_stack_prot; + _r_debug_postinit; }; diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index ad37745..344a6d9 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -161,6 +161,7 @@ static bool matched_symbol(SymLook *, const Obj_Entry *, Sym_Match_Result *, const unsigned long); void r_debug_state(struct r_debug *, struct link_map *) __noinline; +void _r_debug_postinit(struct link_map *) __noinline; /* * Data declarations. @@ -635,6 +636,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) if (obj_main->crt_no_init) preinit_main(); objlist_call_init(&initlist, &lockstate); + _r_debug_postinit(&obj_main->linkmap); objlist_clear(&initlist); dbg("loading filtees"); for (obj = obj_list->next; obj != NULL; obj = obj->next) { @@ -3497,7 +3499,20 @@ r_debug_state(struct r_debug* rd, struct link_map *m) * even when marked __noinline. However, gdb depends on those * calls being made. */ - __asm __volatile("" : : : "memory"); + __compiler_membar(); +} + +/* + * A function called after init routines have completed. This can be used to + * break before a program's entry routine is called, and can be used when + * main is not available in the symbol table. + */ +void +_r_debug_postinit(struct link_map *m) +{ + + /* See r_debug_state(). */ + __compiler_membar(); } /* |