xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/keep-file-symbols.test (revision b14e9e3c0cab6fb4c53e5814b6a2454d4688a49e)
155c81d42SFangrui Song# RUN: yaml2obj %s -o %t
26e4dc6f2SAlexander Shaposhnikov# RUN: llvm-objcopy --strip-all --keep-file-symbols %t %t2
3298ea3f5SJordan Rupprecht# RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=STRIPALL
46e4dc6f2SAlexander Shaposhnikov# RUN: llvm-objcopy --keep-file-symbols --strip-symbol foo %t %t2
5298ea3f5SJordan Rupprecht# RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=STRIP
66e4dc6f2SAlexander Shaposhnikov
705a3f997SEugene Leviant# RUN: llvm-strip --keep-file-symbols %t -o %t3
805a3f997SEugene Leviant# RUN: llvm-readobj --symbols %t3 | FileCheck %s --check-prefix=STRIPALL
905a3f997SEugene Leviant# RUN: llvm-strip --keep-file-symbols --strip-symbol foo %t -o %t4
1005a3f997SEugene Leviant# RUN: llvm-readobj --symbols %t4 | FileCheck %s --check-prefix=STRIP
1105a3f997SEugene Leviant
12*b14e9e3cSFangrui Song# RUN: llvm-objcopy --keep-file-symbols --strip-debug %t %t5
13*b14e9e3cSFangrui Song# RUN: llvm-readobj --symbols %t5 | FileCheck %s --check-prefix=STRIPDEBUG
14*b14e9e3cSFangrui Song# RUN: llvm-objcopy --keep-file-symbols --strip-unneeded %t %t6
15*b14e9e3cSFangrui Song# RUN: llvm-readobj --symbols %t6 | FileCheck %s --check-prefix=STRIPDEBUG
16*b14e9e3cSFangrui Song
17*b14e9e3cSFangrui Song# RUN: llvm-strip --keep-file-symbols --strip-debug %t -o %t7
18*b14e9e3cSFangrui Song# RUN: llvm-readobj --symbols %t7 | FileCheck %s --check-prefix=STRIPDEBUG
19*b14e9e3cSFangrui Song# RUN: llvm-strip --keep-file-symbols --strip-unneeded %t -o %t8
20*b14e9e3cSFangrui Song# RUN: llvm-readobj --symbols %t8 | FileCheck %s --check-prefix=STRIPDEBUG
21*b14e9e3cSFangrui Song
226e4dc6f2SAlexander Shaposhnikov!ELF
236e4dc6f2SAlexander ShaposhnikovFileHeader:
246e4dc6f2SAlexander Shaposhnikov  Class:           ELFCLASS64
256e4dc6f2SAlexander Shaposhnikov  Data:            ELFDATA2LSB
266e4dc6f2SAlexander Shaposhnikov  Type:            ET_REL
276e4dc6f2SAlexander Shaposhnikov  Machine:         EM_X86_64
286e4dc6f2SAlexander ShaposhnikovSections:
29*b14e9e3cSFangrui Song  - Name:            .debugfoo
30*b14e9e3cSFangrui Song    Type:            SHT_PROGBITS
31*b14e9e3cSFangrui Song    Content:         "00000000"
326e4dc6f2SAlexander Shaposhnikov  - Name:            .text
336e4dc6f2SAlexander Shaposhnikov    Type:            SHT_PROGBITS
346e4dc6f2SAlexander Shaposhnikov    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
356e4dc6f2SAlexander Shaposhnikov    Address:         0x1000
366e4dc6f2SAlexander Shaposhnikov    AddressAlign:    0x0000000000000010
376e4dc6f2SAlexander Shaposhnikov    Size:            64
386e4dc6f2SAlexander ShaposhnikovSymbols:
396e4dc6f2SAlexander Shaposhnikov  - Name:     foo
406e4dc6f2SAlexander Shaposhnikov    Type:     STT_FILE
416e4dc6f2SAlexander Shaposhnikov    Section:  .text
426e4dc6f2SAlexander Shaposhnikov  - Name:     bar
436e4dc6f2SAlexander Shaposhnikov    Type:     STT_FUNC
446e4dc6f2SAlexander Shaposhnikov    Section:  .text
456da44ad7SGeorge Rimar    Binding:  STB_GLOBAL
46*b14e9e3cSFangrui Song  - Name:     debugfoo
47*b14e9e3cSFangrui Song    Section:  .debugfoo
48*b14e9e3cSFangrui Song    Binding:  STB_GLOBAL
496e4dc6f2SAlexander Shaposhnikov
506e4dc6f2SAlexander Shaposhnikov#STRIPALL: Symbols [
516e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:  Symbol {
526e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Name:
536e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Value: 0x0
546e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Size: 0
556e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Binding: Local
566e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Type: None
576e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Other: 0
586e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Section: Undefined
596e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:  }
606e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:  Symbol {
616e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Name: foo
626e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Value: 0x0
636e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Size: 0
646e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Binding: Local
656e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Type: File
666e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Other: 0
676e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:    Section: .text
686e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:  }
696e4dc6f2SAlexander Shaposhnikov#STRIPALL-NEXT:]
706e4dc6f2SAlexander Shaposhnikov
716e4dc6f2SAlexander Shaposhnikov#STRIP: Symbols [
726e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:  Symbol {
736e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Name:
746e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Value: 0x0
756e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Size: 0
766e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Binding: Local
776e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Type: None
786e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Other: 0
796e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Section: Undefined
806e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:  }
816e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:  Symbol {
826e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Name: foo
836e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Value: 0x0
846e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Size: 0
856e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Binding: Local
866e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Type: File
876e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Other: 0
886e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Section: .text
896e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:  }
906e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:  Symbol {
916e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Name: bar
926e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Value: 0x0
936e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Size: 0
946e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Binding: Global
956e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Type: Function
966e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Other: 0
976e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:    Section: .text
986e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:  }
99*b14e9e3cSFangrui Song#STRIP-NEXT:  Symbol {
100*b14e9e3cSFangrui Song#STRIP-NEXT:    Name: debugfoo
101*b14e9e3cSFangrui Song#STRIP-NEXT:    Value: 0x0
102*b14e9e3cSFangrui Song#STRIP-NEXT:    Size: 0
103*b14e9e3cSFangrui Song#STRIP-NEXT:    Binding: Global
104*b14e9e3cSFangrui Song#STRIP-NEXT:    Type: None
105*b14e9e3cSFangrui Song#STRIP-NEXT:    Other: 0
106*b14e9e3cSFangrui Song#STRIP-NEXT:    Section: .debugfoo
107*b14e9e3cSFangrui Song#STRIP-NEXT:  }
1086e4dc6f2SAlexander Shaposhnikov#STRIP-NEXT:]
109*b14e9e3cSFangrui Song
110*b14e9e3cSFangrui Song#STRIPDEBUG: Symbols [
111*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:  Symbol {
112*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Name:
113*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Value: 0x0
114*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Size: 0
115*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Binding: Local
116*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Type: None
117*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Other: 0
118*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Section: Undefined
119*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:  }
120*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:  Symbol {
121*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Name: foo
122*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Value: 0x0
123*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Size: 0
124*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Binding: Local
125*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Type: File
126*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Other: 0
127*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Section: .text
128*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:  }
129*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:  Symbol {
130*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Name: bar
131*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Value: 0x0
132*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Size: 0
133*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Binding: Global
134*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Type: Function
135*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Other: 0
136*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:    Section: .text
137*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:  }
138*b14e9e3cSFangrui Song#STRIPDEBUG-NEXT:]