From nobody Fri Apr 8 01:25:26 2022 X-Original-To: dev-commits-src-branches@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 DB8891A83753; Fri, 8 Apr 2022 01:25:26 +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 4KZLCp5bhJz3FTl; Fri, 8 Apr 2022 01:25:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649381126; 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=OsnQG/vJGqL8glFt2ko+MBwRV2ipyiTvYz4ZPEMSWJA=; b=dSXBZNhsOj5Izds/c5sNkFFPyCsOuknqwA914V5u0i54TeGLJe4IWuHHeerbu+MGJIwxqM 3m5jItcPu/2fDnhIRAmvhYrRNZwYDi+4IVj0K/x1Bmii6EQMEK390wBrwqqJzC/bCK2aa9 B8umd4wZ0mhKTcRK5DftMXvGMXPTxDsDlS6r4vLuEXT3h4CLv6tUKikd2s5p7Ley4JiERC NmchW7MghUkwOm1mqrptIqUBRL3O5DyhDSZGDNk5E0De2T9rKykAgV1INWUhvPlS6ojymB dGdBTKKJ8O292/0f4HcTKderLygEIVb203jcjdrXd95y1HnSOEhOcneERUBEjw== 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 9878B1B533; Fri, 8 Apr 2022 01:25:26 +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 2381PQOx095142; Fri, 8 Apr 2022 01:25:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2381PQuR095141; Fri, 8 Apr 2022 01:25:26 GMT (envelope-from git) Date: Fri, 8 Apr 2022 01:25:26 GMT Message-Id: <202204080125.2381PQuR095141@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: bd36c568070b - stable/13 - rtld: extract printer for a single traced object into a helper List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: bd36c568070b7c3794f964e9315d2c41ff3f5c15 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649381126; 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=OsnQG/vJGqL8glFt2ko+MBwRV2ipyiTvYz4ZPEMSWJA=; b=tcbtMxp7S9+vBZKfKzpWEQMySEcRVWUyEzA+wPciJEqwSBr8qZ1McBBG8lRM7XOSNjutt2 rq9YioNzw83P9YSkBT0anFOLX+g0TxIOhlvlXIwdTB7ErH4keXjNj3vwTObhMOcs3vTmlK ndoNRs44+3is7CYqqq6HqYLhALYHeqwe09bscCQhRkpkCQvniucMdBtl4MmowtQjIETpPp fTr5xWfhyMJei4RcOaU8CGdT325zendQ3UnZ9hn6XadYWPp8woaiV3vOtRNpoi/O7mRTM+ ZThVjg37t4DmFNPlVvuqp0MUIOLfQQklPue+XrXG/bpvloPeWqdx9Dlr0vTFag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649381126; a=rsa-sha256; cv=none; b=bGbqGk2yT7K1SKShkGMTepif3Wwb/SNzoFHosTiJGQ48Q/dGO/wG3C2hBaCsCse2TrtPxf 5Rnu37PeasHdC3eBeietWHfFDWqFT+6JxNPeq801J0h3d0Vdatdzi3ejyKLjQMoEHmcIEi pwLWrjcG3tNniK4zAseRTlRP+50cJKHvGHMm6qQb2x0gUhwvSaq5ot0/Pfk4+ECS0tNmUS 9Ti+sJglLuI5Glm96os+CUWa3Ow+2wW7KxPGy2C9T6Db2WHrPlGzb7ZKB1NGw1h+H5yDMn qLi43lcm+N/RITavhuLd2fttx50AH2+6g4fn8GJ4xPMnoeyaIMpc10mZ72kjng== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=bd36c568070b7c3794f964e9315d2c41ff3f5c15 commit bd36c568070b7c3794f964e9315d2c41ff3f5c15 Author: Konstantin Belousov AuthorDate: 2022-03-30 20:46:21 +0000 Commit: Konstantin Belousov CommitDate: 2022-04-08 01:25:17 +0000 rtld: extract printer for a single traced object into a helper (cherry picked from commit 24d0c9c1f565bab6e97ec629f223e85b18bc700a) --- libexec/rtld-elf/rtld.c | 118 ++++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 60 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index f0263ec487d4..a73dc5e5d350 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -4981,11 +4981,66 @@ trace_calc_fmts(const char **main_local, const char **fmt1, const char **fmt2) *fmt2 = "\t%o (%x)\n"; } +static void +trace_print_obj(Obj_Entry *obj, const char *name, const char *path, + const char *main_local, const char *fmt1, const char *fmt2) +{ + const char *fmt; + int c; + + fmt = strncmp(name, "lib", 3) == 0 ? fmt1 : fmt2; /* XXX bogus */ + while ((c = *fmt++) != '\0') { + switch (c) { + default: + rtld_putchar(c); + continue; + case '\\': + switch (c = *fmt) { + case '\0': + continue; + case 'n': + rtld_putchar('\n'); + break; + case 't': + rtld_putchar('\t'); + break; + } + break; + case '%': + switch (c = *fmt) { + case '\0': + continue; + case '%': + default: + rtld_putchar(c); + break; + case 'A': + rtld_putstr(main_local); + break; + case 'a': + rtld_putstr(obj_main->path); + break; + case 'o': + rtld_putstr(name); + break; + case 'p': + rtld_putstr(path); + break; + case 'x': + rtld_printf("%p", obj != NULL ? + obj->mapbase : NULL); + break; + } + break; + } + ++fmt; + } +} + static void trace_loaded_objects(Obj_Entry *obj) { - const char *fmt1, *fmt2, *fmt, *main_local, *list_containers; - int c; + const char *fmt1, *fmt2, *main_local, *list_containers; trace_calc_fmts(&main_local, &fmt1, &fmt2); list_containers = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_ALL); @@ -4993,7 +5048,6 @@ trace_loaded_objects(Obj_Entry *obj) for (; obj != NULL; obj = TAILQ_NEXT(obj, next)) { Needed_Entry *needed; const char *name, *path; - bool is_lib; if (obj->marker) continue; @@ -5009,63 +5063,7 @@ trace_loaded_objects(Obj_Entry *obj) path = "not found"; name = obj->strtab + needed->name; - is_lib = strncmp(name, "lib", 3) == 0; /* XXX - bogus */ - - fmt = is_lib ? fmt1 : fmt2; - while ((c = *fmt++) != '\0') { - switch (c) { - default: - rtld_putchar(c); - continue; - case '\\': - switch (c = *fmt) { - case '\0': - continue; - case 'n': - rtld_putchar('\n'); - break; - case 't': - rtld_putchar('\t'); - break; - } - break; - case '%': - switch (c = *fmt) { - case '\0': - continue; - case '%': - default: - rtld_putchar(c); - break; - case 'A': - rtld_putstr(main_local); - break; - case 'a': - rtld_putstr(obj_main->path); - break; - case 'o': - rtld_putstr(name); - break; -#if 0 - case 'm': - rtld_printf("%d", sodp->sod_major); - break; - case 'n': - rtld_printf("%d", sodp->sod_minor); - break; -#endif - case 'p': - rtld_putstr(path); - break; - case 'x': - rtld_printf("%p", needed->obj ? needed->obj->mapbase : - 0); - break; - } - break; - } - ++fmt; - } + trace_print_obj(obj, name, path, main_local, fmt1, fmt2); } } }