1## Show that llvm-objcopy/llvm-strip removes all symbols and debug sections.
2
3# RUN: yaml2obj %p/Inputs/strip-all.yaml -o %t.exec
4# RUN: yaml2obj %p/Inputs/strip-all-with-dwarf.yaml -o %t.dwarf
5# RUN: yaml2obj %p/Inputs/strip-chained-fixups.yaml -o %t.fixups
6
7## Check that the symbol list satisfies the order: local / defined external /
8## undefined external, otherwise llvm-objcopy will fail.
9# RUN: llvm-objcopy %t.exec /dev/null
10
11# RUN: llvm-objcopy --strip-all %t.exec %t.exec.stripped
12# RUN: llvm-readobj --sections --relocations --symbols %t.exec.stripped \
13# RUN:   | FileCheck --check-prefix=COMMON %s
14
15# RUN: llvm-objcopy --strip-all %t.dwarf %t.dwarf.stripped
16# RUN: llvm-readobj --sections --relocations --symbols %t.dwarf.stripped \
17# RUN:   | FileCheck --check-prefixes=COMMON,DWARF %s
18
19# RUN: llvm-objcopy --strip-all %t.fixups %t.fixups.stripped
20# RUN: llvm-readobj --sections --relocations --symbols %t.fixups.stripped \
21# RUN:   | FileCheck --check-prefix=COMMON %s
22
23## The output of "llvm-strip" should be identical with that of
24## "llvm-strip --strip-all" and "llvm-objcopy --strip-all".
25# RUN: llvm-strip %t.exec -o %t2
26# RUN: llvm-strip --strip-all %t.exec -o %t3
27# RUN: cmp %t2 %t.exec.stripped
28# RUN: cmp %t3 %t.exec.stripped
29
30# RUN: llvm-strip %t.dwarf -o %t4
31# RUN: llvm-strip --strip-all %t.dwarf -o %t5
32# RUN: cmp %t4 %t.dwarf.stripped
33# RUN: cmp %t5 %t.dwarf.stripped
34
35# RUN: llvm-lipo %t.dwarf -create -output %t.dwarf.universal
36# RUN: llvm-strip %t.dwarf.universal -o %t.dwarf.universal.stripped
37# RUN: llvm-lipo %t.dwarf.universal.stripped -thin x86_64 -output %t6
38# RUN: cmp %t6 %t.dwarf.stripped
39
40# RUN: llvm-strip %t.fixups -o %t7
41# RUN: llvm-strip --strip-all %t.fixups -o %t8
42# RUN: cmp %t7 %t.fixups.stripped
43# RUN: cmp %t8 %t.fixups.stripped
44
45## Make sure that debug sections are removed.
46# DWARF:       Sections [
47# DWARF-NOT:     Name: __debug_str
48# DWARF-NOT:     Name: __debug_abbrev
49# DWARF-NOT:     Name: __debug_info
50# DWARF-NOT:     Name: __debug_macinfo
51# DWARF-NOT:     Name: __apple_names
52# DWARF-NOT:     Name: __apple_objc
53# DWARF-NOT:     Name: __apple_namespac
54# DWARF-NOT:     Name: __apple_types
55# DWARF-NOT:     Name: __debug_line
56# DWARF:       ]
57
58## Make sure that all relocations and symbols
59## (except those which have the flag ReferencedDynamically set) are removed.
60# COMMON:      Relocations [
61# COMMON-NEXT: ]
62# COMMON-NEXT: Symbols [
63# COMMON-NEXT:    Symbol {
64# COMMON-NEXT:      Name: __mh_execute_header
65# COMMON-NEXT:      Extern
66# COMMON-NEXT:      Type: Section
67# COMMON-NEXT:      Section: __text
68# COMMON-NEXT:      RefType: UndefinedNonLazy
69# COMMON-NEXT:      Flags [ (0x10)
70# COMMON-NEXT:        ReferencedDynamically (0x10)
71# COMMON-NEXT:      ]
72# COMMON-NEXT:      Value:
73# COMMON-NEXT:    }
74# COMMON-NEXT: ]
75