LLVM 22.0.0git
GOFFObjectFile.h
Go to the documentation of this file.
1//===- GOFFObjectFile.h - GOFF object file implementation -------*- 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-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the GOFFObjectFile class.
10// Record classes and derivatives are also declared and implemented.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_OBJECT_GOFFOBJECTFILE_H
15#define LLVM_OBJECT_GOFFOBJECTFILE_H
16
17#include "llvm/ADT/DenseMap.h"
18#include "llvm/ADT/IndexedMap.h"
23#include "llvm/Support/Debug.h"
27
28namespace llvm {
29
30namespace object {
31
33 friend class GOFFSymbolRef;
34
35 IndexedMap<const uint8_t *> EsdPtrs; // Indexed by EsdId.
37
39 EsdNamesCache;
40
41 typedef DataRefImpl SectionEntryImpl;
42 // (EDID, 0) code, r/o data section
43 // (EDID,PRID) r/w data section
45 mutable DenseMap<uint32_t, SmallVector<uint8_t>> SectionDataCache;
46
47public:
49
51 static inline bool classof(const Binary *V) { return V->isGOFF(); }
52 section_iterator section_begin() const override;
53 section_iterator section_end() const override;
54
55 uint8_t getBytesInAddress() const override { return 8; }
56
57 StringRef getFileFormatName() const override { return "GOFF-SystemZ"; }
58
59 Triple::ArchType getArch() const override { return Triple::systemz; }
60
62
63 bool isRelocatableObject() const override { return true; }
64
65 void moveSymbolNext(DataRefImpl &Symb) const override;
66 basic_symbol_iterator symbol_begin() const override;
67 basic_symbol_iterator symbol_end() const override;
68
69 bool is64Bit() const override {
70 return true;
71 }
72
73 bool isSectionNoLoad(DataRefImpl Sec) const;
74 bool isSectionReadOnlyData(DataRefImpl Sec) const;
75 bool isSectionZeroInit(DataRefImpl Sec) const;
76
77private:
78 // SymbolRef.
80 Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
81 uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
82 uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
83 Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
85 Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
86 uint64_t getSymbolSize(DataRefImpl Symb) const;
87
88 const uint8_t *getSymbolEsdRecord(DataRefImpl Symb) const;
89 bool isSymbolUnresolved(DataRefImpl Symb) const;
90 bool isSymbolIndirect(DataRefImpl Symb) const;
91
92 // SectionRef.
93 void moveSectionNext(DataRefImpl &Sec) const override;
94 virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const override;
95 uint64_t getSectionAddress(DataRefImpl Sec) const override;
96 uint64_t getSectionSize(DataRefImpl Sec) const override;
98 getSectionContents(DataRefImpl Sec) const override;
99 uint64_t getSectionIndex(DataRefImpl Sec) const override { return Sec.d.a; }
100 uint64_t getSectionAlignment(DataRefImpl Sec) const override;
101 bool isSectionCompressed(DataRefImpl Sec) const override { return false; }
102 bool isSectionText(DataRefImpl Sec) const override;
103 bool isSectionData(DataRefImpl Sec) const override;
104 bool isSectionBSS(DataRefImpl Sec) const override { return false; }
105 bool isSectionVirtual(DataRefImpl Sec) const override { return false; }
106 relocation_iterator section_rel_begin(DataRefImpl Sec) const override {
107 return relocation_iterator(RelocationRef(Sec, this));
108 }
109 relocation_iterator section_rel_end(DataRefImpl Sec) const override {
110 return relocation_iterator(RelocationRef(Sec, this));
111 }
112
113 const uint8_t *getSectionEdEsdRecord(DataRefImpl &Sec) const;
114 const uint8_t *getSectionPrEsdRecord(DataRefImpl &Sec) const;
115 const uint8_t *getSectionEdEsdRecord(uint32_t SectionIndex) const;
116 const uint8_t *getSectionPrEsdRecord(uint32_t SectionIndex) const;
117 uint32_t getSectionDefEsdId(DataRefImpl &Sec) const;
118
119 // RelocationRef.
120 void moveRelocationNext(DataRefImpl &Rel) const override {}
121 uint64_t getRelocationOffset(DataRefImpl Rel) const override { return 0; }
122 symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override {
123 DataRefImpl Temp;
124 return basic_symbol_iterator(SymbolRef(Temp, this));
125 }
126 uint64_t getRelocationType(DataRefImpl Rel) const override { return 0; }
127 void getRelocationTypeName(DataRefImpl Rel,
128 SmallVectorImpl<char> &Result) const override {}
129};
130
131class GOFFSymbolRef : public SymbolRef {
132public:
136
140
142 return getObject()->getSymbolFlags(getRawDataRefImpl());
143 }
144
146 return getObject()->getSymbolType(getRawDataRefImpl());
147 }
148
150 return getObject()->getSymbolSize(getRawDataRefImpl());
151 }
152};
153
154} // namespace object
155
156} // namespace llvm
157
158#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static StringRef getSymbolName(SymbolKind SymKind)
#define LLVM_ABI
Definition Compiler.h:213
This file provides utility functions for converting between EBCDIC-1047 and UTF-8.
This file defines the DenseMap class.
This file implements an indexed map.
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
Definition UDTLayout.cpp:35
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Manages the enabling and disabling of subtarget specific features.
const SymbolicFile * getObject() const
DataRefImpl getRawDataRefImpl() const
Triple::ArchType getArch() const override
Expected< SubtargetFeatures > getFeatures() const override
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
GOFFObjectFile(MemoryBufferRef Object, Error &Err)
static bool classof(const Binary *V)
bool is64Bit() const override
StringRef getFileFormatName() const override
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
GOFFSymbolRef(const SymbolRef &B)
Expected< SymbolRef::Type > getSymbolGOFFType() const
Expected< uint32_t > getSymbolGOFFFlags() const
const GOFFObjectFile * getObject() const
ObjectFile(unsigned int Type, MemoryBufferRef Source)
const ObjectFile * getObject() const
Definition ObjectFile.h:493
static constexpr const StringLiteral & getSectionName(DebugSectionKind SectionKind)
Return the name of the section.
content_iterator< SectionRef > section_iterator
Definition ObjectFile.h:49
content_iterator< BasicSymbolRef > basic_symbol_iterator
content_iterator< RelocationRef > relocation_iterator
Definition ObjectFile.h:79
This is an optimization pass for GlobalISel generic memory operations.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:548
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:565
struct llvm::object::DataRefImpl::@005117267142344013370254144343227032034000327225 d