forked from OSchip/llvm-project
[WebAssembly] fix bug in finding .tdata segment
Summary: Fix bug in `wasm-ld`'s `Writer::createInitTLSFunction` that only finds `.tdata` if it's the first section. Reviewers: tlively, aheejin, sbc100 Reviewed By: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64947 llvm-svn: 366500
This commit is contained in:
parent
df4479200b
commit
21aafc2e0c
|
@ -2,8 +2,8 @@
|
|||
|
||||
target triple = "wasm32-unknown-unknown"
|
||||
|
||||
@tls1 = thread_local(localexec) global i32 1, align 4
|
||||
@no_tls = global i32 0, align 4
|
||||
@tls1 = thread_local(localexec) global i32 1, align 4
|
||||
@tls2 = thread_local(localexec) global i32 1, align 4
|
||||
|
||||
define i32* @tls1_addr() {
|
||||
|
@ -49,7 +49,7 @@ define i32* @tls2_addr() {
|
|||
; CHECK-NEXT: Body: 0B
|
||||
; CHECK-NEXT: - Index: 1
|
||||
; CHECK-NEXT: Locals: []
|
||||
; CHECK-NEXT: Body: 20002401200041004108FC0800000B
|
||||
; CHECK-NEXT: Body: 20002401200041004108FC0801000B
|
||||
|
||||
; Expected body of __wasm_init_tls:
|
||||
; local.get 0
|
||||
|
@ -57,7 +57,7 @@ define i32* @tls2_addr() {
|
|||
; local.get 0
|
||||
; i32.const 0
|
||||
; i32.const 8
|
||||
; memory.init 0, 0
|
||||
; memory.init 1, 0
|
||||
; end
|
||||
|
||||
; CHECK-NEXT: - Index: 2
|
||||
|
|
|
@ -771,9 +771,10 @@ void Writer::createInitTLSFunction() {
|
|||
|
||||
OutputSegment *tlsSeg = nullptr;
|
||||
for (auto *seg : segments) {
|
||||
if (seg->name == ".tdata")
|
||||
if (seg->name == ".tdata") {
|
||||
tlsSeg = seg;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
writeUleb128(os, 0, "num locals");
|
||||
|
|
Loading…
Reference in New Issue