[PATCH] D67729: [lld][WebAssembly] Preserve symbol flags in --relocatable output
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 12:34:02 PDT 2019
sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D67729
Files:
lld/wasm/Driver.cpp
lld/wasm/InputFiles.cpp
lld/wasm/SymbolTable.cpp
Index: lld/wasm/SymbolTable.cpp
===================================================================
--- lld/wasm/SymbolTable.cpp
+++ lld/wasm/SymbolTable.cpp
@@ -401,6 +401,7 @@
LLVM_DEBUG(dbgs() << "addUndefinedFunction: " << name << " ["
<< (sig ? toString(*sig) : "none")
<< "] IsCalledDirectly:" << isCalledDirectly << "\n");
+ assert(flags && WASM_SYMBOL_UNDEFINED);
Symbol *s;
bool wasInserted;
@@ -443,6 +444,7 @@
Symbol *SymbolTable::addUndefinedData(StringRef name, uint32_t flags,
InputFile *file) {
LLVM_DEBUG(dbgs() << "addUndefinedData: " << name << "\n");
+ assert(flags && WASM_SYMBOL_UNDEFINED);
Symbol *s;
bool wasInserted;
@@ -464,6 +466,7 @@
InputFile *file,
const WasmGlobalType *type) {
LLVM_DEBUG(dbgs() << "addUndefinedGlobal: " << name << "\n");
+ assert(flags && WASM_SYMBOL_UNDEFINED);
Symbol *s;
bool wasInserted;
Index: lld/wasm/InputFiles.cpp
===================================================================
--- lld/wasm/InputFiles.cpp
+++ lld/wasm/InputFiles.cpp
@@ -421,7 +421,7 @@
Symbol *ObjFile::createUndefined(const WasmSymbol &sym, bool isCalledDirectly) {
StringRef name = sym.Info.Name;
- uint32_t flags = sym.Info.Flags;
+ uint32_t flags = sym.Info.Flags | WASM_SYMBOL_UNDEFINED;
switch (sym.Info.Kind) {
case WASM_SYMBOL_TYPE_FUNCTION:
@@ -509,6 +509,7 @@
bool excludedByComdat = c != -1 && !keptComdats[c];
if (objSym.isUndefined() || excludedByComdat) {
+ flags |= WASM_SYMBOL_UNDEFINED;
if (objSym.isExecutable())
return symtab->addUndefinedFunction(name, name, defaultModule, flags, &f,
nullptr, true);
Index: lld/wasm/Driver.cpp
===================================================================
--- lld/wasm/Driver.cpp
+++ lld/wasm/Driver.cpp
@@ -441,10 +441,8 @@
static UndefinedGlobal *
createUndefinedGlobal(StringRef name, llvm::wasm::WasmGlobalType *type) {
- auto *sym =
- cast<UndefinedGlobal>(symtab->addUndefinedGlobal(name, name,
- defaultModule, 0,
- nullptr, type));
+ auto *sym = cast<UndefinedGlobal>(symtab->addUndefinedGlobal(
+ name, name, defaultModule, WASM_SYMBOL_UNDEFINED, nullptr, type));
config->allowUndefinedSymbols.insert(sym->getName());
sym->isUsedInRegularObj = true;
return sym;
@@ -582,7 +580,8 @@
};
static Symbol *addUndefined(StringRef name) {
- return symtab->addUndefinedFunction(name, "", "", 0, nullptr, nullptr, false);
+ return symtab->addUndefinedFunction(name, "", "", WASM_SYMBOL_UNDEFINED,
+ nullptr, nullptr, false);
}
// Handles -wrap option.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67729.220729.patch
Type: text/x-patch
Size: 2903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190918/67025ddf/attachment-0001.bin>
More information about the llvm-commits
mailing list