macho/macho-go/pkg/ios/macho/fixups.h

35 lines
865 B
C

#ifndef _FIXUPS_
#define _FIXUPS_
#include <stdint.h>
// char* symbols_table
// struct dyld_chained_import* imports_table
//
// some conflicting with cgo if using void*
// so use uint64_t as abstraction
struct ImportTable {
uint64_t symbols_table;
uint64_t imports_table;
uint32_t size;
};
struct ImportSymbol {
int lib_ordinal;
char* name;
};
struct SegmentFix {
uint64_t segment;
uint32_t format;
uint32_t page_count;
uint16_t* pages;
};
void ParseFixUps(uint8_t* raw);
struct ImportTable GetImportsTable(uint8_t* header_ptr);
struct ImportSymbol GetImportsAt(struct ImportTable* table, int i);
int GetSegmentFixAt(uint8_t* buffer, uint32_t i, struct SegmentFix* fix);
int ParseFixValue(int format, uint64_t value, int* bind, uint64_t* ret1, uint64_t* ret2);
uint64_t MakeRebaseFixupOpcode(int next, uint64_t target, uint64_t high8);
#endif