[PATCH] D41473: [WebAssmebly] Fix references to weak aliasesCorresponding LLVM change: https://reviews.llvm.org/D41472
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 20 17:38:27 PST 2017
sbc100 created this revision.
Herald added subscribers: llvm-commits, aheejin.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D41473
Files:
test/wasm/weak-alias-overide.ll
wasm/InputFiles.cpp
wasm/SymbolTable.cpp
Index: wasm/SymbolTable.cpp
===================================================================
--- wasm/SymbolTable.cpp
+++ wasm/SymbolTable.cpp
@@ -83,15 +83,7 @@
const WasmSymbol &Sym) {
DEBUG(dbgs() << "getFunctionSig: " << Sym.Name << "\n");
const WasmObjectFile *WasmObj = Obj.getWasmObj();
- uint32_t FunctionType;
- if (Obj.isImportedFunction(Sym.ElementIndex)) {
- const WasmImport &Import = WasmObj->imports()[Sym.ImportIndex];
- FunctionType = Import.SigIndex;
- } else {
- uint32_t FunctionIndex = Sym.ElementIndex - Obj.NumFunctionImports();
- FunctionType = WasmObj->functionTypes()[FunctionIndex];
- }
- return &WasmObj->types()[FunctionType];
+ return &WasmObj->types()[Sym.FunctionType];
}
// Check the type of new symbol matches that of the symbol is replacing.
Index: wasm/InputFiles.cpp
===================================================================
--- wasm/InputFiles.cpp
+++ wasm/InputFiles.cpp
@@ -198,13 +198,22 @@
DEBUG(dbgs() << "Function: " << WasmSym.ElementIndex << " -> "
<< toString(*S) << "\n");
FunctionSymbols[WasmSym.ElementIndex] = S;
+ if (WasmSym.HasAltIndex)
+ FunctionSymbols[WasmSym.AltIndex] = S;
} else {
DEBUG(dbgs() << "Global: " << WasmSym.ElementIndex << " -> "
<< toString(*S) << "\n");
GlobalSymbols[WasmSym.ElementIndex] = S;
+ if (WasmSym.HasAltIndex)
+ GlobalSymbols[WasmSym.AltIndex] = S;
}
}
+ DEBUG(for (size_t I = 0; I < FunctionSymbols.size(); ++I)
+ assert(FunctionSymbols[I] != nullptr);
+ for (size_t I = 0; I < GlobalSymbols.size(); ++I)
+ assert(GlobalSymbols[I] != nullptr););
+
// Populate `TableSymbols` with all symbols that are called indirectly
uint32_t SegmentCount = WasmObj->elements().size();
if (SegmentCount) {
Index: test/wasm/weak-alias-overide.ll
===================================================================
--- test/wasm/weak-alias-overide.ll
+++ test/wasm/weak-alias-overide.ll
@@ -79,7 +79,7 @@
; CHECK-NEXT: - Offset:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1
-; CHECK-NEXT: Functions: [ 0 ]
+; CHECK-NEXT: Functions: [ 2 ]
; CHECK-NEXT: - Type: CODE
; CHECK-NEXT: Functions:
; CHECK-NEXT: - Locals:
@@ -89,15 +89,15 @@
; CHECK-NEXT: - Locals:
; CHECK-NEXT: Body: 41000B
; CHECK-NEXT: - Locals:
-; CHECK-NEXT: Body: 1080808080000B
+; CHECK-NEXT: Body: 1082808080000B
; CHECK-NEXT: - Locals:
; CHECK-NEXT: Body: 1080808080000B
; CHECK-NEXT: - Locals:
; CHECK-NEXT: Body: 41010B
; CHECK-NEXT: - Locals:
; CHECK-NEXT: - Type: I32
; CHECK-NEXT: Count: 2
-; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081080808080002101200041106A24808080800020010B
+; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081082808080002101200041106A24808080800020010B
; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41473.127810.patch
Type: text/x-patch
Size: 3392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171221/a603782a/attachment.bin>
More information about the llvm-commits
mailing list