diff options
Diffstat (limited to 'llvm/include/llvm/Object/ELFTypes.h')
-rw-r--r-- | llvm/include/llvm/Object/ELFTypes.h | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/llvm/include/llvm/Object/ELFTypes.h b/llvm/include/llvm/Object/ELFTypes.h index f64e7c06e03b..54ebd751d8d2 100644 --- a/llvm/include/llvm/Object/ELFTypes.h +++ b/llvm/include/llvm/Object/ELFTypes.h @@ -15,6 +15,7 @@ #include "llvm/Object/Error.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" +#include "llvm/Support/MathExtras.h" #include <cassert> #include <cstdint> #include <cstring> @@ -43,6 +44,7 @@ template <class ELFT> struct Elf_Nhdr_Impl; template <class ELFT> class Elf_Note_Impl; template <class ELFT> class Elf_Note_Iterator_Impl; template <class ELFT> struct Elf_CGProfile_Impl; +template <class ELFT> struct Elf_BBAddrMap_Impl; template <endianness E, bool Is64> struct ELFType { private: @@ -74,6 +76,7 @@ public: using Note = Elf_Note_Impl<ELFType<E, Is64>>; using NoteIterator = Elf_Note_Iterator_Impl<ELFType<E, Is64>>; using CGProfile = Elf_CGProfile_Impl<ELFType<E, Is64>>; + using BBAddrMap = Elf_BBAddrMap_Impl<ELFType<E, Is64>>; using DynRange = ArrayRef<Dyn>; using ShdrRange = ArrayRef<Shdr>; using SymRange = ArrayRef<Sym>; @@ -128,13 +131,14 @@ using ELF64BE = ELFType<support::big, true>; using Elf_Note = typename ELFT::Note; \ using Elf_Note_Iterator = typename ELFT::NoteIterator; \ using Elf_CGProfile = typename ELFT::CGProfile; \ + using Elf_BBAddrMap = typename ELFT::BBAddrMap; \ using Elf_Dyn_Range = typename ELFT::DynRange; \ using Elf_Shdr_Range = typename ELFT::ShdrRange; \ using Elf_Sym_Range = typename ELFT::SymRange; \ using Elf_Rel_Range = typename ELFT::RelRange; \ using Elf_Rela_Range = typename ELFT::RelaRange; \ using Elf_Relr_Range = typename ELFT::RelrRange; \ - using Elf_Phdr_Range = typename ELFT::PhdrRange; \ + using Elf_Phdr_Range = typename ELFT::PhdrRange; #define LLVM_ELF_COMMA , #define LLVM_ELF_IMPORT_TYPES(E, W) \ @@ -652,9 +656,15 @@ public: Elf_Word getType() const { return Nhdr.n_type; } }; -template <class ELFT> -class Elf_Note_Iterator_Impl - : std::iterator<std::forward_iterator_tag, Elf_Note_Impl<ELFT>> { +template <class ELFT> class Elf_Note_Iterator_Impl { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = Elf_Note_Impl<ELFT>; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + +private: // Nhdr being a nullptr marks the end of iteration. const Elf_Nhdr_Impl<ELFT> *Nhdr = nullptr; size_t RemainingSize = 0u; @@ -727,8 +737,6 @@ public: template <class ELFT> struct Elf_CGProfile_Impl { LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) - Elf_Word cgp_from; - Elf_Word cgp_to; Elf_Xword cgp_weight; }; @@ -788,6 +796,30 @@ template <class ELFT> struct Elf_Mips_ABIFlags { Elf_Word flags2; // General flags }; +// Struct representing the BBAddrMap for one function. +template <class ELFT> struct Elf_BBAddrMap_Impl { + LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) + uintX_t Addr; // Function address + // Struct representing the BBAddrMap information for one basic block. + struct BBEntry { + uint32_t Offset; // Offset of basic block relative to function start. + uint32_t Size; // Size of the basic block. + + // The following fields are decoded from the Metadata field. The encoding + // happens in AsmPrinter.cpp:getBBAddrMapMetadata. + bool HasReturn; // If this block ends with a return (or tail call). + bool HasTailCall; // If this block ends with a tail call. + bool IsEHPad; // If this is an exception handling block. + bool CanFallThrough; // If this block can fall through to its next. + + BBEntry(uint32_t Offset, uint32_t Size, uint32_t Metadata) + : Offset(Offset), Size(Size), HasReturn(Metadata & 1), + HasTailCall(Metadata & (1 << 1)), IsEHPad(Metadata & (1 << 2)), + CanFallThrough(Metadata & (1 << 3)){}; + }; + std::vector<BBEntry> BBEntries; // Basic block entries for this function. +}; + } // end namespace object. } // end namespace llvm. |