brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · bdab2df Raw
69 lines · plain
1# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj < %s | obj2yaml | FileCheck %s2# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj < %s | llvm-readobj --symbols - | FileCheck --check-prefix=SYM %s3 4# Regression test for the wasm MC asm parser rejecting the GNU single-operand5# `.section <name>` form and the `.previous` directive.6#7# glibc's link_warning / stub_warning machinery (include/libc-symbols.h) emits,8# in hundreds of libc .c files, an "unallocated marker section" pair via inline9# asm:10#   asm(".section .gnu.warning.<sym>\n\t.previous");11#   asm(".section .gnu.glibc-stub.<sym>\n\t.previous");   // note the hyphen12# The wasm `.section` handler used to require the wasm flags/type form13# (`.section name,"flags",@type`) and rejected both the bare single-operand14# spelling ("Expected ,") and the hyphenated name ("Expected ,, instead got: -"),15# and `.previous` was an "unknown directive".16#17# wasm-ld has no ELF `.gnu.warning` / `.gnu.glibc-stub` linker-warning feature,18# so these are purely diagnostic, unallocated markers. The parser now accepts19# the GNU single-operand form (including hyphenated names) and switches to the20# (empty) marker section, and implements `.previous` via the section stack so it21# returns to the section active before the marker -- exactly like ELF. The22# marker carries no content and no symbols; real sections/symbols are untouched.23 24        .globl  f25f:26        .functype f () -> ()27        end_function28 29        .section        .rodata.keep,"",@30        .int8 0x1131# Single-operand `.section` + `.previous`: the marker is empty and emission32# returns to .rodata.keep.33        .section        .gnu.warning.sigreturn34        .previous35        .int8 0x2236# A hyphenated marker name (.gnu.glibc-stub.*) parses too.37        .section        .gnu.glibc-stub.sigreturn38        .previous39        .int8 0x3340 41# The three bytes 0x11/0x22/0x33 all land contiguously in .rodata.keep: emission42# after each `.previous` correctly resumes in the section that preceded the43# marker (the round-trip is preserved), so the marker pair is a no-op.44# CHECK:      - Type:            DATA45# CHECK:        Content:         '112233'46# Each marker section is present but empty (no content, no symbols): the47# diagnostic marker is accepted and effectively ignored.48# CHECK:        Content:         ''49# CHECK:        Content:         ''50 51# CHECK:      SegmentInfo:52# CHECK-NEXT:   - Index:           053# CHECK-NEXT:     Name:            .rodata.keep54# CHECK:        - Index:           155# CHECK-NEXT:     Name:            .gnu.warning.sigreturn56# CHECK:        - Index:           257# CHECK-NEXT:     Name:            .gnu.glibc-stub.sigreturn58 59# The real code symbol is unaffected; the markers contribute no symbols.60# SYM:      Symbols [61# SYM-NEXT:   Symbol {62# SYM-NEXT:     Name: f63# SYM-NEXT:     Type: FUNCTION (0x0)64# SYM-NEXT:     Flags [ (0x0)65# SYM-NEXT:     ]66# SYM-NEXT:     ElementIndex: 0x067# SYM-NEXT:   }68# SYM-NEXT: ]69