| Message ID | 20260824214138.3964162-1-vineet.gupta@linux.dev |
|---|---|
| Headers |
Return-Path: <binutils-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 04B7C4BA79AB for <patchwork@sourceware.org>; Mon, 24 Aug 2026 21:42:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04B7C4BA79AB Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=STIp8fbv X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mta1.migadu.com (out-18.mta1.migadu.com [IPv6:2001:41d0:203:375::12]) by sourceware.org (Postfix) with ESMTPS id 981E44BA23F8 for <binutils@sourceware.org>; Mon, 24 Aug 2026 21:41:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 981E44BA23F8 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.dev ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 981E44BA23F8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2001:41d0:203:375::12 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787607709; cv=none; b=CsE+Iqf5hhGCPxgruyqkMCqD7QuSxWW5z5cEGf0n7T0XM+3h0KAMU986LjhysHbqKks1DBF2NaBwD4kSTngE4ON4Z0u6q6UG7fI6KDXPEh4p+Eo6c8rojEIUSAPTQfkX5dmK8hCORNhwoJbaiDwe/kDo5KWDH0KUW/L0T9ZlMnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787607709; c=relaxed/simple; bh=8UzqwRKl/Z5i/ModfEFUbtvsYDJCgTvI9fViZ+PuvaA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EclsO0pjr/A2zVGVq/R5HoT56g3AK9fXV8qOLq545aTgcBkgOTnMJZPKduQZUAjeV807E+jsrW2T8/85+B3D/k/NGtb1rbIEQzckDKLjv3g756YPy+D4XLqd7DpZT5LbHQyo1ce7D8UApydndT0u9y0emnD6LaxwppcNVm6brAo= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=STIp8fbv DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 981E44BA23F8 X-Envelope-To: binutils@sourceware.org DKIM-Signature: a=rsa-sha256; bh=8UzqwRKl/Z5i/ModfEFUbtvsYDJCgTvI9fViZ+PuvaA=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787607706; v=1; x=1788212506; b=STIp8fbv3NK9kjVd10VNYNJiX9BwrFdYR6fw8mExOy2eoak0aUfks4gkm5dG88G5TGc//iHr rLoBvdzzgaMr2TPU+b8IGh/x1FtcvBxzSfvzai+87Zo9tTiN0yN23SODgPcRu480Q5YSbyhZjPF +bbIaTZTL1szxGJEGBHPeHSM= X-Envelope-To: binutils@sourceware.org Received: from gvineet-fedora-PF5JGVFY.thefacebook.com (2620:10d:c090:500::4:2c42) by smtp.migadu.com with ESMTPS id cf880ebe43e150af; Mon, 24 Aug 2026 21:41:46 +0000 X-Mizu-Trace-ID: cf880ebe43e150af X-Migadu-Flow: FLOW_OUT From: Vineet Gupta <vineet.gupta@linux.dev> To: binutils@sourceware.org Cc: bpf@gcc.gnu.org, jose.marchesi@oracle.com, ast@kernel.org, Vineet Gupta <vineet.gupta@linux.dev> Subject: [PATCH v2 0/2] bpf: fix gotol with a signed offset, and run the spacing test Date: Mon, 24 Aug 2026 14:41:36 -0700 Message-ID: <20260824214138.3964162-1-vineet.gupta@linux.dev> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
bpf: fix gotol with a signed offset, and run the spacing test
|
|
Message
Vineet Gupta
Aug. 24, 2026, 9:41 p.m. UTC
In the pseudo-C dialect `gotol +1' is silently assembled as `goto l+1'
leading to libbpf load time failures. LLVM obviously supports this so gas
needs fixing.
Ran into this when trying to enable certain selftests which are
currently clang built only while GCC can build them fine. Moreover those
not run tests are declared passing too [1].
Patch 1: Orthogonal issue discovered in the process. Directed tests for
exactly this exist: spacing-pseudoc.{s,d} but are never run.
Patch 2 fixes the actual mis-assembly.
As part of v1 review [2] it was suggested to simply use 'W%' to mandate
at least whitespace i.e. `goto%W%d16'. However that does not work.
gas strips the whitespace next to a sign in the operand field before
md_assemble sees the line, so rejects valid insn: `if rX > N goto +M'
The registered testsuite does not catch either, as it only ever
writes conditional jumps with label operands. So v2 retains the v1
approach to reject a template whose literal text stops in the
middle of a name, letting a later template match the whole mnemonic.
Tested on bpf-unknown-none: 59 expected passes, no failures.
[1] https://lore.kernel.org/bpf/20260821201316.1059129-1-vineet.gupta@linux.dev/
[2] https://gcc.gnu.org/pipermail/bpf/2026-August/000192.html
Vineet Gupta (2):
gas: bpf: actually run the pseudo-C spacing test
PR 34558: bpf: don't mis-assemble `gotol' with signed offset
gas/config/tc-bpf.c | 28 ++++++++++++++++++-
gas/testsuite/gas/bpf/bpf.exp | 3 ++
.../gas/bpf/jump-gotol-signed-pseudoc.d | 15 ++++++++++
.../gas/bpf/jump-gotol-signed-pseudoc.s | 10 +++++++
gas/testsuite/gas/bpf/spacing-pseudoc.d | 2 +-
5 files changed, 56 insertions(+), 2 deletions(-)
create mode 100644 gas/testsuite/gas/bpf/jump-gotol-signed-pseudoc.d
create mode 100644 gas/testsuite/gas/bpf/jump-gotol-signed-pseudoc.s
Comments
Ping ! On 8/25/26 3:11 AM, Vineet Gupta wrote: > In the pseudo-C dialect `gotol +1' is silently assembled as `goto l+1' > leading to libbpf load time failures. LLVM obviously supports this so gas > needs fixing. > > Ran into this when trying to enable certain selftests which are > currently clang built only while GCC can build them fine. Moreover those > not run tests are declared passing too [1]. > > Patch 1: Orthogonal issue discovered in the process. Directed tests for > exactly this exist: spacing-pseudoc.{s,d} but are never run. > > Patch 2 fixes the actual mis-assembly. > > As part of v1 review [2] it was suggested to simply use 'W%' to mandate > at least whitespace i.e. `goto%W%d16'. However that does not work. > gas strips the whitespace next to a sign in the operand field before > md_assemble sees the line, so rejects valid insn: `if rX > N goto +M' > The registered testsuite does not catch either, as it only ever > writes conditional jumps with label operands. So v2 retains the v1 > approach to reject a template whose literal text stops in the > middle of a name, letting a later template match the whole mnemonic. > > Tested on bpf-unknown-none: 59 expected passes, no failures. > > [1] https://lore.kernel.org/bpf/20260821201316.1059129-1-vineet.gupta@linux.dev/ > [2] https://gcc.gnu.org/pipermail/bpf/2026-August/000192.html > > Vineet Gupta (2): > gas: bpf: actually run the pseudo-C spacing test > PR 34558: bpf: don't mis-assemble `gotol' with signed offset > > gas/config/tc-bpf.c | 28 ++++++++++++++++++- > gas/testsuite/gas/bpf/bpf.exp | 3 ++ > .../gas/bpf/jump-gotol-signed-pseudoc.d | 15 ++++++++++ > .../gas/bpf/jump-gotol-signed-pseudoc.s | 10 +++++++ > gas/testsuite/gas/bpf/spacing-pseudoc.d | 2 +- > 5 files changed, 56 insertions(+), 2 deletions(-) > create mode 100644 gas/testsuite/gas/bpf/jump-gotol-signed-pseudoc.d > create mode 100644 gas/testsuite/gas/bpf/jump-gotol-signed-pseudoc.s >