MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / ParseChainedStarts

Method ParseChainedStarts

view/macho/machoview.cpp:3590–3779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3588
3589
3590void MachoView::ParseChainedStarts(MachOHeader& header, section_64 chainedStarts)
3591{
3592 if (!chainedStarts.offset)
3593 return;
3594
3595 m_logger->LogDebug("Processing Chained Starts");
3596
3597 // Dummy relocation
3598 BNRelocationInfo reloc;
3599 memset(&reloc, 0, sizeof(BNRelocationInfo));
3600 reloc.type = StandardRelocationType;
3601 reloc.size = m_addressSize;
3602 reloc.nativeType = BINARYNINJA_MANUAL_RELOCATION;
3603
3604 bool processBinds = true;
3605
3606 BinaryReader parentReader(GetParentView());
3607 BinaryReader mappedReader(this);
3608
3609 try {
3610 uint64_t fixupHeaderAddress = m_universalImageOffset + chainedStarts.offset;
3611 parentReader.Seek(fixupHeaderAddress);
3612
3613 uint32_t pointerFormat = parentReader.Read32();
3614 uint32_t startsCount = parentReader.Read32();
3615 std::vector<uint32_t> startsOffsets;
3616 for (size_t i = 0; i < startsCount; i++)
3617 {
3618 startsOffsets.push_back(parentReader.Read32());
3619 }
3620
3621 uint8_t strideSize;
3622 ChainedFixupPointerGeneric format;
3623
3624 // Firmware formats will require digging up whatever place they're being used and reversing it.
3625 // They are not handled by dyld.
3626 switch (pointerFormat) {
3627 case DYLD_CHAINED_PTR_ARM64E:
3628 case DYLD_CHAINED_PTR_ARM64E_USERLAND:
3629 case DYLD_CHAINED_PTR_ARM64E_USERLAND24:
3630 strideSize = 8;
3631 format = GenericArm64eFixupFormat;
3632 break;
3633 case DYLD_CHAINED_PTR_ARM64E_KERNEL:
3634 strideSize = 4;
3635 format = GenericArm64eFixupFormat;
3636 break;
3637 // case DYLD_CHAINED_PTR_ARM64E_FIRMWARE: Unsupported.
3638 case DYLD_CHAINED_PTR_64:
3639 case DYLD_CHAINED_PTR_64_OFFSET:
3640 case DYLD_CHAINED_PTR_64_KERNEL_CACHE:
3641 strideSize = 4;
3642 format = Generic64FixupFormat;
3643 break;
3644 case DYLD_CHAINED_PTR_32:
3645 case DYLD_CHAINED_PTR_32_CACHE:
3646 strideSize = 4;
3647 format = Generic32FixupFormat;

Callers

nothing calls this directly

Calls 9

LogDebugMethod · 0.80
push_backMethod · 0.80
LogErrorMethod · 0.80
LogTraceMethod · 0.80
LogWarnMethod · 0.80
AddRelocatedPointerMethod · 0.80
SeekMethod · 0.45
Read32Method · 0.45
Read64Method · 0.45

Tested by

no test coverage detected