Keep string data as it is in the Android asm conversion

android_asm_convert.py renamed identifiers in every directive's operands,
string data included: a string starting with "_" was taken for a quoted
symbol and lost the "_", and one with \" in it was split wrongly, so a
"_" starting a word in it was dropped too. 26 of the guest's objects had
strings or tables cut short. Among them Opus's pulse cache (cache_bits50,
one byte short from entry 338): its encoder picked more pulses than its
tables hold for some bands and crashed (the Steam Frame's crashes in
online games, with push to talk). Also musl's wide character tables,
map sharing's hashed names ("_%s"), the "_lan_" menu check, libtiff's
and the sound code's tables.

.ascii, .asciz and .string are now passed on unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan MaierandClaude Opus 5.5 committed 2026-10-13 21:06:59 +02:00
1 parent 01076509dd
commit c85cf8ece1
2 files changed
+38

No files matched your search

+6
View File
@@ -217,6 +217,12 @@ class Converter:
if op == ".align":
self.emit(f"\t.p2align {args}")
return
if op in (".ascii", ".asciz", ".string"):
# string data, kept as it is: no symbol names in it (renamed, a
# "_" at the start of a word was dropped: a string with \" in it
# went wrong, Opus's tables among them)
self.emit(f"\t{op} {args}")
return
if op.startswith("."):
self.emit(f"\t{op} {self.operands(args)}" if args else f"\t{op}")
return
+32
View File
@@ -0,0 +1,32 @@
"""Tests of tools/android_asm_convert.py, the Mach-O to ELF assembly
conversion of the Android build's guest code."""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from android_asm_convert import Converter # noqa: E402
def convert(*lines):
return Converter(list(lines)).run().split("\n")
def test_symbols_lose_their_underscore():
out = convert("_main:", "\tbl\t_foo", "\t.long\t_bar")
assert out[:3] == ["main:", "\tbl foo", "\t.long bar"]
def test_strings_are_kept():
# (a string starting with "_", or one with \" in it, lost a "_": Opus's
# pulse cache was one byte short, and its encoder crashed)
out = convert(
'\t.asciz\t"_lan_"',
'\t.ascii\t"\\"$&\'\\0063_\\206"',
'\t.string\t"l_.str _foo"',
)
assert out[:3] == [
'\t.asciz "_lan_"',
'\t.ascii "\\"$&\'\\0063_\\206"',
'\t.string "l_.str _foo"',
]