Mercurial > hg > CbC > CbC_llvm
comparison libunwind/src/AddressSpace.hpp @ 252:1f2b6ac9f198 llvm-original
LLVM16-1
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 Aug 2023 09:04:13 +0900 |
parents | c4bab56944e8 |
children |
comparison
equal
deleted
inserted
replaced
237:c80f45b162ad | 252:1f2b6ac9f198 |
---|---|
63 uintptr_t compact_unwind_section_length; | 63 uintptr_t compact_unwind_section_length; |
64 }; | 64 }; |
65 | 65 |
66 // In 10.7.0 or later, libSystem.dylib implements this function. | 66 // In 10.7.0 or later, libSystem.dylib implements this function. |
67 extern "C" bool _dyld_find_unwind_sections(void *, dyld_unwind_sections *); | 67 extern "C" bool _dyld_find_unwind_sections(void *, dyld_unwind_sections *); |
68 | |
69 namespace libunwind { | |
70 bool findDynamicUnwindSections(void *, unw_dynamic_unwind_sections *); | |
71 } | |
68 | 72 |
69 #elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_LIBUNWIND_IS_BAREMETAL) | 73 #elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_LIBUNWIND_IS_BAREMETAL) |
70 | 74 |
71 // When statically linked on bare-metal, the symbols for the EH table are looked | 75 // When statically linked on bare-metal, the symbols for the EH table are looked |
72 // up without going through the dynamic loader. | 76 // up without going through the dynamic loader. |
244 | 248 |
245 /// Read a SLEB128 into a 64-bit word. | 249 /// Read a SLEB128 into a 64-bit word. |
246 inline int64_t LocalAddressSpace::getSLEB128(pint_t &addr, pint_t end) { | 250 inline int64_t LocalAddressSpace::getSLEB128(pint_t &addr, pint_t end) { |
247 const uint8_t *p = (uint8_t *)addr; | 251 const uint8_t *p = (uint8_t *)addr; |
248 const uint8_t *pend = (uint8_t *)end; | 252 const uint8_t *pend = (uint8_t *)end; |
249 int64_t result = 0; | 253 uint64_t result = 0; |
250 int bit = 0; | 254 int bit = 0; |
251 uint8_t byte; | 255 uint8_t byte; |
252 do { | 256 do { |
253 if (p == pend) | 257 if (p == pend) |
254 _LIBUNWIND_ABORT("truncated sleb128 expression"); | 258 _LIBUNWIND_ABORT("truncated sleb128 expression"); |
258 } while (byte & 0x80); | 262 } while (byte & 0x80); |
259 // sign extend negative numbers | 263 // sign extend negative numbers |
260 if ((byte & 0x40) != 0 && bit < 64) | 264 if ((byte & 0x40) != 0 && bit < 64) |
261 result |= (-1ULL) << bit; | 265 result |= (-1ULL) << bit; |
262 addr = (pint_t) p; | 266 addr = (pint_t) p; |
263 return result; | 267 return (int64_t)result; |
264 } | 268 } |
265 | 269 |
266 inline LocalAddressSpace::pint_t | 270 inline LocalAddressSpace::pint_t |
267 LocalAddressSpace::getEncodedP(pint_t &addr, pint_t end, uint8_t encoding, | 271 LocalAddressSpace::getEncodedP(pint_t &addr, pint_t end, uint8_t encoding, |
268 pint_t datarelBase) { | 272 pint_t datarelBase) { |
495 #endif | 499 #endif |
496 info.compact_unwind_section = (uintptr_t)dyldInfo.compact_unwind_section; | 500 info.compact_unwind_section = (uintptr_t)dyldInfo.compact_unwind_section; |
497 info.compact_unwind_section_length = (size_t)dyldInfo.compact_unwind_section_length; | 501 info.compact_unwind_section_length = (size_t)dyldInfo.compact_unwind_section_length; |
498 return true; | 502 return true; |
499 } | 503 } |
504 | |
505 unw_dynamic_unwind_sections dynamicUnwindSectionInfo; | |
506 if (findDynamicUnwindSections((void *)targetAddr, | |
507 &dynamicUnwindSectionInfo)) { | |
508 info.dso_base = dynamicUnwindSectionInfo.dso_base; | |
509 #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) | |
510 info.dwarf_section = (uintptr_t)dynamicUnwindSectionInfo.dwarf_section; | |
511 info.dwarf_section_length = dynamicUnwindSectionInfo.dwarf_section_length; | |
512 #endif | |
513 info.compact_unwind_section = | |
514 (uintptr_t)dynamicUnwindSectionInfo.compact_unwind_section; | |
515 info.compact_unwind_section_length = | |
516 dynamicUnwindSectionInfo.compact_unwind_section_length; | |
517 return true; | |
518 } | |
519 | |
500 #elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_LIBUNWIND_IS_BAREMETAL) | 520 #elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_LIBUNWIND_IS_BAREMETAL) |
501 info.dso_base = 0; | 521 info.dso_base = 0; |
502 // Bare metal is statically linked, so no need to ask the dynamic loader | 522 // Bare metal is statically linked, so no need to ask the dynamic loader |
503 info.dwarf_section_length = (size_t)(&__eh_frame_end - &__eh_frame_start); | 523 info.dwarf_section_length = (size_t)(&__eh_frame_end - &__eh_frame_start); |
504 info.dwarf_section = (uintptr_t)(&__eh_frame_start); | 524 info.dwarf_section = (uintptr_t)(&__eh_frame_start); |