From patchwork Fri Feb 16 14:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Hawkins X-Patchwork-Id: 202129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp533131dyb; Fri, 16 Feb 2024 06:05:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWOgNx94p3CgTrPX1dDd8H4X+AQ3CB5qTKh17dZ3xNxWg+Re5IzZrfsxO0kTZFhEYZFf1+9NU3UCQZ+DPUIMa4tGba4eA== X-Google-Smtp-Source: AGHT+IG8/0+wVQo3Me4YfJul0Igu5U/6tS3Q0J/ZXTbcCvEx2Waiadi9e+mduGQgH4BpfXcSQQjt X-Received: by 2002:a05:620a:a0b:b0:787:3503:6c71 with SMTP id i11-20020a05620a0a0b00b0078735036c71mr4634208qka.5.1708092328068; Fri, 16 Feb 2024 06:05:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708092328; cv=pass; d=google.com; s=arc-20160816; b=qdIQb13uSE7V+vWQFN/Ui9OB2FH2ckjjMirVwSIIEdop0R+Jx8mZW0TWEjT53Ge++f bthxbd2O533iVlRr5b3NSOwWfa0vBxjizrASZUgD7Wak0MYPgzJ2R4prqwjLzZBU5MaH BPE5WqvuX/tcg+/l7ajC1dnEdj0XapIXPwWA6v6kgpIGGI8twgCyF7PdDgOg8HJrmpO6 PppVsal/mV282lh0GRlThcrtVkzzwnzWsVAKeeTnE/YtfYf2ltNu1BS0/zjUDVIteX0B pm6y33oXYHxUdIRQJeC9tck9C6dBKeDr2OLmUo/ifAPEEwRBuAk6KGmaPS3z1G2woAf1 zEoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=PXrKvH73k7FdBBr6il8y9pQbs13faQ7JucP67qcr+7k=; fh=RW0dom+f7TER6EqkTGDgrRNuYf1bNT1FW5P5EV5ahAs=; b=OTSLdNsSUwram8ft0x7AT6GSBCY2fCDxySdMZ2xfRY1lEIwxloz//aQhc+jmPYgbRU q1ggYdgKY1bSonv0GGs8mTR2coqJmfVENAcIOyumf99GMYK9wAp0/d2gD7znUbWODgJk Op4WBFaVlTXF4udebW7/DF3/iLXaSdZN6WcA6ER9yl3zexVsvSuAjd7a/di/6h9cvSSf cbEzAfiD4auUPiKh/Fs1keZ8xB4vWMfKKw1FT8264UaltjF8+gpHnKDStDxmPsneMQoR iffbxVZYwY8MF3Zo7ZHD7t5vy2my41DcXeKv6HIl/eOQZQFRmxOl+7ODbzkA764wvKot 7kZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@obs-cr.20230601.gappssmtp.com header.s=20230601 header.b="B/foYvs2"; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v21-20020a05620a123500b00787284f8c93si3928759qkj.162.2024.02.16.06.05.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 06:05:28 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@obs-cr.20230601.gappssmtp.com header.s=20230601 header.b="B/foYvs2"; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AFBE33858028 for ; Fri, 16 Feb 2024 14:05:27 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by sourceware.org (Postfix) with ESMTPS id 018FE38582A5 for ; Fri, 16 Feb 2024 14:05:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 018FE38582A5 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=obs.cr Authentication-Results: sourceware.org; spf=none smtp.mailfrom=obs.cr ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 018FE38582A5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::82b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708092317; cv=none; b=eYMxbDdAWw23B+xGrE+SXzUxrrUKKtYE2rmcihVB5O2MdHCn6D3V2h9GDSir4RIkViq6Qe8nYNfSlxMFj98Sbm/8ZKjwFyJ3NdXlTbmLc+ZAwMhdcqo5g0SqhoakE2Pzoc07E+bOAVydJ3LMGT115IyQ4zclFqjCVW+qDpNUC+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708092317; c=relaxed/simple; bh=3quo5Q9vXRt5IU+ov4q28mQKAep74ePWG4lsE9xhpJo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EtPfLqKgdhsBWDUMuNaBeC+TqmAk8djjN+qRYdMuqadDJmNUcvd0P0WPACBrV4jaoxGdghMcoxdq4ie8A5BESHauF9v+vJzMr0zk0UgV979Kx7AmBkVxxL9V4ISmdwZWA34UpEXU9+83TUSOiwIso731wNHuN4I5R7cWXgMTXKQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-42a0ba5098bso10992261cf.0 for ; Fri, 16 Feb 2024 06:05:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=obs-cr.20230601.gappssmtp.com; s=20230601; t=1708092306; x=1708697106; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PXrKvH73k7FdBBr6il8y9pQbs13faQ7JucP67qcr+7k=; b=B/foYvs2omBTsuZV8i8ZY5oQySDOS4EYehySDqJSaorzgrJ2uccZzvAWYMK1TL434z V2004A8KjsO8OGcStjlAK6HADBvbFSRdHBRDLQAqdr8Kbv4ZiT8TXsX9zuYuWoD6/8Tq e2B8MC1fqIVeuNu1KExj51/O8nEsl80OZwHaK+khQ8017uL2ojSBJ5Zn5thH/KoClOdn Oo1nBMySxtr+24mvp43raPZDrDREAy3FUEMqRys2U2FCc85ls0ZU65ARSi5XA3XAllFL KXvumujhgk1YV38X7SCN/YE96lNZmGYL8LSqrZ2WXHKeGfUh0ZlEoLm+BQAt7YljjfDb glGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708092306; x=1708697106; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PXrKvH73k7FdBBr6il8y9pQbs13faQ7JucP67qcr+7k=; b=Om2rBR+aIDDTOXxiZ5i7Q85z88j0hTvQ9u3PscoFWha/f2lp38wAzZ9TPtGpTGgj0P JpwjIpJ9hWtxj8QYrMCBfM/J/FVVCc16UFicAOOYhZHXiLxz1oPu0ns7wAaMOjfdX2C7 f6QhwBkeNFiYgYkko03CDubI2qv19MQNpkpVCecJzArycFFCDnzsjgM83oXbyY8uSLz2 H7N3gSGbVe+XgA0hx8Qwg2vz/a3Fv6mLhozP4nbzxaS5XCaAB47A+5Xi2ITBfLcWczyE dOJDd5Fwlb9bE334J3fzCMsplQ/TBiG5DwV+ZAv94MUcfzGut637o2Imu6ExR0Ys3CGL VluQ== X-Gm-Message-State: AOJu0YwjhhFqe4+iy7D7h+Yv5vfkjIRGatBOjqySs5jnflFZa5AtV1n1 dbK1NLVLSEevZPx398Bygo6z3pS6buG7dtYEf6JckAngRHoJV9ukYs0UiTh+8C2JMhlgPtk9nAU e X-Received: by 2002:ac8:5a41:0:b0:42d:e949:9a5a with SMTP id o1-20020ac85a41000000b0042de9499a5amr365348qta.68.1708092305994; Fri, 16 Feb 2024 06:05:05 -0800 (PST) Received: from borderland.rhod.uc.edu ([129.137.96.2]) by smtp.gmail.com with ESMTPSA id jy14-20020a05622a818e00b0042dbca742easm1559949qtb.44.2024.02.16.06.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 06:05:05 -0800 (PST) From: Will Hawkins To: binutils@sourceware.org Cc: Will Hawkins Subject: [PATCH] as: fix bpf expression parsing regression Date: Fri, 16 Feb 2024 09:04:58 -0500 Message-ID: <20240216140501.1039645-1-hawkinsw@obs.cr> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791064621334985719 X-GMAIL-MSGID: 1791064621334985719 As a result of a switch instead of an if, as would issue non-specific error messages when it encountered an operand it could not parse in bpf. This patch fixes that regression and adds a test to prevent it from reoccurring. Tested for bpf-unknown-none on x86_64-redhat-linux. gas/ChangeLog: * config/tc-bpf.c (parse_expression): Change switch to if so that error * condition is handled. * testsuite/gas/bpf/bpf.exp: Invoke new test. * testsuite/gas/bpf/indcall-badoperand.d: New test. * testsuite/gas/bpf/indcall-badoperand.l: New test. * testsuite/gas/bpf/indcall-badoperand.s: New test. Signed-off-by: Will Hawkins --- gas/config/tc-bpf.c | 2 +- gas/testsuite/gas/bpf/bpf.exp | 3 +++ gas/testsuite/gas/bpf/indcall-badoperand.d | 3 +++ gas/testsuite/gas/bpf/indcall-badoperand.l | 3 +++ gas/testsuite/gas/bpf/indcall-badoperand.s | 8 ++++++++ 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gas/testsuite/gas/bpf/indcall-badoperand.d create mode 100644 gas/testsuite/gas/bpf/indcall-badoperand.l create mode 100644 gas/testsuite/gas/bpf/indcall-badoperand.s diff --git a/gas/config/tc-bpf.c b/gas/config/tc-bpf.c index 43e098c2a86..86489c72898 100644 --- a/gas/config/tc-bpf.c +++ b/gas/config/tc-bpf.c @@ -1240,7 +1240,7 @@ parse_expression (char *s, expressionS *exp) s = input_line_pointer; input_line_pointer = saved_input_line_pointer; - switch (exp->X_op == O_absent || exp_parse_failed) + if (exp->X_op == O_absent || exp_parse_failed) return NULL; /* The expression parser may consume trailing whitespaces. We have diff --git a/gas/testsuite/gas/bpf/bpf.exp b/gas/testsuite/gas/bpf/bpf.exp index dae8bd924d0..5faae5b859e 100644 --- a/gas/testsuite/gas/bpf/bpf.exp +++ b/gas/testsuite/gas/bpf/bpf.exp @@ -77,6 +77,9 @@ if {[istarget bpf*-*-*]} { run_dump_test disp32-overflow run_dump_test imm32-overflow + # Bad operand (regression) + run_dump_test indcall-badoperand + # In Pseudo-C it is not possible to refer to symbols # as operands that have the same name than registers. run_dump_test regs-for-symbols-pseudoc diff --git a/gas/testsuite/gas/bpf/indcall-badoperand.d b/gas/testsuite/gas/bpf/indcall-badoperand.d new file mode 100644 index 00000000000..bf2e9e8e643 --- /dev/null +++ b/gas/testsuite/gas/bpf/indcall-badoperand.d @@ -0,0 +1,3 @@ +#as: -EL -mno-relax +#source: indcall-badoperand.s +#error_output: indcall-badoperand.l diff --git a/gas/testsuite/gas/bpf/indcall-badoperand.l b/gas/testsuite/gas/bpf/indcall-badoperand.l new file mode 100644 index 00000000000..d791435a2ac --- /dev/null +++ b/gas/testsuite/gas/bpf/indcall-badoperand.l @@ -0,0 +1,3 @@ +.*: Assembler messages: +.*:7: Error: unrecognized instruction `call %0' +.*:7: Error: expected register name, got '%0' diff --git a/gas/testsuite/gas/bpf/indcall-badoperand.s b/gas/testsuite/gas/bpf/indcall-badoperand.s new file mode 100644 index 00000000000..cf19c0a56b6 --- /dev/null +++ b/gas/testsuite/gas/bpf/indcall-badoperand.s @@ -0,0 +1,8 @@ + + .text + .align 4 +main: + + mov %r0, 1 + call %0 + exit