this repo has no description
1
fork

Configure Feed

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

Non-important fixes

+43 -133
-49
src/dyld/LazyStub.cpp
··· 1 - #include "LazyStub.h" 2 - #include <unistd.h> 3 - #include <sys/mman.h> 4 - #include <stdexcept> 5 - #include <cassert> 6 - 7 - extern "C" void lazystub_loader(); 8 - 9 - LazyStubMgr::LazyStubMgr(void* (*lazyResolver)(void* /*opaque*/), int minStubs) 10 - { 11 - int ps = getpagesize(); 12 - void* mem; 13 - 14 - int bytes = entries * sizeof(LazyStub); 15 - bytes = (bytes + ps - 1) / ps * ps; 16 - 17 - mem = ::mmap(0, bytes, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); 18 - if (mem == MAP_FAILED) 19 - throw std::runtime_error("Failed to map pages for LazyStub"); 20 - 21 - m_pMem = static_cast<LazyStub*>(mem); 22 - m_nMax = bytes / sizeof(LazyStub); 23 - m_nBytes = bytes; 24 - 25 - m_pOpaques = new void*[m_nMax]; 26 - } 27 - 28 - LazyStubMgr::~LazyStubMgr() 29 - { 30 - ::munmap(m_pMem, m_nBytes); 31 - delete [] m_pOpaques; 32 - } 33 - 34 - void* LazyStubMgr::createStub(void* opaque) 35 - { 36 - MutexLock l(m_mutex); 37 - 38 - if (m_nNext >= m_nMax) 39 - throw std::runtime_error("LazyStub buffer full"); 40 - 41 - m_pMem[m_nNext].init(m_nNext, (uint32_t)(long)lazystub_loader); 42 - m_pOpaques[m_nNext] = opaque; 43 - return &m_pMem[m_nNext++]; 44 - } 45 - 46 - void* LazyStubMgr::lazystub_resolve(uint32_t index) 47 - { 48 - } 49 -
-40
src/dyld/LazyStub.h
··· 1 - #ifndef LAZUSTUB_H 2 - #define LAZUSTUB_H 3 - #include <stdint.h> 4 - #include <map> 5 - #include "Mutex.h" 6 - 7 - #pragma pack(1) 8 - struct LazyStub 9 - { 10 - char mov; // b9 (ecx) 11 - uint32_t index; 12 - char jmp; // e9 13 - uint32_t loader; 14 - 15 - void init(uint32_t index, uint32_t loader) 16 - { 17 - mov = 0xb9; 18 - this->index = index; 19 - jmp = 0xe9; 20 - this->loader = loader; 21 - } 22 - }; 23 - #pragma pack() 24 - 25 - class LazyStubMgr 26 - { 27 - public: 28 - LazyStubMgr(void* (*lazyResolver)(void* /*opaque*/), int minStubs = 3000); 29 - ~LazyStubMgr(); 30 - 31 - void* createStub(void* opaque); 32 - static void* lazystub_resolve(uint32_t index) asm("lazystub_resolve"); 33 - private: 34 - Darling::Mutex m_mutex; 35 - LazyStub* m_pMem; 36 - int m_nMax, m_nNext, m_nBytes; 37 - void** m_pOpaques; 38 - }; 39 - 40 - #endif
-41
src/dyld/LazyStubLdr.asm
··· 1 - SEGMENT .text 2 - 3 - extern lazystub_resolve 4 - 5 - global lazystub_loader64 6 - lazystub_loader64: 7 - push rdi 8 - push rsi 9 - push rdx 10 - push rcx 11 - push r8 12 - push r9 13 - push xmm0 14 - push xmm1 15 - push xmm2 16 - push xmm3 17 - push xmm4 18 - push xmm5 19 - push xmm6 20 - push xmm7 21 - 22 - xor rax, rax 23 - mov edx, ebx 24 - call lazystub_resolve 25 - 26 - pop xmm7 27 - pop xmm6 28 - pop xmm5 29 - pop xmm4 30 - pop xmm3 31 - pop xmm2 32 - pop xmm1 33 - pop r9 34 - pop r8 35 - pop rcx 36 - pop rdx 37 - pop rsi 38 - pop rdi 39 - 40 - jmp rax 41 -
+1 -1
src/dyld/MachOLoader.cpp
··· 459 459 sym += bind->addend; 460 460 } 461 461 462 - LOG << "bind " << name << ": " 462 + LOG << "bind " << bind->name << ": " 463 463 << std::hex << *ptr << std::dec << " => " << (void*)sym << " @" << ptr << std::endl; 464 464 #ifdef DEBUG 465 465 if (g_trampoline)
+19
src/dyld/eh/BufReWriter.cpp
··· 1 + /* 2 + This file is part of Darling. 3 + 4 + Copyright (C) 2013 Lubos Dolezel 5 + 6 + Darling is free software: you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation, either version 3 of the License, or 9 + (at your option) any later version. 10 + 11 + Darling is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 + */ 19 + 1 20 #include "BufReWriter.h" 2 21 #include <cassert> 3 22 #include <stdexcept>
+19
src/dyld/eh/BufReWriter.h
··· 1 + /* 2 + This file is part of Darling. 3 + 4 + Copyright (C) 2013 Lubos Dolezel 5 + 6 + Darling is free software: you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation, either version 3 of the License, or 9 + (at your option) any later version. 10 + 11 + Darling is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 + */ 19 + 1 20 #ifndef BUFREWRITER_H 2 21 #define BUFREWRITER_H 3 22 #include "BufReader.h"
+4 -1
src/dyld/eh/CFIWalker.cpp
··· 47 47 int newRegNo = mapRegisterNumber(opaque, origRegNo); 48 48 49 49 if (origRegNo != newRegNo) 50 - return (uint8_t) (instr & 0xC0) | newRegNo; 50 + { 51 + LOG << "Updating mixed instr. register number: " << origRegNo << " -> " << newRegNo << std::endl; 52 + return (uint8_t) (instr & 0xC0) | (newRegNo & 0x3f); 53 + } 51 54 else 52 55 return instr; 53 56 }
-1
src/dyld/eh/EHSection.cpp
··· 302 302 { 303 303 std::stringstream ss; 304 304 ss << "Unsupported character in CIE augmentation string: " << *augP; 305 - delete cie; 306 305 307 306 throw std::runtime_error(ss.str()); 308 307 }