Files
TheRock/compiler/amd-llvm/llvm/test/tools/llvm-objcopy/COFF/add-section.test
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

87 lines
3.6 KiB
Plaintext

# RUN: yaml2obj %s -o %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 can add a section to an object with extended
## relocations.
# RUN: %python %p/../Inputs/ungzip.py %p/Inputs/x86_64-obj-xrelocs.yaml.gz > %t.xrelocs.yaml
# RUN: yaml2obj %t.xrelocs.yaml -o %t.xrelocs.obj
# RUN: llvm-objcopy --add-section=.test.section=%t.sec %t.xrelocs.obj %t1.xrelocs.obj
# RUN: llvm-readobj --file-headers --sections --section-data %t1.xrelocs.obj | FileCheck %s --check-prefixes=CHECK-EXTENDED-RELOCS
# CHECK-EXTENDED-RELOCS: SectionCount: 2
# CHECK-EXTENDED-RELOCS: Name: .data
# CHECK-EXTENDED-RELOCS: RelocationCount: 65535
# CHECK-EXTENDED-RELOCS: Characteristics [
# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_ALIGN_16BYTES
# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_LNK_NRELOC_OVFL
# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_MEM_READ
# CHECK-EXTENDED-RELOCS-NEXT: ]
# CHECK-EXTENDED-RELOCS: Name: .test.section
# CHECK-EXTENDED-RELOCS: Characteristics [
# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_ALIGN_1BYTES
# CHECK-EXTENDED-RELOCS-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
# CHECK-EXTENDED-RELOCS-NEXT: ]
# CHECK-EXTENDED-RELOCS: SectionData (
# CHECK-EXTENDED-RELOCS-NEXT: 0000: {{.+}}|DEADBEEF{{.+}}|
# CHECK-EXTENDED-RELOCS-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 -DFILE=%t2 -DMSG=%errc_ENOENT %s --check-prefixes=ERR1
# ERR1: error: '[[FILE]]': [[MSG]]
## 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:
...