56 lines · c
1//===- bolt/Target/AArch64/AArch64MCSymbolizer.cpp --------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef BOLT_TARGET_AARCH64_AARCH64MCSYMBOLIZER_H10#define BOLT_TARGET_AARCH64_AARCH64MCSYMBOLIZER_H11 12#include "bolt/Core/BinaryFunction.h"13#include "llvm/MC/MCDisassembler/MCSymbolizer.h"14#include <optional>15 16namespace llvm {17namespace bolt {18 19class AArch64MCSymbolizer : public MCSymbolizer {20protected:21 BinaryFunction &Function;22 bool CreateNewSymbols{true};23 24 /// Modify relocation \p Rel based on type of the relocation and the25 /// instruction it was applied to. Return the new relocation info, or26 /// std::nullopt if the relocation should be ignored, e.g. in the case the27 /// instruction was modified by the linker.28 std::optional<Relocation> adjustRelocation(const Relocation &Rel,29 const MCInst &Inst) const;30 31 /// Return true if \p PageAddress is a valid page address for .got section.32 bool isPageAddressValidForGOT(uint64_t PageAddress) const;33 34public:35 AArch64MCSymbolizer(BinaryFunction &Function, bool CreateNewSymbols = true)36 : MCSymbolizer(*Function.getBinaryContext().Ctx, nullptr),37 Function(Function), CreateNewSymbols(CreateNewSymbols) {}38 39 AArch64MCSymbolizer(const AArch64MCSymbolizer &) = delete;40 AArch64MCSymbolizer &operator=(const AArch64MCSymbolizer &) = delete;41 virtual ~AArch64MCSymbolizer();42 43 bool tryAddingSymbolicOperand(MCInst &Inst, raw_ostream &CStream,44 int64_t Value, uint64_t Address, bool IsBranch,45 uint64_t Offset, uint64_t OpSize,46 uint64_t InstSize) override;47 48 void tryAddingPcLoadReferenceComment(raw_ostream &CStream, int64_t Value,49 uint64_t Address) override;50};51 52} // namespace bolt53} // namespace llvm54 55#endif56