brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 86cda15 Raw
77 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 an absolute-valued symbol.5#6# A symbol defined as a bare integer constant ("sym = N" / ".set sym, N", with7# no symbol reference) has no base symbol. wasm has no absolute addressing, so8# WasmObjectWriter's alias pass (getBaseSymbol() == null) used to abort MC9# finalization with:10#   fatal error: error in backend: <sym>: absolute addressing not supported!11#12# glibc emits exactly this construct for address-taken linkage markers, e.g.13# _NL_CURRENT_DEFINE in locale/localeinfo.h:14#   asm(".globl _nl_current_LC_ADDRESS_used\n_nl_current_LC_ADDRESS_used = 2");15# The symbol's *address* is taken to force a translation unit to be linked, and16# any read of it is expected to yield the constant.17#18# Such a symbol is now lowered to a real defined data object holding the19# constant in its own data section (MCWasmStreamer::emitAssignment). It then has20# a genuine wasm linear-memory address that can be taken and resolved at link21# by wasm-ld (an undefined reference to it in another object binds to this22# definition), and a load of it yields the constant. This is never-silent: the23# address is real, the value24# is preserved, and nothing is dropped. Both the "=" and ".set" spellings are25# covered.26 27        .globl  marker_used28marker_used = 229 30        .globl  set_marker31        .set    set_marker, 532 33        .globl  f34f:35        .functype f () -> ()36        end_function37 38# Each absolute-constant symbol is emitted as a *defined* DATA symbol (not an39# undefined/absolute symbol and not a crash), with a real segment + size.40 41# CHECK:      Symbols [42# CHECK-NEXT:   Symbol {43# CHECK-NEXT:     Name: marker_used44# CHECK-NEXT:     Type: DATA (0x1)45# CHECK-NEXT:     Flags [ (0x0)46# CHECK-NEXT:     ]47# CHECK-NEXT:     Offset: 0x048# CHECK-NEXT:     Segment: 0x049# CHECK-NEXT:     Size: 0x450# CHECK-NEXT:   }51# CHECK-NEXT:   Symbol {52# CHECK-NEXT:     Name: set_marker53# CHECK-NEXT:     Type: DATA (0x1)54# CHECK-NEXT:     Flags [ (0x80)55# CHECK-NEXT:       NO_STRIP (0x80)56# CHECK-NEXT:     ]57# CHECK-NEXT:     Offset: 0x058# CHECK-NEXT:     Segment: 0x159# CHECK-NEXT:     Size: 0x460# CHECK-NEXT:   }61# CHECK-NEXT:   Symbol {62# CHECK-NEXT:     Name: f63# CHECK-NEXT:     Type: FUNCTION (0x0)64# CHECK-NEXT:     Flags [ (0x0)65# CHECK-NEXT:     ]66# CHECK-NEXT:     ElementIndex: 0x067# CHECK-NEXT:   }68# CHECK-NEXT: ]69 70# The data each symbol points at holds the constant little-endian (value71# preserved): marker_used == 2, set_marker == 5, each in its own named segment.72 73# YAML:      Content:         '02000000'74# YAML:      Content:         '05000000'75# YAML:      Name:            .data.marker_used76# YAML:      Name:            .data.set_marker77