git: c25f36f630fc - main - rtld: extract calculation of the format strings for trace into a helper
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 01 Apr 2022 00:51:27 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=c25f36f630fce4b7af39d4bd0a3e23a2dc3396ff
commit c25f36f630fce4b7af39d4bd0a3e23a2dc3396ff
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-03-30 20:35:37 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-04-01 00:51:21 +0000
rtld: extract calculation of the format strings for trace into a helper
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34716
---
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 9ab84b3e3fa3..a5c2755a0cb2 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -4920,21 +4920,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)) {