[Object][Wasm] Move WasmSymbolInfo directly into WasmSymbol (NFC) (#80219)
Move the WasmSymbolInfos from their own vector on the WasmLinkingData
directly into the WasmSymbol object. Removing the const-ref to an
external object allows the vector of WasmSymbols to be safely
expanded/reallocated; generating symbol info from the name section will
require this, as the numbers of function and data segment names are
stored separately.
This is a step toward generating symbol information from name sections
for #76107
GitOrigin-RevId: ef1f999e13bd58394bc1099c87a470d91682153d
diff --git a/wasm/InputFiles.cpp b/wasm/InputFiles.cpp
index f43c39b..473208a 100644
--- a/wasm/InputFiles.cpp
+++ b/wasm/InputFiles.cpp
@@ -15,6 +15,7 @@
#include "lld/Common/Args.h"
#include "lld/Common/CommonLinkerContext.h"
#include "lld/Common/Reproduce.h"
+#include "llvm/BinaryFormat/Wasm.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/Wasm.h"
#include "llvm/Support/Path.h"
@@ -322,20 +323,19 @@
return;
}
- auto *info = make<WasmSymbolInfo>();
- info->Name = tableImport->Field;
- info->Kind = WASM_SYMBOL_TYPE_TABLE;
- info->ImportModule = tableImport->Module;
- info->ImportName = tableImport->Field;
- info->Flags = WASM_SYMBOL_UNDEFINED;
- info->Flags |= WASM_SYMBOL_NO_STRIP;
- info->ElementIndex = 0;
- LLVM_DEBUG(dbgs() << "Synthesizing symbol for table import: " << info->Name
+ WasmSymbolInfo info;
+ info.Name = tableImport->Field;
+ info.Kind = WASM_SYMBOL_TYPE_TABLE;
+ info.ImportModule = tableImport->Module;
+ info.ImportName = tableImport->Field;
+ info.Flags = WASM_SYMBOL_UNDEFINED | WASM_SYMBOL_NO_STRIP;
+ info.ElementIndex = 0;
+ LLVM_DEBUG(dbgs() << "Synthesizing symbol for table import: " << info.Name
<< "\n");
const WasmGlobalType *globalType = nullptr;
const WasmSignature *signature = nullptr;
auto *wasmSym =
- make<WasmSymbol>(*info, globalType, &tableImport->Table, signature);
+ make<WasmSymbol>(info, globalType, &tableImport->Table, signature);
Symbol *sym = createUndefined(*wasmSym, false);
// We're only sure it's a TableSymbol if the createUndefined succeeded.
if (errorCount())