91 lines · plain
1# RUN: yaml2obj %s -o %t2 3# RUN: not llvm-objcopy --pad-to=1 %t 2>&1 | FileCheck %s --check-prefix=NOT-BINARY4# NOT-BINARY: error: '--pad-to' is only supported for binary output5 6# RUN: not llvm-objcopy -O binary --pad-to= %t 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT7# BAD-FORMAT: error: --pad-to: bad number:8 9# RUN: not llvm-objcopy -O binary --pad-to=x %t 2>&1 | FileCheck %s --check-prefix=BAD-INPUT10# BAD-INPUT: error: --pad-to: bad number: x11 12# RUN: not llvm-objcopy -O binary --pad-to=0x1G %t 2>&1 | FileCheck %s --check-prefix=BAD-INPUT213# BAD-INPUT2: error: --pad-to: bad number: 0x1G14 15# RUN: not llvm-objcopy -O binary --pad-to=ff %t 2>&1 | FileCheck %s --check-prefix=BAD-INPUT316# BAD-INPUT3: error: --pad-to: bad number: ff17 18# RUN: not llvm-objcopy -O binary --pad-to=0x112233445566778899 %t 2>&1 | FileCheck %s --check-prefix=BAD-NUMBER19# BAD-NUMBER: error: --pad-to: bad number: 0x11223344556677889920 21## Save the baseline, not padded output.22# RUN: llvm-objcopy -O binary %t %t.bin23 24## Pad to an address smaller than the binary size.25# RUN: llvm-objcopy -O binary --pad-to=0x20 %t %t-p126# RUN: cmp %t.bin %t-p127# RUN: llvm-objcopy -O binary --pad-to=0x200 %t %t-p228# RUN: cmp %t.bin %t-p229 30## Pad all allocatable sections to a valid address.31# RUN: llvm-objcopy -O binary --pad-to=0x218 %t %t-pad-default32# RUN: od -v -Ax -t x1 %t-pad-default | FileCheck %s --check-prefix=DEFAULT --ignore-case --match-full-lines33# DEFAULT: {{0*}}00 11 22 33 44 55 66 00 00 00 00 00 00 00 00 00 0034# DEFAULT-NEXT: {{0*}}10 77 88 99 aa 00 00 00 0035# DEFAULT-NEXT: {{0*}}1836 37## Use a decimal number for the padding address and verify it is not misunderstood.38# RUN: llvm-objcopy -O binary --pad-to=536 %t %t-pad-decimal39# RUN: od -v -Ax -t x1 %t-pad-decimal | FileCheck %s --check-prefix=DECIMAL --ignore-case --match-full-lines40# DECIMAL: {{0*}}00 11 22 33 44 55 66 00 00 00 00 00 00 00 00 00 0041# DECIMAL-NEXT: {{0*}}10 77 88 99 aa 00 00 00 0042# DECIMAL-NEXT: {{0*}}1843 44## Pad all allocatable sections to a valid address, using --gap-fill.45# RUN: llvm-objcopy -O binary --pad-to=0x218 --gap-fill=0xe9 %t %t-pad-fill46# RUN: od -v -Ax -t x1 %t-pad-fill | FileCheck %s --check-prefix=FILL --ignore-case --match-full-lines47# FILL: {{0*}}00 11 22 33 44 55 66 e9 e9 e9 e9 e9 e9 e9 e9 e9 e948# FILL-NEXT: {{0*}}10 77 88 99 aa e9 e9 e9 e949# FILL-NEXT: {{0*}}1850 51## Remove the last section containing data and test that the padded space is gap filled.52# RUN: llvm-objcopy -O binary --pad-to=0x218 --gap-fill=0xe9 --remove-section=.section2 %t %t-filled53# RUN: od -v -Ax -t x1 %t-filled | FileCheck %s --check-prefix=REMOVE-SECTION --ignore-case --match-full-lines54# REMOVE-SECTION: {{0*}}00 11 22 33 44 55 66 e9 e9 e9 e9 e9 e9 e9 e9 e9 e955# REMOVE-SECTION-NEXT: {{0*}}10 e9 e9 e9 e9 e9 e9 e9 e956# REMOVE-SECTION-NEXT: {{0*}}1857 58--- !ELF59FileHeader:60 Class: ELFCLASS6461 Data: ELFDATA2LSB62 Type: ET_EXEC63 Machine: EM_X86_6464Sections:65 - Name: .section166 Type: SHT_PROGBITS67 Flags: [ SHF_ALLOC ]68 Address: 0x020069 Size: 0x670 Content: '112233445566'71 - Name: .space72 Type: Fill73 Pattern: '01234567'74 Size: 0x475 - Name: .section276 Type: SHT_PROGBITS77 Flags: [ SHF_WRITE, SHF_ALLOC ]78 Address: 0x021079 Content: '778899aa'80 - Name: .bss81 Type: SHT_NOBITS82 Flags: [ SHF_WRITE, SHF_ALLOC ]83 Address: 0x022084 Size: 0x000885 - Name: .comment86 Type: SHT_PROGBITS87 Flags: [ SHF_MERGE, SHF_STRINGS ]88 EntSize: 0x000189 Content: ''90...91