Lines Matching +full:os +full:- +full:data +full:- +full:offset

1 //===-- ARMWinEHPrinter.cpp - Windows on ARM EH Data Printer ----*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Windows on ARM uses a series of serialised data structures (RuntimeFunction)
11 // there are two different ways that this data is represented.
13 // For functions with canonical forms for the prologue and epilogue, the data
14 // can be stored in a "packed" form. In this case, the data is packed into the
15 // RuntimeFunction's remaining 30-bits and can fully describe the entire frame.
17 // +---------------------------------------+
19 // +---------------------------------------+
20 // | Packed Form Data |
21 // +---------------------------------------+
24 // associated with such a frame as they can be derived from the provided data.
25 // The decoder does not synthesize this data as it is unnecessary for the
29 // For functions that are large or do not match canonical forms, the data is
30 // split up into two portions, with the actual data residing in the "exception
31 // data" table (.xdata) with a reference to the entry from the "procedure data"
34 // The exception data contains information about the frame setup, all of the
36 // the associated exception handler. Additionally, the entry contains byte-code
39 // +---------------------------------------+
41 // +---------------------------------------+
42 // | Exception Data Entry Address |
43 // +---------------------------------------+
46 // first resolve the exception data entry address. This structure
53 // The decoder itself is table-driven, using the first byte to determine the
59 // The byte-code maintains a 1-1 instruction mapping, indicating both the width
75 raw_ostream &operator<<(raw_ostream &OS, const ARM::WinEH::ReturnType &RT) {
78 OS << "pop {pc}";
81 OS << "bx <reg>";
84 OS << "b.w <target>";
87 OS << "(no epilogue)";
90 return OS;
95 uint64_t Offset = 0) {
97 raw_string_ostream OS(Buffer);
100 OS << Name << " ";
102 if (Offset)
103 OS << format("+0x%" PRIX64 " (0x%" PRIX64 ")", Offset, Address);
105 OS << format("(0x%" PRIX64 ")", Address);
107 OS << format("0x%" PRIX64, Address);
109 return OS.str();
119 { 0x80, 0x00, 1, &Decoder::opcode_0xxxxxxx }, // UOP_STACK_FREE (16-bit)
120 { 0xc0, 0x80, 2, &Decoder::opcode_10Lxxxxx }, // UOP_POP (32-bit)
121 { 0xf0, 0xc0, 1, &Decoder::opcode_1100xxxx }, // UOP_STACK_SAVE (16-bit)
122 { 0xf8, 0xd0, 1, &Decoder::opcode_11010Lxx }, // UOP_POP (16-bit)
123 { 0xf8, 0xd8, 1, &Decoder::opcode_11011Lxx }, // UOP_POP (32-bit)
124 { 0xf8, 0xe0, 1, &Decoder::opcode_11100xxx }, // UOP_VPOP (32-bit)
125 { 0xfc, 0xe8, 2, &Decoder::opcode_111010xx }, // UOP_STACK_FREE (32-bit)
126 { 0xfe, 0xec, 2, &Decoder::opcode_1110110L }, // UOP_POP (16-bit)
127 { 0xff, 0xee, 2, &Decoder::opcode_11101110 }, // UOP_MICROSOFT_SPECIFIC (16-bit)
132 { 0xff, 0xef, 2, &Decoder::opcode_11101111 }, // UOP_LDRPC_POSTINC (32-bit)
133 { 0xff, 0xf5, 2, &Decoder::opcode_11110101 }, // UOP_VPOP (32-bit)
134 { 0xff, 0xf6, 2, &Decoder::opcode_11110110 }, // UOP_VPOP (32-bit)
135 { 0xff, 0xf7, 3, &Decoder::opcode_11110111 }, // UOP_STACK_RESTORE (16-bit)
136 { 0xff, 0xf8, 4, &Decoder::opcode_11111000 }, // UOP_STACK_RESTORE (16-bit)
137 { 0xff, 0xf9, 3, &Decoder::opcode_11111001 }, // UOP_STACK_RESTORE (32-bit)
138 { 0xff, 0xfa, 4, &Decoder::opcode_11111010 }, // UOP_STACK_RESTORE (32-bit)
139 { 0xff, 0xfb, 1, &Decoder::opcode_11111011 }, // UOP_NOP (16-bit)
140 { 0xff, 0xfc, 1, &Decoder::opcode_11111100 }, // UOP_NOP (32-bit)
141 { 0xff, 0xfd, 1, &Decoder::opcode_11111101 }, // UOP_NOP (16-bit) / END
142 { 0xff, 0xfe, 1, &Decoder::opcode_11111110 }, // UOP_NOP (32-bit) / END
147 // https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling
179 static void printRange(raw_ostream &OS, ListSeparator &LS, unsigned First,
182 OS << LS << Letter << First;
184 OS << LS << Letter << First << "-" << Letter << Last;
187 static void printRange(raw_ostream &OS, uint32_t Mask, ListSeparator &LS,
189 int First = -1;
196 printRange(OS, LS, First, RI - 1, Letter);
197 First = -1;
202 printRange(OS, LS, First, End, Letter);
206 OS << '{';
208 printRange(OS, GPRMask, LS, 0, 12, 'r');
210 OS << LS << "lr";
212 OS << LS << "pc";
213 OS << '}';
217 OS << '{';
219 printRange(OS, VFPMask, LS, 0, 31, 'd');
220 OS << '}';
229 if (VA >= Address && (VA - Address) <= Size)
255 uint64_t Offset) {
258 if (RelocationOffset == Offset)
278 uint32_t Offset = CoffSym.getValue() + SymbolOffset - CS.getValue();
279 if (Offset <= SymbolOffset) {
280 SymbolOffset = Offset;
295 // Try to locate a relocation that points at the offset in the section
299 // We found a relocation symbol; the immediate offset needs to be added
303 Expected<uint64_t> AddressOrErr = SymOrErr->getAddress();
306 llvm::raw_string_ostream OS(Buf);
307 logAllUnhandledErrors(AddressOrErr.takeError(), OS);
308 report_fatal_error(Twine(OS.str()));
311 // the caller to print it as an offset on the symbol name.
318 // find a descriptive symbol if possible. The immediate offset contains
319 // the image relative address, and we shouldn't add any offset to the
328 bool Decoder::opcode_0xxxxxxx(const uint8_t *OC, unsigned &Offset,
330 uint8_t Imm = OC[Offset] & 0x7f;
332 OC[Offset],
335 ++Offset;
339 bool Decoder::opcode_10Lxxxxx(const uint8_t *OC, unsigned &Offset,
341 unsigned Link = (OC[Offset] & 0x20) >> 5;
343 | ((OC[Offset + 0] & 0x1f) << 8)
344 | ((OC[Offset + 1] & 0xff) << 0);
349 OC[Offset + 0], OC[Offset + 1],
352 OS << '\n';
354 Offset += 2;
358 bool Decoder::opcode_1100xxxx(const uint8_t *OC, unsigned &Offset,
362 OC[Offset], OC[Offset] & 0xf);
365 OC[Offset], OC[Offset] & 0xf);
366 ++Offset;
370 bool Decoder::opcode_11010Lxx(const uint8_t *OC, unsigned &Offset,
372 unsigned Link = (OC[Offset] & 0x4) >> 2;
373 unsigned Count = (OC[Offset] & 0x3);
376 | (((1 << (Count + 1)) - 1) << 4);
378 SW.startLine() << format("0x%02x ; %s ", OC[Offset],
381 OS << '\n';
383 ++Offset;
387 bool Decoder::opcode_11011Lxx(const uint8_t *OC, unsigned &Offset,
389 unsigned Link = (OC[Offset] & 0x4) >> 2;
390 unsigned Count = (OC[Offset] & 0x3) + 4;
393 | (((1 << (Count + 1)) - 1) << 4);
395 SW.startLine() << format("0x%02x ; %s.w ", OC[Offset],
398 OS << '\n';
400 ++Offset;
404 bool Decoder::opcode_11100xxx(const uint8_t *OC, unsigned &Offset,
406 unsigned High = (OC[Offset] & 0x7);
407 uint32_t VFPMask = (((1 << (High + 1)) - 1) << 8);
409 SW.startLine() << format("0x%02x ; %s ", OC[Offset],
412 OS << '\n';
414 ++Offset;
418 bool Decoder::opcode_111010xx(const uint8_t *OC, unsigned &Offset,
420 uint16_t Imm = ((OC[Offset + 0] & 0x03) << 8) | ((OC[Offset + 1] & 0xff) << 0);
423 OC[Offset + 0], OC[Offset + 1],
427 Offset += 2;
431 bool Decoder::opcode_1110110L(const uint8_t *OC, unsigned &Offset,
433 uint16_t GPRMask = ((OC[Offset + 0] & 0x01) << (Prologue ? 14 : 15))
434 | ((OC[Offset + 1] & 0xff) << 0);
436 SW.startLine() << format("0x%02x 0x%02x ; %s ", OC[Offset + 0],
437 OC[Offset + 1], Prologue ? "push" : "pop");
439 OS << '\n';
441 Offset += 2;
445 bool Decoder::opcode_11101110(const uint8_t *OC, unsigned &Offset,
449 if (OC[Offset + 1] & 0xf0)
451 OC[Offset + 0], OC[Offset + 1]);
454 << format("0x%02x 0x%02x ; microsoft-specific (type: %u)\n",
455 OC[Offset + 0], OC[Offset + 1], OC[Offset + 1] & 0x0f);
457 Offset += 2;
461 bool Decoder::opcode_11101111(const uint8_t *OC, unsigned &Offset,
463 if (OC[Offset + 1] & 0xf0)
465 OC[Offset + 0], OC[Offset + 1]);
468 << format("0x%02x 0x%02x ; str.w lr, [sp, #-%u]!\n",
469 OC[Offset + 0], OC[Offset + 1], OC[Offset + 1] << 2);
473 OC[Offset + 0], OC[Offset + 1], OC[Offset + 1] << 2);
475 Offset += 2;
479 bool Decoder::opcode_11110101(const uint8_t *OC, unsigned &Offset,
481 unsigned Start = (OC[Offset + 1] & 0xf0) >> 4;
482 unsigned End = (OC[Offset + 1] & 0x0f) >> 0;
483 uint32_t VFPMask = ((1 << (End + 1 - Start)) - 1) << Start;
485 SW.startLine() << format("0x%02x 0x%02x ; %s ", OC[Offset + 0],
486 OC[Offset + 1], Prologue ? "vpush" : "vpop");
488 OS << '\n';
490 Offset += 2;
494 bool Decoder::opcode_11110110(const uint8_t *OC, unsigned &Offset,
496 unsigned Start = (OC[Offset + 1] & 0xf0) >> 4;
497 unsigned End = (OC[Offset + 1] & 0x0f) >> 0;
498 uint32_t VFPMask = ((1 << (End + 1 - Start)) - 1) << (16 + Start);
500 SW.startLine() << format("0x%02x 0x%02x ; %s ", OC[Offset + 0],
501 OC[Offset + 1], Prologue ? "vpush" : "vpop");
503 OS << '\n';
505 Offset += 2;
509 bool Decoder::opcode_11110111(const uint8_t *OC, unsigned &Offset,
511 uint32_t Imm = (OC[Offset + 1] << 8) | (OC[Offset + 2] << 0);
514 OC[Offset + 0], OC[Offset + 1], OC[Offset + 2],
518 Offset += 3;
522 bool Decoder::opcode_11111000(const uint8_t *OC, unsigned &Offset,
524 uint32_t Imm = (OC[Offset + 1] << 16)
525 | (OC[Offset + 2] << 8)
526 | (OC[Offset + 3] << 0);
530 OC[Offset + 0], OC[Offset + 1], OC[Offset + 2], OC[Offset + 3],
533 Offset += 4;
537 bool Decoder::opcode_11111001(const uint8_t *OC, unsigned &Offset,
539 uint32_t Imm = (OC[Offset + 1] << 8) | (OC[Offset + 2] << 0);
543 OC[Offset + 0], OC[Offset + 1], OC[Offset + 2],
546 Offset += 3;
550 bool Decoder::opcode_11111010(const uint8_t *OC, unsigned &Offset,
552 uint32_t Imm = (OC[Offset + 1] << 16)
553 | (OC[Offset + 2] << 8)
554 | (OC[Offset + 3] << 0);
558 OC[Offset + 0], OC[Offset + 1], OC[Offset + 2], OC[Offset + 3],
561 Offset += 4;
565 bool Decoder::opcode_11111011(const uint8_t *OC, unsigned &Offset,
567 SW.startLine() << format("0x%02x ; nop\n", OC[Offset]);
568 ++Offset;
572 bool Decoder::opcode_11111100(const uint8_t *OC, unsigned &Offset,
574 SW.startLine() << format("0x%02x ; nop.w\n", OC[Offset]);
575 ++Offset;
579 bool Decoder::opcode_11111101(const uint8_t *OC, unsigned &Offset,
581 SW.startLine() << format("0x%02x ; bx <reg>\n", OC[Offset]);
582 ++Offset;
586 bool Decoder::opcode_11111110(const uint8_t *OC, unsigned &Offset,
588 SW.startLine() << format("0x%02x ; b.w <target>\n", OC[Offset]);
589 ++Offset;
593 bool Decoder::opcode_11111111(const uint8_t *OC, unsigned &Offset,
595 ++Offset;
600 bool Decoder::opcode_alloc_s(const uint8_t *OC, unsigned &Offset,
602 uint32_t NumBytes = (OC[Offset] & 0x1F) << 4;
603 SW.startLine() << format("0x%02x ; %s sp, #%u\n", OC[Offset],
606 ++Offset;
610 bool Decoder::opcode_save_r19r20_x(const uint8_t *OC, unsigned &Offset,
612 uint32_t Off = (OC[Offset] & 0x1F) << 3;
615 "0x%02x ; stp x19, x20, [sp, #-%u]!\n", OC[Offset], Off);
618 "0x%02x ; ldp x19, x20, [sp], #%u\n", OC[Offset], Off);
619 ++Offset;
623 bool Decoder::opcode_save_fplr(const uint8_t *OC, unsigned &Offset,
625 uint32_t Off = (OC[Offset] & 0x3F) << 3;
627 "0x%02x ; %s x29, x30, [sp, #%u]\n", OC[Offset],
629 ++Offset;
633 bool Decoder::opcode_save_fplr_x(const uint8_t *OC, unsigned &Offset,
635 uint32_t Off = ((OC[Offset] & 0x3F) + 1) << 3;
638 "0x%02x ; stp x29, x30, [sp, #-%u]!\n", OC[Offset], Off);
641 "0x%02x ; ldp x29, x30, [sp], #%u\n", OC[Offset], Off);
642 ++Offset;
646 bool Decoder::opcode_alloc_m(const uint8_t *OC, unsigned &Offset,
648 uint32_t NumBytes = ((OC[Offset] & 0x07) << 8);
649 NumBytes |= (OC[Offset + 1] & 0xFF);
652 OC[Offset], OC[Offset + 1],
655 Offset += 2;
659 bool Decoder::opcode_save_regp(const uint8_t *OC, unsigned &Offset,
661 uint32_t Reg = ((OC[Offset] & 0x03) << 8);
662 Reg |= (OC[Offset + 1] & 0xC0);
665 uint32_t Off = (OC[Offset + 1] & 0x3F) << 3;
668 OC[Offset], OC[Offset + 1],
670 Offset += 2;
674 bool Decoder::opcode_save_regp_x(const uint8_t *OC, unsigned &Offset,
676 uint32_t Reg = ((OC[Offset] & 0x03) << 8);
677 Reg |= (OC[Offset + 1] & 0xC0);
680 uint32_t Off = ((OC[Offset + 1] & 0x3F) + 1) << 3;
683 "0x%02x%02x ; stp x%u, x%u, [sp, #-%u]!\n",
684 OC[Offset], OC[Offset + 1], Reg,
689 OC[Offset], OC[Offset + 1], Reg,
691 Offset += 2;
695 bool Decoder::opcode_save_reg(const uint8_t *OC, unsigned &Offset,
697 uint32_t Reg = (OC[Offset] & 0x03) << 8;
698 Reg |= (OC[Offset + 1] & 0xC0);
701 uint32_t Off = (OC[Offset + 1] & 0x3F) << 3;
703 OC[Offset], OC[Offset + 1],
706 Offset += 2;
710 bool Decoder::opcode_save_reg_x(const uint8_t *OC, unsigned &Offset,
712 uint32_t Reg = (OC[Offset] & 0x01) << 8;
713 Reg |= (OC[Offset + 1] & 0xE0);
716 uint32_t Off = ((OC[Offset + 1] & 0x1F) + 1) << 3;
718 SW.startLine() << format("0x%02x%02x ; str x%u, [sp, #-%u]!\n",
719 OC[Offset], OC[Offset + 1], Reg, Off);
722 OC[Offset], OC[Offset + 1], Reg, Off);
723 Offset += 2;
727 bool Decoder::opcode_save_lrpair(const uint8_t *OC, unsigned &Offset,
729 uint32_t Reg = (OC[Offset] & 0x01) << 8;
730 Reg |= (OC[Offset + 1] & 0xC0);
734 uint32_t Off = (OC[Offset + 1] & 0x3F) << 3;
736 OC[Offset], OC[Offset + 1],
739 Offset += 2;
743 bool Decoder::opcode_save_fregp(const uint8_t *OC, unsigned &Offset,
745 uint32_t Reg = (OC[Offset] & 0x01) << 8;
746 Reg |= (OC[Offset + 1] & 0xC0);
749 uint32_t Off = (OC[Offset + 1] & 0x3F) << 3;
751 OC[Offset], OC[Offset + 1],
754 Offset += 2;
758 bool Decoder::opcode_save_fregp_x(const uint8_t *OC, unsigned &Offset,
760 uint32_t Reg = (OC[Offset] & 0x01) << 8;
761 Reg |= (OC[Offset + 1] & 0xC0);
764 uint32_t Off = ((OC[Offset + 1] & 0x3F) + 1) << 3;
767 "0x%02x%02x ; stp d%u, d%u, [sp, #-%u]!\n", OC[Offset],
768 OC[Offset + 1], Reg, Reg + 1, Off);
771 "0x%02x%02x ; ldp d%u, d%u, [sp], #%u\n", OC[Offset],
772 OC[Offset + 1], Reg, Reg + 1, Off);
773 Offset += 2;
777 bool Decoder::opcode_save_freg(const uint8_t *OC, unsigned &Offset,
779 uint32_t Reg = (OC[Offset] & 0x01) << 8;
780 Reg |= (OC[Offset + 1] & 0xC0);
783 uint32_t Off = (OC[Offset + 1] & 0x3F) << 3;
785 OC[Offset], OC[Offset + 1],
788 Offset += 2;
792 bool Decoder::opcode_save_freg_x(const uint8_t *OC, unsigned &Offset,
794 uint32_t Reg = ((OC[Offset + 1] & 0xE0) >> 5) + 8;
795 uint32_t Off = ((OC[Offset + 1] & 0x1F) + 1) << 3;
798 "0x%02x%02x ; str d%u, [sp, #-%u]!\n", OC[Offset],
799 OC[Offset + 1], Reg, Off);
802 "0x%02x%02x ; ldr d%u, [sp], #%u\n", OC[Offset],
803 OC[Offset + 1], Reg, Off);
804 Offset += 2;
808 bool Decoder::opcode_alloc_l(const uint8_t *OC, unsigned &Offset,
811 (OC[Offset + 1] << 16) | (OC[Offset + 2] << 8) | (OC[Offset + 3] << 0);
814 "0x%02x%02x%02x%02x ; %s sp, #%u\n", OC[Offset], OC[Offset + 1],
815 OC[Offset + 2], OC[Offset + 3],
817 Offset += 4;
821 bool Decoder::opcode_setfp(const uint8_t *OC, unsigned &Offset, unsigned Length,
823 SW.startLine() << format("0x%02x ; mov %s, %s\n", OC[Offset],
826 ++Offset;
830 bool Decoder::opcode_addfp(const uint8_t *OC, unsigned &Offset, unsigned Length,
832 unsigned NumBytes = OC[Offset + 1] << 3;
834 "0x%02x%02x ; %s %s, %s, #%u\n", OC[Offset], OC[Offset + 1],
838 Offset += 2;
842 bool Decoder::opcode_nop(const uint8_t *OC, unsigned &Offset, unsigned Length,
844 SW.startLine() << format("0x%02x ; nop\n", OC[Offset]);
845 ++Offset;
849 bool Decoder::opcode_end(const uint8_t *OC, unsigned &Offset, unsigned Length,
851 SW.startLine() << format("0x%02x ; end\n", OC[Offset]);
852 ++Offset;
856 bool Decoder::opcode_end_c(const uint8_t *OC, unsigned &Offset, unsigned Length,
858 SW.startLine() << format("0x%02x ; end_c\n", OC[Offset]);
859 ++Offset;
863 bool Decoder::opcode_save_next(const uint8_t *OC, unsigned &Offset,
866 SW.startLine() << format("0x%02x ; save next\n", OC[Offset]);
869 OC[Offset]);
870 ++Offset;
874 bool Decoder::opcode_save_any_reg(const uint8_t *OC, unsigned &Offset,
877 bool Writeback = (OC[Offset + 1] & 0x20) == 0x20;
880 bool Paired = (OC[Offset + 1] & 0x40) == 0x40;
882 // - 0 is an x register
883 // - 1 is the low half of a q register
884 // - 2 is a whole q register
885 int RegKind = (OC[Offset + 2] & 0xC0) >> 6;
886 // Encoded register name (0 -> x0/q0, 1 -> x1/q1, etc.)
887 int Reg = OC[Offset + 1] & 0x1F;
888 // Encoded stack offset of load/store instruction; decoding varies by mode.
889 int StackOffset = OC[Offset + 2] & 0x3F;
897 SW.startLine() << format("0x%02x%02x%02x ; ", OC[Offset],
898 OC[Offset + 1], OC[Offset + 2]);
905 --MaxReg;
907 --MaxReg;
908 if ((OC[Offset + 1] & 0x80) == 0x80 || RegKind == 3 || Reg > MaxReg) {
910 Offset += 3;
940 SW.getOStream() << format("[sp, #-%d]!\n", StackOffset);
947 Offset += 3;
951 bool Decoder::opcode_trap_frame(const uint8_t *OC, unsigned &Offset,
953 SW.startLine() << format("0x%02x ; trap frame\n", OC[Offset]);
954 ++Offset;
958 bool Decoder::opcode_machine_frame(const uint8_t *OC, unsigned &Offset,
961 OC[Offset]);
962 ++Offset;
966 bool Decoder::opcode_context(const uint8_t *OC, unsigned &Offset,
968 SW.startLine() << format("0x%02x ; context\n", OC[Offset]);
969 ++Offset;
973 bool Decoder::opcode_ec_context(const uint8_t *OC, unsigned &Offset,
975 SW.startLine() << format("0x%02x ; EC context\n", OC[Offset]);
976 ++Offset;
980 bool Decoder::opcode_clear_unwound_to_call(const uint8_t *OC, unsigned &Offset,
983 OC[Offset]);
984 ++Offset;
988 bool Decoder::opcode_pac_sign_lr(const uint8_t *OC, unsigned &Offset,
991 SW.startLine() << format("0x%02x ; pacibsp\n", OC[Offset]);
993 SW.startLine() << format("0x%02x ; autibsp\n", OC[Offset]);
994 ++Offset;
998 void Decoder::decodeOpcodes(ArrayRef<uint8_t> Opcodes, unsigned Offset,
1000 assert((!Prologue || Offset == 0) && "prologue should always use offset 0");
1003 for (unsigned OI = Offset, OE = Opcodes.size(); !Terminated && OI < OE; ) {
1008 Opcodes.data()[OI]);
1015 SW.startLine() << format("Opcode 0x%02x goes past the unwind data\n",
1021 (this->*DecodeRing[DI].Routine)(Opcodes.data(), OI, 0, Prologue);
1036 uint64_t Offset = VA - SectionVA;
1037 const ulittle32_t *Data =
1038 reinterpret_cast<const ulittle32_t *>(Contents.data() + Offset);
1043 if (Contents.size() - Offset < 8)
1046 const ExceptionDataRecord XData(Data, isAArch64);
1061 if ((int64_t)(Contents.size() - Offset - 4 * HeaderWords(XData) -
1062 (XData.E() ? 0 : XData.EpilogueCount() * 4) -
1065 report_fatal_error("Malformed unwind data");
1113 COFF, Section, Offset + HandlerOffset * sizeof(uint32_t),
1123 Expected<StringRef> Name = Symbol->getName();
1126 llvm::raw_string_ostream OS(Buf);
1127 logAllUnhandledErrors(Name.takeError(), OS);
1128 report_fatal_error(Twine(OS.str()));
1140 const SectionRef Section, uint64_t Offset,
1147 COFF, Section, Offset, RF.BeginAddress, FunctionAddress, FunctionOffset,
1152 COFF, Section, Offset + 4, RF.ExceptionInformationRVA(), XDataAddress,
1162 Expected<StringRef> FunctionNameOrErr = Function->getName();
1165 llvm::raw_string_ostream OS(Buf);
1166 logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
1167 report_fatal_error(Twine(OS.str()));
1176 Expected<StringRef> Name = XDataRecord->getName();
1179 llvm::raw_string_ostream OS(Buf);
1180 logAllUnhandledErrors(Name.takeError(), OS);
1181 report_fatal_error(Twine(OS.str()));
1187 Expected<section_iterator> SIOrErr = XDataRecord->getSection();
1208 const SectionRef Section, uint64_t Offset,
1216 COFF, Section, Offset, RF.BeginAddress, FunctionAddress, FunctionOffset,
1221 Expected<StringRef> FunctionNameOrErr = Function->getName();
1224 llvm::raw_string_ostream OS(Buf);
1225 logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
1226 report_fatal_error(Twine(OS.str()));
1255 OS << "\n";
1259 int FpOffset = 4 * llvm::popcount(GPRMask & ((1U << 11) - 1));
1268 OS << "\n";
1271 SW.startLine() << "push {r0-r3}\n";
1285 OS << "\n";
1290 OS << "\n";
1306 const SectionRef Section, uint64_t Offset,
1315 COFF, Section, Offset, RF.BeginAddress, FunctionAddress, FunctionOffset,
1320 Expected<StringRef> FunctionNameOrErr = Function->getName();
1323 llvm::raw_string_ostream OS(Buf);
1324 logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
1325 report_fatal_error(Twine(OS.str()));
1343 // at https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling,
1345 // are printed for the non-packed case.
1353 int LocSZ = (RF.FrameSize() << 4) - SavSZ;
1358 SW.startLine() << format("stp x29, lr, [sp, #-%d]!\n", LocSZ);
1364 SW.startLine() << format("sub sp, sp, #%d\n", LocSZ - 4080);
1370 SW.startLine() << format("stp x6, x7, [sp, #%d]\n", SavSZ - 16);
1371 SW.startLine() << format("stp x4, x5, [sp, #%d]\n", SavSZ - 32);
1372 SW.startLine() << format("stp x2, x3, [sp, #%d]\n", SavSZ - 48);
1374 SW.startLine() << format("stp x0, x1, [sp, #%d]\n", SavSZ - 64);
1379 SW.startLine() << format("stp x0, x1, [sp, #-%d]!\n", SavSZ);
1383 for (int I = (FloatRegs + 1) / 2 - 1; I >= 0; I--) {
1384 if (I == (FloatRegs + 1) / 2 - 1 && FloatRegs % 2 == 1) {
1389 SW.startLine() << format("stp d%d, d%d, [sp, #-%d]!\n", 8 + 2 * I,
1398 SW.startLine() << format("str lr, [sp, #-%d]!\n", SavSZ);
1400 SW.startLine() << format("str lr, [sp, #%d]\n", IntSZ - 8);
1402 for (int I = (RF.RegI() + 1) / 2 - 1; I >= 0; I--) {
1403 if (I == (RF.RegI() + 1) / 2 - 1 && RF.RegI() % 2 == 1) {
1416 SW.startLine() << format("str x%d, [sp, #-%d]!\n", 19 + 2 * I, SavSZ);
1422 SW.startLine() << format("stp x19, x20, [sp, #-%d]!\n", SavSZ);
1429 // https://github.com/MicrosoftDocs/cpp-docs/pull/4202 for upstream
1441 uint64_t Offset = PDataEntrySize * Index;
1442 const ulittle32_t *Data =
1443 reinterpret_cast<const ulittle32_t *>(Contents.data() + Offset);
1445 const RuntimeFunction Entry(Data);
1448 return dumpUnpackedEntry(COFF, Section, Offset, Index, Entry);
1450 const RuntimeFunctionARM64 EntryARM64(Data);
1451 return dumpPackedARM64Entry(COFF, Section, Offset, Index, EntryARM64);
1453 return dumpPackedEntry(COFF, Section, Offset, Index, Entry);
1463 errs() << ".pdata content is not " << PDataEntrySize << "-byte aligned\n";
1479 if (NameOrErr->starts_with(".pdata"))