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