mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 07:01:03 +08:00
[lld][WebAssembly] Fix handling of comdat functions in init array.
When hidden symbols are discarded by comdat rules we still want to create a local defined symbol, otherwise `Symbol::isDiscarded()` relies on begin able to check `getChunk->discarded`. This is a followup on rL362769. The comdat.ll test was previously GC'ing the `__wasm_call_ctors` functions so `do_init` was not actually being included in the link. Once that function was included in triggered the crash bug that this change addresses. Fixes: https://github.com/emscripten-core/emscripten/issues/8981 Differential Revision: https://reviews.llvm.org/D64872 llvm-svn: 366358
This commit is contained in:
@@ -380,22 +380,20 @@ Symbol *ObjFile::createDefined(const WasmSymbol &sym) {
|
||||
case WASM_SYMBOL_TYPE_FUNCTION: {
|
||||
InputFunction *func =
|
||||
functions[sym.Info.ElementIndex - wasmObj->getNumImportedFunctions()];
|
||||
if (func->discarded)
|
||||
return nullptr;
|
||||
if (sym.isBindingLocal())
|
||||
return make<DefinedFunction>(name, flags, this, func);
|
||||
if (func->discarded)
|
||||
return nullptr;
|
||||
return symtab->addDefinedFunction(name, flags, this, func);
|
||||
}
|
||||
case WASM_SYMBOL_TYPE_DATA: {
|
||||
InputSegment *seg = segments[sym.Info.DataRef.Segment];
|
||||
if (seg->discarded)
|
||||
return nullptr;
|
||||
|
||||
uint32_t offset = sym.Info.DataRef.Offset;
|
||||
uint32_t size = sym.Info.DataRef.Size;
|
||||
|
||||
if (sym.isBindingLocal())
|
||||
return make<DefinedData>(name, flags, this, seg, offset, size);
|
||||
if (seg->discarded)
|
||||
return nullptr;
|
||||
return symtab->addDefinedData(name, flags, this, seg, offset, size);
|
||||
}
|
||||
case WASM_SYMBOL_TYPE_GLOBAL: {
|
||||
|
||||
Reference in New Issue
Block a user