From mboxrd@z Thu Jan 1 00:00:00 1970 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 2CF9C1A5B8A for ; Mon, 17 Nov 2025 00:47:20 +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=1763340441; cv=none; b=MACshj+eAj9yu2JGTN7fcR6zJlJ+mMoPLoYNnN2cO/oyfnTaNQRNwRFu5pZy4RthP3W8DyJxNcoBLF0me7DiawVpdN1/Cm9ajiAPA6v33tjEcyJhcM69mCpJsRktoo0dXbvffOm5ppDNaDCzua9AmogAbhpebphvYrCP96r0+og= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763340441; c=relaxed/simple; bh=KqFoPh2849hGDfx0eJgTZV2DNbz6HOm3atcQFNx1Lzo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l6PCpSgXVmfJJEpZ6DYyTTZjNTeeYJ9w7Cg+kG9NBv23UT+fpE7/sid7OyB7mtm6D8abvJkHOr57tzogdUZ9gygoX28BjRbTKPTPhplEao5yD9+jv5yXNlf2zSn3EO66T3XAgCEpoAnmovG4ap7hXTgLa5VPFG4QQUeCzXQrUEw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ufVYJHQ1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ufVYJHQ1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70440C4CEF5; Mon, 17 Nov 2025 00:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763340440; bh=KqFoPh2849hGDfx0eJgTZV2DNbz6HOm3atcQFNx1Lzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ufVYJHQ1/Gf29cf1oBWrnkcq6uK5uBVL9kQ7/AS4pu+hiLpwIB9EfJ3RcLgL0WYoB 0z70bBo0Id/g9U6/p51DmZNxf56dQiF1G7rSFAC7M4wI7BnbGBC/tZpx9+AVr0ZBgy B/S/BayuR3c9nfW1ZgSIvSV3jMcZuNiORndT408O4h/J5yQ87dU0SD89K0R04N2YfR Ae3/73nUQkSyybBRwUJAsXSFTH71xBVU1nFcXOADa2ZmLU36BnvtywWOiMBGfCN1Wz V1GfzMq7faHHYT8OuDxUXunBcXVpwyovRwzx9IHSarBAISVkwhqlZFvXvtYtY5xXRp CP0N95GN5du1A== From: Puranjay Mohan To: bpf@vger.kernel.org Cc: Puranjay Mohan , Puranjay Mohan , Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , Eduard Zingerman , Xu Kuohai , Catalin Marinas , Will Deacon , kernel-team@meta.com Subject: [PATCH bpf-next 3/4] libbpf: Ignore relocations for .jumptables sections Date: Mon, 17 Nov 2025 00:46:38 +0000 Message-ID: <20251117004656.33292-4-puranjay@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251117004656.33292-1-puranjay@kernel.org> References: <20251117004656.33292-1-puranjay@kernel.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit .jumptables sections generated by LLVM store byte offsets from the start of the section to the jump's target instruction. On arm64 builds of LLVM, it generates a rel section to add the section address to each entry in the jump table, therefore storing the absolute address of the jump target into the table. For BPF usage of .jumptables, we only care about the instruction offsets and calculate the final address much later after the JIT has finished, and called bpf_prog_update_insn_ptrs() Without the change in this commit, compilation fails with: libbpf: relocation against STT_SECTION in non-exec section is not supported! Error: failed to link 'tools/testing/selftests/bpf/cpuv4/bpf_gotox.bpf.o': Invalid argument (22) This is due to the presence of a relocation section for .jumptables (non-exec) against syscall (STT_SECTION): Relocation section '.rel.jumptables' at offset 0x5b50 contains 263 entries: Offset Info Type Symbol's Value Symbol's Name 000000000000 0000000300000002 R_BPF_64_ABS64 0000000000000000 syscall 000000000008 0000000300000002 R_BPF_64_ABS64 0000000000000000 syscall [...] Signed-off-by: Puranjay Mohan --- tools/lib/bpf/linker.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index f4403e3cf994..f4295962983b 100644 --- a/tools/lib/bpf/linker.c +++ b/tools/lib/bpf/linker.c @@ -634,6 +634,10 @@ static bool is_ignored_sec(struct src_sec *sec) if (strcmp(name, BTF_ELF_SEC) == 0 || strcmp(name, BTF_EXT_ELF_SEC) == 0) return true; + + /* .jumptables don't need relocations */ + if (strcmp(name, JUMPTABLES_SEC) == 0) + return true; } return false; -- 2.47.3