Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lld/wasm/Symbols.h
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | public: | ||||
void setHidden(bool isHidden); | void setHidden(bool isHidden); | ||||
// Get/set the index in the output symbol table. This is only used for | // Get/set the index in the output symbol table. This is only used for | ||||
// relocatable output. | // relocatable output. | ||||
uint32_t getOutputSymbolIndex() const; | uint32_t getOutputSymbolIndex() const; | ||||
void setOutputSymbolIndex(uint32_t index); | void setOutputSymbolIndex(uint32_t index); | ||||
WasmSymbolType getWasmType() const; | WasmSymbolType getWasmType() const; | ||||
bool isImported() const; | |||||
bool isExported() const; | bool isExported() const; | ||||
bool isExportedExplicit() const; | bool isExportedExplicit() const; | ||||
// Indicates that the symbol is used in an __attribute__((used)) directive | // Indicates that the symbol is used in an __attribute__((used)) directive | ||||
// or similar. | // or similar. | ||||
bool isNoStrip() const; | bool isNoStrip() const; | ||||
const WasmSignature* getSignature() const; | const WasmSignature* getSignature() const; | ||||
uint32_t getGOTIndex() const { | uint32_t getGOTIndex() const { | ||||
assert(gotIndex != INVALID_INDEX); | assert(gotIndex != INVALID_INDEX); | ||||
return gotIndex; | return gotIndex; | ||||
} | } | ||||
void setGOTIndex(uint32_t index); | void setGOTIndex(uint32_t index); | ||||
bool hasGOTIndex() const { return gotIndex != INVALID_INDEX; } | bool hasGOTIndex() const { return gotIndex != INVALID_INDEX; } | ||||
protected: | protected: | ||||
Symbol(StringRef name, Kind k, uint32_t flags, InputFile *f) | Symbol(StringRef name, Kind k, uint32_t flags, InputFile *f) | ||||
: name(name), file(f), symbolKind(k), referenced(!config->gcSections), | : name(name), file(f), symbolKind(k), referenced(!config->gcSections), | ||||
requiresGOT(false), isUsedInRegularObj(false), forceExport(false), | requiresGOT(false), isUsedInRegularObj(false), forceExport(false), | ||||
canInline(false), traced(false), isStub(false), flags(flags) {} | forceImport(false), canInline(false), traced(false), isStub(false), | ||||
flags(flags) {} | |||||
StringRef name; | StringRef name; | ||||
InputFile *file; | InputFile *file; | ||||
uint32_t outputSymbolIndex = INVALID_INDEX; | uint32_t outputSymbolIndex = INVALID_INDEX; | ||||
uint32_t gotIndex = INVALID_INDEX; | uint32_t gotIndex = INVALID_INDEX; | ||||
Kind symbolKind; | Kind symbolKind; | ||||
public: | public: | ||||
bool referenced : 1; | bool referenced : 1; | ||||
// True for data symbols that needs a dummy GOT entry. Used for static | // True for data symbols that needs a dummy GOT entry. Used for static | ||||
// linking of GOT accesses. | // linking of GOT accesses. | ||||
bool requiresGOT : 1; | bool requiresGOT : 1; | ||||
// True if the symbol was used for linking and thus need to be added to the | // 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 | // output file's symbol table. This is true for all symbols except for | ||||
// unreferenced DSO symbols, lazy (archive) symbols, and bitcode symbols that | // unreferenced DSO symbols, lazy (archive) symbols, and bitcode symbols that | ||||
// are unreferenced except by other bitcode objects. | // are unreferenced except by other bitcode objects. | ||||
bool isUsedInRegularObj : 1; | bool isUsedInRegularObj : 1; | ||||
// True if this symbol is explicitly marked for export (i.e. via the | // True if this symbol is explicitly marked for export (i.e. via the | ||||
// -e/--export command line flag) | // -e/--export command line flag) | ||||
bool forceExport : 1; | bool forceExport : 1; | ||||
bool forceImport : 1; | |||||
// False if LTO shouldn't inline whatever this symbol points to. If a symbol | // 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 | // is overwritten after LTO, LTO shouldn't inline the symbol because it | ||||
// doesn't know the final contents of the symbol. | // doesn't know the final contents of the symbol. | ||||
bool canInline : 1; | bool canInline : 1; | ||||
// True if this symbol is specified by --trace-symbol option. | // True if this symbol is specified by --trace-symbol option. | ||||
bool traced : 1; | bool traced : 1; | ||||
▲ Show 20 Lines • Show All 485 Lines • ▼ Show 20 Lines | T *replaceSymbol(Symbol *s, ArgT &&... arg) { | ||||
assert(static_cast<Symbol *>(static_cast<T *>(nullptr)) == nullptr && | assert(static_cast<Symbol *>(static_cast<T *>(nullptr)) == nullptr && | ||||
"Not a Symbol"); | "Not a Symbol"); | ||||
Symbol symCopy = *s; | Symbol symCopy = *s; | ||||
T *s2 = new (s) T(std::forward<ArgT>(arg)...); | T *s2 = new (s) T(std::forward<ArgT>(arg)...); | ||||
s2->isUsedInRegularObj = symCopy.isUsedInRegularObj; | s2->isUsedInRegularObj = symCopy.isUsedInRegularObj; | ||||
s2->forceExport = symCopy.forceExport; | s2->forceExport = symCopy.forceExport; | ||||
s2->forceImport = symCopy.forceImport; | |||||
s2->canInline = symCopy.canInline; | s2->canInline = symCopy.canInline; | ||||
s2->traced = symCopy.traced; | s2->traced = symCopy.traced; | ||||
s2->referenced = symCopy.referenced; | s2->referenced = symCopy.referenced; | ||||
// Print out a log message if --trace-symbol was specified. | // Print out a log message if --trace-symbol was specified. | ||||
// This is for debugging. | // This is for debugging. | ||||
if (s2->traced) | if (s2->traced) | ||||
printTraceSymbol(s2); | printTraceSymbol(s2); | ||||
Show All 14 Lines |