brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · e034275 Raw
54 lines · plain
1# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj < %s | llvm-readobj --symbols - | FileCheck %s2# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj < %s | obj2yaml | FileCheck --check-prefix=YAML %s3 4# Regression test for a wasm backend abort on a bare label symbol.5#6# A bare label (".globl foo" / "foo:", with no .functype and no .size) is routed7# by the assembler into a per-label text section on the assumption it will8# become a function; when nothing follows, it stays an untyped -- hence DATA --9# symbol in an empty text section with no .size. WasmObjectWriter used to abort10# MC finalization with:11#   fatal error: error in backend: data symbols must have a size set with .size: foo12# (and then "data symbols must live in a data section").13#14# glibc's elf/Makefile builds the rtld symbol map by piping exactly such bare15# labels through the assembler ("echo .globl $sym; echo $sym:"). On ELF a16# missing size means size 0, so default to 0 and give the marker its own real,17# empty (size-0) data segment (mirroring commit 751ce8312's homing of an18# absolute-constant marker). The symbol is a genuine, addressable, size-0 DATA19# symbol rather than a backend crash; nothing is silently dropped.20#21# Symbols that DO set .size keep it (sized_data == 8 below), and a .size that is22# present but does not evaluate is still a genuine error (covered by the23# never-silent run in the toolchain notes).24 25        .globl  foo26foo:27 28        .globl  sized_data29        .type   sized_data,@object30        .size   sized_data, 831        .section .data.sized_data,"",@32sized_data:33        .zero   834 35# A bare label becomes a *defined*, size-0 DATA symbol (not an abort, not an36# undefined symbol), and an explicitly sized data symbol keeps its size.37 38# CHECK:      Symbols [39# CHECK:        Symbol {40# CHECK:          Name: foo41# CHECK-NEXT:     Type: DATA (0x1)42# CHECK:          Size: 0x043# CHECK:        }44# CHECK:        Symbol {45# CHECK:          Name: sized_data46# CHECK-NEXT:     Type: DATA (0x1)47# CHECK:          Size: 0x848# CHECK:        }49# CHECK:      ]50 51# YAML: SymbolTable:52# YAML-DAG: Name: foo53# YAML-DAG: Name: sized_data54