git: c193f01267d7 - stable/13 - rtld: trace preloaded objects
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 08 Apr 2022 01:25:29 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c193f01267d76729ed9cd928038680868d24761d commit c193f01267d76729ed9cd928038680868d24761d Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-03-30 21:01:54 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-04-08 01:25:17 +0000 rtld: trace preloaded objects (cherry picked from commit 0913953c9ed0f6ac3dd57aa06e1d7c8a1a6c5530) --- libexec/rtld-elf/rtld.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index dea6e3c8c037..1b874327ce0c 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -172,7 +172,7 @@ static int symlook_needed(SymLook *, const Needed_Entry *, DoneList *); static int symlook_obj1_sysv(SymLook *, const Obj_Entry *); static int symlook_obj1_gnu(SymLook *, const Obj_Entry *); static void *tls_get_addr_slow(Elf_Addr **, int, size_t, bool) __noinline; -static void trace_loaded_objects(Obj_Entry *); +static void trace_loaded_objects(Obj_Entry *, bool); static void unlink_object(Obj_Entry *); static void unload_object(Obj_Entry *, RtldLockState *lockstate); static void unref_dag(Obj_Entry *); @@ -872,7 +872,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) dump_auxv(aux_info); if (ld_tracing) { /* We're done */ - trace_loaded_objects(obj_main); + trace_loaded_objects(obj_main, true); exit(0); } @@ -3878,7 +3878,7 @@ dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags, lock_release(rtld_bind_lock, lockstate); return (obj); trace: - trace_loaded_objects(obj); + trace_loaded_objects(obj, false); if (lockstate == &mlockstate) lock_release(rtld_bind_lock, lockstate); exit(0); @@ -5038,17 +5038,17 @@ trace_print_obj(Obj_Entry *obj, const char *name, const char *path, } static void -trace_loaded_objects(Obj_Entry *obj) +trace_loaded_objects(Obj_Entry *obj, bool show_preload) { const char *fmt1, *fmt2, *main_local; - bool list_containers; + const char *name, *path; + bool first_spurious, list_containers; trace_calc_fmts(&main_local, &fmt1, &fmt2); list_containers = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_ALL) != NULL; for (; obj != NULL; obj = TAILQ_NEXT(obj, next)) { Needed_Entry *needed; - const char *name, *path; if (obj->marker) continue; @@ -5068,6 +5068,23 @@ trace_loaded_objects(Obj_Entry *obj) fmt1, fmt2); } } + + if (show_preload) { + first_spurious = true; + TAILQ_FOREACH(obj, &obj_list, next) { + if (obj->marker || obj == obj_main || obj->traced) + continue; + + if (first_spurious) { + rtld_printf("[preloaded]\n"); + first_spurious = false; + } + Name_Entry *fname = STAILQ_FIRST(&obj->names); + name = fname == NULL ? "<unknown>" : fname->name; + trace_print_obj(obj, name, obj->path, main_local, + fmt1, fmt2); + } + } } /*