mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-02 20:21:59 -05:00
DroidDeck-Bionic preloads libfakeinput.so into its Wine processes (tools/bionic-runtime/build.sh builds fakeinput_steam.cpp for bionic). The fortified read/poll/ppoll entry points (#2916) call glibc's __chk_fail, which bionic does not export, so the bionic build of the library cannot be loaded: "CANNOT LINK EXECUTABLE .../wine: cannot locate symbol "__chk_fail"" and no Wine program starts. Every DroidDeck-Bionic pack built from main since #2916 is affected (r67 predates it). The bounds failures now go through fakeinput_chk_fail(): abort() on bionic, __chk_fail() as before on glibc. tools/tests/test_fakeinput_bionic.py fails if __chk_fail is named outside the non-bionic branch again. Co-authored-by: The412Banner <[email protected]>
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
from pathlib import Path
|
|
import re
|
|
import unittest
|
|
|
|
SOURCE = Path(__file__).resolve().parents[2] / "app/src/main/cpp/fakeinput_steam.cpp"
|
|
|
|
|
|
def code_only(text):
|
|
"""The source without its comments and string literals."""
|
|
text = re.sub(r"/\*.*?\*/", " ", text, flags=re.S)
|
|
text = re.sub(r"//[^\n]*", " ", text)
|
|
return re.sub(r'"(?:\\.|[^"\\\n])*"', '""', text)
|
|
|
|
|
|
class FakeinputBionicTest(unittest.TestCase):
|
|
# DroidDeck-Bionic preloads this library into its Wine processes (tools/bionic-runtime/build.sh). bionic
|
|
# exports no __chk_fail: a library that names it there cannot be loaded, so no Wine program starts
|
|
# ("cannot locate symbol "__chk_fail"").
|
|
def test_glibcs_fortify_failure_is_named_only_off_bionic(self):
|
|
code = code_only(SOURCE.read_text())
|
|
guarded = re.compile(r"#if defined\(__BIONIC__\)\n(?P<bionic>.*?)#else\n(?P<glibc>.*?)#endif\n", re.S)
|
|
blocks = [m for m in guarded.finditer(code) if "__chk_fail" in m.group("glibc")]
|
|
self.assertTrue(blocks, "the glibc-only __chk_fail is behind #if defined(__BIONIC__) ... #else")
|
|
for block in blocks:
|
|
self.assertNotIn("__chk_fail", block.group("bionic"))
|
|
self.assertNotIn("__chk_fail", guarded.sub("", code))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|