brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · daed00e Raw
73 lines · plain
1# A strong, undefined symbol that MC was forced to classify as2# WASM_SYMBOL_TYPE_DATA -- because it is referenced only by a GNU-as style3# assembler alias ("alias = target", with no `.functype`, as glibc's4# libc_hidden_builtin redirect emits, e.g. `memset = __GI_memset`) -- must5# resolve against a real FUNCTION definition of the same name instead of being6# rejected with a spurious "symbol type mismatch". This mirrors ELF/GNU-ld and7# is the link-time consequence of the MC-side fix in8# llvm/test/MC/WebAssembly/alias-undefined-target.s.9#10# The relaxation is tightly guarded (never-silent): two *defined* symbols of11# conflicting type still error, and a *weak* undefined data symbol (whose DATA12# typing is load-bearing -- it may legitimately resolve to address 0) still13# errors against a function.14 15# RUN: rm -rf %t && split-file %s %t16# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/alias.s -o %t/alias.o17# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/func.s -o %t/func.o18# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/data.s -o %t/data.o19# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/weakalias.s -o %t/weakalias.o20 21## GREEN: a strong undefined-data alias target binds to a defined FUNCTION, in22## either object order, and resolves to the FUNCTION definition.23# RUN: wasm-ld -r -o %t/r1.o %t/alias.o %t/func.o24# RUN: llvm-objdump --syms %t/r1.o | FileCheck %s --check-prefix=FUNC25# RUN: wasm-ld -r -o %t/r2.o %t/func.o %t/alias.o26# RUN: llvm-objdump --syms %t/r2.o | FileCheck %s --check-prefix=FUNC27 28## NEVER-SILENT: a genuine defined-data vs defined-function conflict still errors.29# RUN: not wasm-ld -r -o %t/r3.o %t/data.o %t/func.o 2>&1 | FileCheck %s --check-prefix=CONFLICT30# RUN: not wasm-ld -r -o %t/r4.o %t/func.o %t/data.o 2>&1 | FileCheck %s --check-prefix=CONFLICT31 32## NEVER-SILENT: a *weak* undefined-data symbol still errors against a function.33# RUN: not wasm-ld -r -o %t/r5.o %t/weakalias.o %t/func.o 2>&1 | FileCheck %s --check-prefix=CONFLICT34# RUN: not wasm-ld -r -o %t/r6.o %t/func.o %t/weakalias.o 2>&1 | FileCheck %s --check-prefix=CONFLICT35 36# FUNC: F {{.*}}__GI_memset37# CONFLICT: error: symbol type mismatch: __GI_memset38 39#--- alias.s40## __GI_memset is referenced only as the target of a module-scope alias, so it41## reaches the object as a strong, undefined, untyped (-> DATA) symbol.42mymemset = __GI_memset43.globl pad44pad:45  .functype pad () -> ()46  end_function47 48#--- func.s49.globl __GI_memset50__GI_memset:51  .functype __GI_memset (i32, i32, i32) -> (i32)52  local.get 053  end_function54 55#--- data.s56## A genuine DATA definition of the same name -- a real, explicit type that57## must still conflict with the function definition.58.globl __GI_memset59.section .data.__GI_memset,"",@60__GI_memset:61  .int32 062.size __GI_memset, 463 64#--- weakalias.s65## Same alias shape, but the target is explicitly weak: its DATA typing is66## load-bearing (it may resolve to 0), so it must still error against a function.67.weak __GI_memset68weakmemset = __GI_memset69.globl wpad70wpad:71  .functype wpad () -> ()72  end_function73