xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/strip-multiple-files.test (revision 55c81d4282c5da0189711261a11537bc8a7fe85c)
1*55c81d42SFangrui Song# RUN: yaml2obj %s -o %t.o
26e4dc6f2SAlexander Shaposhnikov
36e4dc6f2SAlexander Shaposhnikov# Run llvm-strip normally. This will create a stripped object file for later
46e4dc6f2SAlexander Shaposhnikov# tests so we only have to run FileCheck on it once.
56e4dc6f2SAlexander Shaposhnikov# RUN: cp %t.o %t.1.o
66e4dc6f2SAlexander Shaposhnikov# RUN: llvm-strip --keep-symbol=foo %t.1.o -o %t.stripped.o
7298ea3f5SJordan Rupprecht# RUN: llvm-readobj --symbols %t.stripped.o | FileCheck %s
86e4dc6f2SAlexander Shaposhnikov
96e4dc6f2SAlexander Shaposhnikov# llvm-strip on two files:
106e4dc6f2SAlexander Shaposhnikov# RUN: cp %t.o %t.1.o
116e4dc6f2SAlexander Shaposhnikov# RUN: cp %t.o %t.2.o
126e4dc6f2SAlexander Shaposhnikov# RUN: llvm-strip --keep-symbol=foo %t.1.o %t.2.o
136e4dc6f2SAlexander Shaposhnikov# RUN: cmp %t.1.o %t.stripped.o
146e4dc6f2SAlexander Shaposhnikov# RUN: cmp %t.2.o %t.stripped.o
156e4dc6f2SAlexander Shaposhnikov
166e4dc6f2SAlexander Shaposhnikov# llvm-strip on three files:
176e4dc6f2SAlexander Shaposhnikov# RUN: cp %t.o %t.1.o
186e4dc6f2SAlexander Shaposhnikov# RUN: cp %t.o %t.2.o
196e4dc6f2SAlexander Shaposhnikov# RUN: cp %t.o %t.3.o
206e4dc6f2SAlexander Shaposhnikov# RUN: llvm-strip --keep-symbol=foo %t.1.o %t.2.o %t.3.o
216e4dc6f2SAlexander Shaposhnikov# RUN: cmp %t.1.o %t.stripped.o
226e4dc6f2SAlexander Shaposhnikov# RUN: cmp %t.2.o %t.stripped.o
236e4dc6f2SAlexander Shaposhnikov# RUN: cmp %t.3.o %t.stripped.o
246e4dc6f2SAlexander Shaposhnikov
256e4dc6f2SAlexander Shaposhnikov# -o cannot be used with multiple input files
266e4dc6f2SAlexander Shaposhnikov# RUN: cp %t.o %t.1.o
276e4dc6f2SAlexander Shaposhnikov# RUN: cp %t.o %t.2.o
286e4dc6f2SAlexander Shaposhnikov# RUN: not llvm-strip --keep-symbol=foo -o %t.stripped.o %t.1.o %t.2.o 2>&1 \
296e4dc6f2SAlexander Shaposhnikov# RUN:   | FileCheck %s --check-prefix=BAD-O-FLAG
306e4dc6f2SAlexander Shaposhnikov
316e4dc6f2SAlexander Shaposhnikov!ELF
326e4dc6f2SAlexander ShaposhnikovFileHeader:
336e4dc6f2SAlexander Shaposhnikov  Class:           ELFCLASS64
346e4dc6f2SAlexander Shaposhnikov  Data:            ELFDATA2LSB
356e4dc6f2SAlexander Shaposhnikov  Type:            ET_REL
366e4dc6f2SAlexander Shaposhnikov  Machine:         EM_X86_64
376e4dc6f2SAlexander ShaposhnikovSections:
386e4dc6f2SAlexander Shaposhnikov  - Name:            .text
396e4dc6f2SAlexander Shaposhnikov    Type:            SHT_PROGBITS
406e4dc6f2SAlexander Shaposhnikov    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
416e4dc6f2SAlexander ShaposhnikovSymbols:
426e4dc6f2SAlexander Shaposhnikov  - Name:     foo
436e4dc6f2SAlexander Shaposhnikov    Type:     STT_FUNC
446e4dc6f2SAlexander Shaposhnikov    Section:  .text
456e4dc6f2SAlexander Shaposhnikov    Value:    0x1234
466e4dc6f2SAlexander Shaposhnikov    Size:     8
476e4dc6f2SAlexander Shaposhnikov  - Name:     bar
486e4dc6f2SAlexander Shaposhnikov    Type:     STT_FUNC
496e4dc6f2SAlexander Shaposhnikov    Section:  .text
506e4dc6f2SAlexander Shaposhnikov    Value:    0x5678
516e4dc6f2SAlexander Shaposhnikov    Size:     8
526e4dc6f2SAlexander Shaposhnikov
536e4dc6f2SAlexander Shaposhnikov# CHECK:      Symbols [
546e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:   Symbol {
556e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Name:
566e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Value: 0x0
576e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Size: 0
586e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Binding: Local
596e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Type: None
606e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Other: 0
616e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Section: Undefined
626e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:   }
636e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:   Symbol {
646e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Name: foo
656e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Value: 0x1234
666e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Size: 8
676e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Binding: Local
686e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Type: Function
696e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Other: 0
706e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:     Section: .text
716e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT:   }
726e4dc6f2SAlexander Shaposhnikov# CHECK-NEXT: ]
736e4dc6f2SAlexander Shaposhnikov
74d54d4f99SAlex Brachet# BAD-O-FLAG: multiple input files cannot be used in combination with -o
75