From patchwork Fri Mar 29 09:33:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13610488 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F5E52D622 for ; Fri, 29 Mar 2024 09:34:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711704853; cv=none; b=UA5BDBls+0drMJbI2cBEdC89YC/nZ5dKXIaR6HQ+UEcX3EJNQb8VtjbD3RZUP4RMvIz/V349WDxO+Ra+rhvAYs3gQiea1KViz6DWE5h1GRG1gzxTRB4whWCp+Dy3Fh4yq9SE810huujIk94uDmsn9r1WnD9N2Ce0PyxkLRYx0WQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711704853; c=relaxed/simple; bh=YqzLsUuh++ZlBracS/PXtopG9p7kP2UzeZKBKBcMbbY=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=HYdq5IsaJy4WRX/LUgdyx3t3FfBlXV+Jp2yueYKOiftM7iNimyFR/+ANbnFXo860gmlof2EZZ/O08EgdatTJ0J1BNuqKHiwTbJmXLclfBvKCbNymIeJ9MJYium0c5UsrYJIqJYuOKDnrgv3r5lNNCT4Y+K19lPHhu0d4DpIkF9Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=wcU3pgyb; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wcU3pgyb" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-3418412a734so1051299f8f.0 for ; Fri, 29 Mar 2024 02:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711704850; x=1712309650; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=kSI+K3Sj79xTDwp3kEwJFO6zCHnVt2HEzFL8mdP9uWo=; b=wcU3pgybbRvCTZ1vJMWfwkW7xBg7/ga1kZvWCgcRCxQyjEVQoXHXOjjjDHHWz/xnl+ CK48PX5YV7EKeDv8C48L2k20pe6TfywKVEVTSzGmUGMAyzfYpo+IkoDdE1Mweleo+Y7j N3FmaHxZZQl6jhQUx/LP+WZi0DE/gGeoHpkSPHx7e8PIrS0Rp5B/op6beWYfMiXwcZM5 8V+nlVYg4b4F+4yz2vu71jge92y3gCLP5eHzctjUEEz82aFXmuW8NKULquHHPo/16IuU MTD0MUjheKHP3s8F7F7T91dTCmmRBKI16G5WGkRBCfiGKobq6gBXoy/EgeSECWFsbxkS FQVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711704850; x=1712309650; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kSI+K3Sj79xTDwp3kEwJFO6zCHnVt2HEzFL8mdP9uWo=; b=u/xtNP32L+n58ItczinMxOsZDjzcVi9N5G96us4hN1bA8gAPllMq3v4vf/yxt1JQNu BfExVXnMEahZadmeH0SMTIaBIR4/V1/JNNtH0fkReMb9NmDlciF9NRFd7YVEnTeceBMs xKRWf+2uOrAT2uAp4eJiKe19Y+5JMzBHApXMPqGdWT1u9Oh1lfgAhR/S6oj2LsA1Ngo9 lUHr+TWqf24v8+vmyVa1NBRIEdaN4OzREwu8W1I874rUpf4yUi3PIxj3Pgg/Ta0JCCv9 htXbVCOW4WA23A1C6Qo8NFhipYzCNnX3hqHJ1eVSMMSOOhiJ8kC54MFzktmJsaQ+7jZD 8IeA== X-Forwarded-Encrypted: i=1; AJvYcCXAwi8fBq4HHRKsF4ZUr6bLP+cz/AJ8zBWelZHZg2CB7C3+c0+eUEl2cUoUGkNKKE0gT7wwMxZ+ra9DgRqLrKWPsper X-Gm-Message-State: AOJu0YwxOjsMphkWO38rVBrPjhxGGQgH3L16DRzDgig/jm/dIVSpr/W1 Se1t8FEVRwSoTYd2CpqqBOKxy0c5YTm1OlkNSkUG2hDV2q4qSfquIrTtx2Br0m6ZiCfpkg== X-Google-Smtp-Source: AGHT+IGcwlMy3+7hgVTbOD2Y2cNsSH8oCeqS+0FGa05sbpjsthtpwwKqM1asTqo0T9/0yAvtPJ1tq/sc X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a5d:6a10:0:b0:343:3e4a:3e73 with SMTP id m16-20020a5d6a10000000b003433e4a3e73mr147wru.5.1711704849580; Fri, 29 Mar 2024 02:34:09 -0700 (PDT) Date: Fri, 29 Mar 2024 10:33:57 +0100 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1576; i=ardb@kernel.org; h=from:subject; bh=O3B+MP1L7ukd5u8YOc4vTvrdKdbfN6TIr9UOdzn8cCc=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIY2tm/X8qeDsk1anEj4xy3xvMXDL+PvbzvfTVLOvZkIrt WZm2N7sKGVhEONgkBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABOp8WNk2BrKNsf/Rvoj06Ay Nr7quce9uhbwTF3UumaK9qeZaxwnWjIyvBC/c3X//Vqfio13YwOnnz6X6CzX933tJmYWK453R1d b8wIA X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240329093356.276289-5-ardb+git@google.com> Subject: [PATCH 0/3] kbuild: Avoid weak external linkage where possible From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , Masahiro Yamada , Arnd Bergmann , Martin KaFai Lau , linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, bpf@vger.kernel.org From: Ard Biesheuvel Weak external linkage is intended for cases where a symbol reference can remain unsatisfied in the final link. Taking the address of such a symbol should yield NULL if the reference was not satisfied. Given that ordinary RIP or PC relative references cannot produce NULL, some kind of indirection is always needed in such cases, and in position independent code, this results in a GOT entry. In ordinary code, it is arch specific but amounts to the same thing. While unavoidable in some cases, weak references are currently also used to declare symbols that are always defined in the final link, but not in the first linker pass. This means we end up with worse codegen for no good reason. So let's clean this up, by providing preliminary definitions that are only used as a fallback. Cc: Masahiro Yamada Cc: Arnd Bergmann Cc: Martin KaFai Lau Cc: linux-arch@vger.kernel.org Cc: linux-kbuild@vger.kernel.org Cc: bpf@vger.kernel.org Ard Biesheuvel (3): kallsyms: Avoid weak references for kallsyms symbols vmlinux: Avoid weak reference to notes section btf: Avoid weak external references include/asm-generic/vmlinux.lds.h | 21 ++++++++++++++ kernel/bpf/btf.c | 4 +-- kernel/kallsyms.c | 6 ---- kernel/kallsyms_internal.h | 30 ++++++++------------ kernel/ksysfs.c | 4 +-- lib/buildid.c | 4 +-- 6 files changed, 39 insertions(+), 30 deletions(-)