1 # RUN: yaml2obj %s > %t.o
3 # Tests that only global symbols (via -G/--keep-global-symbols) are kept via
4 # the several different variants of -G/--keep-global-symbol(s).
6 # Local1: Local because "-G Local1" doesn't make symbols global.
7 # Local2: Global because of "--globalize-symbol Local2".
8 # Weak1: Weak because "-G Weak1" doesn't make symbols global.
9 # Weak2: Global because of "--globalize-symbol Weak2".
10 # Weak3: Local because no -G flag covers it.
11 # Global1: Global because of "-G Global1".
12 # Global2: Global because of "--keep-global-symbol Global2".
13 # Global3: Global because of "--keep-global-symbols %t-globals1.txt".
14 # Global4: Global because of "--keep-global-symbols %t-globals2.txt".
15 # Global5: Local, it appears in %t-globals2.txt but only in comments and as
16 # part of another symbol
17 # Global6: Local, it appears in %t-globals2.txt but only part of another symbol
18 # "Global5 Global6": Global, because it appears in %t-globals2.txt, but we only
19 # trim leading and trailing whitespace. We don't just take the first chunk
20 # that looks like a symbol.
21 # Global7: Global, because even though it doesn't appear as any -G flags, does
22 # not get demoted since it's undefined.
24 # RUN: echo Global2 > %t-globals1.txt
25 # RUN: echo " Global3 " > %t-globals2.txt
26 # RUN: echo "Global4 # Global5" >> %t-globals2.txt
27 # RUN: echo " Global5 Global6 " >> %t-globals2.txt
28 # RUN: echo "Unknown" >> %t-globals2.txt
29 # RUN: echo " " >> %t-globals2.txt
30 # RUN: echo "# File with no symbols" > %t-globals3.txt
31 # RUN: echo "^Global[0-9]+([[:space:]]Global6)*$" > %t-globals-regexp.txt
35 # RUN: --keep-global-symbol Global2 \
36 # RUN: --keep-global-symbols %t-globals1.txt \
37 # RUN: --keep-global-symbols %t-globals2.txt \
39 # RUN: --globalize-symbol Local2 \
41 # RUN: --globalize-symbol Weak2 \
43 # RUN: llvm-readelf --symbols %t.2.o | FileCheck %s
45 # RUN: llvm-objcopy --regex --keep-global-symbols %t-globals-regexp.txt %t.o %t.3.o
46 # RUN: llvm-readelf --symbols %t.3.o | FileCheck %s --check-prefix=REGEXP
57 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
81 - Name: "Global5 Global6"
96 # CHECK: Symbol table '.symtab' contains 14 entries:
97 # CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
98 # CHECK-NEXT: 0: {{.*}} LOCAL {{.*}}
99 # CHECK-NEXT: 1: {{.*}} LOCAL {{.*}} Local1
100 # CHECK-NEXT: 2: {{.*}} LOCAL {{.*}} Global5
101 # CHECK-NEXT: 3: {{.*}} LOCAL {{.*}} Global6
102 # CHECK-NEXT: 4: {{.*}} LOCAL {{.*}} Weak3
103 # CHECK-NEXT: 5: {{.*}} GLOBAL {{.*}} Local2
104 # CHECK-NEXT: 6: {{.*}} GLOBAL {{.*}} Global1
105 # CHECK-NEXT: 7: {{.*}} GLOBAL {{.*}} Global2
106 # CHECK-NEXT: 8: {{.*}} GLOBAL {{.*}} Global3
107 # CHECK-NEXT: 9: {{.*}} GLOBAL {{.*}} Global4
108 # CHECK-NEXT: 10: {{.*}} GLOBAL {{.*}} Global5 Global6
109 # CHECK-NEXT: 11: {{.*}} GLOBAL {{.*}} UND Global7
110 # CHECK-NEXT: 12: {{.*}} WEAK {{.*}} Weak1
111 # CHECK-NEXT: 13: {{.*}} GLOBAL {{.*}} Weak2
113 # REGEXP: 6: {{.*}} GLOBAL {{.*}} Global1
114 # REGEXP-NEXT: 7: {{.*}} GLOBAL {{.*}} Global2
115 # REGEXP-NEXT: 8: {{.*}} GLOBAL {{.*}} Global3
116 # REGEXP-NEXT: 9: {{.*}} GLOBAL {{.*}} Global4
117 # REGEXP-NEXT: 10: {{.*}} GLOBAL {{.*}} Global5
118 # REGEXP-NEXT: 11: {{.*}} GLOBAL {{.*}} Global6
119 # REGEXP-NEXT: 12: {{.*}} GLOBAL {{.*}} Global5 Global6
120 # REGEXP-NEXT: 13: {{.*}} GLOBAL {{.*}} UND Global7