]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bpf: fix bpf expression parsing regression in GAS
authorWill Hawkins <hawkinsw@obs.cr>
Mon, 19 Feb 2024 18:24:19 +0000 (19:24 +0100)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Mon, 19 Feb 2024 19:48:17 +0000 (20:48 +0100)
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.

gas/ChangeLog
gas/config/tc-bpf.c
gas/testsuite/gas/bpf/bpf.exp

index 3ae1d7773596c35b34d4187944a659b5287faf60..88e61083c4472302d140d924647a327b20923f4e 100644 (file)
@@ -1,3 +1,12 @@
+2024-02-19 Will Hawkins  <hawkinsw@obs.cr>
+
+       * config/tc-bpf.c (parse_expression): Change switch to if so that
+       error condition is handled.
+       * testsuite/gas/bpf/indcall-badoperand.d: New test.
+       * testsuite/gas/bpf/indcall-badoperand.l: Likewise.
+       * testsuite/gas/bpf/indcall-badoperand.s: Likewise.
+       * testsuite/gas/bpf/bpf.exp: Invoke new test.
+
 2024-02-19  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
        * config/tc-bpf.c (md_assemble): Fix to take into account that
index e23de4e0d19ae49aeb8f6f72ddaff332eb4ab293..dfa44ea194c12af88040886e28f84cf1fc893f3f 100644 (file)
@@ -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
index dae8bd924d09dab3d69a823f063edd97ea170c9b..5faae5b859e600cb63eec20548f2fe583b30ce04 100644 (file)
@@ -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