brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · e24ec88 Raw
49 lines · plain
1# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj < %s | llvm-readobj --symbols - | FileCheck %s2 3# Regression test for a wasm object-writer crash (null deref in4# WasmObjectWriter::writeOneObject during MC finalization).5#6# An assembler symbol assignment / alias ("alias = target", i.e. ".set") whose7# target is *undefined in this translation unit* must not crash. This is8# pervasive in glibc, where libc_hidden_def / strong_alias emit exactly9#   mempcpy = __mempcpy10# and the target is frequently defined in another object and resolved by11# wasm-ld at final link.12#13# Mirroring ELF/GNU-as, an alias to a target undefined in the current TU is14# itself undefined here and is not materialized as a definition: an15# unreferenced alias is dropped from the linking section entirely. The alias16# still resolves correctly via the object that *defines* the target (covered17# by alias.s / function-alias.ll).18 19mempcpy = __mempcpy20 21        .globl  defined_fn22defined_fn:23        .functype defined_fn () -> ()24        end_function25 26# The writer must not crash. The alias "mempcpy" must NOT be emitted (an27# unreferenced alias to an undefined target is dropped, mirroring ELF/GNU-as);28# its target "__mempcpy" remains an undefined symbol resolved at final link,29# and the real function "defined_fn" is unaffected. The exact CHECK-NEXT chain30# below (ending at the closing "]") asserts that no "mempcpy" alias symbol31# leaks into the linking symbol table.32 33# CHECK:      Symbols [34# CHECK-NEXT:   Symbol {35# CHECK-NEXT:     Name: __mempcpy36# CHECK-NEXT:     Type: DATA (0x1)37# CHECK-NEXT:     Flags [ (0x10)38# CHECK-NEXT:       UNDEFINED (0x10)39# CHECK-NEXT:     ]40# CHECK-NEXT:   }41# CHECK-NEXT:   Symbol {42# CHECK-NEXT:     Name: defined_fn43# CHECK-NEXT:     Type: FUNCTION (0x0)44# CHECK-NEXT:     Flags [ (0x0)45# CHECK-NEXT:     ]46# CHECK-NEXT:     ElementIndex: 0x047# CHECK-NEXT:   }48# CHECK-NEXT: ]49