LLVM  14.0.0git
Wasm.h
Go to the documentation of this file.
1 //===- Wasm.h - Wasm 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 WasmObjectFile class, which implements the ObjectFile
10 // interface for Wasm files.
11 //
12 // See: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_OBJECT_WASM_H
17 #define LLVM_OBJECT_WASM_H
18 
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/BinaryFormat/Wasm.h"
22 #include "llvm/Config/llvm-config.h"
23 #include "llvm/MC/MCSymbolWasm.h"
24 #include "llvm/Object/Binary.h"
25 #include "llvm/Object/ObjectFile.h"
26 #include "llvm/Support/Error.h"
28 #include <cstddef>
29 #include <cstdint>
30 #include <vector>
31 
32 namespace llvm {
33 namespace object {
34 
35 class WasmSymbol {
36 public:
44 
50 
51  bool isTypeFunction() const {
53  }
54 
55  bool isTypeTable() const { return Info.Kind == wasm::WASM_SYMBOL_TYPE_TABLE; }
56 
57  bool isTypeData() const { return Info.Kind == wasm::WASM_SYMBOL_TYPE_DATA; }
58 
59  bool isTypeGlobal() const {
61  }
62 
63  bool isTypeSection() const {
65  }
66 
67  bool isTypeTag() const { return Info.Kind == wasm::WASM_SYMBOL_TYPE_TAG; }
68 
69  bool isDefined() const { return !isUndefined(); }
70 
71  bool isUndefined() const {
72  return (Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) != 0;
73  }
74 
75  bool isBindingWeak() const {
77  }
78 
79  bool isBindingGlobal() const {
81  }
82 
83  bool isBindingLocal() const {
85  }
86 
87  unsigned getBinding() const {
89  }
90 
91  bool isHidden() const {
93  }
94 
95  unsigned getVisibility() const {
97  }
98 
99  void print(raw_ostream &Out) const;
100 
101 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
102  LLVM_DUMP_METHOD void dump() const;
103 #endif
104 };
105 
106 struct WasmSection {
107  WasmSection() = default;
108 
109  uint32_t Type = 0; // Section type (See below)
110  uint32_t Offset = 0; // Offset with in the file
111  StringRef Name; // Section name (User-defined sections only)
112  uint32_t Comdat = UINT32_MAX; // From the "comdat info" section
113  ArrayRef<uint8_t> Content; // Section content
114  std::vector<wasm::WasmRelocation> Relocations; // Relocations for this section
115 };
116 
117 struct WasmSegment {
120 };
121 
122 class WasmObjectFile : public ObjectFile {
123 
124 public:
126 
127  const wasm::WasmObjectHeader &getHeader() const;
128  const WasmSymbol &getWasmSymbol(const DataRefImpl &Symb) const;
129  const WasmSymbol &getWasmSymbol(const SymbolRef &Symbol) const;
130  const WasmSection &getWasmSection(const SectionRef &Section) const;
132 
133  static bool classof(const Binary *v) { return v->isWasm(); }
134 
135  const wasm::WasmDylinkInfo &dylinkInfo() const { return DylinkInfo; }
136  const wasm::WasmProducerInfo &getProducerInfo() const { return ProducerInfo; }
138  return TargetFeatures;
139  }
140  ArrayRef<wasm::WasmSignature> types() const { return Signatures; }
141  ArrayRef<uint32_t> functionTypes() const { return FunctionTypes; }
142  ArrayRef<wasm::WasmImport> imports() const { return Imports; }
143  ArrayRef<wasm::WasmTable> tables() const { return Tables; }
144  ArrayRef<wasm::WasmLimits> memories() const { return Memories; }
145  ArrayRef<wasm::WasmGlobal> globals() const { return Globals; }
146  ArrayRef<wasm::WasmTag> tags() const { return Tags; }
147  ArrayRef<wasm::WasmExport> exports() const { return Exports; }
148  ArrayRef<WasmSymbol> syms() const { return Symbols; }
149  const wasm::WasmLinkingData &linkingData() const { return LinkingData; }
150  uint32_t getNumberOfSymbols() const { return Symbols.size(); }
151  ArrayRef<wasm::WasmElemSegment> elements() const { return ElemSegments; }
152  ArrayRef<WasmSegment> dataSegments() const { return DataSegments; }
153  ArrayRef<wasm::WasmFunction> functions() const { return Functions; }
154  ArrayRef<wasm::WasmDebugName> debugNames() const { return DebugNames; }
155  uint32_t startFunction() const { return StartFunction; }
156  uint32_t getNumImportedGlobals() const { return NumImportedGlobals; }
157  uint32_t getNumImportedTables() const { return NumImportedTables; }
158  uint32_t getNumImportedFunctions() const { return NumImportedFunctions; }
159  uint32_t getNumImportedTags() const { return NumImportedTags; }
160  uint32_t getNumSections() const { return Sections.size(); }
161  void moveSymbolNext(DataRefImpl &Symb) const override;
162 
163  Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
164 
165  basic_symbol_iterator symbol_begin() const override;
166 
167  basic_symbol_iterator symbol_end() const override;
168  Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
169 
170  Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
171  uint64_t getWasmSymbolValue(const WasmSymbol &Sym) const;
172  uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
173  uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
174  uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
178 
179  // Overrides from SectionRef.
180  void moveSectionNext(DataRefImpl &Sec) const override;
181  Expected<StringRef> getSectionName(DataRefImpl Sec) const override;
182  uint64_t getSectionAddress(DataRefImpl Sec) const override;
183  uint64_t getSectionIndex(DataRefImpl Sec) const override;
184  uint64_t getSectionSize(DataRefImpl Sec) const override;
186  getSectionContents(DataRefImpl Sec) const override;
187  uint64_t getSectionAlignment(DataRefImpl Sec) const override;
188  bool isSectionCompressed(DataRefImpl Sec) const override;
189  bool isSectionText(DataRefImpl Sec) const override;
190  bool isSectionData(DataRefImpl Sec) const override;
191  bool isSectionBSS(DataRefImpl Sec) const override;
192  bool isSectionVirtual(DataRefImpl Sec) const override;
194  relocation_iterator section_rel_end(DataRefImpl Sec) const override;
195 
196  // Overrides from RelocationRef.
197  void moveRelocationNext(DataRefImpl &Rel) const override;
198  uint64_t getRelocationOffset(DataRefImpl Rel) const override;
199  symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
200  uint64_t getRelocationType(DataRefImpl Rel) const override;
202  SmallVectorImpl<char> &Result) const override;
203 
204  section_iterator section_begin() const override;
205  section_iterator section_end() const override;
206  uint8_t getBytesInAddress() const override;
207  StringRef getFileFormatName() const override;
208  Triple::ArchType getArch() const override;
209  SubtargetFeatures getFeatures() const override;
210  bool isRelocatableObject() const override;
211  bool isSharedObject() const;
212 
213  struct ReadContext {
214  const uint8_t *Start;
215  const uint8_t *Ptr;
216  const uint8_t *End;
217  };
218 
219 private:
220  bool isValidFunctionIndex(uint32_t Index) const;
221  bool isDefinedFunctionIndex(uint32_t Index) const;
222  bool isValidGlobalIndex(uint32_t Index) const;
223  bool isValidTableNumber(uint32_t Index) const;
224  bool isDefinedGlobalIndex(uint32_t Index) const;
225  bool isDefinedTableNumber(uint32_t Index) const;
226  bool isValidTagIndex(uint32_t Index) const;
227  bool isDefinedTagIndex(uint32_t Index) const;
228  bool isValidFunctionSymbol(uint32_t Index) const;
229  bool isValidTableSymbol(uint32_t Index) const;
230  bool isValidGlobalSymbol(uint32_t Index) const;
231  bool isValidTagSymbol(uint32_t Index) const;
232  bool isValidDataSymbol(uint32_t Index) const;
233  bool isValidSectionSymbol(uint32_t Index) const;
234  wasm::WasmFunction &getDefinedFunction(uint32_t Index);
235  const wasm::WasmFunction &getDefinedFunction(uint32_t Index) const;
236  wasm::WasmGlobal &getDefinedGlobal(uint32_t Index);
237  wasm::WasmTag &getDefinedTag(uint32_t Index);
238 
239  const WasmSection &getWasmSection(DataRefImpl Ref) const;
241  uint32_t getSymbolSectionIdImpl(const WasmSymbol &Symb) const;
242 
243  Error parseSection(WasmSection &Sec);
244  Error parseCustomSection(WasmSection &Sec, ReadContext &Ctx);
245 
246  // Standard section types
247  Error parseTypeSection(ReadContext &Ctx);
248  Error parseImportSection(ReadContext &Ctx);
249  Error parseFunctionSection(ReadContext &Ctx);
250  Error parseTableSection(ReadContext &Ctx);
251  Error parseMemorySection(ReadContext &Ctx);
252  Error parseTagSection(ReadContext &Ctx);
253  Error parseGlobalSection(ReadContext &Ctx);
254  Error parseExportSection(ReadContext &Ctx);
255  Error parseStartSection(ReadContext &Ctx);
256  Error parseElemSection(ReadContext &Ctx);
257  Error parseCodeSection(ReadContext &Ctx);
258  Error parseDataSection(ReadContext &Ctx);
259  Error parseDataCountSection(ReadContext &Ctx);
260 
261  // Custom section types
262  Error parseDylinkSection(ReadContext &Ctx);
263  Error parseDylink0Section(ReadContext &Ctx);
264  Error parseNameSection(ReadContext &Ctx);
265  Error parseLinkingSection(ReadContext &Ctx);
266  Error parseLinkingSectionSymtab(ReadContext &Ctx);
267  Error parseLinkingSectionComdat(ReadContext &Ctx);
268  Error parseProducersSection(ReadContext &Ctx);
269  Error parseTargetFeaturesSection(ReadContext &Ctx);
270  Error parseRelocSection(StringRef Name, ReadContext &Ctx);
271 
272  wasm::WasmObjectHeader Header;
273  std::vector<WasmSection> Sections;
274  wasm::WasmDylinkInfo DylinkInfo;
275  wasm::WasmProducerInfo ProducerInfo;
276  std::vector<wasm::WasmFeatureEntry> TargetFeatures;
277  std::vector<wasm::WasmSignature> Signatures;
278  std::vector<uint32_t> FunctionTypes;
279  std::vector<wasm::WasmTable> Tables;
280  std::vector<wasm::WasmLimits> Memories;
281  std::vector<wasm::WasmGlobal> Globals;
282  std::vector<wasm::WasmTag> Tags;
283  std::vector<wasm::WasmImport> Imports;
284  std::vector<wasm::WasmExport> Exports;
285  std::vector<wasm::WasmElemSegment> ElemSegments;
286  std::vector<WasmSegment> DataSegments;
287  llvm::Optional<size_t> DataCount;
288  std::vector<wasm::WasmFunction> Functions;
289  std::vector<WasmSymbol> Symbols;
290  std::vector<wasm::WasmDebugName> DebugNames;
291  uint32_t StartFunction = -1;
292  bool HasLinkingSection = false;
293  bool HasDylinkSection = false;
294  bool SeenCodeSection = false;
295  bool HasMemory64 = false;
296  wasm::WasmLinkingData LinkingData;
297  uint32_t NumImportedGlobals = 0;
298  uint32_t NumImportedTables = 0;
299  uint32_t NumImportedFunctions = 0;
300  uint32_t NumImportedTags = 0;
301  uint32_t CodeSection = 0;
302  uint32_t DataSection = 0;
303  uint32_t TagSection = 0;
304  uint32_t GlobalSection = 0;
305  uint32_t TableSection = 0;
306 };
307 
309 public:
310  // We define orders for all core wasm sections and known custom sections.
311  enum : int {
312  // Sentinel, must be zero
314 
315  // Core sections
329 
330  // Custom sections
331  // "dylink" should be the very first section in the module
333  // "linking" section requires DATA section in order to validate data symbols
335  // Must come after "linking" section in order to validate reloc indexes.
337  // "name" section must appear after DATA. Comes after "linking" to allow
338  // symbol table to set default function name.
340  // "producers" section must appear after "name" section.
342  // "target_features" section must appear after producers section
344 
345  // Must be last
347 
348  };
349 
350  // Sections that may or may not be present, but cannot be predecessors
352 
353  bool isValidSectionOrder(unsigned ID, StringRef CustomSectionName = "");
354 
355 private:
356  bool Seen[WASM_NUM_SEC_ORDERS] = {}; // Sections that have been seen already
357 
358  // Returns -1 for unknown sections.
359  int getSectionOrder(unsigned ID, StringRef CustomSectionName = "");
360 };
361 
362 } // end namespace object
363 
365  Sym.print(OS);
366  return OS;
367 }
368 
369 } // end namespace llvm
370 
371 #endif // LLVM_OBJECT_WASM_H
llvm::object::WasmSectionOrderChecker
Definition: Wasm.h:308
MemoryBuffer.h
llvm::wasm::WASM_SYMBOL_TYPE_SECTION
@ WASM_SYMBOL_TYPE_SECTION
Definition: Wasm.h:370
llvm::wasm::WasmTag
Definition: Wasm.h:116
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:491
llvm::object::WasmObjectFile::linkingData
const wasm::WasmLinkingData & linkingData() const
Definition: Wasm.h:149
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::object::WasmObjectFile::WasmObjectFile
WasmObjectFile(MemoryBufferRef Object, Error &Err)
Definition: WasmObjectFile.cpp:260
llvm::object::WasmObjectFile::symbol_begin
basic_symbol_iterator symbol_begin() const override
Definition: WasmObjectFile.cpp:1537
llvm::object::WasmObjectFile::getFeatures
SubtargetFeatures getFeatures() const override
Definition: WasmObjectFile.cpp:1816
llvm::object::WasmSegment
Definition: Wasm.h:117
llvm::object::WasmObjectFile::ReadContext::Start
const uint8_t * Start
Definition: Wasm.h:214
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_NONE
@ WASM_SEC_ORDER_NONE
Definition: Wasm.h:313
llvm::object::WasmObjectFile::debugNames
ArrayRef< wasm::WasmDebugName > debugNames() const
Definition: Wasm.h:154
llvm::object::WasmSection::Content
ArrayRef< uint8_t > Content
Definition: Wasm.h:113
StringRef.h
llvm::object::WasmObjectFile::syms
ArrayRef< WasmSymbol > syms() const
Definition: Wasm.h:148
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_EXPORT
@ WASM_SEC_ORDER_EXPORT
Definition: Wasm.h:323
llvm::object::WasmObjectFile::getBytesInAddress
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
Definition: WasmObjectFile.cpp:1806
llvm::object::WasmSectionOrderChecker::isValidSectionOrder
bool isValidSectionOrder(unsigned ID, StringRef CustomSectionName="")
Definition: WasmObjectFile.cpp:1939
llvm::object::WasmSymbol::Info
const wasm::WasmSymbolInfo & Info
Definition: Wasm.h:45
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_CODE
@ WASM_SEC_ORDER_CODE
Definition: Wasm.h:327
llvm::object::WasmSymbol::isDefined
bool isDefined() const
Definition: Wasm.h:69
llvm::object::WasmSegment::Data
wasm::WasmDataSegment Data
Definition: Wasm.h:119
llvm::wasm::WASM_SYMBOL_BINDING_LOCAL
const unsigned WASM_SYMBOL_BINDING_LOCAL
Definition: Wasm.h:390
llvm::wasm::WASM_SYMBOL_TYPE_TABLE
@ WASM_SYMBOL_TYPE_TABLE
Definition: Wasm.h:372
llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL
@ WASM_SYMBOL_TYPE_GLOBAL
Definition: Wasm.h:369
llvm::object::WasmSection
Definition: Wasm.h:106
Error.h
llvm::wasm::WasmRelocation
Definition: Wasm.h:183
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_IMPORT
@ WASM_SEC_ORDER_IMPORT
Definition: Wasm.h:317
llvm::object::WasmSymbol::isTypeFunction
bool isTypeFunction() const
Definition: Wasm.h:51
llvm::object::WasmObjectFile::dylinkInfo
const wasm::WasmDylinkInfo & dylinkInfo() const
Definition: Wasm.h:135
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::object::WasmObjectFile::isSectionCompressed
bool isSectionCompressed(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1722
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_GLOBAL
@ WASM_SEC_ORDER_GLOBAL
Definition: Wasm.h:322
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_PRODUCERS
@ WASM_SEC_ORDER_PRODUCERS
Definition: Wasm.h:341
llvm::object::WasmObjectFile::getSectionName
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1672
llvm::Optional< size_t >
llvm::wasm::WASM_SYMBOL_UNDEFINED
const unsigned WASM_SYMBOL_UNDEFINED
Definition: Wasm.h:393
llvm::object::WasmObjectFile::memories
ArrayRef< wasm::WasmLimits > memories() const
Definition: Wasm.h:144
llvm::object::WasmObjectFile::getSymbolValueImpl
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override
Definition: WasmObjectFile.cpp:1598
llvm::object::WasmObjectFile::getRelocationTypeName
void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const override
Definition: WasmObjectFile.cpp:1775
llvm::object::WasmObjectFile::isSectionBSS
bool isSectionBSS(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1734
llvm::object::WasmObjectFile::functions
ArrayRef< wasm::WasmFunction > functions() const
Definition: Wasm.h:153
llvm::wasm::WasmSymbolInfo::Kind
uint8_t Kind
Definition: Wasm.h:197
llvm::object::WasmObjectFile::types
ArrayRef< wasm::WasmSignature > types() const
Definition: Wasm.h:140
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::wasm::WasmFunction
Definition: Wasm.h:140
llvm::object::WasmObjectFile::getNumImportedGlobals
uint32_t getNumImportedGlobals() const
Definition: Wasm.h:156
llvm::object::WasmObjectFile::isRelocatableObject
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
Definition: WasmObjectFile.cpp:1820
llvm::object::WasmObjectFile::getArch
Triple::ArchType getArch() const override
Definition: WasmObjectFile.cpp:1812
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::object::WasmObjectFile::getNumberOfSymbols
uint32_t getNumberOfSymbols() const
Definition: Wasm.h:150
llvm::wasm::WasmProducerInfo
Definition: Wasm.h:53
llvm::object::WasmObjectFile::getNumSections
uint32_t getNumSections() const
Definition: Wasm.h:160
llvm::object::WasmObjectFile::moveSectionNext
void moveSectionNext(DataRefImpl &Sec) const override
Definition: WasmObjectFile.cpp:1670
llvm::object::WasmSymbol::isHidden
bool isHidden() const
Definition: Wasm.h:91
llvm::object::WasmSection::Name
StringRef Name
Definition: Wasm.h:111
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_DYLINK
@ WASM_SEC_ORDER_DYLINK
Definition: Wasm.h:332
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_DATACOUNT
@ WASM_SEC_ORDER_DATACOUNT
Definition: Wasm.h:326
llvm::wasm::WASM_SYMBOL_BINDING_WEAK
const unsigned WASM_SYMBOL_BINDING_WEAK
Definition: Wasm.h:389
llvm::object::WasmSymbol::GlobalType
const wasm::WasmGlobalType * GlobalType
Definition: Wasm.h:46
llvm::object::WasmSymbol::Signature
const wasm::WasmSignature * Signature
Definition: Wasm.h:49
llvm::Triple::ArchType
ArchType
Definition: Triple.h:47
llvm::object::WasmObjectFile::ReadContext::End
const uint8_t * End
Definition: Wasm.h:216
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
llvm::object::WasmObjectFile::ReadContext::Ptr
const uint8_t * Ptr
Definition: Wasm.h:215
llvm::wasm::WASM_SYMBOL_VISIBILITY_MASK
const unsigned WASM_SYMBOL_VISIBILITY_MASK
Definition: Wasm.h:386
MCSymbolWasm.h
llvm::object::WasmObjectFile::getWasmRelocation
const wasm::WasmRelocation & getWasmRelocation(const RelocationRef &Ref) const
Definition: WasmObjectFile.cpp:1835
llvm::object::WasmObjectFile
Definition: Wasm.h:122
llvm::wasm::WASM_SYMBOL_VISIBILITY_HIDDEN
const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN
Definition: Wasm.h:392
llvm::object::WasmSymbol::isTypeTag
bool isTypeTag() const
Definition: Wasm.h:67
llvm::object::WasmSymbol
Definition: Wasm.h:35
llvm::object::WasmObjectFile::isSectionText
bool isSectionText(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1726
llvm::object::WasmObjectFile::getSymbolAlignment
uint32_t getSymbolAlignment(DataRefImpl Symb) const override
Definition: WasmObjectFile.cpp:1602
llvm::SubtargetFeatures
Manages the enabling and disabling of subtarget specific features.
Definition: SubtargetFeature.h:183
llvm::object::WasmObjectFile::getSymbolSectionId
uint32_t getSymbolSectionId(SymbolRef Sym) const
Definition: WasmObjectFile.cpp:1646
llvm::wasm::WasmGlobalType
Definition: Wasm.h:98
llvm::object::WasmObjectFile::getNumImportedTags
uint32_t getNumImportedTags() const
Definition: Wasm.h:159
llvm::object::WasmObjectFile::getSymbolSection
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
Definition: WasmObjectFile.cpp:1636
llvm::object::WasmSymbol::WasmSymbol
WasmSymbol(const wasm::WasmSymbolInfo &Info, const wasm::WasmGlobalType *GlobalType, const wasm::WasmTableType *TableType, const wasm::WasmTagType *TagType, const wasm::WasmSignature *Signature)
Definition: Wasm.h:37
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION
@ WASM_SYMBOL_TYPE_FUNCTION
Definition: Wasm.h:367
llvm::object::WasmObjectFile::moveRelocationNext
void moveRelocationNext(DataRefImpl &Rel) const override
Definition: WasmObjectFile.cpp:1753
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_TYPE
@ WASM_SEC_ORDER_TYPE
Definition: Wasm.h:316
llvm::object::WasmObjectFile::getTargetFeatures
ArrayRef< wasm::WasmFeatureEntry > getTargetFeatures() const
Definition: Wasm.h:137
llvm::Comdat
Definition: Comdat.h:31
llvm::object::WasmSymbol::isUndefined
bool isUndefined() const
Definition: Wasm.h:71
llvm::object::WasmObjectFile::getHeader
const wasm::WasmObjectHeader & getHeader() const
Definition: WasmObjectFile.cpp:1513
llvm::object::WasmSymbol::print
void print(raw_ostream &Out) const
Definition: WasmObjectFile.cpp:40
llvm::object::WasmObjectFile::getSectionIndex
uint64_t getSectionIndex(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1701
llvm::object::WasmObjectFile::elements
ArrayRef< wasm::WasmElemSegment > elements() const
Definition: Wasm.h:151
llvm::wasm::WasmDylinkInfo
Definition: Wasm.h:44
llvm::OutputFileType::Object
@ Object
llvm::object::SectionRef
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:80
llvm::object::WasmSymbol::isTypeSection
bool isTypeSection() const
Definition: Wasm.h:63
llvm::object::WasmObjectFile::tables
ArrayRef< wasm::WasmTable > tables() const
Definition: Wasm.h:143
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_RELOC
@ WASM_SEC_ORDER_RELOC
Definition: Wasm.h:336
llvm::object::WasmSymbol::isBindingWeak
bool isBindingWeak() const
Definition: Wasm.h:75
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
uint64_t
llvm::object::WasmObjectFile::getSymbolType
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
Definition: WasmObjectFile.cpp:1613
llvm::object::symbol_iterator
Definition: ObjectFile.h:207
llvm::object::WasmObjectFile::section_begin
section_iterator section_begin() const override
Definition: WasmObjectFile.cpp:1794
llvm::object::WasmSymbol::isTypeData
bool isTypeData() const
Definition: Wasm.h:57
llvm::object::WasmObjectFile::imports
ArrayRef< wasm::WasmImport > imports() const
Definition: Wasm.h:142
llvm::object::WasmObjectFile::getSymbolFlags
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
Definition: WasmObjectFile.cpp:1519
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_LINKING
@ WASM_SEC_ORDER_LINKING
Definition: Wasm.h:334
ArrayRef.h
llvm::wasm::WASM_SYMBOL_TYPE_TAG
@ WASM_SYMBOL_TYPE_TAG
Definition: Wasm.h:371
llvm::object::WasmSection::WasmSection
WasmSection()=default
llvm::object::WasmSectionOrderChecker::WASM_NUM_SEC_ORDERS
@ WASM_NUM_SEC_ORDERS
Definition: Wasm.h:346
llvm::object::WasmObjectFile::getProducerInfo
const wasm::WasmProducerInfo & getProducerInfo() const
Definition: Wasm.h:136
llvm::object::WasmObjectFile::getNumImportedTables
uint32_t getNumImportedTables() const
Definition: Wasm.h:157
ObjectFile.h
llvm::object::WasmObjectFile::getSectionAddress
uint64_t getSectionAddress(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1699
llvm::object::WasmObjectFile::startFunction
uint32_t startFunction() const
Definition: Wasm.h:155
llvm::object::content_iterator
Definition: SymbolicFile.h:67
llvm::wasm::WasmTagType
Definition: Wasm.h:110
llvm::object::WasmObjectFile::getWasmSymbolValue
uint64_t getWasmSymbolValue(const WasmSymbol &Sym) const
Definition: WasmObjectFile.cpp:1572
llvm::object::WasmObjectFile::functionTypes
ArrayRef< uint32_t > functionTypes() const
Definition: Wasm.h:141
llvm::object::WasmObjectFile::isSharedObject
bool isSharedObject() const
Definition: WasmObjectFile.cpp:1822
llvm::object::WasmObjectFile::getSymbolName
Expected< StringRef > getSymbolName(DataRefImpl Symb) const override
Definition: WasmObjectFile.cpp:1559
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_NAME
@ WASM_SEC_ORDER_NAME
Definition: Wasm.h:339
llvm::object::WasmObjectFile::getNumImportedFunctions
uint32_t getNumImportedFunctions() const
Definition: Wasm.h:158
llvm::object::WasmSymbol::isBindingGlobal
bool isBindingGlobal() const
Definition: Wasm.h:79
llvm::ArrayRef< uint8_t >
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:228
llvm::object::Binary::isWasm
bool isWasm() const
Definition: Binary.h:134
llvm::object::Binary
Definition: Binary.h:32
llvm::object::WasmObjectFile::getSectionContents
Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1711
llvm::object::WasmSymbol::isTypeGlobal
bool isTypeGlobal() const
Definition: Wasm.h:59
llvm::wasm::WasmObjectHeader
Definition: Wasm.h:34
llvm::wasm::WasmGlobal
Definition: Wasm.h:103
uint32_t
llvm::wasm::WASM_SYMBOL_BINDING_MASK
const unsigned WASM_SYMBOL_BINDING_MASK
Definition: Wasm.h:385
llvm::object::WasmObjectFile::globals
ArrayRef< wasm::WasmGlobal > globals() const
Definition: Wasm.h:145
llvm::object::DataRefImpl
Definition: SymbolicFile.h:33
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_START
@ WASM_SEC_ORDER_START
Definition: Wasm.h:324
llvm::object::WasmObjectFile::isSectionVirtual
bool isSectionVirtual(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1736
llvm::object::WasmSection::Offset
uint32_t Offset
Definition: Wasm.h:110
llvm::wasm::WasmSymbolInfo
Definition: Wasm.h:195
llvm::object::WasmSegment::SectionOffset
uint32_t SectionOffset
Definition: Wasm.h:118
llvm::object::WasmObjectFile::isSectionData
bool isSectionData(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1730
llvm::object::WasmObjectFile::getSectionSize
uint64_t getSectionSize(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1705
llvm::object::WasmObjectFile::getWasmSection
const WasmSection & getWasmSection(const SectionRef &Section) const
Definition: WasmObjectFile.cpp:1830
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_TABLE
@ WASM_SEC_ORDER_TABLE
Definition: Wasm.h:319
llvm::object::WasmObjectFile::ReadContext
Definition: Wasm.h:213
llvm::object::WasmObjectFile::dataSegments
ArrayRef< WasmSegment > dataSegments() const
Definition: Wasm.h:152
llvm::object::WasmObjectFile::getSectionAlignment
uint64_t getSectionAlignment(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1718
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_MEMORY
@ WASM_SEC_ORDER_MEMORY
Definition: Wasm.h:320
llvm::object::WasmObjectFile::moveSymbolNext
void moveSymbolNext(DataRefImpl &Symb) const override
Definition: WasmObjectFile.cpp:1517
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::object::WasmObjectFile::getRelocationSymbol
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
Definition: WasmObjectFile.cpp:1760
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_TARGET_FEATURES
@ WASM_SEC_ORDER_TARGET_FEATURES
Definition: Wasm.h:343
llvm::object::WasmSymbol::getBinding
unsigned getBinding() const
Definition: Wasm.h:87
llvm::object::WasmObjectFile::tags
ArrayRef< wasm::WasmTag > tags() const
Definition: Wasm.h:146
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_FUNCTION
@ WASM_SEC_ORDER_FUNCTION
Definition: Wasm.h:318
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::wasm::WASM_SYMBOL_BINDING_GLOBAL
const unsigned WASM_SYMBOL_BINDING_GLOBAL
Definition: Wasm.h:388
llvm::object::WasmObjectFile::getWasmSymbol
const WasmSymbol & getWasmSymbol(const DataRefImpl &Symb) const
Definition: WasmObjectFile.cpp:1551
llvm::wasm::WasmSymbolInfo::Flags
uint32_t Flags
Definition: Wasm.h:198
llvm::object::WasmObjectFile::section_end
section_iterator section_end() const override
Definition: WasmObjectFile.cpp:1800
llvm::wasm::WasmDataSegment
Definition: Wasm.h:153
llvm::object::WasmObjectFile::getSymbolAddress
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
Definition: WasmObjectFile.cpp:1563
llvm::object::WasmObjectFile::getRelocationOffset
uint64_t getRelocationOffset(DataRefImpl Rel) const override
Definition: WasmObjectFile.cpp:1755
llvm::object::WasmObjectFile::symbol_end
basic_symbol_iterator symbol_end() const override
Definition: WasmObjectFile.cpp:1544
llvm::object::WasmObjectFile::section_rel_begin
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1738
Wasm.h
llvm::object::WasmSymbol::TableType
const wasm::WasmTableType * TableType
Definition: Wasm.h:47
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:79
Binary.h
llvm::object::WasmObjectFile::getCommonSymbolSizeImpl
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
Definition: WasmObjectFile.cpp:1607
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_ELEM
@ WASM_SEC_ORDER_ELEM
Definition: Wasm.h:325
llvm::object::WasmSymbol::isTypeTable
bool isTypeTable() const
Definition: Wasm.h:55
llvm::object::WasmObjectFile::exports
ArrayRef< wasm::WasmExport > exports() const
Definition: Wasm.h:147
llvm::object::WasmSymbol::getVisibility
unsigned getVisibility() const
Definition: Wasm.h:95
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_DATA
@ WASM_SEC_ORDER_DATA
Definition: Wasm.h:328
llvm::SmallVectorImpl< char >
llvm::object::SymbolRef
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: ObjectFile.h:167
llvm::object::WasmObjectFile::classof
static bool classof(const Binary *v)
Definition: Wasm.h:133
llvm::object::WasmSectionOrderChecker::WASM_SEC_ORDER_TAG
@ WASM_SEC_ORDER_TAG
Definition: Wasm.h:321
llvm::wasm::WasmLinkingData
Definition: Wasm.h:226
llvm::object::WasmSymbol::dump
LLVM_DUMP_METHOD void dump() const
Definition: WasmObjectFile.cpp:54
llvm::object::WasmObjectFile::getRelocationType
uint64_t getRelocationType(DataRefImpl Rel) const override
Definition: WasmObjectFile.cpp:1770
llvm::object::RelocationRef
This is a value type class that represents a single relocation in the list of relocations in the obje...
Definition: ObjectFile.h:51
llvm::object::WasmSectionOrderChecker::DisallowedPredecessors
static int DisallowedPredecessors[WASM_NUM_SEC_ORDERS][WASM_NUM_SEC_ORDERS]
Definition: Wasm.h:351
llvm::object::WasmObjectFile::section_rel_end
relocation_iterator section_rel_end(DataRefImpl Sec) const override
Definition: WasmObjectFile.cpp:1745
llvm::wasm::WasmTableType
Definition: Wasm.h:76
llvm::object::WasmSymbol::TagType
const wasm::WasmTagType * TagType
Definition: Wasm.h:48
llvm::object::WasmSection::Relocations
std::vector< wasm::WasmRelocation > Relocations
Definition: Wasm.h:114
llvm::object::WasmObjectFile::getFileFormatName
StringRef getFileFormatName() const override
Definition: WasmObjectFile.cpp:1810
llvm::wasm::WASM_SYMBOL_TYPE_DATA
@ WASM_SYMBOL_TYPE_DATA
Definition: Wasm.h:368
llvm::wasm::WasmSignature
Definition: Wasm.h:418
llvm::object::WasmSymbol::isBindingLocal
bool isBindingLocal() const
Definition: Wasm.h:83
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:37