From nobody Wed Dec 08 21:59:29 2021 X-Original-To: dev-commits-src-all@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 6BB9018C3ACF; Wed, 8 Dec 2021 21:59:30 +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 4J8WKZ090Bz4Rdh; Wed, 8 Dec 2021 21:59:29 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 91DA31ACC3; Wed, 8 Dec 2021 21:59:29 +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 1B8LxTE3064138; Wed, 8 Dec 2021 21:59:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B8LxTR1064137; Wed, 8 Dec 2021 21:59:29 GMT (envelope-from git) Date: Wed, 8 Dec 2021 21:59:29 GMT Message-Id: <202112082159.1B8LxTR1064137@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: ecd8245e0d77 - main - Kernel linkers: add emergency sysctl to restore old behavior List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: ecd8245e0d7784bcd78dafce233f303eee765068 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639000770; 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=W71jZ7AAdscEZ7ZkADQwRouPZJFr9pnEFbiNgKH8Ck0=; b=T3v7D5PeUy/1NfbMxUcwoo9tteg+qo/4866IdeQxUVUZbCfNoXuhIUtYxrrPfc0+LmnoRk ojmH1/w/DfjLYnMlS4eiOHbduPaaeW8T3DnoJfVDYMZC2Q9JmqYjYbpWvNox5pISsBpgBD 0ItmEP1xNusFNONtyEuUWeG9m2mNliTqRSYA1ZcJnnIUrBJAn9u1zEr0fXwB/94NcnS+sj 9BaPaoyhpDgdDdLJQ9E96UQXxhTBJKP4+NgrNPTK+ez93SkfAnNrJXvOswAe/ighQ2kqDw VOb7SDStJ2aOf/W+7pJDZ5TkaudFTaIYjy17KLOiVHK6tuNrW8war3RYgp05cQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639000770; a=rsa-sha256; cv=none; b=Bsp8q0LloTKdsHWX1nHAfseuUdKJwqtV3t9qfpBh0rmhu7yIjYpyaieRbuR7hClZms4Joo 2xFQGydZZezfHv/4v4duCWgz6dyHrer9vuh81+6xzktaGhb9R3NDJZX9DBtGM+Ow5xA2hW GT/P1/quCsg2MVLuGCZlxCVV7FzVLgFzYl8Ny1wem8kDo+vOvRunRExMu1rkTgsdiuaYbS ky2x7CsMkYiZCThE1tASfNtgjHGW3N7dSRlVxngeD9fl5IjWM2UiShWnCGIJOKBw80CEbK dAhAuqN1FMkCK/nca7gnn2aWiN2EBEjLegQ3h6/3Q1zbYyAEPSBfu/NEsVAUEA== 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=ecd8245e0d7784bcd78dafce233f303eee765068 commit ecd8245e0d7784bcd78dafce233f303eee765068 Author: Konstantin Belousov AuthorDate: 2021-11-07 09:26:26 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-08 21:32:30 +0000 Kernel linkers: add emergency sysctl to restore old behavior allowing linking to static symbols from other files. Default the new settings to true, delaying the change of the kernel linker behavior for other day. Suggested by: emaste PR: 207898 Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32878 --- sys/kern/link_elf.c | 9 +++++++++ sys/kern/link_elf_obj.c | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index dc8002be0e89..cbd30bef4087 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -194,6 +194,11 @@ static struct linker_class link_elf_class = { link_elf_methods, sizeof(struct elf_file) }; +static bool link_elf_leak_locals = true; +SYSCTL_BOOL(_debug, OID_AUTO, link_elf_leak_locals, + CTLFLAG_RWTUN, &link_elf_leak_locals, 0, + "Allow local symbols to participate in global module symbol resolution"); + typedef int (*elf_reloc_fn)(linker_file_t lf, Elf_Addr relocbase, const void *data, int type, elf_lookup_fn lookup); @@ -1552,6 +1557,8 @@ link_elf_lookup_symbol1(linker_file_t lf, const char *name, c_linker_sym_t *sym, static int link_elf_lookup_symbol(linker_file_t lf, const char *name, c_linker_sym_t *sym) { + if (link_elf_leak_locals) + return (link_elf_lookup_debug_symbol(lf, name, sym)); return (link_elf_lookup_symbol1(lf, name, sym, false)); } @@ -1612,6 +1619,8 @@ static int link_elf_symbol_values(linker_file_t lf, c_linker_sym_t sym, linker_symval_t *symval) { + if (link_elf_leak_locals) + return (link_elf_debug_symbol_values(lf, sym, symval)); return (link_elf_symbol_values1(lf, sym, symval, false)); } diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index ec2319ffad47..9be5f7913b49 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -183,6 +184,11 @@ static struct linker_class link_elf_class = { link_elf_methods, sizeof(struct elf_file) }; +static bool link_elf_obj_leak_locals = true; +SYSCTL_BOOL(_debug, OID_AUTO, link_elf_obj_leak_locals, + CTLFLAG_RWTUN, &link_elf_obj_leak_locals, 0, + "Allow local symbols to participate in global module symbol resolution"); + static int relocate_file(elf_file_t ef); static void elf_obj_cleanup_globals_cache(elf_file_t); @@ -1455,7 +1461,8 @@ link_elf_lookup_symbol1(linker_file_t lf, const char *name, c_linker_sym_t *sym, static int link_elf_lookup_symbol(linker_file_t lf, const char *name, c_linker_sym_t *sym) { - return (link_elf_lookup_symbol1(lf, name, sym, false)); + return (link_elf_lookup_symbol1(lf, name, sym, + link_elf_obj_leak_locals)); } static int @@ -1494,7 +1501,8 @@ static int link_elf_symbol_values(linker_file_t lf, c_linker_sym_t sym, linker_symval_t *symval) { - return (link_elf_symbol_values1(lf, sym, symval, false)); + return (link_elf_symbol_values1(lf, sym, symval, + link_elf_obj_leak_locals)); } static int