Debian Codegraph @

llvm/test/tools/llvm-objcopy/ELF/add-section.test

raw
1 # RUN: yaml2obj %s -o %t
2 # RUN: llvm-objcopy -O binary -j .test2 %t %t.sec
3 # RUN: llvm-objcopy -R .test2 %t %t2
4 # RUN: llvm-objcopy --add-section=.test2=%t.sec %t2 %t3
5 # RUN: llvm-readobj --file-headers --sections --section-data %t3 | FileCheck %s
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
27 # CHECK: SectionHeaderCount: 6
28
29 # CHECK: Name: .test1
30 # CHECK: Name: .test3
31 # CHECK: Name: .strtab
32 # CHECK: Name: .shstrtab
33 # CHECK: Offset: 0x[[#%x,OFFSET:]]
34 # CHECK: Size: [[#%u,SIZE:]]
35 # CHECK: Name: .test2
36 # CHECK-NEXT: Type: SHT_PROGBITS
37 # CHECK-NEXT: Flags [ (0x0)
38 # CHECK-NEXT: ]
39 # CHECK-NEXT: Address: 0x0
40 # CHECK-NEXT: Offset: 0x[[#%x,OFFSET+SIZE]]
41 # CHECK-NEXT: Size: 4
42 # CHECK-NEXT: Link: 0
43 # CHECK-NEXT: Info: 0
44 # CHECK-NEXT: AddressAlignment: 1
45 # CHECK-NEXT: EntrySize: 0
46 # CHECK-NEXT: SectionData (
47 # CHECK-NEXT: 0000: DEADBEEF
48 # CHECK-NEXT: )
49
50 ## Test that llvm-objcopy produces an error if the file with section contents
51 ## to be added does not exist.
52 # RUN: not llvm-objcopy --add-section=.section.name=%t.missing %t %t.out 2>&1 | FileCheck -DFILE=%t.missing -DMSG=%errc_ENOENT %s --check-prefixes=ERR1
53
54 # ERR1: error: '[[FILE]]': [[MSG]]
55
56 ## Negative test for invalid --add-sections argument - missing '='.
57 # RUN: not llvm-objcopy --add-section=.section.name %t %t.out 2>&1 | FileCheck %s --check-prefixes=ERR2
58
59 # ERR2: error: bad format for --add-section: missing '='
60
61 ## Negative test for invalid --add-sections argument - missing file name.
62 # RUN: not llvm-objcopy --add-section=.section.name= %t %t.out 2>&1 | FileCheck %s --check-prefixes=ERR3
63
64 # ERR3: error: bad format for --add-section: missing file name