2017-11-18 02:14:09 +08:00
|
|
|
//===- Symbols.h ------------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-11-18 02:14:09 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_WASM_SYMBOLS_H
|
|
|
|
#define LLD_WASM_SYMBOLS_H
|
|
|
|
|
2018-04-21 01:18:06 +08:00
|
|
|
#include "Config.h"
|
2017-11-18 02:14:09 +08:00
|
|
|
#include "lld/Common/LLVM.h"
|
2020-02-06 13:18:55 +08:00
|
|
|
#include "llvm/ADT/Optional.h"
|
2017-11-18 02:14:09 +08:00
|
|
|
#include "llvm/Object/Archive.h"
|
|
|
|
#include "llvm/Object/Wasm.h"
|
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace wasm {
|
|
|
|
|
2019-05-21 17:13:09 +08:00
|
|
|
// Shared string constants
|
|
|
|
|
|
|
|
// The default module name to use for symbol imports.
|
|
|
|
extern const char *defaultModule;
|
|
|
|
|
|
|
|
// The name under which to import or export the wasm table.
|
|
|
|
extern const char *functionTableName;
|
|
|
|
|
2018-11-27 09:08:16 +08:00
|
|
|
using llvm::wasm::WasmSymbolType;
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
class InputFile;
|
2018-01-29 03:57:01 +08:00
|
|
|
class InputChunk;
|
2018-02-21 01:45:38 +08:00
|
|
|
class InputSegment;
|
2018-02-17 07:50:23 +08:00
|
|
|
class InputFunction;
|
2018-02-23 13:08:53 +08:00
|
|
|
class InputGlobal;
|
2021-06-15 16:49:43 +08:00
|
|
|
class InputTag;
|
2018-05-05 07:14:42 +08:00
|
|
|
class InputSection;
|
2021-01-05 19:08:58 +08:00
|
|
|
class InputTable;
|
2019-05-21 17:13:09 +08:00
|
|
|
class OutputSection;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-02-15 06:55:38 +08:00
|
|
|
#define INVALID_INDEX UINT32_MAX
|
|
|
|
|
2018-02-15 02:27:59 +08:00
|
|
|
// The base class for real symbol classes.
|
2017-11-18 02:14:09 +08:00
|
|
|
class Symbol {
|
|
|
|
public:
|
2019-07-05 09:27:39 +08:00
|
|
|
enum Kind : uint8_t {
|
2017-11-18 02:14:09 +08:00
|
|
|
DefinedFunctionKind,
|
2018-02-21 07:38:27 +08:00
|
|
|
DefinedDataKind,
|
2018-02-23 13:08:53 +08:00
|
|
|
DefinedGlobalKind,
|
2021-06-15 16:49:43 +08:00
|
|
|
DefinedTagKind,
|
2021-01-05 19:08:58 +08:00
|
|
|
DefinedTableKind,
|
2018-05-05 07:14:42 +08:00
|
|
|
SectionKind,
|
2019-05-21 17:13:09 +08:00
|
|
|
OutputSectionKind,
|
2017-11-18 02:14:09 +08:00
|
|
|
UndefinedFunctionKind,
|
2018-02-21 07:38:27 +08:00
|
|
|
UndefinedDataKind,
|
2018-02-23 13:08:53 +08:00
|
|
|
UndefinedGlobalKind,
|
2021-01-05 19:08:58 +08:00
|
|
|
UndefinedTableKind,
|
2018-02-28 08:16:11 +08:00
|
|
|
LazyKind,
|
2017-11-18 02:14:09 +08:00
|
|
|
};
|
|
|
|
|
2018-02-17 04:26:15 +08:00
|
|
|
Kind kind() const { return symbolKind; }
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2019-05-21 17:13:09 +08:00
|
|
|
bool isDefined() const { return !isLazy() && !isUndefined(); }
|
2018-02-28 08:16:11 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
bool isUndefined() const {
|
2018-02-23 13:08:53 +08:00
|
|
|
return symbolKind == UndefinedFunctionKind ||
|
2021-01-05 19:08:58 +08:00
|
|
|
symbolKind == UndefinedDataKind ||
|
|
|
|
symbolKind == UndefinedGlobalKind ||
|
|
|
|
symbolKind == UndefinedTableKind;
|
2017-11-18 02:14:09 +08:00
|
|
|
}
|
2018-02-28 08:16:11 +08:00
|
|
|
|
|
|
|
bool isLazy() const { return symbolKind == LazyKind; }
|
|
|
|
|
2018-01-10 08:52:20 +08:00
|
|
|
bool isLocal() const;
|
2017-11-18 02:14:09 +08:00
|
|
|
bool isWeak() const;
|
2017-12-03 10:38:04 +08:00
|
|
|
bool isHidden() const;
|
2021-09-08 16:53:13 +08:00
|
|
|
bool isTLS() const;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2019-06-07 14:00:46 +08:00
|
|
|
// Returns true if this symbol exists in a discarded (due to COMDAT) section
|
|
|
|
bool isDiscarded() const;
|
|
|
|
|
2019-01-30 06:26:31 +08:00
|
|
|
// True if this is an undefined weak symbol. This only works once
|
|
|
|
// all input files have been added.
|
|
|
|
bool isUndefWeak() const {
|
|
|
|
// See comment on lazy symbols for details.
|
|
|
|
return isWeak() && (isUndefined() || isLazy());
|
|
|
|
}
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
// Returns the symbol name.
|
|
|
|
StringRef getName() const { return name; }
|
|
|
|
|
|
|
|
// Returns the file from which this symbol was created.
|
|
|
|
InputFile *getFile() const { return file; }
|
2018-02-23 13:08:53 +08:00
|
|
|
|
2018-02-21 01:45:38 +08:00
|
|
|
InputChunk *getChunk() const;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-04-21 01:18:06 +08:00
|
|
|
// Indicates that the section or import for this symbol will be included in
|
|
|
|
// the final image.
|
2018-02-23 13:08:53 +08:00
|
|
|
bool isLive() const;
|
|
|
|
|
2018-04-21 01:18:06 +08:00
|
|
|
// Marks the symbol's InputChunk as Live, so that it will be included in the
|
|
|
|
// final image.
|
|
|
|
void markLive();
|
|
|
|
|
2018-01-13 06:10:35 +08:00
|
|
|
void setHidden(bool isHidden);
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-03-13 03:56:23 +08:00
|
|
|
// Get/set the index in the output symbol table. This is only used for
|
|
|
|
// relocatable output.
|
2018-02-23 13:08:53 +08:00
|
|
|
uint32_t getOutputSymbolIndex() const;
|
|
|
|
void setOutputSymbolIndex(uint32_t index);
|
|
|
|
|
|
|
|
WasmSymbolType getWasmType() const;
|
2018-06-29 01:04:58 +08:00
|
|
|
bool isExported() const;
|
2021-05-07 11:29:05 +08:00
|
|
|
bool isExportedExplicit() const;
|
2018-02-23 13:08:53 +08:00
|
|
|
|
2019-08-30 06:41:05 +08:00
|
|
|
// Indicates that the symbol is used in an __attribute__((used)) directive
|
|
|
|
// or similar.
|
|
|
|
bool isNoStrip() const;
|
|
|
|
|
2019-02-21 07:19:31 +08:00
|
|
|
const WasmSignature* getSignature() const;
|
|
|
|
|
2019-03-27 03:46:15 +08:00
|
|
|
uint32_t getGOTIndex() const {
|
|
|
|
assert(gotIndex != INVALID_INDEX);
|
|
|
|
return gotIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setGOTIndex(uint32_t index);
|
|
|
|
bool hasGOTIndex() const { return gotIndex != INVALID_INDEX; }
|
|
|
|
|
2018-02-15 02:27:59 +08:00
|
|
|
protected:
|
2018-02-21 01:45:38 +08:00
|
|
|
Symbol(StringRef name, Kind k, uint32_t flags, InputFile *f)
|
2020-02-28 09:32:22 +08:00
|
|
|
: name(name), file(f), symbolKind(k), referenced(!config->gcSections),
|
|
|
|
requiresGOT(false), isUsedInRegularObj(false), forceExport(false),
|
2020-11-24 07:41:07 +08:00
|
|
|
canInline(false), traced(false), isStub(false), flags(flags) {}
|
2019-07-11 13:40:30 +08:00
|
|
|
|
2018-02-15 02:27:59 +08:00
|
|
|
StringRef name;
|
|
|
|
InputFile *file;
|
2018-02-23 13:08:53 +08:00
|
|
|
uint32_t outputSymbolIndex = INVALID_INDEX;
|
2019-03-27 03:46:15 +08:00
|
|
|
uint32_t gotIndex = INVALID_INDEX;
|
2019-07-05 09:27:39 +08:00
|
|
|
Kind symbolKind;
|
|
|
|
|
|
|
|
public:
|
2019-07-08 18:35:08 +08:00
|
|
|
bool referenced : 1;
|
|
|
|
|
2019-09-25 04:52:12 +08:00
|
|
|
// True for data symbols that needs a dummy GOT entry. Used for static
|
|
|
|
// linking of GOT accesses.
|
|
|
|
bool requiresGOT : 1;
|
|
|
|
|
2019-07-05 09:27:39 +08:00
|
|
|
// True if the symbol was used for linking and thus need to be added to the
|
|
|
|
// output file's symbol table. This is true for all symbols except for
|
|
|
|
// unreferenced DSO symbols, lazy (archive) symbols, and bitcode symbols that
|
|
|
|
// are unreferenced except by other bitcode objects.
|
2019-07-08 15:30:07 +08:00
|
|
|
bool isUsedInRegularObj : 1;
|
2019-07-05 09:27:39 +08:00
|
|
|
|
2020-01-07 02:21:05 +08:00
|
|
|
// True if ths symbol is explicitly marked for export (i.e. via the
|
|
|
|
// -e/--export command line flag)
|
2019-07-08 15:30:07 +08:00
|
|
|
bool forceExport : 1;
|
2019-07-05 09:27:39 +08:00
|
|
|
|
|
|
|
// False if LTO shouldn't inline whatever this symbol points to. If a symbol
|
|
|
|
// is overwritten after LTO, LTO shouldn't inline the symbol because it
|
|
|
|
// doesn't know the final contents of the symbol.
|
2019-07-08 15:30:07 +08:00
|
|
|
bool canInline : 1;
|
2019-07-05 09:27:39 +08:00
|
|
|
|
|
|
|
// True if this symbol is specified by --trace-symbol option.
|
2019-07-08 15:30:07 +08:00
|
|
|
bool traced : 1;
|
2020-02-28 09:32:22 +08:00
|
|
|
|
2020-11-24 07:41:07 +08:00
|
|
|
// True if this symbol is a linker-synthesized stub function (traps when
|
|
|
|
// called) and should otherwise be treated as missing/undefined. See
|
|
|
|
// SymbolTable::replaceWithUndefined.
|
2020-12-02 06:04:21 +08:00
|
|
|
// These stubs never appear in the table and any table index relocations
|
|
|
|
// against them will produce address 0 (The table index representing
|
|
|
|
// the null function pointer).
|
2020-11-24 07:41:07 +08:00
|
|
|
bool isStub : 1;
|
|
|
|
|
2020-02-28 09:32:22 +08:00
|
|
|
uint32_t flags;
|
2021-07-15 08:16:15 +08:00
|
|
|
|
|
|
|
llvm::Optional<StringRef> importName;
|
|
|
|
llvm::Optional<StringRef> importModule;
|
2018-02-15 02:27:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class FunctionSymbol : public Symbol {
|
|
|
|
public:
|
|
|
|
static bool classof(const Symbol *s) {
|
|
|
|
return s->kind() == DefinedFunctionKind ||
|
|
|
|
s->kind() == UndefinedFunctionKind;
|
|
|
|
}
|
|
|
|
|
2018-03-13 03:56:23 +08:00
|
|
|
// Get/set the table index
|
|
|
|
void setTableIndex(uint32_t index);
|
2018-01-25 05:45:25 +08:00
|
|
|
uint32_t getTableIndex() const;
|
|
|
|
bool hasTableIndex() const;
|
2017-12-12 06:00:56 +08:00
|
|
|
|
2018-03-13 03:56:23 +08:00
|
|
|
// Get/set the function index
|
|
|
|
uint32_t getFunctionIndex() const;
|
|
|
|
void setFunctionIndex(uint32_t index);
|
|
|
|
bool hasFunctionIndex() const;
|
2017-12-12 06:00:56 +08:00
|
|
|
|
2018-12-08 14:17:43 +08:00
|
|
|
const WasmSignature *signature;
|
2018-06-29 00:53:53 +08:00
|
|
|
|
2018-02-15 02:27:59 +08:00
|
|
|
protected:
|
2018-02-17 07:50:23 +08:00
|
|
|
FunctionSymbol(StringRef name, Kind k, uint32_t flags, InputFile *f,
|
2018-12-08 14:17:43 +08:00
|
|
|
const WasmSignature *sig)
|
|
|
|
: Symbol(name, k, flags, f), signature(sig) {}
|
2018-02-15 02:27:59 +08:00
|
|
|
|
2018-02-15 06:55:38 +08:00
|
|
|
uint32_t tableIndex = INVALID_INDEX;
|
2018-03-13 03:56:23 +08:00
|
|
|
uint32_t functionIndex = INVALID_INDEX;
|
2018-02-15 02:27:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DefinedFunction : public FunctionSymbol {
|
|
|
|
public:
|
2018-02-17 07:50:23 +08:00
|
|
|
DefinedFunction(StringRef name, uint32_t flags, InputFile *f,
|
2018-02-21 01:45:38 +08:00
|
|
|
InputFunction *function);
|
2018-02-15 02:27:59 +08:00
|
|
|
|
|
|
|
static bool classof(const Symbol *s) {
|
|
|
|
return s->kind() == DefinedFunctionKind;
|
|
|
|
}
|
2018-02-21 01:45:38 +08:00
|
|
|
|
2021-08-19 00:57:34 +08:00
|
|
|
// Get the function index to be used when exporting. This only applies to
|
|
|
|
// defined functions and can be differ from the regular function index for
|
|
|
|
// weakly defined functions (that are imported and used via one index but
|
|
|
|
// defined and exported via another).
|
|
|
|
uint32_t getExportedFunctionIndex() const;
|
|
|
|
|
2018-02-21 01:45:38 +08:00
|
|
|
InputFunction *function;
|
2018-02-15 02:27:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class UndefinedFunction : public FunctionSymbol {
|
|
|
|
public:
|
2020-02-06 13:18:55 +08:00
|
|
|
UndefinedFunction(StringRef name, llvm::Optional<StringRef> importName,
|
|
|
|
llvm::Optional<StringRef> importModule, uint32_t flags,
|
2019-02-01 10:29:57 +08:00
|
|
|
InputFile *file = nullptr,
|
2019-05-25 06:45:08 +08:00
|
|
|
const WasmSignature *type = nullptr,
|
|
|
|
bool isCalledDirectly = true)
|
2019-02-01 10:29:57 +08:00
|
|
|
: FunctionSymbol(name, UndefinedFunctionKind, flags, file, type),
|
2021-07-15 08:16:15 +08:00
|
|
|
isCalledDirectly(isCalledDirectly) {
|
|
|
|
this->importName = importName;
|
|
|
|
this->importModule = importModule;
|
|
|
|
}
|
2019-07-11 13:40:30 +08:00
|
|
|
|
2018-02-15 02:27:59 +08:00
|
|
|
static bool classof(const Symbol *s) {
|
|
|
|
return s->kind() == UndefinedFunctionKind;
|
|
|
|
}
|
2019-02-01 10:29:57 +08:00
|
|
|
|
2020-05-02 00:14:59 +08:00
|
|
|
DefinedFunction *stubFunction = nullptr;
|
2019-05-25 06:45:08 +08:00
|
|
|
bool isCalledDirectly;
|
2018-02-15 02:27:59 +08:00
|
|
|
};
|
|
|
|
|
2019-05-21 17:13:09 +08:00
|
|
|
// Section symbols for output sections are different from those for input
|
|
|
|
// section. These are generated by the linker and point the OutputSection
|
|
|
|
// rather than an InputSection.
|
|
|
|
class OutputSectionSymbol : public Symbol {
|
|
|
|
public:
|
|
|
|
OutputSectionSymbol(const OutputSection *s)
|
|
|
|
: Symbol("", OutputSectionKind, llvm::wasm::WASM_SYMBOL_BINDING_LOCAL,
|
|
|
|
nullptr),
|
|
|
|
section(s) {}
|
|
|
|
|
|
|
|
static bool classof(const Symbol *s) {
|
|
|
|
return s->kind() == OutputSectionKind;
|
|
|
|
}
|
|
|
|
|
|
|
|
const OutputSection *section;
|
|
|
|
};
|
|
|
|
|
2018-05-05 07:14:42 +08:00
|
|
|
class SectionSymbol : public Symbol {
|
|
|
|
public:
|
2021-05-13 07:48:34 +08:00
|
|
|
SectionSymbol(uint32_t flags, const InputChunk *s, InputFile *f = nullptr)
|
2019-05-21 17:13:09 +08:00
|
|
|
: Symbol("", SectionKind, flags, f), section(s) {}
|
|
|
|
|
2018-05-05 07:14:42 +08:00
|
|
|
static bool classof(const Symbol *s) { return s->kind() == SectionKind; }
|
|
|
|
|
2019-05-21 17:13:09 +08:00
|
|
|
const OutputSectionSymbol *getOutputSectionSymbol() const;
|
2018-05-05 07:14:42 +08:00
|
|
|
|
2021-05-13 07:48:34 +08:00
|
|
|
const InputChunk *section;
|
2018-05-05 07:14:42 +08:00
|
|
|
};
|
|
|
|
|
2018-02-21 07:38:27 +08:00
|
|
|
class DataSymbol : public Symbol {
|
2018-02-15 02:27:59 +08:00
|
|
|
public:
|
|
|
|
static bool classof(const Symbol *s) {
|
2018-02-21 07:38:27 +08:00
|
|
|
return s->kind() == DefinedDataKind || s->kind() == UndefinedDataKind;
|
2018-02-15 02:27:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2018-02-21 07:38:27 +08:00
|
|
|
DataSymbol(StringRef name, Kind k, uint32_t flags, InputFile *f)
|
2018-02-21 01:45:38 +08:00
|
|
|
: Symbol(name, k, flags, f) {}
|
2018-02-15 02:27:59 +08:00
|
|
|
};
|
|
|
|
|
2018-02-21 07:38:27 +08:00
|
|
|
class DefinedData : public DataSymbol {
|
2018-02-15 02:27:59 +08:00
|
|
|
public:
|
2018-04-27 13:50:40 +08:00
|
|
|
// Constructor for regular data symbols originating from input files.
|
2021-05-15 07:25:04 +08:00
|
|
|
DefinedData(StringRef name, uint32_t flags, InputFile *f, InputChunk *segment,
|
|
|
|
uint64_t value, uint64_t size)
|
2018-02-21 07:38:27 +08:00
|
|
|
: DataSymbol(name, DefinedDataKind, flags, f), segment(segment),
|
2021-02-27 07:22:23 +08:00
|
|
|
value(value), size(size) {}
|
2018-02-15 02:27:59 +08:00
|
|
|
|
2018-02-23 13:08:53 +08:00
|
|
|
// Constructor for linker synthetic data symbols.
|
|
|
|
DefinedData(StringRef name, uint32_t flags)
|
|
|
|
: DataSymbol(name, DefinedDataKind, flags, nullptr) {}
|
2018-02-15 02:27:59 +08:00
|
|
|
|
2018-02-23 13:08:53 +08:00
|
|
|
static bool classof(const Symbol *s) { return s->kind() == DefinedDataKind; }
|
|
|
|
|
|
|
|
// Returns the output virtual address of a defined data symbol.
|
2021-05-11 23:58:13 +08:00
|
|
|
uint64_t getVA() const;
|
2021-02-27 07:22:23 +08:00
|
|
|
void setVA(uint64_t va);
|
2017-12-06 03:05:45 +08:00
|
|
|
|
2018-02-23 13:08:53 +08:00
|
|
|
// Returns the offset of a defined data symbol within its OutputSegment.
|
2020-06-06 00:03:12 +08:00
|
|
|
uint64_t getOutputSegmentOffset() const;
|
|
|
|
uint64_t getOutputSegmentIndex() const;
|
|
|
|
uint64_t getSize() const { return size; }
|
2018-02-23 13:08:53 +08:00
|
|
|
|
2021-05-15 07:25:04 +08:00
|
|
|
InputChunk *segment = nullptr;
|
2021-02-27 07:22:23 +08:00
|
|
|
uint64_t value = 0;
|
2018-02-21 01:45:38 +08:00
|
|
|
|
2018-02-15 02:27:59 +08:00
|
|
|
protected:
|
2020-06-06 00:03:12 +08:00
|
|
|
uint64_t size = 0;
|
2018-02-15 02:27:59 +08:00
|
|
|
};
|
|
|
|
|
2018-02-21 07:38:27 +08:00
|
|
|
class UndefinedData : public DataSymbol {
|
2018-02-15 02:27:59 +08:00
|
|
|
public:
|
2018-02-21 07:38:27 +08:00
|
|
|
UndefinedData(StringRef name, uint32_t flags, InputFile *file = nullptr)
|
|
|
|
: DataSymbol(name, UndefinedDataKind, flags, file) {}
|
2018-02-15 02:27:59 +08:00
|
|
|
static bool classof(const Symbol *s) {
|
2018-02-21 07:38:27 +08:00
|
|
|
return s->kind() == UndefinedDataKind;
|
2018-02-15 02:27:59 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-23 13:08:53 +08:00
|
|
|
class GlobalSymbol : public Symbol {
|
|
|
|
public:
|
|
|
|
static bool classof(const Symbol *s) {
|
|
|
|
return s->kind() == DefinedGlobalKind || s->kind() == UndefinedGlobalKind;
|
|
|
|
}
|
|
|
|
|
|
|
|
const WasmGlobalType *getGlobalType() const { return globalType; }
|
|
|
|
|
2018-03-13 03:56:23 +08:00
|
|
|
// Get/set the global index
|
|
|
|
uint32_t getGlobalIndex() const;
|
|
|
|
void setGlobalIndex(uint32_t index);
|
|
|
|
bool hasGlobalIndex() const;
|
|
|
|
|
2018-02-23 13:08:53 +08:00
|
|
|
protected:
|
|
|
|
GlobalSymbol(StringRef name, Kind k, uint32_t flags, InputFile *f,
|
|
|
|
const WasmGlobalType *globalType)
|
|
|
|
: Symbol(name, k, flags, f), globalType(globalType) {}
|
|
|
|
|
|
|
|
const WasmGlobalType *globalType;
|
2018-03-13 03:56:23 +08:00
|
|
|
uint32_t globalIndex = INVALID_INDEX;
|
2018-02-23 13:08:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DefinedGlobal : public GlobalSymbol {
|
|
|
|
public:
|
|
|
|
DefinedGlobal(StringRef name, uint32_t flags, InputFile *file,
|
|
|
|
InputGlobal *global);
|
|
|
|
|
|
|
|
static bool classof(const Symbol *s) {
|
|
|
|
return s->kind() == DefinedGlobalKind;
|
|
|
|
}
|
|
|
|
|
|
|
|
InputGlobal *global;
|
|
|
|
};
|
|
|
|
|
|
|
|
class UndefinedGlobal : public GlobalSymbol {
|
|
|
|
public:
|
2020-02-06 13:18:55 +08:00
|
|
|
UndefinedGlobal(StringRef name, llvm::Optional<StringRef> importName,
|
|
|
|
llvm::Optional<StringRef> importModule, uint32_t flags,
|
|
|
|
InputFile *file = nullptr,
|
2018-02-23 13:08:53 +08:00
|
|
|
const WasmGlobalType *type = nullptr)
|
2021-07-15 08:16:15 +08:00
|
|
|
: GlobalSymbol(name, UndefinedGlobalKind, flags, file, type) {
|
|
|
|
this->importName = importName;
|
|
|
|
this->importModule = importModule;
|
|
|
|
}
|
2019-07-11 13:40:30 +08:00
|
|
|
|
2018-02-23 13:08:53 +08:00
|
|
|
static bool classof(const Symbol *s) {
|
|
|
|
return s->kind() == UndefinedGlobalKind;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-05 19:08:58 +08:00
|
|
|
class TableSymbol : public Symbol {
|
|
|
|
public:
|
|
|
|
static bool classof(const Symbol *s) {
|
|
|
|
return s->kind() == DefinedTableKind || s->kind() == UndefinedTableKind;
|
|
|
|
}
|
|
|
|
|
|
|
|
const WasmTableType *getTableType() const { return tableType; }
|
|
|
|
void setLimits(const WasmLimits &limits);
|
|
|
|
|
|
|
|
// Get/set the table number
|
|
|
|
uint32_t getTableNumber() const;
|
|
|
|
void setTableNumber(uint32_t number);
|
|
|
|
bool hasTableNumber() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
TableSymbol(StringRef name, Kind k, uint32_t flags, InputFile *f,
|
|
|
|
const WasmTableType *type)
|
|
|
|
: Symbol(name, k, flags, f), tableType(type) {}
|
|
|
|
|
|
|
|
const WasmTableType *tableType;
|
|
|
|
uint32_t tableNumber = INVALID_INDEX;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DefinedTable : public TableSymbol {
|
|
|
|
public:
|
|
|
|
DefinedTable(StringRef name, uint32_t flags, InputFile *file,
|
|
|
|
InputTable *table);
|
|
|
|
|
|
|
|
static bool classof(const Symbol *s) { return s->kind() == DefinedTableKind; }
|
|
|
|
|
|
|
|
InputTable *table;
|
|
|
|
};
|
|
|
|
|
|
|
|
class UndefinedTable : public TableSymbol {
|
|
|
|
public:
|
|
|
|
UndefinedTable(StringRef name, llvm::Optional<StringRef> importName,
|
|
|
|
llvm::Optional<StringRef> importModule, uint32_t flags,
|
|
|
|
InputFile *file, const WasmTableType *type)
|
2021-07-15 08:16:15 +08:00
|
|
|
: TableSymbol(name, UndefinedTableKind, flags, file, type) {
|
|
|
|
this->importName = importName;
|
|
|
|
this->importModule = importModule;
|
|
|
|
}
|
2021-01-05 19:08:58 +08:00
|
|
|
|
|
|
|
static bool classof(const Symbol *s) {
|
|
|
|
return s->kind() == UndefinedTableKind;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-06-15 16:49:43 +08:00
|
|
|
// A tag is a general format to distinguish typed entities. Each tag has an
|
|
|
|
// attribute and a type. Currently the attribute can only specify that the tag
|
|
|
|
// is for an exception tag.
|
2018-12-08 14:17:43 +08:00
|
|
|
//
|
2021-06-15 16:49:43 +08:00
|
|
|
// In exception handling, tags are used to distinguish different kinds of
|
|
|
|
// exceptions. For example, they can be used to distinguish different language's
|
|
|
|
// exceptions, e.g., all C++ exceptions have the same tag and Java exceptions
|
|
|
|
// would have a distinct tag. Wasm can filter the exceptions it catches based on
|
|
|
|
// their tag.
|
2018-12-08 14:17:43 +08:00
|
|
|
//
|
2021-06-15 16:49:43 +08:00
|
|
|
// A single TagSymbol object represents a single tag. The C++ exception symbol
|
|
|
|
// is a weak symbol generated in every object file in which exceptions are used,
|
|
|
|
// and is named '__cpp_exception' for linking.
|
|
|
|
class TagSymbol : public Symbol {
|
2018-12-08 14:17:43 +08:00
|
|
|
public:
|
2021-06-15 16:49:43 +08:00
|
|
|
static bool classof(const Symbol *s) { return s->kind() == DefinedTagKind; }
|
2018-12-08 14:17:43 +08:00
|
|
|
|
2021-06-15 16:49:43 +08:00
|
|
|
// Get/set the tag index
|
|
|
|
uint32_t getTagIndex() const;
|
|
|
|
void setTagIndex(uint32_t index);
|
|
|
|
bool hasTagIndex() const;
|
2018-12-08 14:17:43 +08:00
|
|
|
|
|
|
|
const WasmSignature *signature;
|
|
|
|
|
|
|
|
protected:
|
2021-06-15 16:49:43 +08:00
|
|
|
TagSymbol(StringRef name, Kind k, uint32_t flags, InputFile *f,
|
[WebAssembly] Remove WasmTagType
This removes `WasmTagType`. `WasmTagType` contained an attribute and a
signature index:
```
struct WasmTagType {
uint8_t Attribute;
uint32_t SigIndex;
};
```
Currently the attribute field is not used and reserved for future use,
and always 0. And that this class contains `SigIndex` as its property is
a little weird in the place, because the tag type's signature index is
not an inherent property of a tag but rather a reference to another
section that changes after linking. This makes tag handling in the
linker also weird that tag-related methods are taking both `WasmTagType`
and `WasmSignature` even though `WasmTagType` contains a signature
index. This is because the signature index changes in linking so it
doesn't have any info at this point. This instead moves `SigIndex` to
`struct WasmTag` itself, as we did for `struct WasmFunction` in D111104.
In this CL, in lib/MC and lib/Object, this now treats tag types in the
same way as function types. Also in YAML, this removes `struct Tag`,
because now it only contains the tag index. Also tags set `SigIndex` in
`WasmImport` union, as functions do.
I think this makes things simpler and makes tag handling more in line
with function handling. These two shares similar properties in that both
of them have signatures, but they are kind of nominal so having the same
signature doesn't mean they are the same element.
Also a drive-by fix: the reserved 'attirubute' part's encoding changed
from uleb32 to uint8 a while ago. This was fixed in lib/MC and
lib/Object but not in YAML. This doesn't change object files because the
field's value is always 0 and its encoding is the same for the both
encoding.
This is effectively NFC; I didn't mark it as such just because it
changed YAML test results.
Reviewed By: sbc100, tlively
Differential Revision: https://reviews.llvm.org/D111086
2021-10-02 10:07:41 +08:00
|
|
|
const WasmSignature *sig)
|
|
|
|
: Symbol(name, k, flags, f), signature(sig) {}
|
2018-12-08 14:17:43 +08:00
|
|
|
|
2021-06-15 16:49:43 +08:00
|
|
|
uint32_t tagIndex = INVALID_INDEX;
|
2018-12-08 14:17:43 +08:00
|
|
|
};
|
|
|
|
|
2021-06-15 16:49:43 +08:00
|
|
|
class DefinedTag : public TagSymbol {
|
2018-12-08 14:17:43 +08:00
|
|
|
public:
|
2021-06-15 16:49:43 +08:00
|
|
|
DefinedTag(StringRef name, uint32_t flags, InputFile *file, InputTag *tag);
|
2018-12-08 14:17:43 +08:00
|
|
|
|
2021-06-15 16:49:43 +08:00
|
|
|
static bool classof(const Symbol *s) { return s->kind() == DefinedTagKind; }
|
2018-12-08 14:17:43 +08:00
|
|
|
|
2021-06-15 16:49:43 +08:00
|
|
|
InputTag *tag;
|
2018-12-08 14:17:43 +08:00
|
|
|
};
|
|
|
|
|
2019-01-30 06:26:31 +08:00
|
|
|
// LazySymbol represents a symbol that is not yet in the link, but we know where
|
|
|
|
// to find it if needed. If the resolver finds both Undefined and Lazy for the
|
|
|
|
// same name, it will ask the Lazy to load a file.
|
|
|
|
//
|
|
|
|
// A special complication is the handling of weak undefined symbols. They should
|
|
|
|
// not load a file, but we have to remember we have seen both the weak undefined
|
|
|
|
// and the lazy. We represent that with a lazy symbol with a weak binding. This
|
|
|
|
// means that code looking for undefined symbols normally also has to take lazy
|
|
|
|
// symbols into consideration.
|
2018-02-15 02:27:59 +08:00
|
|
|
class LazySymbol : public Symbol {
|
|
|
|
public:
|
2019-01-30 06:26:31 +08:00
|
|
|
LazySymbol(StringRef name, uint32_t flags, InputFile *file,
|
2018-11-27 09:08:16 +08:00
|
|
|
const llvm::object::Archive::Symbol &sym)
|
2019-01-30 06:26:31 +08:00
|
|
|
: Symbol(name, LazyKind, flags, file), archiveSymbol(sym) {}
|
2018-02-15 02:27:59 +08:00
|
|
|
|
|
|
|
static bool classof(const Symbol *s) { return s->kind() == LazyKind; }
|
2018-03-01 06:51:51 +08:00
|
|
|
void fetch();
|
2020-08-08 07:12:33 +08:00
|
|
|
void setWeak();
|
2019-12-20 09:23:59 +08:00
|
|
|
MemoryBufferRef getMemberBuffer();
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2019-01-30 06:26:31 +08:00
|
|
|
// Lazy symbols can have a signature because they can replace an
|
|
|
|
// UndefinedFunction which which case we need to be able to preserve the
|
2020-04-02 00:21:08 +08:00
|
|
|
// signature.
|
2019-01-30 06:26:31 +08:00
|
|
|
// TODO(sbc): This repetition of the signature field is inelegant. Revisit
|
|
|
|
// the use of class hierarchy to represent symbol taxonomy.
|
|
|
|
const WasmSignature *signature = nullptr;
|
|
|
|
|
2018-03-01 06:51:51 +08:00
|
|
|
private:
|
2018-11-27 09:08:16 +08:00
|
|
|
llvm::object::Archive::Symbol archiveSymbol;
|
2017-11-18 02:14:09 +08:00
|
|
|
};
|
|
|
|
|
2018-02-03 06:59:56 +08:00
|
|
|
// linker-generated symbols
|
|
|
|
struct WasmSym {
|
2019-06-27 04:12:33 +08:00
|
|
|
// __global_base
|
|
|
|
// Symbol marking the start of the global section.
|
|
|
|
static DefinedData *globalBase;
|
|
|
|
|
2018-02-03 06:59:56 +08:00
|
|
|
// __stack_pointer
|
2018-02-07 11:04:53 +08:00
|
|
|
// Global that holds the address of the top of the explicit value stack in
|
|
|
|
// linear memory.
|
2018-11-16 02:15:54 +08:00
|
|
|
static GlobalSymbol *stackPointer;
|
2018-02-03 06:59:56 +08:00
|
|
|
|
[WebAssembly] Implement thread-local storage (local-exec model)
Summary:
Thread local variables are placed inside a `.tdata` segment. Their symbols are
offsets from the start of the segment. The address of a thread local variable
is computed as `__tls_base` + the offset from the start of the segment.
`.tdata` segment is a passive segment and `memory.init` is used once per thread
to initialize the thread local storage.
`__tls_base` is a wasm global. Since each thread has its own wasm instance,
it is effectively thread local. Currently, `__tls_base` must be initialized
at thread startup, and so cannot be used with dynamic libraries.
`__tls_base` is to be initialized with a new linker-synthesized function,
`__wasm_init_tls`, which takes as an argument a block of memory to use as the
storage for thread locals. It then initializes the block of memory and sets
`__tls_base`. As `__wasm_init_tls` will handle the memory initialization,
the memory does not have to be zeroed.
To help allocating memory for thread-local storage, a new compiler intrinsic
is introduced: `__builtin_wasm_tls_size()`. This instrinsic function returns
the size of the thread-local storage for the current function.
The expected usage is to run something like the following upon thread startup:
__wasm_init_tls(malloc(__builtin_wasm_tls_size()));
Reviewers: tlively, aheejin, kripken, sbc100
Subscribers: dschuff, jgravelle-google, hiraditya, sunfish, jfb, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D64537
llvm-svn: 366272
2019-07-17 06:00:45 +08:00
|
|
|
// __tls_base
|
|
|
|
// Global that holds the address of the base of the current thread's
|
|
|
|
// TLS block.
|
|
|
|
static GlobalSymbol *tlsBase;
|
|
|
|
|
|
|
|
// __tls_size
|
|
|
|
// Symbol whose value is the size of the TLS block.
|
|
|
|
static GlobalSymbol *tlsSize;
|
|
|
|
|
[WebAssembly] Compute and export TLS block alignment
Summary:
Add immutable WASM global `__tls_align` which stores the alignment
requirements of the TLS segment.
Add `__builtin_wasm_tls_align()` intrinsic to get this alignment in Clang.
The expected usage has now changed to:
__wasm_init_tls(memalign(__builtin_wasm_tls_align(),
__builtin_wasm_tls_size()));
Reviewers: tlively, aheejin, sbc100, sunfish, alexcrichton
Reviewed By: tlively
Subscribers: dschuff, jgravelle-google, hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D65028
llvm-svn: 366624
2019-07-20 07:34:16 +08:00
|
|
|
// __tls_size
|
|
|
|
// Symbol whose value is the alignment of the TLS block.
|
|
|
|
static GlobalSymbol *tlsAlign;
|
|
|
|
|
2018-02-07 11:04:53 +08:00
|
|
|
// __data_end
|
|
|
|
// Symbol marking the end of the data and bss.
|
2018-02-21 07:38:27 +08:00
|
|
|
static DefinedData *dataEnd;
|
2018-02-07 11:04:53 +08:00
|
|
|
|
2018-02-03 06:59:56 +08:00
|
|
|
// __heap_base
|
2018-02-07 11:04:53 +08:00
|
|
|
// Symbol marking the end of the data, bss and explicit stack. Any linear
|
|
|
|
// memory following this address is not used by the linked code and can
|
|
|
|
// therefore be used as a backing store for brk()/malloc() implementations.
|
2018-02-21 07:38:27 +08:00
|
|
|
static DefinedData *heapBase;
|
2018-02-03 06:59:56 +08:00
|
|
|
|
2019-09-05 03:50:39 +08:00
|
|
|
// __wasm_init_memory_flag
|
|
|
|
// Symbol whose contents are nonzero iff memory has already been initialized.
|
|
|
|
static DefinedData *initMemoryFlag;
|
2018-02-03 06:59:56 +08:00
|
|
|
|
2019-07-04 06:04:54 +08:00
|
|
|
// __wasm_init_memory
|
2019-09-05 03:50:39 +08:00
|
|
|
// Function that initializes passive data segments during instantiation.
|
2019-07-04 06:04:54 +08:00
|
|
|
static DefinedFunction *initMemory;
|
|
|
|
|
2019-09-05 03:50:39 +08:00
|
|
|
// __wasm_call_ctors
|
|
|
|
// Function that directly calls all ctors in priority order.
|
|
|
|
static DefinedFunction *callCtors;
|
|
|
|
|
2020-10-01 08:21:57 +08:00
|
|
|
// __wasm_call_dtors
|
|
|
|
// Function that calls the libc/etc. cleanup function.
|
|
|
|
static DefinedFunction *callDtors;
|
|
|
|
|
2020-12-10 10:14:31 +08:00
|
|
|
// __wasm_apply_data_relocs
|
2019-04-05 02:40:51 +08:00
|
|
|
// Function that applies relocations to data segment post-instantiation.
|
2020-12-10 10:14:31 +08:00
|
|
|
static DefinedFunction *applyDataRelocs;
|
|
|
|
|
|
|
|
// __wasm_apply_global_relocs
|
2021-08-27 03:29:32 +08:00
|
|
|
// Function that applies relocations to wasm globals post-instantiation.
|
2020-12-10 10:14:31 +08:00
|
|
|
// Unlike __wasm_apply_data_relocs this needs to run on every thread.
|
|
|
|
static DefinedFunction *applyGlobalRelocs;
|
2019-04-05 02:40:51 +08:00
|
|
|
|
2021-08-27 03:29:32 +08:00
|
|
|
// __wasm_apply_global_tls_relocs
|
|
|
|
// Like applyGlobalRelocs but for globals that hold TLS addresess. These
|
|
|
|
// must be delayed until __wasm_init_tls.
|
|
|
|
static DefinedFunction *applyGlobalTLSRelocs;
|
|
|
|
|
[WebAssembly] Implement thread-local storage (local-exec model)
Summary:
Thread local variables are placed inside a `.tdata` segment. Their symbols are
offsets from the start of the segment. The address of a thread local variable
is computed as `__tls_base` + the offset from the start of the segment.
`.tdata` segment is a passive segment and `memory.init` is used once per thread
to initialize the thread local storage.
`__tls_base` is a wasm global. Since each thread has its own wasm instance,
it is effectively thread local. Currently, `__tls_base` must be initialized
at thread startup, and so cannot be used with dynamic libraries.
`__tls_base` is to be initialized with a new linker-synthesized function,
`__wasm_init_tls`, which takes as an argument a block of memory to use as the
storage for thread locals. It then initializes the block of memory and sets
`__tls_base`. As `__wasm_init_tls` will handle the memory initialization,
the memory does not have to be zeroed.
To help allocating memory for thread-local storage, a new compiler intrinsic
is introduced: `__builtin_wasm_tls_size()`. This instrinsic function returns
the size of the thread-local storage for the current function.
The expected usage is to run something like the following upon thread startup:
__wasm_init_tls(malloc(__builtin_wasm_tls_size()));
Reviewers: tlively, aheejin, kripken, sbc100
Subscribers: dschuff, jgravelle-google, hiraditya, sunfish, jfb, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D64537
llvm-svn: 366272
2019-07-17 06:00:45 +08:00
|
|
|
// __wasm_init_tls
|
|
|
|
// Function that allocates thread-local storage and initializes it.
|
|
|
|
static DefinedFunction *initTLS;
|
|
|
|
|
2020-12-10 10:14:31 +08:00
|
|
|
// Pointer to the function that is to be used in the start section.
|
|
|
|
// (normally an alias of initMemory, or applyGlobalRelocs).
|
|
|
|
static DefinedFunction *startFunction;
|
|
|
|
|
2018-02-03 06:59:56 +08:00
|
|
|
// __dso_handle
|
2018-02-21 07:38:27 +08:00
|
|
|
// Symbol used in calls to __cxa_atexit to determine current DLL
|
|
|
|
static DefinedData *dsoHandle;
|
2018-11-15 08:37:21 +08:00
|
|
|
|
|
|
|
// __table_base
|
|
|
|
// Used in PIC code for offset of indirect function table
|
2018-11-16 02:15:54 +08:00
|
|
|
static UndefinedGlobal *tableBase;
|
2019-08-14 01:02:02 +08:00
|
|
|
static DefinedData *definedTableBase;
|
2021-04-23 07:54:58 +08:00
|
|
|
// 32-bit copy in wasm64 to work around init expr limitations.
|
|
|
|
// These can potentially be removed again once we have
|
|
|
|
// https://github.com/WebAssembly/extended-const
|
|
|
|
static UndefinedGlobal *tableBase32;
|
|
|
|
static DefinedData *definedTableBase32;
|
2018-11-15 08:37:21 +08:00
|
|
|
|
|
|
|
// __memory_base
|
|
|
|
// Used in PIC code for offset of global data
|
2018-11-16 02:15:54 +08:00
|
|
|
static UndefinedGlobal *memoryBase;
|
2019-08-14 01:02:02 +08:00
|
|
|
static DefinedData *definedMemoryBase;
|
2021-01-14 17:15:56 +08:00
|
|
|
|
|
|
|
// __indirect_function_table
|
|
|
|
// Used as an address space for function pointers, with each function that is
|
|
|
|
// used as a function pointer being allocated a slot.
|
|
|
|
static TableSymbol *indirectFunctionTable;
|
2018-02-15 02:27:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// A buffer class that is large enough to hold any Symbol-derived
|
|
|
|
// object. We allocate memory using this class and instantiate a symbol
|
|
|
|
// using the placement new.
|
|
|
|
union SymbolUnion {
|
|
|
|
alignas(DefinedFunction) char a[sizeof(DefinedFunction)];
|
2018-02-21 07:38:27 +08:00
|
|
|
alignas(DefinedData) char b[sizeof(DefinedData)];
|
2018-02-23 13:08:53 +08:00
|
|
|
alignas(DefinedGlobal) char c[sizeof(DefinedGlobal)];
|
2021-06-15 16:49:43 +08:00
|
|
|
alignas(DefinedTag) char d[sizeof(DefinedTag)];
|
2021-01-05 19:08:58 +08:00
|
|
|
alignas(DefinedTable) char e[sizeof(DefinedTable)];
|
|
|
|
alignas(LazySymbol) char f[sizeof(LazySymbol)];
|
|
|
|
alignas(UndefinedFunction) char g[sizeof(UndefinedFunction)];
|
|
|
|
alignas(UndefinedData) char h[sizeof(UndefinedData)];
|
|
|
|
alignas(UndefinedGlobal) char i[sizeof(UndefinedGlobal)];
|
|
|
|
alignas(UndefinedTable) char j[sizeof(UndefinedTable)];
|
|
|
|
alignas(SectionSymbol) char k[sizeof(SectionSymbol)];
|
2018-02-03 06:59:56 +08:00
|
|
|
};
|
|
|
|
|
2019-07-08 15:30:07 +08:00
|
|
|
// It is important to keep the size of SymbolUnion small for performance and
|
|
|
|
// memory usage reasons. 96 bytes is a soft limit based on the size of
|
|
|
|
// UndefinedFunction on a 64-bit system.
|
2020-05-02 00:14:59 +08:00
|
|
|
static_assert(sizeof(SymbolUnion) <= 120, "SymbolUnion too large");
|
2019-07-08 15:30:07 +08:00
|
|
|
|
2019-02-06 10:35:18 +08:00
|
|
|
void printTraceSymbol(Symbol *sym);
|
2019-05-24 21:29:17 +08:00
|
|
|
void printTraceSymbolUndefined(StringRef name, const InputFile* file);
|
2019-02-06 10:35:18 +08:00
|
|
|
|
2018-02-15 02:27:59 +08:00
|
|
|
template <typename T, typename... ArgT>
|
|
|
|
T *replaceSymbol(Symbol *s, ArgT &&... arg) {
|
2018-02-15 06:55:38 +08:00
|
|
|
static_assert(std::is_trivially_destructible<T>(),
|
|
|
|
"Symbol types must be trivially destructible");
|
2018-11-20 07:31:28 +08:00
|
|
|
static_assert(sizeof(T) <= sizeof(SymbolUnion), "SymbolUnion too small");
|
2018-02-15 02:27:59 +08:00
|
|
|
static_assert(alignof(T) <= alignof(SymbolUnion),
|
|
|
|
"SymbolUnion not aligned enough");
|
2018-02-15 06:43:43 +08:00
|
|
|
assert(static_cast<Symbol *>(static_cast<T *>(nullptr)) == nullptr &&
|
|
|
|
"Not a Symbol");
|
2018-05-31 02:07:52 +08:00
|
|
|
|
|
|
|
Symbol symCopy = *s;
|
|
|
|
|
|
|
|
T *s2 = new (s) T(std::forward<ArgT>(arg)...);
|
|
|
|
s2->isUsedInRegularObj = symCopy.isUsedInRegularObj;
|
2018-06-29 01:21:46 +08:00
|
|
|
s2->forceExport = symCopy.forceExport;
|
2019-05-24 22:14:25 +08:00
|
|
|
s2->canInline = symCopy.canInline;
|
2019-02-06 10:35:18 +08:00
|
|
|
s2->traced = symCopy.traced;
|
|
|
|
|
|
|
|
// Print out a log message if --trace-symbol was specified.
|
|
|
|
// This is for debugging.
|
|
|
|
if (s2->traced)
|
|
|
|
printTraceSymbol(s2);
|
|
|
|
|
2018-05-31 02:07:52 +08:00
|
|
|
return s2;
|
2018-02-15 02:27:59 +08:00
|
|
|
}
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
} // namespace wasm
|
|
|
|
|
|
|
|
// Returns a symbol name for an error message.
|
2018-03-10 06:59:34 +08:00
|
|
|
std::string toString(const wasm::Symbol &sym);
|
2017-12-06 00:50:46 +08:00
|
|
|
std::string toString(wasm::Symbol::Kind kind);
|
2018-11-10 00:57:41 +08:00
|
|
|
std::string maybeDemangleSymbol(StringRef name);
|
2017-11-18 02:14:09 +08:00
|
|
|
|
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|