[lld] r320426 - [WebAssembly] Preserve ordering of global symbols
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 13:52:22 PST 2017
Author: sbc
Date: Mon Dec 11 13:52:21 2017
New Revision: 320426
URL: http://llvm.org/viewvc/llvm-project?rev=320426&view=rev
Log:
[WebAssembly] Preserve ordering of global symbols
This change restores the behavior that global indexes
are assigned in object file order. This was accidentally
changed in https://reviews.llvm.org/D40859.
Differential Revision: https://reviews.llvm.org/D41038
Modified:
lld/trunk/test/wasm/data-layout.ll
lld/trunk/wasm/Writer.cpp
Modified: lld/trunk/test/wasm/data-layout.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/data-layout.ll?rev=320426&r1=320425&r2=320426&view=diff
==============================================================================
--- lld/trunk/test/wasm/data-layout.ll (original)
+++ lld/trunk/test/wasm/data-layout.ll Mon Dec 11 13:52:21 2017
@@ -20,27 +20,27 @@
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1052
+; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: I32
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1024
+; CHECK-NEXT: Value: 1040
; CHECK-NEXT: - Type: I32
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1040
+; CHECK-NEXT: Value: 1048
; CHECK-NEXT: - Type: I32
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1048
+; CHECK-NEXT: Value: 1052
; CHECK: - Type: DATA
; CHECK-NEXT: Relocations:
; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
-; CHECK-NEXT: Index: 1
+; CHECK-NEXT: Index: 4
; CHECK-NEXT: Offset: 0x0000001F
; CHECK-NEXT: Segments:
; CHECK-NEXT: - SectionOffset: 7
Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=320426&r1=320425&r2=320426&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Mon Dec 11 13:52:21 2017
@@ -614,15 +614,13 @@ void Writer::assignSymbolIndexes() {
for (ObjFile *File : Symtab->ObjectFiles) {
DEBUG(dbgs() << "assignSymbolIndexes: " << File->getName() << "\n");
for (Symbol *Sym : File->getSymbols()) {
- if (Sym->hasOutputIndex() || !Sym->isDefined())
+ // Assign indexes for symbols defined with this file.
+ if (!Sym->isDefined() || File != Sym->getFile())
continue;
-
if (Sym->isFunction()) {
- if (Sym->getFile() && isa<ObjFile>(Sym->getFile())) {
- auto *Obj = cast<ObjFile>(Sym->getFile());
- Sym->setOutputIndex(Obj->FunctionIndexOffset +
- Sym->getFunctionIndex());
- }
+ auto *Obj = cast<ObjFile>(Sym->getFile());
+ Sym->setOutputIndex(Obj->FunctionIndexOffset +
+ Sym->getFunctionIndex());
} else if (Config->EmitRelocs) {
DefinedGlobals.emplace_back(Sym);
Sym->setOutputIndex(GlobalIndex++);
More information about the llvm-commits
mailing list