LLVM 20.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"
22#include "llvm/Support/Debug.h"
26
27namespace llvm {
28
29namespace object {
30
31class GOFFObjectFile : public ObjectFile {
32 friend class GOFFSymbolRef;
33
34 IndexedMap<const uint8_t *> EsdPtrs; // Indexed by EsdId.
36
38 EsdNamesCache;
39
41 // (EDID, 0) code, r/o data section
42 // (EDID,PRID) r/w data section
44 mutable DenseMap<uint32_t, SmallVector<uint8_t>> SectionDataCache;
45
46public:
48
50 static inline bool classof(const Binary *V) { return V->isGOFF(); }
51 section_iterator section_begin() const override;
52 section_iterator section_end() const override;
53
54 uint8_t getBytesInAddress() const override { return 8; }
55
56 StringRef getFileFormatName() const override { return "GOFF-SystemZ"; }
57
58 Triple::ArchType getArch() const override { return Triple::systemz; }
59
61
62 bool isRelocatableObject() const override { return true; }
63
64 void moveSymbolNext(DataRefImpl &Symb) const override;
65 basic_symbol_iterator symbol_begin() const override;
66 basic_symbol_iterator symbol_end() const override;
67
68 bool is64Bit() const override {
69 return true;
70 }
71
72 bool isSectionNoLoad(DataRefImpl Sec) const;
73 bool isSectionReadOnlyData(DataRefImpl Sec) const;
74 bool isSectionZeroInit(DataRefImpl Sec) const;
75
76private:
77 // SymbolRef.
79 Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
80 uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
81 uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
82 Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
84 Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
85 uint64_t getSymbolSize(DataRefImpl Symb) const;
86
87 const uint8_t *getSymbolEsdRecord(DataRefImpl Symb) const;
88 bool isSymbolUnresolved(DataRefImpl Symb) const;
89 bool isSymbolIndirect(DataRefImpl Symb) const;
90
91 // SectionRef.
92 void moveSectionNext(DataRefImpl &Sec) const override;
93 virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const override;
94 uint64_t getSectionAddress(DataRefImpl Sec) const override;
95 uint64_t getSectionSize(DataRefImpl Sec) const override;
97 getSectionContents(DataRefImpl Sec) const override;
98 uint64_t getSectionIndex(DataRefImpl Sec) const override { return Sec.d.a; }
99 uint64_t getSectionAlignment(DataRefImpl Sec) const override;
100 bool isSectionCompressed(DataRefImpl Sec) const override { return false; }
101 bool isSectionText(DataRefImpl Sec) const override;
102 bool isSectionData(DataRefImpl Sec) const override;
103 bool isSectionBSS(DataRefImpl Sec) const override { return false; }
104 bool isSectionVirtual(DataRefImpl Sec) const override { return false; }
105 relocation_iterator section_rel_begin(DataRefImpl Sec) const override {
106 return relocation_iterator(RelocationRef(Sec, this));
107 }
108 relocation_iterator section_rel_end(DataRefImpl Sec) const override {
109 return relocation_iterator(RelocationRef(Sec, this));
110 }
111
112 const uint8_t *getSectionEdEsdRecord(DataRefImpl &Sec) const;
113 const uint8_t *getSectionPrEsdRecord(DataRefImpl &Sec) const;
114 const uint8_t *getSectionEdEsdRecord(uint32_t SectionIndex) const;
115 const uint8_t *getSectionPrEsdRecord(uint32_t SectionIndex) const;
116 uint32_t getSectionDefEsdId(DataRefImpl &Sec) const;
117
118 // RelocationRef.
119 void moveRelocationNext(DataRefImpl &Rel) const override {}
120 uint64_t getRelocationOffset(DataRefImpl Rel) const override { return 0; }
121 symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override {
122 DataRefImpl Temp;
123 return basic_symbol_iterator(SymbolRef(Temp, this));
124 }
125 uint64_t getRelocationType(DataRefImpl Rel) const override { return 0; }
126 void getRelocationTypeName(DataRefImpl Rel,
127 SmallVectorImpl<char> &Result) const override {}
128};
129
130class GOFFSymbolRef : public SymbolRef {
131public:
133 assert(isa<GOFFObjectFile>(SymbolRef::getObject()));
134 }
135
136 const GOFFObjectFile *getObject() const {
137 return cast<GOFFObjectFile>(BasicSymbolRef::getObject());
138 }
139
141 return getObject()->getSymbolFlags(getRawDataRefImpl());
142 }
143
145 return getObject()->getSymbolType(getRawDataRefImpl());
146 }
147
149 return getObject()->getSymbolSize(getRawDataRefImpl());
150 }
151};
152
153} // namespace object
154
155} // namespace llvm
156
157#endif
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
Definition: UDTLayout.cpp:36
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Tagged union holding either a T or a Error.
Definition: Error.h:481
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Manages the enabling and disabling of subtarget specific features.
const SymbolicFile * getObject() const
Definition: SymbolicFile.h:214
DataRefImpl getRawDataRefImpl() const
Definition: SymbolicFile.h:210
Triple::ArchType getArch() const override
Expected< SubtargetFeatures > getFeatures() const override
section_iterator section_begin() const override
basic_symbol_iterator symbol_end() const override
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
static bool classof(const Binary *V)
bool isSectionReadOnlyData(DataRefImpl Sec) const
bool isSectionNoLoad(DataRefImpl Sec) const
bool is64Bit() const override
section_iterator section_end() const override
Expected< StringRef > getSymbolName(SymbolRef Symbol) const
void moveSymbolNext(DataRefImpl &Symb) const override
StringRef getFileFormatName() const override
basic_symbol_iterator symbol_begin() const override
bool isSectionZeroInit(DataRefImpl Sec) const
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
This class is the base class for all object file types.
Definition: ObjectFile.h:229
friend class RelocationRef
Definition: ObjectFile.h:287
friend class SymbolRef
Definition: ObjectFile.h:247
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: ObjectFile.h:168
const ObjectFile * getObject() const
Definition: ObjectFile.h:488
content_iterator< RelocationRef > relocation_iterator
Definition: ObjectFile.h:77
content_iterator< BasicSymbolRef > basic_symbol_iterator
Definition: SymbolicFile.h:143
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
struct llvm::object::DataRefImpl::@371 d