this repo has no description
1
fork

Configure Feed

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

Fixed/removed misleading comments in src/dyld/eh + other subtle changes

+38 -28
+19 -13
src/dyld/MachOLoader.cpp
··· 660 660 auto eh_frame = b.macho->get_eh_frame(); 661 661 if (eh_frame.first) 662 662 { 663 - EHSection ehSection; 664 - void* eh_data; 665 - uintptr_t bytes; 666 - void* eh_frame_ptr; 667 - 668 - eh_frame_ptr = (void*) (eh_frame.first + b.slide); 669 - LOG << "Reworking __eh_frame at " << eh_frame_ptr << std::endl; 670 - 671 - ehSection.load(eh_frame_ptr, eh_frame.second); 672 - ehSection.store(&eh_data, &bytes); 673 - 674 - LOG << "Registering reworked __eh_frame at " << eh_data << std::endl; 675 - __register_frame(eh_data); // TODO: free when unloading the image 663 + try 664 + { 665 + EHSection ehSection; 666 + void *reworked_eh_data, *original_eh_data; 667 + 668 + original_eh_data = (void*) (eh_frame.first + b.slide); 669 + LOG << "Reworking __eh_frame at " << original_eh_data << std::endl; 670 + 671 + ehSection.load(original_eh_data, eh_frame.second); 672 + ehSection.store(&reworked_eh_data, nullptr); 673 + 674 + LOG << "Registering reworked __eh_frame at " << reworked_eh_data << std::endl; 675 + __register_frame(reworked_eh_data); // TODO: free when unloading the image 676 + } 677 + catch (const std::exception& e) 678 + { 679 + LOG << "Failed to rework the __eh_frame: " << e.what() << std::endl; 680 + LOG << "Exception handling WILL NOT WORK!\n"; 681 + } 676 682 } 677 683 678 684 for (LoaderHookFunc* func : g_machoLoaderHooks)
+17 -14
src/dyld/eh/EHSection.cpp
··· 79 79 loadCIE(reader, endPos, location); 80 80 else 81 81 { 82 - uintptr_t pos = reader.pos() - sizeof(id); // offset is from the id field 82 + uintptr_t pos = reader.pos() - sizeof(id); // offset is from the id field to the length field of CIE 83 83 pos -= id; 84 84 85 85 auto it = m_ciePositions.find(pos); ··· 186 186 fde->length = reader.readDwarfPointer(cie->ptrEncoding); // if ptrEncoding is relative, then in context of length, it is still just a plain number 187 187 188 188 if (*cie->augmentationString == 'z') 189 - { 190 189 fde->augmentationDataLength = reader.readLEB128(); 191 - //fde->augmentationData = reinterpret_cast<const uint8_t*>(reader.readBlock(fde->augmentationDataLength)); 192 - } 193 190 else 194 - { 195 191 fde->augmentationDataLength = 0; 196 - //fde->augmentationData = nullptr; 197 - } 198 192 199 193 if (strchr(cie->augmentationString, 'L') && cie->lsdaEncoding != 0xff) // DW_EH_PE_omit 200 194 fde->lsdaPointer = reader.readDwarfPointer(cie->lsdaEncoding); ··· 234 228 // terminating entry 235 229 writer.write32(0); 236 230 237 - *length = writer.pos() - reinterpret_cast<uintptr_t>(*mem); 231 + if (length != nullptr) 232 + *length = writer.pos() - reinterpret_cast<uintptr_t>(*mem); 238 233 } 239 234 240 235 void EHSection::storeCIE(BufWriter& writer, CIE* cie) ··· 270 265 else 271 266 throw std::runtime_error("Invalid CIE version"); 272 267 273 - // TODO: cie->lsdaEncodingPtr 274 - // augmentation data length will always be 275 - // 1 + 1 + 1 + 4|8 276 - 277 268 uint64_t augLength = 0; 278 269 if (strchr(cie->augmentationString, 'L')) 279 270 augLength++; ··· 299 290 break; 300 291 case 'P': 301 292 { 302 - cie->personality.relocateToAddr(writer.pos()+1, m_originalStart, m_originalEnd); // not relocated?! 293 + cie->personality.relocateToAddr(writer.pos()+1, m_originalStart, m_originalEnd); 303 294 writer.write(cie->personality.encoding); 304 295 writer.writeDwarfPointer(cie->personality); 305 296 break; ··· 348 339 349 340 fde->startAddress.relocateToAddr(writer.pos(), m_originalStart, m_originalEnd); 350 341 writer.writeDwarfPointer(fde->startAddress); 351 - writer.writeDwarfPointer(fde->length); // length cannot be relative 342 + writer.writeDwarfPointer(fde->length); 352 343 353 344 if (*cie->augmentationString == 'z') 354 345 { ··· 373 364 374 365 void EHSection::swapRegisterNumbers(const std::vector<std::pair<int, int>>& swapList) 375 366 { 367 + for (CIE* cie : m_cies) 368 + { 369 + swapRegisterNumbers(cie->instructions, swapList); 370 + 371 + for (FDE* fde : cie->fdes) 372 + swapRegisterNumbers(fde->instructions, swapList); 373 + } 374 + } 375 + 376 + void EHSection::swapRegisterNumbers(std::vector<uint8_t>& where, const std::vector<std::pair<int, int>>& swapList) 377 + { 378 + // TODO: 376 379 }
+2 -1
src/dyld/eh/EHSection.h
··· 58 58 59 59 void storeCIE(BufWriter& writer, CIE* cie); 60 60 void storeFDE(BufWriter& writer, FDE* fde, CIE* cie, uintptr_t cieStart); 61 + 62 + static void swapRegisterNumbers(std::vector<uint8_t>& where, const std::vector<std::pair<int, int>>& swapList); 61 63 private: 62 64 // Needed for relative pointer adjustments 63 65 uintptr_t m_originalStart, m_originalEnd; ··· 65 67 struct FDE 66 68 { 67 69 DwarfPointer startAddress, length; 68 - const uint8_t* augmentationData; 69 70 int64_t augmentationDataLength; 70 71 DwarfPointer lsdaPointer; 71 72