brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 558cac5 Raw
102 lines · plain
1# Test that undefined weak externals (global_var) and (foo) don't cause2# link failures and resolve to zero.3 4# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s5# RUN: wasm-ld -strip-all %t.o -o %t.wasm6# RUN: obj2yaml %t.wasm | FileCheck %s7 8# Also verify test that strong references in another file do cause link9# failure (See https://github.com/llvm/llvm-project/issues/60806)10 11# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/strong-refs.s -o %t-strong.o12# RUN: not wasm-ld -strip-all %t.o %t-strong.o -o %t.wasm 2>&1 | FileCheck --check-prefix=ERROR %s13# RUN: not wasm-ld -strip-all %t-strong.o %t.o -o %t.wasm 2>&1 | FileCheck --check-prefix=ERROR %s14 15# ERROR: undefined symbol: global_var16 17.functype foo () -> (i32)18 19.globl  get_address_of_foo20get_address_of_foo:21  .functype get_address_of_foo () -> (i32)22  i32.const foo23  end_function24 25.globl  get_address_of_global_var26get_address_of_global_var:27  .functype get_address_of_global_var () -> (i32)28  i32.const global_var29  end_function30 31.globl  _start32_start:33  .functype _start () -> ()34  call  get_address_of_global_var35  drop36  call  get_address_of_foo37  drop38  call  foo39  drop40  end_function41 42.weak foo43.weak global_var44 45# CHECK:      --- !WASM46# CHECK-NEXT: FileHeader:47# CHECK-NEXT:   Version:         0x148# CHECK-NEXT: Sections:49# CHECK-NEXT:   - Type:            TYPE50# CHECK-NEXT:     Signatures:51# CHECK-NEXT:       - Index:           052# CHECK-NEXT:         ParamTypes:      []53# CHECK-NEXT:         ReturnTypes:54# CHECK-NEXT:           - I3255# CHECK-NEXT:       - Index:           156# CHECK-NEXT:         ParamTypes:      []57# CHECK-NEXT:         ReturnTypes:     []58# CHECK-NEXT:   - Type:            FUNCTION59# CHECK-NEXT:     FunctionTypes:   [ 0, 0, 0, 1 ]60# CHECK-NEXT:   - Type:            TABLE61# CHECK-NEXT:     Tables:62# CHECK-NEXT:       - Index:           063# CHECK-NEXT:         ElemType:        FUNCREF64# CHECK-NEXT:         Limits:65# CHECK-NEXT:           Flags:           [ HAS_MAX ]66# CHECK-NEXT:           Minimum:         0x167# CHECK-NEXT:           Maximum:         0x168# CHECK-NEXT:   - Type:            MEMORY69# CHECK-NEXT:     Memories:70# CHECK-NEXT:       - Minimum:         0x171# CHECK-NEXT:   - Type:            GLOBAL72# CHECK-NEXT:     Globals:73# CHECK-NEXT:       - Index:           074# CHECK-NEXT:         Type:            I3275# CHECK-NEXT:         Mutable:         true76# CHECK-NEXT:         InitExpr:77# CHECK-NEXT:           Opcode:          I32_CONST78# CHECK-NEXT:           Value:           6553679# CHECK-NEXT:   - Type:            EXPORT80# CHECK-NEXT:     Exports:81# CHECK-NEXT:       - Name:            memory82# CHECK-NEXT:         Kind:            MEMORY83# CHECK-NEXT:         Index:           084# CHECK-NEXT:       - Name:            _start85# CHECK-NEXT:         Kind:            FUNCTION86# CHECK-NEXT:         Index:           387# CHECK-NEXT:   - Type:            CODE88# CHECK-NEXT:     Functions:89# CHECK-NEXT:       - Index:           090# CHECK-NEXT:         Locals:91# CHECK-NEXT:         Body:            000B92# CHECK-NEXT:       - Index:           193# CHECK-NEXT:         Locals:94# CHECK-NEXT:         Body:            4180808080000B95# CHECK-NEXT:       - Index:           296# CHECK-NEXT:         Locals:97# CHECK-NEXT:         Body:            4180808080000B98# CHECK-NEXT:       - Index:           399# CHECK-NEXT:         Locals:100# CHECK-NEXT:         Body:            1082808080001A1081808080001A1080808080001A0B101# CHECK-NEXT: ...102