RuntimeDyldMachO.cpp (280031) | RuntimeDyldMachO.cpp (283526) |
---|---|
1//===-- RuntimeDyldMachO.cpp - Run-time dynamic linker for MC-JIT -*- C++ -*-=// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 163 unchanged lines hidden (view full) --- 172 } 173} 174 175bool RuntimeDyldMachO::isCompatibleFile(const object::ObjectFile &Obj) const { 176 return Obj.isMachO(); 177} 178 179template <typename Impl> | 1//===-- RuntimeDyldMachO.cpp - Run-time dynamic linker for MC-JIT -*- C++ -*-=// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 163 unchanged lines hidden (view full) --- 172 } 173} 174 175bool RuntimeDyldMachO::isCompatibleFile(const object::ObjectFile &Obj) const { 176 return Obj.isMachO(); 177} 178 179template <typename Impl> |
180void RuntimeDyldMachOCRTPBase<Impl>::finalizeLoad(const ObjectFile &ObjImg, | 180void RuntimeDyldMachOCRTPBase |
181 ObjSectionToIDMap &SectionMap) { 182 unsigned EHFrameSID = RTDYLD_INVALID_SECTION_ID; 183 unsigned TextSID = RTDYLD_INVALID_SECTION_ID; 184 unsigned ExceptTabSID = RTDYLD_INVALID_SECTION_ID; | 181 ObjSectionToIDMap &SectionMap) { 182 unsigned EHFrameSID = RTDYLD_INVALID_SECTION_ID; 183 unsigned TextSID = RTDYLD_INVALID_SECTION_ID; 184 unsigned ExceptTabSID = RTDYLD_INVALID_SECTION_ID; |
185 ObjSectionToIDMap::iterator i, e; | |
186 | 185 |
187 for (i = SectionMap.begin(), e = SectionMap.end(); i != e; ++i) { 188 const SectionRef &Section = i->first; | 186 for (const auto &Section : Obj.sections()) { |
189 StringRef Name; 190 Section.getName(Name); | 187 StringRef Name; 188 Section.getName(Name); |
191 if (Name == "__eh_frame") 192 EHFrameSID = i->second; 193 else if (Name == "__text") 194 TextSID = i->second; | 189 190 // Force emission of the __text, __eh_frame, and __gcc_except_tab sections 191 // if they're present. Otherwise call down to the impl to handle other 192 // sections that have already been emitted. 193 if (Name == "__text") 194 TextSID = findOrEmitSection(Obj, Section, true, SectionMap); 195 else if (Name == "__eh_frame") 196 EHFrameSID = findOrEmitSection(Obj, Section, false, SectionMap); |
195 else if (Name == "__gcc_except_tab") | 197 else if (Name == "__gcc_except_tab") |
196 ExceptTabSID = i->second; 197 else 198 impl().finalizeSection(ObjImg, i->second, Section); | 198 ExceptTabSID = findOrEmitSection(Obj, Section, true, SectionMap); 199 else { 200 auto I = SectionMap.find(Section); 201 if (I != SectionMap.end()) 202 impl().finalizeSection(Obj, I->second, Section); 203 } |
199 } 200 UnregisteredEHFrameSections.push_back( 201 EHFrameRelatedSections(EHFrameSID, TextSID, ExceptTabSID)); 202} 203 204template <typename Impl> 205unsigned char *RuntimeDyldMachOCRTPBase<Impl>::processFDE(unsigned char *P, 206 int64_t DeltaForText, --- 26 unchanged lines hidden (view full) --- 233 TargetPtrT NewLSDA = LSDA - DeltaForEH; 234 writeBytesUnaligned(NewLSDA, P, sizeof(TargetPtrT)); 235 } 236 237 return Ret; 238} 239 240static int64_t computeDelta(SectionEntry *A, SectionEntry *B) { | 204 } 205 UnregisteredEHFrameSections.push_back( 206 EHFrameRelatedSections(EHFrameSID, TextSID, ExceptTabSID)); 207} 208 209template <typename Impl> 210unsigned char *RuntimeDyldMachOCRTPBase<Impl>::processFDE(unsigned char *P, 211 int64_t DeltaForText, --- 26 unchanged lines hidden (view full) --- 238 TargetPtrT NewLSDA = LSDA - DeltaForEH; 239 writeBytesUnaligned(NewLSDA, P, sizeof(TargetPtrT)); 240 } 241 242 return Ret; 243} 244 245static int64_t computeDelta(SectionEntry *A, SectionEntry *B) { |
241 int64_t ObjDistance = A->ObjAddress - B->ObjAddress; | 246 int64_t ObjDistance = 247 static_cast<int64_t>(A->ObjAddress) - static_cast<int64_t>(B->ObjAddress); |
242 int64_t MemDistance = A->LoadAddress - B->LoadAddress; 243 return ObjDistance - MemDistance; 244} 245 246template <typename Impl> 247void RuntimeDyldMachOCRTPBase<Impl>::registerEHFrames() { 248 249 if (!MemMgr) --- 51 unchanged lines hidden --- | 248 int64_t MemDistance = A->LoadAddress - B->LoadAddress; 249 return ObjDistance - MemDistance; 250} 251 252template <typename Impl> 253void RuntimeDyldMachOCRTPBase<Impl>::registerEHFrames() { 254 255 if (!MemMgr) --- 51 unchanged lines hidden --- |