Skip to content

Commit 69c80c9

Browse files
bdash0cyn
authored andcommitted
[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.
1 parent 8ef932b commit 69c80c9

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

view/macho/machoview.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,8 +2900,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS
29002900
if (name == NULL)
29012901
throw MachoFormatException();
29022902

2903-
DefineMachoSymbol(symtype, string(name), address, binding, true);
2904-
29052903
memset(&externReloc, 0, sizeof(externReloc));
29062904
externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION;
29072905
externReloc.address = address;
@@ -2916,8 +2914,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS
29162914
if (name == NULL)
29172915
throw MachoFormatException();
29182916

2919-
DefineMachoSymbol(symtype, string(name), address, binding, true);
2920-
29212917
memset(&externReloc, 0, sizeof(externReloc));
29222918
externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION;
29232919
externReloc.address = address;
@@ -2933,8 +2929,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS
29332929
if (name == NULL)
29342930
throw MachoFormatException();
29352931

2936-
DefineMachoSymbol(symtype, string(name), address, binding, true);
2937-
29382932
memset(&externReloc, 0, sizeof(externReloc));
29392933
externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION;
29402934
externReloc.address = address;
@@ -2954,8 +2948,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS
29542948
uint64_t skip = readLEB128(table, tableSize, i);
29552949
for (; count > 0; count--)
29562950
{
2957-
DefineMachoSymbol(symtype, string(name), address, binding, true);
2958-
29592951
memset(&externReloc, 0, sizeof(externReloc));
29602952
externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION;
29612953
externReloc.address = address;
@@ -3540,9 +3532,6 @@ void MachoView::ParseChainedFixups(MachOHeader& header, linkedit_data_command ch
35403532
if (!entry.name.empty())
35413533
{
35423534
reloc.address = targetAddress;
3543-
DefineMachoSymbol(ImportAddressSymbol, entry.name,
3544-
targetAddress,
3545-
entry.weak ? WeakBinding : GlobalBinding, true);
35463535

35473536
BNRelocationInfo externReloc;
35483537
memset(&externReloc, 0, sizeof(externReloc));

0 commit comments

Comments
 (0)