From 3e7c1b6a41c666f227237d5751b29d3538aa68b3 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Thu, 15 May 2025 22:04:58 -0700 Subject: [MachO] Don't add symbols when processing bind fixups The target of the bind opcode has its symbol applied when the dynamic symbol table is parsed. This was previously adding a symbol at the fixed-up address with the name of the symbol being bound. This was resulting in dozens of `_OBJC_CLASS_$_NSObject`, `_OBJC_METACLASS_$_NSObject`, and `__objc_empty_cache` symbols being created: one for each `objc_class` that referenced those symbols. --- view/macho/machoview.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/view/macho/machoview.cpp b/view/macho/machoview.cpp index cb38826c..dde5fa86 100644 --- a/view/macho/machoview.cpp +++ b/view/macho/machoview.cpp @@ -2900,8 +2900,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS if (name == NULL) throw MachoFormatException(); - DefineMachoSymbol(symtype, string(name), address, binding, true); - memset(&externReloc, 0, sizeof(externReloc)); externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION; externReloc.address = address; @@ -2916,8 +2914,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS if (name == NULL) throw MachoFormatException(); - DefineMachoSymbol(symtype, string(name), address, binding, true); - memset(&externReloc, 0, sizeof(externReloc)); externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION; externReloc.address = address; @@ -2933,8 +2929,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS if (name == NULL) throw MachoFormatException(); - DefineMachoSymbol(symtype, string(name), address, binding, true); - memset(&externReloc, 0, sizeof(externReloc)); externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION; externReloc.address = address; @@ -2954,8 +2948,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS uint64_t skip = readLEB128(table, tableSize, i); for (; count > 0; count--) { - DefineMachoSymbol(symtype, string(name), address, binding, true); - memset(&externReloc, 0, sizeof(externReloc)); externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION; externReloc.address = address; @@ -3540,9 +3532,6 @@ void MachoView::ParseChainedFixups(MachOHeader& header, linkedit_data_command ch if (!entry.name.empty()) { reloc.address = targetAddress; - DefineMachoSymbol(ImportAddressSymbol, entry.name, - targetAddress, - entry.weak ? WeakBinding : GlobalBinding, true); BNRelocationInfo externReloc; memset(&externReloc, 0, sizeof(externReloc)); -- cgit v1.3.1