Debian Codegraph @

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

raw
1 # RUN: yaml2obj %s -o %t
2 # RUN: llvm-objcopy -O binary -j .text %t %t2
3 # RUN: llvm-objcopy -O binary --only-section .text %t %t3
4 # RUN: llvm-objcopy --dump-section .text=%t4 %t %t5
5 # RUN: llvm-objcopy --dump-section .foo=%t6 %t %t7
6 # RUN: not llvm-objcopy --dump-section .bar=%t8 %t %t9 2>&1 | FileCheck %s --check-prefix=NOBITS -DINPUT=%t
7 # RUN: llvm-objcopy --dump-section .text=%t10 --dump-section .foo=%t11 %t /dev/null
8 # RUN: llvm-objcopy --dump-section .empty=%t.empty %t /dev/null
9 # RUN: od -t x1 %t2 | FileCheck %s --ignore-case
10 # RUN: od -t x1 %t6 | FileCheck %s --ignore-case --check-prefix=NON-ALLOC
11 # RUN: wc -c %t2 | FileCheck %s --check-prefix=SIZE
12 # RUN: wc -c %t.empty | FileCheck %s --check-prefix=EMPTY
13 # RUN: diff %t2 %t3
14 # RUN: diff %t4 %t3
15 # RUN: diff %t10 %t3
16 # RUN: diff %t11 %t6
17
18 !ELF
19 FileHeader:
20 Class: ELFCLASS64
21 Data: ELFDATA2LSB
22 Type: ET_EXEC
23 Machine: EM_X86_64
24 Sections:
25 - Name: .text
26 Type: SHT_PROGBITS
27 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
28 AddressAlign: 0x0000000000001000
29 Content: "DEADBEEF"
30 - Name: .foo
31 Type: SHT_PROGBITS
32 Flags: [ SHF_WRITE ]
33 Content: "CAFE"
34 - Name: .empty
35 Type: SHT_PROGBITS
36 Flags: [ SHF_ALLOC ]
37 - Name: .bar
38 Type: SHT_NOBITS
39 Flags: [ SHF_WRITE ]
40 ProgramHeaders:
41 - Type: PT_LOAD
42 Flags: [ PF_X, PF_R ]
43 FirstSec: .text
44 LastSec: .text
45
46 # CHECK: 0000000 de ad be ef
47
48 # NON-ALLOC: 0000000 ca fe
49
50 # SIZE: 4
51
52 # NOBITS: error: '[[INPUT]]': cannot dump section '.bar': it has no contents
53
54 # EMPTY: 0
55
56 # RUN: not llvm-objcopy --dump-section =/dev/null %t /dev/null 2>&1 | \
57 # RUN: FileCheck %s --check-prefix=ERR -DFILE=%t "-DSECTION="
58 # RUN: not llvm-objcopy --dump-section .missing=/dev/null %t /dev/null 2>&1 | \
59 # RUN: FileCheck %s --check-prefix=ERR -DFILE=%t -DSECTION=.missing
60
61 # ERR: error: '[[FILE]]': section '[[SECTION]]' not found
62
63 # RUN: not llvm-objcopy --dump-section .text %t /dev/null 2>&1 | FileCheck %s --check-prefix=ERR2
64 # RUN: not llvm-objcopy --dump-section .text= %t /dev/null 2>&1 | FileCheck %s --check-prefix=ERR2
65
66 # ERR2: error: bad format for --dump-section, expected section=file
67
68 # RUN: not llvm-objcopy --dump-section .text=not_exists/text-section %t 2>&1 \
69 # RUN: | FileCheck -DMSG=%errc_ENOENT %s -DINPUT=%t --check-prefix=NO-SUCH-PATH
70 # NO-SUCH-PATH: error: 'not_exists/text-section': [[MSG]]