brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · e1244ee Raw
45 lines · plain
1## Test that we properly detect and report out-of-bounds offsets in literal sections.2## We're intentionally testing fatal errors (for malformed input files), and3## fatal errors aren't supported for testing when main is run twice.4# XFAIL: main-run-twice5 6# REQUIRES: x867# RUN: rm -rf %t; split-file %s %t8 9## Test WordLiteralInputSection bounds checking10# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/word-literal.s -o %t/word-literal.o11# RUN: not %lld -dylib %t/word-literal.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=WORD12 13## Test CStringInputSection bounds checking14# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/cstring.s -o %t/cstring.o15# RUN: not %lld -dylib %t/cstring.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=CSTRING16 17# WORD: error: {{.*}}word-literal.o:(__literal4): offset is outside the section18# CSTRING: error: {{.*}}cstring.o:(__cstring): offset is outside the section19 20#--- word-literal.s21.section __TEXT,__literal4,4byte_literals22L_literal:23  .long 0x0102030424 25.text26.globl _main27_main:28  # We use a subtractor expression to force a section relocation. Symbol relocations29  # don't trigger the error.30  .long L_literal - _main + 431 32.subsections_via_symbols33 34#--- cstring.s35## Create a cstring section with a reference that points past the end36.cstring37L_str:38  .asciz "foo"39 40.text41.globl _main42_main:43  .long L_str - _main + 444 45.subsections_via_symbols