[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug binutils/31283] windmc (s390x) fails with: parser: syntax error
From: |
cvs-commit at gcc dot gnu.org |
Subject: |
[Bug binutils/31283] windmc (s390x) fails with: parser: syntax error |
Date: |
Thu, 08 Feb 2024 09:50:21 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=31283
--- Comment #9 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The binutils-2_42-branch branch has been updated by Alan Modra
<amodra@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e19278f72bdc92e720b2d6c144ddedff5821b56c
commit e19278f72bdc92e720b2d6c144ddedff5821b56c
Author: Richard W.M. Jones <rjones@redhat.com>
Date: Wed Jan 24 12:25:23 2024 +0000
PR 31283 windmc: Parse input correctly on big endian hosts
On big endian hosts (eg. s390x) the windmc tool fails to parse even
trivial files:
$ cat test.mc
;
$ ./binutils/windmc ./test.mc
In test.mc at line 1: parser: syntax error.
In test.mc at line 1: fatal: syntax error.
The tool starts by reading the input as Windows CP1252 and then
converting it internally into an array of UTF-16LE, which it then
processes as an array of unsigned short (typedef unichar).
There are lots of ways this is wrong, but in the specific case of big
endian machines the little endian pairs of bytes are byte-swapped.
For example, the ';' character in the input above is first converted
to UTF16-LE byte sequence { 0x3b, 0x00 }, which is then cast to
unsigned short. On a big endian machine the first unichar appears to
be 0x3b00. The lexer is unable to recognize this as the comment
character ((unichar)';') and so parsing fails.
The simple fix is to convert the input to UTF-16BE on big endian
machines (and do the reverse conversion when writing the output).
Fixes: https://sourceware.org/bugzilla/show_bug.cgi?id=31283
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
(cherry picked from commit 3f8f9745c75b333515f399fc2908ede2ed8014e9)
--
You are receiving this mail because:
You are on the CC list for the bug.