Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2376287lqt; Mon, 22 Apr 2024 09:03:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbMTBNWOZTEM6WTawcxWj8SInhBh/ZIx4dzRLZ487Cmanpq+yCKzxZ6VgC3CoR7piMX4Cch094YMMsXiTb7uXxbgvuNg7A3e22lxYL5Q== X-Google-Smtp-Source: AGHT+IFHzh6rtRjaDSVcJN21F9kcRZ+V69aiyfhjUg/xRCR3xumIQIgKRR5ymDJJuC2Ph7PLC4JY X-Received: by 2002:a17:906:855:b0:a52:5a6c:a359 with SMTP id f21-20020a170906085500b00a525a6ca359mr6437110ejd.63.1713801828801; Mon, 22 Apr 2024 09:03:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713801828; cv=pass; d=google.com; s=arc-20160816; b=YpSDWqnNWeXnpH+JP7bU2jmQSIUx/FdcJGnIkbtI0UaU41QMUigCaMAtlQxsAoYHTw 8At8o7pnZmiM9Cdue+QgiImz2uRphLKh0Z1op2OEJGNC4BwAio5HxcV2GlsVYM0W+cS1 V5W0MgIGqNi4NyaNqiQIwQCSSN0L1/l9Cca+Vsh/ik5z8REThrmBIGkngm/dCM9KA3Lf inDexbuYREQPQutq6K3SzJQYQ/WV4m2GI6gmJDBb8jLOjCTUhbTPNoJakxOSoczpbGmI Ur7dW9lZ+E51c8Xs0MShosXJpZic2rxO62Qfqh3OmJtc2nYP9aHtjHsaBghTTb0JtPgO ItZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=dBs8i8vCmWrThVYVVlO0WFhWMcbrMHQ6q5IZI1wBE+Q=; fh=lq1pwA6r3TM4mstbakzPxWECy869fcqXv2zFh8WuSXo=; b=AUeEd52qJg+vWqVi2cRrEHyr+6KVbii1jx5EUCHJ4h845CHXeAt/ll2B73V/JyYIw0 G1uBiXzXdCAlh/i7ys1aZj+SSwnzwv7l4El2howKxrxO4Dssbop8mIYtuqkLNG3KBTF8 yTwva6sW5DL0kh6FblnSdqzyNucoyXKViPIkeFlbDg4fCVVZ4LiGwcoIENiavk0IRZDY YrSnreqaYBDGpZdFpAlwF0bbtGTyRw3cXdkDKYKZKBATqTSC9G+xZa5nJXOBBs9ZeH33 X6MJmjvZc8HlnYM5sE8JjGFSJMwJHLd/8MGbjxKW2a4kvxs+789ILSA7F1I1P4Dms8UZ VadA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s1uHVpyU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-153673-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153673-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id nc42-20020a1709071c2a00b00a55b67ca565si1331615ejc.948.2024.04.22.09.03.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 09:03:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153673-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s1uHVpyU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-153673-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153673-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 74E501F23606 for ; Mon, 22 Apr 2024 16:03:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1396F15359C; Mon, 22 Apr 2024 16:03:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="s1uHVpyU" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3858515381E; Mon, 22 Apr 2024 16:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713801800; cv=none; b=XRjhw6EkRqwbaVeJjjM+Bj68lkCStzWd60HW3jSekUe6bizg6/Ivves2xMdKZIKybCCkdzwknb2Ns1kKG6bNow3TZQCOJo6EP1ApVBuA4FRt+RkroA/izWxbSztFAt2igwHWWvUODiM5ZMdN0xFYuq4uuDhkndiV0eTNlgcZfOo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713801800; c=relaxed/simple; bh=ZJWwic3XrHjXmdZ+9q8lK0cufHqWrJSthx0d2ZJpeAk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=jatRIeg3fmrgZd8joRM6r02ws/dyw4EHBp/fiJBhCICEa2+gUwIar9CAOyxZqqYuY5VK6luLGvp42iCnty0Y8mE/9MkLcIWg1xGo2bdR654k/B5fHc+8snJlXn7g39TH5qMzY1269hpjoC0j/uVUCRsTYlRohczjqQNGiuBG840= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s1uHVpyU; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5E94C113CC; Mon, 22 Apr 2024 16:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713801799; bh=ZJWwic3XrHjXmdZ+9q8lK0cufHqWrJSthx0d2ZJpeAk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=s1uHVpyUQ2UwRxxd4ouLYYS8iTrt/8TV/kbRBKV61DhfrujuIfQqKadyAR9b9Eb0M N1rtVCmbgxLz74Gj1CzWT4ORqHSQwG1flMS7gUcBI4LBSwDHIqY75h0Bta4X+pDd4K Qd228EawHoxi1fRhbbvmQc79kt0V82bF35yYqZS1yaZ/rgKZL6rUUVKvE9IBAY2yDd 0T97hMk+JDc1iWsBzKoxbpGWwY5reqf4uUbr5ByWD0pFVJ+47zbH2TCg7o8OdL5Zet X1TXMRdJXlV0NYbk1pd5O+FMNpjUC853SUhiWPQH6SAi0/tPPFOVE3eZQAsI9D0yJ/ ofhO82gU+aHNA== Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2d858501412so62238571fa.0; Mon, 22 Apr 2024 09:03:19 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCW5hiY1LoaeqqobN/TRiXt0yRIxnS9IKD9qINaRbCLbzjQ3RWYfP93snb/ZLqae0SGl80eeclSH+iQN/MWa0ESXM5hz6eLyPETRmJQ3 X-Gm-Message-State: AOJu0Yxi/OsXCt7folQmcKojaRvG6lAT+J9cl+cJ9vvKsPmVaXF41aNR MT30tSZ5cLdIEsWO3jyaeXOuoneGvNSVwthDGiuYeDS3V+zxxhRSqv0V3G5pE6tmLVvGK89xfAS Ofw9Z5UvFdn+JviJCMeLpdZCWPjs= X-Received: by 2002:a2e:960d:0:b0:2d3:2ecf:c26a with SMTP id v13-20020a2e960d000000b002d32ecfc26amr6581548ljh.13.1713801798518; Mon, 22 Apr 2024 09:03:18 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240420145303.238068-2-ardb+git@google.com> In-Reply-To: <20240420145303.238068-2-ardb+git@google.com> From: Masahiro Yamada Date: Tue, 23 Apr 2024 01:02:42 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5] kallsyms: Avoid weak references for kallsyms symbols To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel , linux-kbuild@vger.kernel.org, Nick Desaulniers , Kees Cook , Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Apr 20, 2024 at 11:53=E2=80=AFPM Ard Biesheuvel wrote: > > From: Ard Biesheuvel > > kallsyms is a directory of all the symbols in the vmlinux binary, and so > creating it poses somewhat of a chicken-and-egg problem, as its non-zero > size affects the layout of the binary, and therefore the values of the > symbols. > > For this reason, the kernel is linked more than once, and the first pass > does not include any kallsyms data at all. For the linker to accept > this, the symbol declarations describing the kallsyms metadata are > emitted as having weak linkage, so they can remain unsatisfied. During > the subsequent passes, the weak references are satisfied by the kallsyms > metadata that was constructed based on information gathered from the > preceding passes. > > Weak references lead to somewhat worse codegen, because taking their > address may need to produce NULL (if the reference was unsatisfied), and > this is not usually supported by RIP or PC relative symbol references. > > Given that these references are ultimately always satisfied in the final > link, let's drop the weak annotation on the declarations, and instead, > provide fallback definitions with weak linkage. This informs the > compiler that ultimately, the reference will always be satisfied. > > While at it, drop the FRV specific annotation that these symbols reside > in .rodata - FRV is long gone. > > Cc: Masahiro Yamada > Cc: linux-kbuild@vger.kernel.org > Acked-by: Nick Desaulniers > Acked-by: Kees Cook > Acked-by: Arnd Bergmann > Link: https://lore.kernel.org/all/20240415075837.2349766-5-ardb+git@googl= e.com > Signed-off-by: Ard Biesheuvel > --- > v5: - avoid PROVIDE() in the linker script, use weak definitions instead > - drop tested-by, replace reviewed-by with acked-by > Applied to linux-kbuild. Thanks. --=20 Best Regards Masahiro Yamada