87 lines · plain
1# RUN: yaml2obj %s -o %t2 3## Test that llvm-objcopy adds a section to the given object with expected4## contents.5# RUN: echo DEADBEEF > %t.sec6# RUN: llvm-objcopy --add-section=.test.section=%t.sec %t %t17# RUN: llvm-readobj --file-headers --sections --section-data %t1 | FileCheck %s --check-prefixes=CHECK-ADD8 9# CHECK-ADD: SectionCount: 210# CHECK-ADD: Name: .text11# CHECK-ADD: Name: .test.section12# CHECK-ADD: Characteristics [13# CHECK-ADD-NEXT: IMAGE_SCN_ALIGN_1BYTES14# CHECK-ADD-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA15# CHECK-ADD-NEXT: ]16# CHECK-ADD: SectionData (17# CHECK-ADD-NEXT: 0000: {{.+}}|DEADBEEF{{.+}}|18# CHECK-ADD-NEXT: )19 20## Test that llvm-objcopy can add a section with an empty name.21# RUN: llvm-objcopy --add-section==%t.sec %t %t1.empty.name22# RUN: llvm-readobj --file-headers --sections --section-data %t1.empty.name | FileCheck %s --check-prefixes=CHECK-ADD-EMPTY-NAME23 24# CHECK-ADD-EMPTY-NAME: SectionCount: 225# CHECK-ADD-EMPTY-NAME: Name: .text26# 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_1BYTES29# CHECK-ADD-EMPTY-NAME-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA30# 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: )34 35## Test that llvm-objcopy can add a section to an object with extended36## relocations.37# RUN: %python %p/../Inputs/ungzip.py %p/Inputs/x86_64-obj-xrelocs.yaml.gz > %t.xrelocs.yaml38# RUN: yaml2obj %t.xrelocs.yaml -o %t.xrelocs.obj39# RUN: llvm-objcopy --add-section=.test.section=%t.sec %t.xrelocs.obj %t1.xrelocs.obj40# RUN: llvm-readobj --file-headers --sections --section-data %t1.xrelocs.obj | FileCheck %s --check-prefixes=CHECK-EXTENDED-RELOCS41 42# CHECK-EXTENDED-RELOCS: SectionCount: 243# CHECK-EXTENDED-RELOCS: Name: .data44# CHECK-EXTENDED-RELOCS: RelocationCount: 6553545# CHECK-EXTENDED-RELOCS: Characteristics [46# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_ALIGN_16BYTES47# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA48# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_LNK_NRELOC_OVFL49# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_MEM_READ50# CHECK-EXTENDED-RELOCS-NEXT: ]51# CHECK-EXTENDED-RELOCS: Name: .test.section52# CHECK-EXTENDED-RELOCS: Characteristics [53# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_ALIGN_1BYTES54# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA55# CHECK-EXTENDED-RELOCS-NEXT: ]56# CHECK-EXTENDED-RELOCS: SectionData (57# CHECK-EXTENDED-RELOCS-NEXT: 0000: {{.+}}|DEADBEEF{{.+}}|58# CHECK-EXTENDED-RELOCS-NEXT: )59 60## Test that llvm-objcopy produces an error if the file with section contents61## to be added does not exist.62# RUN: not llvm-objcopy --add-section=.another.section=%t2 %t %t3 2>&1 | FileCheck -DFILE=%t2 -DMSG=%errc_ENOENT %s --check-prefixes=ERR163 64# ERR1: error: '[[FILE]]': [[MSG]]65 66## Another negative test for invalid --add-sections command line argument.67# RUN: not llvm-objcopy --add-section=.another.section %t %t3 2>&1 | FileCheck %s --check-prefixes=ERR268 69# ERR2: error: bad format for --add-section: missing '='70 71## Negative test for invalid --add-sections argument - missing file name.72# RUN: not llvm-objcopy --add-section=.section.name= %t %t3 2>&1 | FileCheck %s --check-prefixes=ERR373 74# ERR3: error: bad format for --add-section: missing file name75 76--- !COFF77header:78 Machine: IMAGE_FILE_MACHINE_AMD6479 Characteristics: [ ]80sections:81 - Name: .text82 Characteristics: [ ]83 Alignment: 484 SectionData: 488B0500000000C385symbols:86...87