Skip to content

Commit 0e784a1

Browse files
committed
[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 5ecf8d5 commit 0e784a1

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
@@ -2876,8 +2876,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS
28762876
if (name == NULL)
28772877
throw MachoFormatException();
28782878

2879-
DefineMachoSymbol(symtype, string(name), address, binding, true);
2880-
28812879
memset(&externReloc, 0, sizeof(externReloc));
28822880
externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION;
28832881
externReloc.address = address;
@@ -2892,8 +2890,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS
28922890
if (name == NULL)
28932891
throw MachoFormatException();
28942892

2895-
DefineMachoSymbol(symtype, string(name), address, binding, true);
2896-
28972893
memset(&externReloc, 0, sizeof(externReloc));
28982894
externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION;
28992895
externReloc.address = address;
@@ -2909,8 +2905,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS
29092905
if (name == NULL)
29102906
throw MachoFormatException();
29112907

2912-
DefineMachoSymbol(symtype, string(name), address, binding, true);
2913-
29142908
memset(&externReloc, 0, sizeof(externReloc));
29152909
externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION;
29162910
externReloc.address = address;
@@ -2930,8 +2924,6 @@ void MachoView::ParseDynamicTable(BinaryReader& reader, MachOHeader& header, BNS
29302924
uint64_t skip = readLEB128(table, tableSize, i);
29312925
for (; count > 0; count--)
29322926
{
2933-
DefineMachoSymbol(symtype, string(name), address, binding, true);
2934-
29352927
memset(&externReloc, 0, sizeof(externReloc));
29362928
externReloc.nativeType = BINARYNINJA_MANUAL_RELOCATION;
29372929
externReloc.address = address;
@@ -3516,9 +3508,6 @@ void MachoView::ParseChainedFixups(MachOHeader& header, linkedit_data_command ch
35163508
if (!entry.name.empty())
35173509
{
35183510
reloc.address = targetAddress;
3519-
DefineMachoSymbol(ImportAddressSymbol, entry.name,
3520-
targetAddress,
3521-
entry.weak ? WeakBinding : GlobalBinding, true);
35223511

35233512
BNRelocationInfo externReloc;
35243513
memset(&externReloc, 0, sizeof(externReloc));

0 commit comments

Comments
 (0)