Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions view/macho/machoview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,9 @@ MachOHeader MachoView::HeaderForAddress(BinaryView* data, uint64_t address, bool
}
break;
case LC_LOAD_DYLIB:
case LC_LOAD_WEAK_DYLIB:
case LC_REEXPORT_DYLIB:
case LC_LOAD_UPWARD_DYLIB:
{
uint32_t offset = reader.Read32();
reader.Read32(); // timestamp
Expand Down Expand Up @@ -2087,6 +2090,8 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_
if (objcProcessor)
objcProcessor->AddRelocatedPointer(relocationLocation, slidTarget);
}

Ref<Metadata> symbolToLibraryMapping = new Metadata(KeyValueDataType);
for (auto& [relocation, name, ordinal] : header.bindingRelocations)
{
bool handled = false;
Expand Down Expand Up @@ -2149,6 +2154,8 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_
DefineRelocation(m_arch, relocation, symbol, relocation.address);
handled = true;
}
if (ordinal - 1 < header.dylibs.size())
symbolToLibraryMapping->SetValueForKey(name, new Metadata(header.dylibs[ordinal - 1].first));
}
break;
}
Expand All @@ -2157,6 +2164,8 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_
m_logger->LogErrorF("Failed to find external symbol {:?}, couldn't bind symbol at {:#x}", name, relocation.address);
}

StoreMetadata("SymbolExternalLibraryMapping", std::move(symbolToLibraryMapping), true);

auto relocationHandler = m_arch->GetRelocationHandler("Mach-O");
if (relocationHandler)
{
Expand Down
Loading