]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gas/expr.c
gas: rework handling of backslashes in quoted symbol names
authorJan Beulich <jbeulich@suse.com>
Tue, 4 Jan 2022 09:05:17 +0000 (10:05 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 4 Jan 2022 09:05:17 +0000 (10:05 +0100)
commit5ed4d49d107c46670a7994711f0284776a35284e
treed883166be8b96d7aa83f6c1f7dfc0d1ebfbc6c53
parent79541a6d9220e800ebc5278594105982d6e1d80c
gas: rework handling of backslashes in quoted symbol names

Strange effects can result from the present handling, e.g.:

.if 1
"backslash\\":
.endif

yields first (correctly) "missing closing `"'" but then also "invalid
character '\' in mnemonic" and further "end of file inside conditional".
Symbols names ending in \ are in principle not expressable with that
scheme.

Instead of recording whether a backslash was seen, inspect the
subsequent character right away. Only accept \\ (meaning a single
backslash in the resulting symbol name) and \" (meaning an embedded
double quote in the resulting symbol name) for now, warning about any
other combination.

While perhaps not necessary immediately, also permit concatenated
strings to form a symbol name. This may become useful if going forward
we would want to support \<octal> or \x<hex> sequences, where closing
and re-opening quotes can be useful to delimit such sequences.

The ELF "Multibyte symbol names" test gets switched away from using
.set, as that would now also mean excluding nios2 and pru. By using
.equiv instead, even the existing #notarget can be dropped. (For h8300
the .section directive additionally needs attributes specified, to avoid
a target specific warning.)
gas/expr.c
gas/testsuite/gas/all/quoted-sym-names.d
gas/testsuite/gas/all/quoted-sym-names.s
gas/testsuite/gas/elf/syms.d
gas/testsuite/gas/elf/syms.s