LLVM 18.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 IndexedMap<const uint8_t *> EsdPtrs; // Indexed by EsdId.
33
35 EsdNamesCache;
36
38 // (EDID, 0) code, r/o data section
39 // (EDID,PRID) r/w data section
41 mutable DenseMap<uint32_t, std::string> SectionDataCache;
42
43public:
45
47 static inline bool classof(const Binary *V) { return V->isGOFF(); }
48 section_iterator section_begin() const override;
49 section_iterator section_end() const override;
50
51 uint8_t getBytesInAddress() const override { return 8; }
52
53 StringRef getFileFormatName() const override { return "GOFF-SystemZ"; }
54
55 Triple::ArchType getArch() const override { return Triple::systemz; }
56
58
59 bool isRelocatableObject() const override { return true; }
60
61 void moveSymbolNext(DataRefImpl &Symb) const override;
62 basic_symbol_iterator symbol_begin() const override;
63 basic_symbol_iterator symbol_end() const override;
64
65 bool is64Bit() const override {
66 return true;
67 }
68
69private:
70 // SymbolRef.
72 Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
73 uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
74 uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
75 Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
76 Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override;
77 Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
78
79 const uint8_t *getSymbolEsdRecord(DataRefImpl Symb) const;
80 bool isSymbolUnresolved(DataRefImpl Symb) const;
81 bool isSymbolIndirect(DataRefImpl Symb) const;
82
83 // SectionRef.
84 void moveSectionNext(DataRefImpl &Sec) const override {}
85 virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const override {
86 return StringRef();
87 }
88 uint64_t getSectionAddress(DataRefImpl Sec) const override { return 0; }
89 uint64_t getSectionSize(DataRefImpl Sec) const override { return 0; }
90 virtual Expected<ArrayRef<uint8_t>>
91 getSectionContents(DataRefImpl Sec) const override {
92 return ArrayRef<uint8_t>();
93 }
94 uint64_t getSectionIndex(DataRefImpl Sec) const override { return 0; }
95 uint64_t getSectionAlignment(DataRefImpl Sec) const override { return 0; }
96 bool isSectionCompressed(DataRefImpl Sec) const override { return false; }
97 bool isSectionText(DataRefImpl Sec) const override { return false; }
98 bool isSectionData(DataRefImpl Sec) const override { return false; }
99 bool isSectionBSS(DataRefImpl Sec) const override { return false; }
100 bool isSectionVirtual(DataRefImpl Sec) const override { return false; }
101 relocation_iterator section_rel_begin(DataRefImpl Sec) const override {
102 return relocation_iterator(RelocationRef(Sec, this));
103 }
104 relocation_iterator section_rel_end(DataRefImpl Sec) const override {
105 return relocation_iterator(RelocationRef(Sec, this));
106 }
107
108 const uint8_t *getSectionEdEsdRecord(DataRefImpl &Sec) const;
109 const uint8_t *getSectionPrEsdRecord(DataRefImpl &Sec) const;
110 const uint8_t *getSectionEdEsdRecord(uint32_t SectionIndex) const;
111 const uint8_t *getSectionPrEsdRecord(uint32_t SectionIndex) const;
112
113 // RelocationRef.
114 void moveRelocationNext(DataRefImpl &Rel) const override {}
115 uint64_t getRelocationOffset(DataRefImpl Rel) const override { return 0; }
116 symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override {
117 DataRefImpl Temp;
118 return basic_symbol_iterator(SymbolRef(Temp, this));
119 }
120 uint64_t getRelocationType(DataRefImpl Rel) const override { return 0; }
121 void getRelocationTypeName(DataRefImpl Rel,
122 SmallVectorImpl<char> &Result) const override {}
123};
124
125} // namespace object
126
127} // namespace llvm
128
129#endif
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.
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:474
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Manages the enabling and disabling of subtarget specific features.
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 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 isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
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
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