@@ -790,6 +790,9 @@ MachOHeader MachoView::HeaderForAddress(BinaryView* data, uint64_t address, bool
790790 }
791791 break ;
792792 case LC_LOAD_DYLIB :
793+ case LC_LOAD_WEAK_DYLIB :
794+ case LC_REEXPORT_DYLIB :
795+ case LC_LOAD_UPWARD_DYLIB :
793796 {
794797 uint32_t offset = reader.Read32 ();
795798 reader.Read32 (); // timestamp
@@ -2087,6 +2090,8 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_
20872090 if (objcProcessor)
20882091 objcProcessor->AddRelocatedPointer (relocationLocation, slidTarget);
20892092 }
2093+
2094+ Ref<Metadata> symbolToLibraryMapping = new Metadata (KeyValueDataType);
20902095 for (auto & [relocation, name, ordinal] : header.bindingRelocations )
20912096 {
20922097 bool handled = false ;
@@ -2149,6 +2154,8 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_
21492154 DefineRelocation (m_arch, relocation, symbol, relocation.address );
21502155 handled = true ;
21512156 }
2157+ if (ordinal - 1 < header.dylibs .size ())
2158+ symbolToLibraryMapping->SetValueForKey (name, new Metadata (header.dylibs [ordinal - 1 ].first ));
21522159 }
21532160 break ;
21542161 }
@@ -2157,6 +2164,8 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_
21572164 m_logger->LogErrorF (" Failed to find external symbol {:?}, couldn't bind symbol at {:#x}" , name, relocation.address );
21582165 }
21592166
2167+ StoreMetadata (" SymbolExternalLibraryMapping" , std::move (symbolToLibraryMapping), true );
2168+
21602169 auto relocationHandler = m_arch->GetRelocationHandler (" Mach-O" );
21612170 if (relocationHandler)
21622171 {
0 commit comments