With commit
6ae8a30d44f016cafb46a75843b5109316eb1996, arguments followed
by a C-style comment ended up with a trailing space. That extra space
character confused the PRU register name matching, leading to spurious
errors about unrecognized registers. This affected existing code like
newlib's setjmp.s for pru.
Fix by stripping the trailing whitespace for any argument.
Even with
6ae8a30d44f016cafb46a75843b5109316eb1996 reverted, this patch
is safe to be applied.
Successfully regression-tested with GCC and newlib testsuites for pru-unknown-elf.
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
char *p;
char *end = NULL;
int i;
+ size_t len;
p = argstr;
i = 0;
bool terminate = false;
as_bad (_("too many arguments"));
}
+ /* Strip trailing whitespace. */
+ len = strlen (parsed_args[i]);
+ for (char *temp = parsed_args[i] + len - 1;
+ len && ISSPACE (*temp);
+ temp--, len--)
+ *temp = '\0';
+
if (*parsestr == '\0' || (p != NULL && *p == '\0'))
terminate = true;
++i;
--- /dev/null
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: whitespace parsing
+
+# Test the whitespace parsing
+
+.*: +file format elf32-pru
+
+Disassembly of section .text:
+0+0000 <[^>]*> 1300e2e1 mov r1, sp
+0+0004 <[^>]*> 1300e2e1 mov r1, sp
+0+0008 <[^>]*> 1300e2e1 mov r1, sp
--- /dev/null
+# Source file used to test the whitespace parsing.
+
+foo:
+ mov r1 /* comment */, r2 /* ... */
+ mov r1 /* comment */, r2 /* ... */
+ mov /* x */ r1 /* comment */ , r2 /* ... */