BPF List
 help / color / mirror / Atom feed
From: Puranjay Mohan <puranjay@kernel.org>
To: bpf@vger.kernel.org
Cc: Puranjay Mohan <puranjay@kernel.org>,
	Puranjay Mohan <puranjay12@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Xu Kuohai <xukuohai@huaweicloud.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	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	[thread overview]
Message-ID: <20251117004656.33292-4-puranjay@kernel.org> (raw)
In-Reply-To: <20251117004656.33292-1-puranjay@kernel.org>

.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 <puranjay@kernel.org>
---
 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


  parent reply	other threads:[~2025-11-17  0:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17  0:46 [PATCH bpf-next 0/4] bpf: arm64: Indirect jumps Puranjay Mohan
2025-11-17  0:46 ` [PATCH bpf-next 1/4] bpf: arm64: Add support for instructions array Puranjay Mohan
2025-11-17  8:22   ` Anton Protopopov
2025-11-17  0:46 ` [PATCH bpf-next 2/4] bpf: arm64: Add support for indirect jumps Puranjay Mohan
2025-11-17  8:23   ` Anton Protopopov
2025-11-17  0:46 ` Puranjay Mohan [this message]
2025-11-17  0:46 ` [PATCH bpf-next 4/4] selftests: bpf: Enable gotox tests from arm64 Puranjay Mohan
2025-11-17  8:24   ` Anton Protopopov
2025-11-17  8:08 ` [PATCH bpf-next 0/4] bpf: arm64: Indirect jumps Anton Protopopov
2025-11-17 13:01   ` Puranjay Mohan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251117004656.33292-4-puranjay@kernel.org \
    --to=puranjay@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=puranjay12@gmail.com \
    --cc=will@kernel.org \
    --cc=xukuohai@huaweicloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox