Skip to content

Commit ef182d5

Browse files
committed
[WebAssembly] Backport custom import name changes for lld to 8.0.
Specifically, this backports r352645, r352828, and r353473 to the 8.0 branch. The trunk patches don't apply cleanly to 8.0 due to some contemporaneous mass-rename and mass-clang-tidy patches, so this merges them to simplify rebasing. r352645 [WebAssembly] Fix crash with LTO + relocatable + undefined symbols r352828 [WebAssembly] Support imports from custom module names r353473 [WebAssembly] Fix imported function symbol names that differ from their import names in the .o format By Dan Gohman! llvm-svn: 353833
1 parent 33e2530 commit ef182d5

18 files changed

+332
-198
lines changed

lld/test/wasm/data-layout.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ target triple = "wasm32-unknown-unknown"
8585
; RELOC: - Type: DATA
8686
; RELOC-NEXT: Relocations:
8787
; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
88-
; RELOC-NEXT: Index: 6
88+
; RELOC-NEXT: Index: 3
8989
; RELOC-NEXT: Offset: 0x00000018
9090
; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
91-
; RELOC-NEXT: Index: 3
91+
; RELOC-NEXT: Index: 4
9292
; RELOC-NEXT: Offset: 0x0000002E
9393
; RELOC-NEXT: Addend: 4
9494
; RELOC-NEXT: Segments:
@@ -148,7 +148,7 @@ target triple = "wasm32-unknown-unknown"
148148
; RELOC-NEXT: Flags: [ ]
149149
; RELOC-NEXT: Segment: 2
150150
; RELOC-NEXT: Size: 4
151-
; RELOC: - Index: 6
151+
; RELOC-NEXT: - Index: 3
152152
; RELOC-NEXT: Kind: DATA
153153
; RELOC-NEXT: Name: hello_str
154154
; RELOC-NEXT: Flags: [ ]

lld/test/wasm/import-module.ll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; RUN: llc -filetype=obj %s -o %t.o
2+
; RUN: wasm-ld --allow-undefined -o %t.wasm %t.o
3+
; RUN: obj2yaml %t.wasm | FileCheck %s
4+
5+
target triple = "wasm32-unknown-unknown-wasm"
6+
7+
define void @_start() {
8+
call void @foo();
9+
ret void
10+
}
11+
12+
declare void @foo() #0
13+
14+
attributes #0 = { "wasm-import-module"="bar" }
15+
16+
; CHECK: - Type: IMPORT
17+
; CHECK-NEXT: Imports:
18+
; CHECK-NEXT: - Module: bar
19+
; CHECK-NEXT: Field: foo
20+
; CHECK-NEXT: Kind: FUNCTION
21+
; CHECK-NEXT: SigIndex: 0

lld/test/wasm/import-names.ll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; RUN: llc -filetype=obj %s -o %t.o
2+
; RUN: wasm-ld --allow-undefined -o %t.wasm %t.o
3+
; RUN: obj2yaml %t.wasm | FileCheck %s
4+
5+
target triple = "wasm32-unknown-unknown"
6+
7+
declare void @f0() #0
8+
9+
define void @_start() {
10+
call void @f0()
11+
ret void
12+
}
13+
14+
attributes #0 = { "wasm-import-module"="somewhere" "wasm-import-name"="something" }
15+
16+
; CHECK: - Type: IMPORT
17+
; CHECK-NEXT: Imports:
18+
; CHECK-NEXT: - Module: somewhere
19+
; CHECK-NEXT: Field: something
20+
; CHECK-NEXT: Kind: FUNCTION
21+
; CHECK-NEXT: SigIndex: 0
22+
23+
; CHECK: - Type: CUSTOM
24+
; CHECK-NEXT: Name: name
25+
; CHECK-NEXT: FunctionNames:
26+
; CHECK-NEXT: - Index: 0
27+
; CHECK-NEXT: Name: f0

lld/test/wasm/init-fini.ll

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -163,64 +163,64 @@ entry:
163163
; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ]
164164
; RELOC-NEXT: Function: 7
165165
; RELOC-NEXT: - Index: 6
166+
; RELOC-NEXT: Kind: DATA
167+
; RELOC-NEXT: Name: __dso_handle
168+
; RELOC-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN, UNDEFINED ]
169+
; RELOC-NEXT: - Index: 7
170+
; RELOC-NEXT: Kind: FUNCTION
171+
; RELOC-NEXT: Name: externDtor
172+
; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN, UNDEFINED ]
173+
; RELOC-NEXT: Function: 0
174+
; RELOC-NEXT: - Index: 8
175+
; RELOC-NEXT: Kind: FUNCTION
176+
; RELOC-NEXT: Name: externCtor
177+
; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN, UNDEFINED ]
178+
; RELOC-NEXT: Function: 1
179+
; RELOC-NEXT: - Index: 9
180+
; RELOC-NEXT: Kind: FUNCTION
181+
; RELOC-NEXT: Name: myctor
182+
; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ]
183+
; RELOC-NEXT: Function: 14
184+
; RELOC-NEXT: - Index: 10
185+
; RELOC-NEXT: Kind: FUNCTION
186+
; RELOC-NEXT: Name: mydtor
187+
; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ]
188+
; RELOC-NEXT: Function: 15
189+
; RELOC-NEXT: - Index: 11
190+
; RELOC-NEXT: Kind: GLOBAL
191+
; RELOC-NEXT: Name: __stack_pointer
192+
; RELOC-NEXT: Flags: [ UNDEFINED ]
193+
; RELOC-NEXT: Global: 0
194+
; RELOC-NEXT: - Index: 12
166195
; RELOC-NEXT: Kind: FUNCTION
167196
; RELOC-NEXT: Name: .Lcall_dtors.101
168197
; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
169198
; RELOC-NEXT: Function: 8
170-
; RELOC-NEXT: - Index: 7
199+
; RELOC-NEXT: - Index: 13
171200
; RELOC-NEXT: Kind: FUNCTION
172201
; RELOC-NEXT: Name: .Lregister_call_dtors.101
173202
; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
174203
; RELOC-NEXT: Function: 9
175-
; RELOC-NEXT: - Index: 8
176-
; RELOC-NEXT: Kind: DATA
177-
; RELOC-NEXT: Name: __dso_handle
178-
; RELOC-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN, UNDEFINED ]
179-
; RELOC-NEXT: - Index: 9
204+
; RELOC-NEXT: - Index: 14
180205
; RELOC-NEXT: Kind: FUNCTION
181206
; RELOC-NEXT: Name: .Lcall_dtors.1001
182207
; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
183208
; RELOC-NEXT: Function: 10
184-
; RELOC-NEXT: - Index: 10
209+
; RELOC-NEXT: - Index: 15
185210
; RELOC-NEXT: Kind: FUNCTION
186211
; RELOC-NEXT: Name: .Lregister_call_dtors.1001
187212
; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
188213
; RELOC-NEXT: Function: 11
189-
; RELOC-NEXT: - Index: 11
214+
; RELOC-NEXT: - Index: 16
190215
; RELOC-NEXT: Kind: FUNCTION
191216
; RELOC-NEXT: Name: .Lcall_dtors.4000
192217
; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
193218
; RELOC-NEXT: Function: 12
194-
; RELOC-NEXT: - Index: 12
195-
; RELOC-NEXT: Kind: FUNCTION
196-
; RELOC-NEXT: Name: externDtor
197-
; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN, UNDEFINED ]
198-
; RELOC-NEXT: Function: 0
199-
; RELOC-NEXT: - Index: 13
219+
; RELOC-NEXT: - Index: 17
200220
; RELOC-NEXT: Kind: FUNCTION
201221
; RELOC-NEXT: Name: .Lregister_call_dtors.4000
202222
; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
203223
; RELOC-NEXT: Function: 13
204-
; RELOC-NEXT: - Index: 14
205-
; RELOC-NEXT: Kind: FUNCTION
206-
; RELOC-NEXT: Name: externCtor
207-
; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN, UNDEFINED ]
208-
; RELOC-NEXT: Function: 1
209-
; RELOC-NEXT: - Index: 15
210-
; RELOC-NEXT: Kind: FUNCTION
211-
; RELOC-NEXT: Name: myctor
212-
; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ]
213-
; RELOC-NEXT: Function: 14
214-
; RELOC-NEXT: - Index: 16
215-
; RELOC-NEXT: Kind: FUNCTION
216-
; RELOC-NEXT: Name: mydtor
217-
; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ]
218-
; RELOC-NEXT: Function: 15
219-
; RELOC-NEXT: - Index: 17
220-
; RELOC-NEXT: Kind: GLOBAL
221-
; RELOC-NEXT: Name: __stack_pointer
222-
; RELOC-NEXT: Flags: [ UNDEFINED ]
223-
; RELOC-NEXT: Global: 0
224224
; RELOC-NEXT: - Index: 18
225225
; RELOC-NEXT: Kind: FUNCTION
226226
; RELOC-NEXT: Name: .Lcall_dtors.101
@@ -251,36 +251,36 @@ entry:
251251
; RELOC-NEXT: Name: .Lregister_call_dtors.2002
252252
; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
253253
; RELOC-NEXT: Function: 21
254-
; RELOC-NEXT: InitFunctions:
254+
; RELOC-NEXT: InitFunctions:
255255
; RELOC-NEXT: - Priority: 101
256256
; RELOC-NEXT: Symbol: 0
257257
; RELOC-NEXT: - Priority: 101
258258
; RELOC-NEXT: Symbol: 1
259259
; RELOC-NEXT: - Priority: 101
260-
; RELOC-NEXT: Symbol: 7
260+
; RELOC-NEXT: Symbol: 13
261261
; RELOC-NEXT: - Priority: 101
262-
; RELOC-NEXT: Symbol: 15
262+
; RELOC-NEXT: Symbol: 9
263263
; RELOC-NEXT: - Priority: 101
264264
; RELOC-NEXT: Symbol: 19
265265
; RELOC-NEXT: - Priority: 202
266-
; RELOC-NEXT: Symbol: 15
266+
; RELOC-NEXT: Symbol: 9
267267
; RELOC-NEXT: - Priority: 202
268268
; RELOC-NEXT: Symbol: 21
269269
; RELOC-NEXT: - Priority: 1001
270270
; RELOC-NEXT: Symbol: 0
271271
; RELOC-NEXT: - Priority: 1001
272-
; RELOC-NEXT: Symbol: 10
273-
; RELOC-NEXT: - Priority: 2002
274272
; RELOC-NEXT: Symbol: 15
275273
; RELOC-NEXT: - Priority: 2002
274+
; RELOC-NEXT: Symbol: 9
275+
; RELOC-NEXT: - Priority: 2002
276276
; RELOC-NEXT: Symbol: 23
277277
; RELOC-NEXT: - Priority: 4000
278-
; RELOC-NEXT: Symbol: 14
278+
; RELOC-NEXT: Symbol: 8
279279
; RELOC-NEXT: - Priority: 4000
280-
; RELOC-NEXT: Symbol: 13
280+
; RELOC-NEXT: Symbol: 17
281281
; RELOC-NEXT: - Type: CUSTOM
282282
; RELOC-NEXT: Name: name
283-
; RELOC-NEXT: FunctionNames:
283+
; RELOC-NEXT: FunctionNames:
284284
; RELOC-NEXT: - Index: 0
285285
; RELOC-NEXT: Name: externDtor
286286
; RELOC-NEXT: - Index: 1

0 commit comments

Comments
 (0)