Path: blob/main/contrib/llvm-project/llvm/tools/llvm-readobj/ARMWinEHPrinter.h
35230 views
//===--- ARMWinEHPrinter.h - Windows on ARM Unwind Information Printer ----===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_TOOLS_LLVM_READOBJ_ARMWINEHPRINTER_H9#define LLVM_TOOLS_LLVM_READOBJ_ARMWINEHPRINTER_H1011#include "llvm/Object/COFF.h"12#include "llvm/Support/ErrorOr.h"13#include "llvm/Support/ScopedPrinter.h"1415namespace llvm {16namespace ARM {17namespace WinEH {18class RuntimeFunction;19class RuntimeFunctionARM64;2021class Decoder {22static const size_t PDataEntrySize;2324ScopedPrinter &SW;25raw_ostream &OS;26bool isAArch64;2728struct RingEntry {29uint8_t Mask;30uint8_t Value;31uint8_t Length;32bool (Decoder::*Routine)(const uint8_t *, unsigned &, unsigned, bool);33};34static const RingEntry Ring[];35static const RingEntry Ring64[];3637bool opcode_0xxxxxxx(const uint8_t *Opcodes, unsigned &Offset,38unsigned Length, bool Prologue);39bool opcode_10Lxxxxx(const uint8_t *Opcodes, unsigned &Offset,40unsigned Length, bool Prologue);41bool opcode_1100xxxx(const uint8_t *Opcodes, unsigned &Offset,42unsigned Length, bool Prologue);43bool opcode_11010Lxx(const uint8_t *Opcodes, unsigned &Offset,44unsigned Length, bool Prologue);45bool opcode_11011Lxx(const uint8_t *Opcodes, unsigned &Offset,46unsigned Length, bool Prologue);47bool opcode_11100xxx(const uint8_t *Opcodes, unsigned &Offset,48unsigned Length, bool Prologue);49bool opcode_111010xx(const uint8_t *Opcodes, unsigned &Offset,50unsigned Length, bool Prologue);51bool opcode_1110110L(const uint8_t *Opcodes, unsigned &Offset,52unsigned Length, bool Prologue);53bool opcode_11101110(const uint8_t *Opcodes, unsigned &Offset,54unsigned Length, bool Prologue);55bool opcode_11101111(const uint8_t *Opcodes, unsigned &Offset,56unsigned Length, bool Prologue);57bool opcode_11110101(const uint8_t *Opcodes, unsigned &Offset,58unsigned Length, bool Prologue);59bool opcode_11110110(const uint8_t *Opcodes, unsigned &Offset,60unsigned Length, bool Prologue);61bool opcode_11110111(const uint8_t *Opcodes, unsigned &Offset,62unsigned Length, bool Prologue);63bool opcode_11111000(const uint8_t *Opcodes, unsigned &Offset,64unsigned Length, bool Prologue);65bool opcode_11111001(const uint8_t *Opcodes, unsigned &Offset,66unsigned Length, bool Prologue);67bool opcode_11111010(const uint8_t *Opcodes, unsigned &Offset,68unsigned Length, bool Prologue);69bool opcode_11111011(const uint8_t *Opcodes, unsigned &Offset,70unsigned Length, bool Prologue);71bool opcode_11111100(const uint8_t *Opcodes, unsigned &Offset,72unsigned Length, bool Prologue);73bool opcode_11111101(const uint8_t *Opcodes, unsigned &Offset,74unsigned Length, bool Prologue);75bool opcode_11111110(const uint8_t *Opcodes, unsigned &Offset,76unsigned Length, bool Prologue);77bool opcode_11111111(const uint8_t *Opcodes, unsigned &Offset,78unsigned Length, bool Prologue);7980// ARM64 unwind codes start here.81bool opcode_alloc_s(const uint8_t *Opcodes, unsigned &Offset, unsigned Length,82bool Prologue);83bool opcode_save_r19r20_x(const uint8_t *Opcodes, unsigned &Offset,84unsigned Length, bool Prologue);85bool opcode_save_fplr(const uint8_t *Opcodes, unsigned &Offset,86unsigned Length, bool Prologue);87bool opcode_save_fplr_x(const uint8_t *Opcodes, unsigned &Offset,88unsigned Length, bool Prologue);89bool opcode_alloc_m(const uint8_t *Opcodes, unsigned &Offset, unsigned Length,90bool Prologue);91bool opcode_save_regp(const uint8_t *Opcodes, unsigned &Offset,92unsigned Length, bool Prologue);93bool opcode_save_regp_x(const uint8_t *Opcodes, unsigned &Offset,94unsigned Length, bool Prologue);95bool opcode_save_reg(const uint8_t *Opcodes, unsigned &Offset,96unsigned Length, bool Prologue);97bool opcode_save_reg_x(const uint8_t *Opcodes, unsigned &Offset,98unsigned Length, bool Prologue);99bool opcode_save_lrpair(const uint8_t *Opcodes, unsigned &Offset,100unsigned Length, bool Prologue);101bool opcode_save_fregp(const uint8_t *Opcodes, unsigned &Offset,102unsigned Length, bool Prologue);103bool opcode_save_fregp_x(const uint8_t *Opcodes, unsigned &Offset,104unsigned Length, bool Prologue);105bool opcode_save_freg(const uint8_t *Opcodes, unsigned &Offset,106unsigned Length, bool Prologue);107bool opcode_save_freg_x(const uint8_t *Opcodes, unsigned &Offset,108unsigned Length, bool Prologue);109bool opcode_alloc_l(const uint8_t *Opcodes, unsigned &Offset, unsigned Length,110bool Prologue);111bool opcode_setfp(const uint8_t *Opcodes, unsigned &Offset, unsigned Length,112bool Prologue);113bool opcode_addfp(const uint8_t *Opcodes, unsigned &Offset, unsigned Length,114bool Prologue);115bool opcode_nop(const uint8_t *Opcodes, unsigned &Offset, unsigned Length,116bool Prologue);117bool opcode_end(const uint8_t *Opcodes, unsigned &Offset, unsigned Length,118bool Prologue);119bool opcode_end_c(const uint8_t *Opcodes, unsigned &Offset, unsigned Length,120bool Prologue);121bool opcode_save_next(const uint8_t *Opcodes, unsigned &Offset,122unsigned Length, bool Prologue);123bool opcode_save_any_reg(const uint8_t *Opcodes, unsigned &Offset,124unsigned Length, bool Prologue);125bool opcode_trap_frame(const uint8_t *Opcodes, unsigned &Offset,126unsigned Length, bool Prologue);127bool opcode_machine_frame(const uint8_t *Opcodes, unsigned &Offset,128unsigned Length, bool Prologue);129bool opcode_context(const uint8_t *Opcodes, unsigned &Offset, unsigned Length,130bool Prologue);131bool opcode_ec_context(const uint8_t *Opcodes, unsigned &Offset,132unsigned Length, bool Prologue);133bool opcode_clear_unwound_to_call(const uint8_t *Opcodes, unsigned &Offset,134unsigned Length, bool Prologue);135bool opcode_pac_sign_lr(const uint8_t *Opcodes, unsigned &Offset,136unsigned Length, bool Prologue);137138void decodeOpcodes(ArrayRef<uint8_t> Opcodes, unsigned Offset,139bool Prologue);140141void printGPRMask(uint16_t Mask);142void printVFPMask(uint32_t Mask);143144ErrorOr<object::SectionRef>145getSectionContaining(const object::COFFObjectFile &COFF, uint64_t Address);146147ErrorOr<object::SymbolRef>148getSymbol(const object::COFFObjectFile &COFF, uint64_t Address,149bool FunctionOnly = false);150151ErrorOr<object::SymbolRef>152getRelocatedSymbol(const object::COFFObjectFile &COFF,153const object::SectionRef &Section, uint64_t Offset);154155ErrorOr<object::SymbolRef>156getSymbolForLocation(const object::COFFObjectFile &COFF,157const object::SectionRef &Section,158uint64_t OffsetInSection, uint64_t ImmediateOffset,159uint64_t &SymbolAddress, uint64_t &SymbolOffset,160bool FunctionOnly = false);161162object::SymbolRef getPreferredSymbol(const object::COFFObjectFile &COFF,163object::SymbolRef Sym,164uint64_t &SymbolOffset);165166bool dumpXDataRecord(const object::COFFObjectFile &COFF,167const object::SectionRef &Section,168uint64_t FunctionAddress, uint64_t VA);169bool dumpUnpackedEntry(const object::COFFObjectFile &COFF,170const object::SectionRef Section, uint64_t Offset,171unsigned Index, const RuntimeFunction &Entry);172bool dumpPackedEntry(const object::COFFObjectFile &COFF,173const object::SectionRef Section, uint64_t Offset,174unsigned Index, const RuntimeFunction &Entry);175bool dumpPackedARM64Entry(const object::COFFObjectFile &COFF,176const object::SectionRef Section, uint64_t Offset,177unsigned Index, const RuntimeFunctionARM64 &Entry);178bool dumpProcedureDataEntry(const object::COFFObjectFile &COFF,179const object::SectionRef Section, unsigned Entry,180ArrayRef<uint8_t> Contents);181void dumpProcedureData(const object::COFFObjectFile &COFF,182const object::SectionRef Section);183184public:185Decoder(ScopedPrinter &SW, bool isAArch64) : SW(SW),186OS(SW.getOStream()),187isAArch64(isAArch64) {}188Error dumpProcedureData(const object::COFFObjectFile &COFF);189};190}191}192}193194#endif195196197