iterate fixups segment pages
was not parse through each page, so it stucks on one page
This commit is contained in:
parent
06525b8a5e
commit
8e1e176068
@ -127,9 +127,9 @@ func (mc *MachoContext) CollectBindSymbolsModern() []*ImportSymbol {
|
||||
pages := ([]C.ushort)(unsafe.Slice(fix.pages, fix.page_count))
|
||||
reader := bytes.NewReader(mc.buf)
|
||||
for page_i := 0; page_i < int(fix.page_count); page_i++ {
|
||||
// fmt.Printf(" page offset=%x\n", pages[page_i])
|
||||
|
||||
address := int64(fix.segment) + int64(pages[page_i])
|
||||
// loop through each page in segment, each page has size fix.page_size
|
||||
// the first item in page is offset through pages[page_i]
|
||||
address := int64(fix.segment) + int64(page_i) * int64(fix.page_size) + int64(pages[page_i])
|
||||
reader.Seek(address, io.SeekStart)
|
||||
|
||||
code := make([]byte, 8)
|
||||
|
@ -54,6 +54,7 @@ int GetSegmentFixAt(uint8_t* buffer, uint32_t i, struct SegmentFix* fix) {
|
||||
fix->format = chain_header->pointer_format;
|
||||
fix->page_count = chain_header->page_count;
|
||||
fix->pages = chain_header->page_start;
|
||||
fix->page_size = chain_header->page_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ struct SegmentFix {
|
||||
uint64_t segment;
|
||||
uint32_t format;
|
||||
uint32_t page_count;
|
||||
uint16_t page_size;
|
||||
uint16_t* pages;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user