Jake Ehrlich | e8437de | 2017-12-19 00:47:30 +0000 | [diff] [blame] | 1 | # RUN: yaml2obj %s > %t |
| 2 | # RUN: llvm-objcopy -O binary -j .test2 %t %t.sec |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 3 | # RUN: llvm-objcopy -R .test2 %t %t2 |
Jordan Rupprecht | 298ea3f | 2019-01-11 18:06:31 +0000 | [diff] [blame] | 4 | # RUN: llvm-objcopy --add-section=.test2=%t.sec %t2 %t3 |
| 5 | # RUN: llvm-readobj --file-headers --sections --section-data %t3 | FileCheck %s |
Jake Ehrlich | e8437de | 2017-12-19 00:47:30 +0000 | [diff] [blame] | 6 | |
| 7 | !ELF |
| 8 | FileHeader: |
| 9 | Class: ELFCLASS64 |
| 10 | Data: ELFDATA2LSB |
| 11 | Type: ET_REL |
| 12 | Machine: EM_X86_64 |
| 13 | Sections: |
| 14 | - Name: .test1 |
| 15 | Type: SHT_PROGBITS |
| 16 | Flags: [ SHF_ALLOC ] |
| 17 | Content: "c3c3c3c3" |
| 18 | - Name: .test2 |
| 19 | Type: SHT_PROGBITS |
| 20 | Flags: [ SHF_ALLOC ] |
| 21 | Content: "DEADBEEF" |
| 22 | - Name: .test3 |
| 23 | Type: SHT_PROGBITS |
| 24 | Flags: [ SHF_ALLOC ] |
| 25 | Content: "32323232" |
| 26 | |
George Rimar | 2779987 | 2019-10-20 14:47:17 +0000 | [diff] [blame] | 27 | # CHECK: SectionHeaderCount: 6 |
Jake Ehrlich | e8437de | 2017-12-19 00:47:30 +0000 | [diff] [blame] | 28 | |
| 29 | # CHECK: Name: .test1 |
| 30 | # CHECK: Name: .test3 |
Jake Ehrlich | e8437de | 2017-12-19 00:47:30 +0000 | [diff] [blame] | 31 | # CHECK: Name: .strtab |
| 32 | # CHECK: Name: .shstrtab |
| 33 | # CHECK: Name: .test2 |
| 34 | # CHECK: SectionData ( |
| 35 | # CHECK-NEXT: 0000: DEADBEEF |
| 36 | # CHECK-NEXT: ) |
Sergey Dmitriev | 899bdaa | 2019-07-29 16:22:40 +0000 | [diff] [blame] | 37 | |
| 38 | ## Test that llvm-objcopy produces an error if the file with section contents |
| 39 | ## to be added does not exist. |
| 40 | # RUN: not llvm-objcopy --add-section=.section.name=%t.missing %t %t.out 2>&1 | FileCheck -DFILE1=%t -DFILE2=%t.missing %s --check-prefixes=ERR1 |
| 41 | |
| 42 | # ERR1: error: '[[FILE1]]': '[[FILE2]]': {{[Nn]}}o such file or directory |
| 43 | |
| 44 | ## Negative test for invalid --add-sections argument - missing '='. |
| 45 | # RUN: not llvm-objcopy --add-section=.section.name %t %t.out 2>&1 | FileCheck %s --check-prefixes=ERR2 |
| 46 | |
| 47 | # ERR2: error: bad format for --add-section: missing '=' |
| 48 | |
| 49 | ## Negative test for invalid --add-sections argument - missing file name. |
| 50 | # RUN: not llvm-objcopy --add-section=.section.name= %t %t.out 2>&1 | FileCheck %s --check-prefixes=ERR3 |
| 51 | |
| 52 | # ERR3: error: bad format for --add-section: missing file name |