| 964 | |
| 965 | |
| 966 | void MachoView::ParseFunctionStarts(Platform* platform, uint64_t textBase, function_starts_command functionStarts) |
| 967 | { |
| 968 | BinaryReader reader(GetParentView()); |
| 969 | reader.SetEndianness(m_endian); |
| 970 | reader.SetVirtualBase(m_universalImageOffset); |
| 971 | try |
| 972 | { |
| 973 | if (m_header.ident.filetype == MH_DSYM) |
| 974 | { |
| 975 | m_logger->LogDebug("Skipping LC_FUNCTION_STARTS parsing"); |
| 976 | return; |
| 977 | } |
| 978 | |
| 979 | reader.Seek(functionStarts.funcoff); |
| 980 | DataBuffer buffer = reader.Read(functionStarts.funcsize); |
| 981 | size_t i = 0; |
| 982 | uint64_t curfunc = textBase; |
| 983 | uint64_t curOffset = 0; |
| 984 | |
| 985 | while (i < functionStarts.funcsize) |
| 986 | { |
| 987 | curOffset = readLEB128(buffer, functionStarts.funcsize, i); |
| 988 | if (curOffset == 0) |
| 989 | continue; |
| 990 | curfunc += curOffset; |
| 991 | uint64_t target = curfunc; |
| 992 | if (!IsValidFunctionStart(target)) |
| 993 | { |
| 994 | m_logger->LogWarn("Possible error processing LC_FUNCTION_STARTS! Not adding function at: 0x%" PRIx64 "\n", target); |
| 995 | continue; |
| 996 | } |
| 997 | Ref<Platform> targetPlatform = platform->GetAssociatedPlatformByAddress(target); |
| 998 | AddFunctionForAnalysis(targetPlatform, target); |
| 999 | m_logger->LogDebug("Adding function start: %#" PRIx64 "\n", curfunc); |
| 1000 | } |
| 1001 | } |
| 1002 | catch (ReadException&) |
| 1003 | { |
| 1004 | m_logger->LogDebug("LC_FUNCTION_STARTS command invalid"); |
| 1005 | } |
| 1006 | } |
| 1007 | |
| 1008 | |
| 1009 | bool MachoView::ParseRelocationEntry(const relocation_info& info, uint64_t start, BNRelocationInfo& result) |
nothing calls this directly
no test coverage detected