git: 61bb7ef55105 - stable/13 - rtld: extract calculation of the format strings for trace into a helper
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 08 Apr 2022 01:25:25 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=61bb7ef5510535bc3660cd3ab2f969ef44af1ccc commit 61bb7ef5510535bc3660cd3ab2f969ef44af1ccc Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-03-30 20:35:37 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-04-08 01:25:17 +0000 rtld: extract calculation of the format strings for trace into a helper (cherry picked from commit c25f36f630fce4b7af39d4bd0a3e23a2dc3396ff) --- libexec/rtld-elf/rtld.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index b495c5f5d8a8..f0263ec487d4 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -4966,21 +4966,28 @@ symlook_obj1_gnu(SymLook *req, const Obj_Entry *obj) } static void -trace_loaded_objects(Obj_Entry *obj) +trace_calc_fmts(const char **main_local, const char **fmt1, const char **fmt2) { - const char *fmt1, *fmt2, *fmt, *main_local, *list_containers; - int c; + *main_local = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_PROGNAME); + if (*main_local == NULL) + *main_local = ""; - if ((main_local = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_PROGNAME)) == - NULL) - main_local = ""; + *fmt1 = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_FMT1); + if (*fmt1 == NULL) + *fmt1 = "\t%o => %p (%x)\n"; - if ((fmt1 = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_FMT1)) == NULL) - fmt1 = "\t%o => %p (%x)\n"; + *fmt2 = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_FMT2); + if (*fmt2 == NULL) + *fmt2 = "\t%o (%x)\n"; +} - if ((fmt2 = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_FMT2)) == NULL) - fmt2 = "\t%o (%x)\n"; +static void +trace_loaded_objects(Obj_Entry *obj) +{ + const char *fmt1, *fmt2, *fmt, *main_local, *list_containers; + int c; + trace_calc_fmts(&main_local, &fmt1, &fmt2); list_containers = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_ALL); for (; obj != NULL; obj = TAILQ_NEXT(obj, next)) {