this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Correct pre-10.6 image rebasing

+13 -10
+4 -6
src/dyld/MachOLoader.cpp
··· 299 299 } 300 300 } 301 301 302 - void MachOLoader::doRelocations(const std::vector<MachO::Relocation*>& rels, intptr segmentBase, intptr slide) 302 + void MachOLoader::doRelocations(const std::vector<MachO::Relocation*>& rels, intptr slide) 303 303 { 304 - TRACE2(segmentBase, slide); 304 + TRACE1(slide); 305 305 m_lastResolvedSymbol.clear(); 306 306 m_lastResolvedAddress = 0; 307 307 308 308 for (const MachO::Relocation* rel : rels) 309 309 { 310 - uintptr_t* ptr = (uintptr_t*) (uintptr_t(rel->addr) + segmentBase + slide); 310 + uintptr_t* ptr = (uintptr_t*) (uintptr_t(rel->addr) + slide); 311 311 uintptr_t symbol; 312 312 uintptr_t value = *ptr; 313 313 ··· 622 622 if (!bindLater) 623 623 doBind(mach.binds(), slide, !bindLazy); 624 624 625 - segmentBase = mach.relocation_base(); 626 - 627 - doRelocations(mach.relocations(), segmentBase, slide); 625 + doRelocations(mach.relocations(), slide); 628 626 doMProtect(); // decrease the segment protection value 629 627 630 628 if (!bindLater)
+1 -1
src/dyld/MachOLoader.h
··· 67 67 void* doBind(const std::vector<MachO::Bind*>& binds, intptr slide, bool resolveLazy = false); 68 68 69 69 // Binds external relocations 70 - void doRelocations(const std::vector<MachO::Relocation*>& rels, intptr segmentBase, intptr slide); 70 + void doRelocations(const std::vector<MachO::Relocation*>& rels, intptr slide); 71 71 72 72 // Calls mprotect() to switch segment protections to the "initial" value. 73 73 // We initially set the maximum value.
+8 -3
src/libmach-o/MachOImpl.cpp
··· 752 752 void MachOImpl::readInternalRelocation(const struct relocation_info* reloc) 753 753 { 754 754 Rebase* rebase; 755 + const uint64_t relocBase = relocation_base(); 755 756 756 757 #ifndef __x86_64__ // "In the OS X x86-64 environment scattered relocations are not used." 757 758 if (reloc->r_address & R_SCATTERED) ··· 788 789 return; 789 790 } 790 791 791 - rebase = new Rebase { uint64_t(reloc->r_address) & 0xffffffff, REBASE_TYPE_POINTER }; 792 + rebase = new Rebase { uint64_t(reloc->r_address + relocBase) & 0xffffffff, REBASE_TYPE_POINTER }; 793 + 794 + LOG << "Adding a rebase: 0x" << std::hex << rebase->vmaddr << std::dec << std::endl; 792 795 } 793 796 794 797 if (rebase) ··· 797 800 798 801 void MachOImpl::readExternalRelocation(const struct relocation_info* reloc, uint32_t* symtab, const char* symstrtab) 799 802 { 803 + const uint64_t relocBase = relocation_base(); 804 + 800 805 if (!reloc->r_extern) 801 806 throw std::runtime_error("Invalid external relocation"); 802 807 ··· 821 826 Relocation* relocation = new Relocation; 822 827 nlist* sym = (nlist*)(symtab + reloc->r_symbolnum * (m_is64 ? 4 : 3)); 823 828 824 - relocation->addr = reloc->r_address; 829 + relocation->addr = reloc->r_address + relocBase; 825 830 relocation->name = symstrtab + sym->n_strx; 826 831 relocation->pcrel = reloc->r_pcrel != 0; 827 832 828 - LOG << "External relocation: " << std::hex << relocation->addr << std::dec 833 + LOG << "External relocation: 0x" << std::hex << relocation->addr << std::dec 829 834 << "; name: " << relocation->name << "; pcrel: " << relocation->pcrel << std::endl; 830 835 831 836 m_relocations.push_back(relocation);