From patchwork Tue Apr 21 09:00:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Stelmach?= X-Patchwork-Id: 133450 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 959F44BA9020 for ; Tue, 21 Apr 2026 09:01:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 959F44BA9020 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=samsung.com header.i=@samsung.com header.a=rsa-sha256 header.s=mail20170921 header.b=MU4Hx2ro X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by sourceware.org (Postfix) with ESMTPS id 0ACD04BA23D9 for ; Tue, 21 Apr 2026 09:00:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0ACD04BA23D9 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=samsung.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0ACD04BA23D9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=210.118.77.12 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776762044; cv=none; b=W2BTWgI4fM1djajkfkjGZe6ftFTsSvRnCIWkslq+gwDnPxDiMcZCXeNbO/AwtJtXI0YYZXMQIzZyMjxhlLWVGfdGB8v95Q5OLHxZAgZviRgF9QH1h3OnD/Uepc51T4QJf7/PTrQwkca+2sadgKAZYsuv4z66TYUJEWALEIPadyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776762044; c=relaxed/simple; bh=xze3e2azsX4DT3BkaaRB3CQlefwiCpHuyFsl8vvGwTM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aQfpgLdCmh4CxnbWsNhHuJBfQLL3bpwQXu+yudaMSzCHloZyPEIhdfJ+PsRIEFAQzc4EkjI7WcCnC54kJyDcgvE8D7ihqcBwH3BTMTzpwKsDdw9Ib4IdI3nMVZeEOoT7TDE5MpgfjPdCtOiPw+YvMJASGMF7DvsMHPq5CbwHFXM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0ACD04BA23D9 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20260421090042euoutp028c9a457d354dbe90cdaa00ae126b97b7~oU6nzjpt63042630426euoutp02c for ; Tue, 21 Apr 2026 09:00:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20260421090042euoutp028c9a457d354dbe90cdaa00ae126b97b7~oU6nzjpt63042630426euoutp02c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1776762042; bh=B3pSE+wanztl7pgR6fdYwaWUYKSMDZTGKX+W4yQWMUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MU4Hx2rof9pYNtXWpS7jRAeYxTdKpA25P/todNyqFz1S+DWZY0udroioGvuBgjGI1 gu07ADc4fC70w3eUjcCBG2NUMlsHi2Pq9F5Pmz3VBDzNhKr0vjbxftTlouzawoqiQW phhFdIrY9JFtgyEZvHhmZ+7zuUFTrEFxKfO80lbo= Received: from eusmtip2.samsung.com (unknown [203.254.199.222]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20260421090041eucas1p165ef40e3d03f80d2efbf10bbb05b1a9c~oU6nRVcmj2862128621eucas1p1h; Tue, 21 Apr 2026 09:00:41 +0000 (GMT) Received: from localhost (unknown [106.120.51.111]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20260421090041eusmtip258d76c5b3d8a984c8500f37db59ec25d~oU6nM95Cb1714417144eusmtip2h; Tue, 21 Apr 2026 09:00:41 +0000 (GMT) From: =?utf-8?q?=C5=81ukasz_Stelmach?= To: libc-alpha@sourceware.org Cc: j.kryszyn@samsung.com, m.szyprowski@samsung.com, k.lewandowsk@samsung.com, cw00.choi@samsung.com, dongkyun.s@samsung.com, sungguk.na@samsung.com, Mateusz Moscicki , =?utf-8?q?=C5=81ukasz_Stelmach?= Subject: [RFC 2/3] ldconfig: Add an option to ignore standard path during ld.so.cache generation Date: Tue, 21 Apr 2026 11:00:19 +0200 Message-ID: <20260421090020.59726-3-l.stelmach@samsung.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260421090020.59726-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-CMS-MailID: 20260421090041eucas1p165ef40e3d03f80d2efbf10bbb05b1a9c X-Msg-Generator: CA X-RootMTR: 20260421090041eucas1p165ef40e3d03f80d2efbf10bbb05b1a9c X-EPHeader: CA X-CMS-RootMailID: 20260421090041eucas1p165ef40e3d03f80d2efbf10bbb05b1a9c References: <20260421090020.59726-1-l.stelmach@samsung.com> X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org From: Mateusz Moscicki Add -I/--ignore-standard-dirs option to ignore standard library paths. With this change, it is possible to generate an ld.so.cache file that contains only libraries from the directories included in the specified config, without adding libraries from standard paths such as /lib, /usr/lib, etc. Usage: cat < ldconf.txt /opt/lib /opt/lib-special EOF ldconfig -C ld.so.cache.custom -f ldconf.txt -I Signed-off-by: Mateusz Mościcki Signed-off-by: Łukasz Stelmach --- elf/ldconfig.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 0f3ef707dd..2ca763313a 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -111,6 +111,11 @@ static char *cache_file; /* Configuration file. */ static const char *config_file; +#ifdef DLCONF +/* Don't add the standard system paths */ +static int opt_ignore_standard; +#endif /* DLCONF */ + /* Name and version of program. */ static void print_version (FILE *stream, struct argp_state *state); void (*argp_program_version_hook) (FILE *, struct argp_state *) @@ -133,6 +138,9 @@ static const struct argp_option options[] = { NULL, 'l', NULL, 0, N_("Manually link individual libraries."), 0}, { "format", 'c', N_("FORMAT"), 0, N_("Format to use: new (default), old, or compat"), 0}, { "ignore-aux-cache", 'i', NULL, 0, N_("Ignore auxiliary cache file"), 0}, +#ifdef DLCONF + { "ignore-standard-dirs", 'I', NULL, 0, N_("Ignore standard directories"), 0}, +#endif /* DLCONF */ { NULL, 0, NULL, 0, NULL, 0 } }; @@ -198,6 +206,11 @@ parse_opt (int key, char *arg, struct argp_state *state) else if (strcmp (arg, "new") == 0) opt_format = opt_format_new; break; +#ifdef DLCONF + case 'I': + opt_ignore_standard = 1; + break; +#endif /* DLCONF */ default: return ARGP_ERR_UNKNOWN; } @@ -1287,11 +1300,17 @@ main (int argc, char **argv) if (!opt_only_cline) { parse_conf (config_file, true); - +#ifdef DLCONF + if (!opt_ignore_standard) + { +#endif /* DLCONF */ /* Always add the standard search paths. */ add_system_dir (SLIBDIR); if (strcmp (SLIBDIR, LIBDIR)) add_system_dir (LIBDIR); +#ifdef DLCONF + } +#endif /* DLCONF */ } const char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE;