From nobody Fri Apr 01 00:51:27 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EAE811A52E90; Fri, 1 Apr 2022 00:51:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KV1nq6J9tz3nZD; Fri, 1 Apr 2022 00:51:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648774287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2D3/5W1bySgd7UlICtBFTJdpr2raSCv5jhLOgRD2NMI=; b=xOSOlbWmI9uA7DmcYNq9s1mUjsZTikoUz/n1Vs6/zJJ5FSlgS2nL/skP+pktMxOS01DqWT 0ShgI0C3uCqsi4r3xsTm6FsH8gqBOCtEG1h8SExDOha9RoAFjKGGDyxa9ehw/xEjXO+3zn fKh+ijNTUXe8tW7BiJr9D07KSoDU2QkZsezYRuGMl01q5jQJlt5bQE0DTkfX8KFalj8Vj5 6tdp96drePsXovmh08oCkYHsV5d34/E2GbQqe18413ggg9sd6bXdQIMb17HSqQ3djpVdfz gkiPh0Zu1eZMzSKQHFS6dS/FtccwjMUgHb9rkbu1kGOBGDNnSndSDrqMXeOlkA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B80B720AE; Fri, 1 Apr 2022 00:51:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2310pR4D012564; Fri, 1 Apr 2022 00:51:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2310pRm3012563; Fri, 1 Apr 2022 00:51:27 GMT (envelope-from git) Date: Fri, 1 Apr 2022 00:51:27 GMT Message-Id: <202204010051.2310pRm3012563@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: c25f36f630fc - main - rtld: extract calculation of the format strings for trace into a helper List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c25f36f630fce4b7af39d4bd0a3e23a2dc3396ff Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648774287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2D3/5W1bySgd7UlICtBFTJdpr2raSCv5jhLOgRD2NMI=; b=vrUYZbAjgY+MjtvwByr2UeSmXfgM8keJ2j/xqySG19S3ImJoHmeOjeH2ASZ5PtzqBeJEd6 10wvVhy2csfTxG4sCKulqLF15JI5rZzTZScsRbq7KAUz0NC2OcTRuyxH+Ld+RdF7lfAWDy znBfeU6MeOD/PChoigg89SzgaE097Bnk3ajT0GbQ/jwuJQS8iuPX4Sn/nlI2XCXC2iPPgJ A7N7mF80z/fzKVtLWHJULH/bTwEL65JwuKCzsXjU7F3Gp7/GgeGL2hYE5t1tyP5RKyutNe B/Z/3mNlNNB9inzUNntac37ut0teP6UxJ6heq9vt8b7nmUEr+jQdUd4FVnwpzg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648774287; a=rsa-sha256; cv=none; b=raqhOyuk/tiB67MIwca4VGSh/sf99RHHCAC3LtnDlYQsFVdmrWRQWtaRmh1OQSI/5KSlTR pfM+v6tg7yW6W3CH242HsqxDXqh8WIZQVFRvtLYWTxMEoH5bLV/W5C1QeP8oOq8/r2P4lP GdkaAmFK2GE6dWet+erB+LoOS3qdefegX93Au/n0AiB2Qwh+PQBe3sDQ1aJiv14CdJ2b40 oQ3s1x7HS6xAffQxkusnWFn7H/bi+D/IVzHjjP9+Vvzat6umXdOqXK05qQgltHQZ0Amec4 /vRFMe1BUDtgF5s3l7Xs26wHIQx/eRLfZVLAL4cNnb7GeN8a8gbOYOB4q4RWsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c25f36f630fce4b7af39d4bd0a3e23a2dc3396ff commit c25f36f630fce4b7af39d4bd0a3e23a2dc3396ff Author: Konstantin Belousov AuthorDate: 2022-03-30 20:35:37 +0000 Commit: Konstantin Belousov 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)) {