1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
| # RUN: yaml2obj %s > %t
## Test that llvm-objcopy adds a section to the given object with expected
## contents.
# RUN: echo DEADBEEF > %t.sec
# RUN: llvm-objcopy --add-section=.test.section=%t.sec %t %t1
# RUN: llvm-readobj --file-headers --sections --section-data %t1 | FileCheck %s --check-prefixes=CHECK-ADD
# CHECK-ADD: SectionCount: 2
# CHECK-ADD: Name: .text
# CHECK-ADD: Name: .test.section
# CHECK-ADD: Characteristics [
# CHECK-ADD-NEXT: IMAGE_SCN_ALIGN_1BYTES
# CHECK-ADD-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
# CHECK-ADD-NEXT: ]
# CHECK-ADD: SectionData (
# CHECK-ADD-NEXT: 0000: {{.+}}|DEADBEEF{{.+}}|
# CHECK-ADD-NEXT: )
## Test that llvm-objcopy can add a section with an empty name.
# RUN: llvm-objcopy --add-section==%t.sec %t %t1.empty.name
# RUN: llvm-readobj --file-headers --sections --section-data %t1.empty.name | FileCheck %s --check-prefixes=CHECK-ADD-EMPTY-NAME
# CHECK-ADD-EMPTY-NAME: SectionCount: 2
# CHECK-ADD-EMPTY-NAME: Name: .text
# CHECK-ADD-EMPTY-NAME: Name: (00 00 00 00 00 00 00 00)
# CHECK-ADD-EMPTY-NAME: Characteristics [
# CHECK-ADD-EMPTY-NAME-NEXT: IMAGE_SCN_ALIGN_1BYTES
# CHECK-ADD-EMPTY-NAME-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
# CHECK-ADD-EMPTY-NAME-NEXT: ]
# CHECK-ADD-EMPTY-NAME: SectionData (
# CHECK-ADD-EMPTY-NAME-NEXT: 0000: {{.+}}|DEADBEEF{{.+}}|
# CHECK-ADD-EMPTY-NAME-NEXT: )
## Test that llvm-objcopy produces an error if the file with section contents
## to be added does not exist.
# RUN: not llvm-objcopy --add-section=.another.section=%t2 %t %t3 2>&1 | FileCheck -DFILE1=%t -DFILE2=%t2 %s --check-prefixes=ERR1
# ERR1: error: '[[FILE1]]': '[[FILE2]]': {{[Nn]}}o such file or directory
## Another negative test for invalid --add-sections command line argument.
# RUN: not llvm-objcopy --add-section=.another.section %t %t3 2>&1 | FileCheck %s --check-prefixes=ERR2
# ERR2: error: bad format for --add-section: missing '='
## Negative test for invalid --add-sections argument - missing file name.
# RUN: not llvm-objcopy --add-section=.section.name= %t %t3 2>&1 | FileCheck %s --check-prefixes=ERR3
# ERR3: error: bad format for --add-section: missing file name
--- !COFF
header:
Machine: IMAGE_FILE_MACHINE_AMD64
Characteristics: [ ]
sections:
- Name: .text
Characteristics: [ ]
Alignment: 4
SectionData: 488B0500000000C3
symbols:
...
|