2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/more-foo.s -o %t/more-foo.o
5 # RUN: %lld -dylib %t/test.o %t/more-foo.o -o %t/test
6 # RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/test | \
7 # RUN: FileCheck %s --check-prefix=STR --implicit-check-not foo --implicit-check-not bar
8 # RUN: llvm-objdump --macho --section="__DATA,ptrs" --syms %t/test | FileCheck %s
9 # RUN: llvm-readobj --section-headers %t/test | FileCheck %s --check-prefix=HEADER
11 ## Make sure we only have 3 deduplicated strings in __cstring.
12 # STR: Contents of (__TEXT,__cstring) section
13 # STR: {{[[:xdigit:]]+}} foo
14 # STR: {{[[:xdigit:]]+}} barbaz
15 # STR: {{[[:xdigit:]]+}} {{$}}
17 ## Make sure both symbol and section relocations point to the right thing.
18 # CHECK: Contents of (__DATA,ptrs) section
19 # CHECK-NEXT: __TEXT:__cstring:foo
20 # CHECK-NEXT: __TEXT:__cstring:foo
21 # CHECK-NEXT: __TEXT:__cstring:foo
22 # CHECK-NEXT: __TEXT:__cstring:foo
23 # CHECK-NEXT: __TEXT:__cstring:foo
24 # CHECK-NEXT: __TEXT:__cstring:foo
25 # CHECK-NEXT: __TEXT:__cstring:barbaz
26 # CHECK-NEXT: __TEXT:__cstring:baz
27 # CHECK-NEXT: __TEXT:__cstring:barbaz
28 # CHECK-NEXT: __TEXT:__cstring:baz
29 # CHECK-NEXT: __TEXT:__cstring:{{$}}
30 # CHECK-NEXT: __TEXT:__cstring:{{$}}
32 ## Make sure the symbol addresses are correct too.
33 # CHECK: SYMBOL TABLE:
34 # CHECK-DAG: [[#%.16x,FOO:]] l O __TEXT,__cstring _local_foo1
35 # CHECK-DAG: [[#FOO]] l O __TEXT,__cstring _local_foo2
36 # CHECK-DAG: [[#FOO]] g O __TEXT,__cstring _globl_foo1
37 # CHECK-DAG: [[#FOO]] g O __TEXT,__cstring _globl_foo2
38 # CHECK-DAG: [[#%.16x,BAR:]] l O __TEXT,__cstring _bar1
39 # CHECK-DAG: [[#BAR]] l O __TEXT,__cstring _bar2
40 # CHECK-DAG: [[#%.16x,ZERO:]] l O __TEXT,__cstring _zero1
41 # CHECK-DAG: [[#ZERO]] l O __TEXT,__cstring _zero2
43 ## Make sure we set the right alignment and flags.
44 # HEADER: Name: __cstring
45 # HEADER-NEXT: Segment: __TEXT
46 # HEADER-NEXT: Address:
48 # HEADER-NEXT: Offset:
49 # HEADER-NEXT: Alignment: 4
50 # HEADER-NEXT: RelocationOffset:
51 # HEADER-NEXT: RelocationCount: 0
52 # HEADER-NEXT: Type: CStringLiterals
53 # HEADER-NEXT: Attributes [ (0x0)
55 # HEADER-NEXT: Reserved1: 0x0
56 # HEADER-NEXT: Reserved2: 0x0
57 # HEADER-NEXT: Reserved3: 0x0
85 .section __DATA,ptrs,literal_pointers
100 .globl _globl_foo1, _globl_foo2