xref: /llvm-project/llvm/test/tools/llvm-objcopy/MachO/strip-debug.test (revision cf7edb6ea507949ce859510970698c9c11887d98)
130ccee71SFangrui Song## Show that llvm-objcopy/llvm-strip removes all symbols and debug sections.
230ccee71SFangrui Song
330ccee71SFangrui Song# RUN: yaml2obj %p/Inputs/strip-all-with-dwarf.yaml -o %t
430ccee71SFangrui Song
530ccee71SFangrui Song# RUN: llvm-objcopy --strip-debug %t %t.stripped
665a2de7eSGeorgii Rymar# RUN: llvm-readobj --sections %t.stripped | FileCheck /dev/null \
730ccee71SFangrui Song# RUN:   --implicit-check-not='Name: __debug' --implicit-check-not='Name: __apple'
830ccee71SFangrui Song
930ccee71SFangrui Song## Make sure that all symbols are kept.
1030ccee71SFangrui Song# RUN: llvm-readobj --symbols %t | FileCheck %s --check-prefix=SYM
1130ccee71SFangrui Song# RUN: llvm-readobj --symbols %t.stripped | FileCheck %s --check-prefix=SYM
1230ccee71SFangrui Song
1330ccee71SFangrui Song# SYM:         Symbols [
1430ccee71SFangrui Song# SYM-COUNT-3: Symbol
1530ccee71SFangrui Song# SYM:         ]
1630ccee71SFangrui Song
1730ccee71SFangrui Song## Make sure that all relocations to non-debug sections are kept.
1830ccee71SFangrui Song# RUN: llvm-readobj -r %t | FileCheck %s --check-prefixes=RELOC,DEBUG
1930ccee71SFangrui Song# RUN: llvm-readobj -r %t.stripped | FileCheck %s --check-prefix=RELOC
2030ccee71SFangrui Song
2136663d50SFangrui Song# RUN: llvm-strip --strip-debug %t -o %t.stripped2
2236663d50SFangrui Song# RUN: cmp %t.stripped %t.stripped2
2336663d50SFangrui Song
2430ccee71SFangrui Song# RELOC:      Relocations [
2530ccee71SFangrui Song# RELOC-NEXT:   Section __text {
26*cf7edb6eSAlexander Shaposhnikov# RELOC-NEXT:     0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
27*cf7edb6eSAlexander Shaposhnikov# RELOC-NEXT:     0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _main
2830ccee71SFangrui Song# RELOC-NEXT:   }
2930ccee71SFangrui Song# DEBUG:        Section __debug_info {
30*cf7edb6eSAlexander Shaposhnikov# DEBUG-NEXT:     0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
31*cf7edb6eSAlexander Shaposhnikov# DEBUG-NEXT:     0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
32*cf7edb6eSAlexander Shaposhnikov# DEBUG-NEXT:     0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
33*cf7edb6eSAlexander Shaposhnikov# DEBUG-NEXT:     0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
3430ccee71SFangrui Song# DEBUG-NEXT:   }
3530ccee71SFangrui Song# RELOC-NEXT:   Section __compact_unwind {
36*cf7edb6eSAlexander Shaposhnikov# RELOC-NEXT:     0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
3730ccee71SFangrui Song# RELOC-NEXT:   }
3830ccee71SFangrui Song# DEBUG-NEXT:   Section __debug_line {
39*cf7edb6eSAlexander Shaposhnikov# DEBUG-NEXT:     0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
4030ccee71SFangrui Song# DEBUG-NEXT:   }
4130ccee71SFangrui Song# RELOC-NEXT: ]
42