mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-25 22:15:57 +00:00
A plugin built with default visibility calls its own exported functions through its PLT. Challenge Mode's Enemy Health Regeneration plugin (exefs subsdk8) does so for the std::vector<const char*> constructor it carries, and the service run counted that as a library call outside the reviewed list, so the plugin was refused and its whole mod stayed off. runtime/loader.c resolve binds such a JUMP_SLOT straight to the plugin's own definition (a host override still wins and stays counted), and tools/exefs_plugins.py plt_imports maps the PLT stub to that code, so the reach check follows into it instead of naming an import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ed8fa04034
commit
6f97dca93a
4 files changed
+43
-4
No files matched your search
+13
-2
@@ -457,8 +457,15 @@ def check_record(rec, impls, game=frozenset()):
|
||||
# ---- the code the hooks reach
|
||||
def plt_imports(nso, img, base, text_end):
|
||||
"""{absolute address of a PLT stub: the import its GOT slot binds} (adrp x16; ldr x17, [x16, #slot]; add x16, x16,
|
||||
#slot; br x17), from the JUMP_SLOT relocations."""
|
||||
slots = {off: nso.syms[sym][0] for off, typ, sym, _ in nso.relocs if typ == R_AARCH64_JUMP_SLOT}
|
||||
#slot; br x17), from the JUMP_SLOT relocations. A slot whose symbol the plugin defines itself binds to that
|
||||
definition (runtime/loader.c resolve), so its stub maps to the absolute address of the plugin's own code instead of
|
||||
a name: a plugin built with default visibility calls its own exported functions through its PLT (the
|
||||
std::vector<const char*> constructor of Challenge Mode's Enemy Health Regeneration)."""
|
||||
slots = {}
|
||||
for off, typ, sym, _ in nso.relocs:
|
||||
if typ == R_AARCH64_JUMP_SLOT:
|
||||
name, _, shndx, value, _ = nso.syms[sym]
|
||||
slots[off] = base + value if shndx else name
|
||||
out = {}
|
||||
for o in range(0, text_end - 16, 4):
|
||||
w0, w1, _, w3 = struct.unpack_from('<4I', img, o)
|
||||
@@ -499,6 +506,10 @@ def reach(img, base, text_end, roots, plt, stubs=()):
|
||||
if a in seen:
|
||||
break
|
||||
if a in plt:
|
||||
if isinstance(plt[a], int): # the plugin's own function behind its PLT: the path goes on there
|
||||
seen.add(a)
|
||||
a = plt[a]
|
||||
continue
|
||||
imports[plt[a]] = imports.get(plt[a], 0) + 1
|
||||
break
|
||||
if not base <= a < base + text_end:
|
||||
|
||||
Reference in new issue
Block a user