Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 1 | # RUN: yaml2obj %s > %t |
Alexander Shaposhnikov | ecc8483 | 2018-05-31 20:42:13 +0000 | [diff] [blame] | 2 | # RUN: cp %t %t3 |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 3 | # RUN: llvm-objcopy --strip-all %t %t2 |
Jordan Rupprecht | 298ea3f | 2019-01-11 18:06:31 +0000 | [diff] [blame] | 4 | # RUN: llvm-readobj --file-headers --sections %t2 | FileCheck %s |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 5 | |
Alexander Shaposhnikov | ecc8483 | 2018-05-31 20:42:13 +0000 | [diff] [blame] | 6 | # Verify that the previous llvm-objcopy's run has not modified the input. |
| 7 | # RUN: cmp %t %t3 |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 8 | |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 9 | # RUN: llvm-strip %t3 |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 10 | # RUN: cmp %t2 %t3 |
| 11 | |
Alexander Shaposhnikov | ecc8483 | 2018-05-31 20:42:13 +0000 | [diff] [blame] | 12 | # RUN: cp %t %t4 |
| 13 | # RUN: llvm-strip %t4 -o %t5 |
| 14 | # RUN: cmp %t2 %t5 |
| 15 | |
| 16 | # Verify that the previous llvm-strip's run has not modified the input. |
| 17 | # RUN: cmp %t %t4 |
| 18 | |
| 19 | # RUN: cp %t %t-should-remain-the-same |
| 20 | # RUN: llvm-strip %t4 -o %t-should-remain-the-same -o %t-should-be-stripped |
| 21 | # RUN: cmp %t2 %t-should-be-stripped |
| 22 | # RUN: cmp %t %t-should-remain-the-same |
| 23 | |
Alexander Shaposhnikov | 42b5ef0 | 2018-07-06 17:51:03 +0000 | [diff] [blame] | 24 | # RUN: rm -f %t.a |
| 25 | # RUN: llvm-ar crs %t.a %t |
| 26 | # RUN: llvm-objcopy --strip-all %t.a %t.a |
| 27 | # RUN: llvm-ar p %t.a > %t6 |
| 28 | # RUN: cmp %t2 %t6 |
| 29 | |
Stephen Hines | e8c3c5f | 2018-07-12 17:42:17 +0000 | [diff] [blame] | 30 | # RUN: cp %t %t7 |
Fangrui Song | 2db79e9 | 2019-04-26 02:10:10 +0000 | [diff] [blame] | 31 | # RUN: llvm-strip --strip-all %t7 |
Stephen Hines | e8c3c5f | 2018-07-12 17:42:17 +0000 | [diff] [blame] | 32 | # RUN: cmp %t2 %t7 |
| 33 | |
| 34 | # RUN: cp %t %t8 |
Fangrui Song | 2db79e9 | 2019-04-26 02:10:10 +0000 | [diff] [blame] | 35 | # RUN: llvm-objcopy -S %t8 %t8 |
Stephen Hines | e8c3c5f | 2018-07-12 17:42:17 +0000 | [diff] [blame] | 36 | # RUN: cmp %t2 %t8 |
| 37 | |
Jake Ehrlich | 5e49846 | 2018-10-09 21:14:09 +0000 | [diff] [blame] | 38 | # RUN: cp %t %t9 |
Fangrui Song | 2db79e9 | 2019-04-26 02:10:10 +0000 | [diff] [blame] | 39 | # RUN: llvm-strip -s %t9 |
Jake Ehrlich | 5e49846 | 2018-10-09 21:14:09 +0000 | [diff] [blame] | 40 | # RUN: cmp %t2 %t9 |
| 41 | |
Stephen Hines | e6e75bf | 2018-07-26 20:05:31 +0000 | [diff] [blame] | 42 | # Verify that a non-existent symbol table (after first call to llvm-strip) |
| 43 | # can be handled correctly. |
Fangrui Song | 2db79e9 | 2019-04-26 02:10:10 +0000 | [diff] [blame] | 44 | # RUN: cp %t %t10 |
| 45 | # RUN: llvm-strip --strip-all --keep-symbol=unavailable_symbol %t10 |
| 46 | # RUN: llvm-strip --strip-all --keep-symbol=unavailable_symbol %t10 |
| 47 | # RUN: cmp %t2 %t10 |
Stephen Hines | e6e75bf | 2018-07-26 20:05:31 +0000 | [diff] [blame] | 48 | |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 49 | !ELF |
| 50 | FileHeader: |
| 51 | Class: ELFCLASS64 |
| 52 | Data: ELFDATA2LSB |
| 53 | Type: ET_REL |
| 54 | Machine: EM_X86_64 |
| 55 | Sections: |
James Henderson | b5de5e2 | 2019-03-14 11:47:41 +0000 | [diff] [blame] | 56 | - Name: non_alloc_in_segment |
| 57 | Type: SHT_PROGBITS |
| 58 | Flags: [ ] |
| 59 | Size: 4 |
Jake Ehrlich | 6ad72d0 | 2017-11-27 18:56:01 +0000 | [diff] [blame] | 60 | - Name: .bss |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 61 | Type: SHT_NOBITS |
Jake Ehrlich | 6ad72d0 | 2017-11-27 18:56:01 +0000 | [diff] [blame] | 62 | Flags: [ SHF_ALLOC ] |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 63 | - Name: .text |
| 64 | Type: SHT_PROGBITS |
| 65 | Flags: [ SHF_ALLOC, SHF_EXECINSTR ] |
Jake Ehrlich | 6ad72d0 | 2017-11-27 18:56:01 +0000 | [diff] [blame] | 66 | - Name: .blarg |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 67 | Type: SHT_PROGBITS |
| 68 | Flags: [ ] |
Jake Ehrlich | 6ad72d0 | 2017-11-27 18:56:01 +0000 | [diff] [blame] | 69 | - Name: .gnu.warning.foo |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 70 | Type: SHT_PROGBITS |
James Henderson | b5de5e2 | 2019-03-14 11:47:41 +0000 | [diff] [blame] | 71 | ProgramHeaders: |
| 72 | # Use an arbitrary segment type to show that the segment type is unimportant. |
| 73 | - Type: 0x61234567 |
| 74 | Sections: |
| 75 | - Section: non_alloc_in_segment |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 76 | |
James Henderson | b5de5e2 | 2019-03-14 11:47:41 +0000 | [diff] [blame] | 77 | # CHECK: SectionHeaderCount: 6 |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 78 | |
James Henderson | b5de5e2 | 2019-03-14 11:47:41 +0000 | [diff] [blame] | 79 | # CHECK: Name: non_alloc_in_segment |
Jake Ehrlich | 6ad72d0 | 2017-11-27 18:56:01 +0000 | [diff] [blame] | 80 | # CHECK: Name: .bss |
| 81 | # CHECK: Name: .text |
| 82 | # CHECK: Name: .gnu.warning.foo |
| 83 | # CHECK: Name: .shstrtab |