mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
inspect_macho reported only the symbol-table spelling (`_main`), while LLDB, dlsym and observe_native_calls use the runtime spelling (`main`). Passing a static name as a breakpoint silently selected a different function, so results from the two tools could not be joined by name. Keep `name` as the exact symbol-table fact and add a derived `runtime_name` to every export and import row, produced by one shared Mach-O symbol-name owner. Managed P/Invoke verification now uses the same owner instead of its own underscore stripping. Fixes #5298 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
23 lines
988 B
TypeScript
23 lines
988 B
TypeScript
/**
|
|
* Runtime spelling of a Mach-O symbol-table name.
|
|
*
|
|
* Darwin compilers prefix every language-level symbol with one underscore in
|
|
* the Mach-O symbol table: C `_main`, Itanium C++ `__ZN3rea3addEii`, Swift
|
|
* `_$s…`, Objective-C class data `_OBJC_CLASS_$_…`. dyld `dlsym` and LLDB name
|
|
* those symbols without that one underscore. Names the compiler does not
|
|
* prefix, such as Objective-C method symbols (`-[Class selector]`) and
|
|
* assembler-local labels, are already spelled as the runtime names them.
|
|
*
|
|
* The symbol-table name stays the source fact; this is its derived runtime
|
|
* name. Returns null when no name is known or nothing remains after the prefix.
|
|
*/
|
|
export const machoRuntimeSymbolName = (
|
|
symbolTableName: string | null,
|
|
): string | null => {
|
|
if (symbolTableName === null) return null;
|
|
const runtimeName = symbolTableName.startsWith("_")
|
|
? symbolTableName.slice(1)
|
|
: symbolTableName;
|
|
return runtimeName.length === 0 ? null : runtimeName;
|
|
};
|