LLVM 24.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
47 // Flattened data for all logical records (record type + continuous data
48 // without headers).
50
51 // Populate FlattenedData with all logical records.
52 Error createFlattenedData();
53
54 // Helper to get continuous data from a logical record (includes prefix +
55 // continuations) Returns the number of physical records consumed (including
56 // the initial record)
57 Expected<unsigned> getContinuousData(SmallVectorImpl<uint8_t> &CompleteData,
58 int DataIndex, uint16_t DataLength,
59 const uint8_t *Record) const;
60
61public:
62 // Get the flattened data structure
65 return FlattenedData;
66 }
67
68 Expected<StringRef> getSymbolName(SymbolRef Symbol) const;
69
71 static inline bool classof(const Binary *V) { return V->isGOFF(); }
72 section_iterator section_begin() const override;
73 section_iterator section_end() const override;
74
75 uint8_t getBytesInAddress() const override { return 8; }
76
77 StringRef getFileFormatName() const override { return "GOFF-SystemZ"; }
78
79 Triple::ArchType getArch() const override { return Triple::systemz; }
80
82
83 bool isRelocatableObject() const override { return true; }
84
85 void moveSymbolNext(DataRefImpl &Symb) const override;
86 basic_symbol_iterator symbol_begin() const override;
87 basic_symbol_iterator symbol_end() const override;
88
89 bool is64Bit() const override {
90 return true;
91 }
92
93 bool isSectionNoLoad(DataRefImpl Sec) const;
94 bool isSectionReadOnlyData(DataRefImpl Sec) const;
95 bool isSectionZeroInit(DataRefImpl Sec) const;
96
97private:
98 // SymbolRef.
99 Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
100 Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
101 uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
102 uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
103 Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
105 Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
106 uint64_t getSymbolSize(DataRefImpl Symb) const;
107
108 const uint8_t *getSymbolEsdRecord(DataRefImpl Symb) const;
109 bool isSymbolUnresolved(DataRefImpl Symb) const;
110 bool isSymbolIndirect(DataRefImpl Symb) const;
111
112 // SectionRef.
113 void moveSectionNext(DataRefImpl &Sec) const override;
115 uint64_t getSectionAddress(DataRefImpl Sec) const override;
116 uint64_t getSectionSize(DataRefImpl Sec) const override;
118 getSectionContents(DataRefImpl Sec) const override;
119 uint64_t getSectionIndex(DataRefImpl Sec) const override { return Sec.d.a; }
120 uint64_t getSectionAlignment(DataRefImpl Sec) const override;
121 bool isSectionCompressed(DataRefImpl Sec) const override { return false; }
122 bool isSectionText(DataRefImpl Sec) const override;
123 bool isSectionData(DataRefImpl Sec) const override;
124 bool isSectionBSS(DataRefImpl Sec) const override { return false; }
125 bool isSectionVirtual(DataRefImpl Sec) const override { return false; }
126 relocation_iterator section_rel_begin(DataRefImpl Sec) const override {
127 return relocation_iterator(RelocationRef(Sec, this));
128 }
129 relocation_iterator section_rel_end(DataRefImpl Sec) const override {
130 return relocation_iterator(RelocationRef(Sec, this));
131 }
132
133 const uint8_t *getSectionEdEsdRecord(DataRefImpl &Sec) const;
134 const uint8_t *getSectionPrEsdRecord(DataRefImpl &Sec) const;
135 const uint8_t *getSectionEdEsdRecord(uint32_t SectionIndex) const;
136 const uint8_t *getSectionPrEsdRecord(uint32_t SectionIndex) const;
137 uint32_t getSectionDefEsdId(DataRefImpl &Sec) const;
138
139 // RelocationRef.
140 void moveRelocationNext(DataRefImpl &Rel) const override {}
141 uint64_t getRelocationOffset(DataRefImpl Rel) const override { return 0; }
142 symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override {
143 DataRefImpl Temp;
144 return basic_symbol_iterator(SymbolRef(Temp, this));
145 }
146 uint64_t getRelocationType(DataRefImpl Rel) const override { return 0; }
147 void getRelocationTypeName(DataRefImpl Rel,
148 SmallVectorImpl<char> &Result) const override {}
149};
150
151class GOFFSymbolRef : public SymbolRef {
152public:
156
160
162 return getObject()->getSymbolFlags(getRawDataRefImpl());
163 }
164
166 return getObject()->getSymbolType(getRawDataRefImpl());
167 }
168
170 return getObject()->getSymbolSize(getRawDataRefImpl());
171 }
172};
173
174} // namespace object
175
176} // namespace llvm
177
178#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:215
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 class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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)
const SmallVector< std::pair< GOFF::RecordType, SmallVector< uint8_t > > > & getFlattenedData() const
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)
Represents a GOFF physical record.
Definition GOFF.h:31
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition ObjectFile.h:170
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:547
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
struct llvm::object::DataRefImpl::@005117267142344013370254144343227032034000327225 d