fix(ghidra): resolve secondary symbols at function entries (#1195)

* fix(ghidra): resolve secondary symbols at function entries

* test(ghidra): derive interior bytes from decoded instructions
This commit is contained in:
Ysopwnable
2026-10-09 12:19:07 +08:00
committed by GitHub
parent f36c10f9e8
commit 6fbdbd6820
7 changed files with 193 additions and 4 deletions
+3
View File
@@ -7,6 +7,9 @@ binaries and Ghidra projects are never committed.
It covers imports, an external `puts` function, linker thunks, source symbols,
direct calls, a targetless callback call, two referenced strings, and a
multi-block branch.
- `entry-aliases.c` preserves secondary imported entry labels, a bare-hex
alias, and an interior label. The native CLI/MCP lane verifies entry selection,
annotation, interior-label rejection, and unchanged source bytes.
- `cross-format.c` is freestanding so the verifier can produce AArch64 ELF,
x86-64 PE, and x86-64 Mach-O targets from the same semantics. It preserves an
exported entry, direct and indirect calls, a volatile string reference, and a
+19
View File
@@ -0,0 +1,19 @@
// Keep secondary imported entry labels and a non-entry control in one function.
#if defined(__APPLE__)
#define REA_SYMBOL(name) "_" name
#else
#define REA_SYMBOL(name) name
#endif
__attribute__((noinline, used)) int rea_alias_target(void) {
__asm__ volatile(".globl " REA_SYMBOL("rea_interior") "\n"
REA_SYMBOL("rea_interior") ":");
return 17;
}
__asm__(".globl " REA_SYMBOL("rea_entry_alias") "\n"
".set " REA_SYMBOL("rea_entry_alias") ", " REA_SYMBOL("rea_alias_target") "\n"
// A bare hexadecimal identifier must still resolve as an entry label.
".globl dead\n.set dead, " REA_SYMBOL("rea_alias_target") "\n");
int main(void) { return rea_alias_target(); }