1 # RUN: yaml2obj %s -o %t
3 # RUN: not llvm-objcopy --pad-to=1 %t 2>&1 | FileCheck %s --check-prefix=NOT-BINARY
4 # NOT-BINARY: error: '--pad-to' is only supported for binary output
6 # RUN: not llvm-objcopy -O binary --pad-to= %t 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT
7 # BAD-FORMAT: error: --pad-to: bad number:
9 # RUN: not llvm-objcopy -O binary --pad-to=x %t 2>&1 | FileCheck %s --check-prefix=BAD-INPUT
10 # BAD-INPUT: error: --pad-to: bad number: x
12 # RUN: not llvm-objcopy -O binary --pad-to=0x1G %t 2>&1 | FileCheck %s --check-prefix=BAD-INPUT2
13 # BAD-INPUT2: error: --pad-to: bad number: 0x1G
15 # RUN: not llvm-objcopy -O binary --pad-to=ff %t 2>&1 | FileCheck %s --check-prefix=BAD-INPUT3
16 # BAD-INPUT3: error: --pad-to: bad number: ff
18 # RUN: not llvm-objcopy -O binary --pad-to=0x112233445566778899 %t 2>&1 | FileCheck %s --check-prefix=BAD-NUMBER
19 # BAD-NUMBER: error: --pad-to: bad number: 0x112233445566778899
21 ## Save the baseline, not padded output.
22 # RUN: llvm-objcopy -O binary %t %t.bin
24 ## Pad to an address smaller than the binary size.
25 # RUN: llvm-objcopy -O binary --pad-to=0x20 %t %t-p1
26 # RUN: cmp %t.bin %t-p1
27 # RUN: llvm-objcopy -O binary --pad-to=0x200 %t %t-p2
28 # RUN: cmp %t.bin %t-p2
30 ## Pad all allocatable sections to a valid address.
31 # RUN: llvm-objcopy -O binary --pad-to=0x218 %t %t-pad-default
32 # RUN: od -v -Ax -t x1 %t-pad-default | FileCheck %s --check-prefix=DEFAULT --ignore-case --match-full-lines
33 # DEFAULT: {{0*}}00 11 22 33 44 55 66 00 00 00 00 00 00 00 00 00 00
34 # DEFAULT-NEXT: {{0*}}10 77 88 99 aa 00 00 00 00
35 # DEFAULT-NEXT: {{0*}}18
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-decimal
39 # RUN: od -v -Ax -t x1 %t-pad-decimal | FileCheck %s --check-prefix=DECIMAL --ignore-case --match-full-lines
40 # DECIMAL: {{0*}}00 11 22 33 44 55 66 00 00 00 00 00 00 00 00 00 00
41 # DECIMAL-NEXT: {{0*}}10 77 88 99 aa 00 00 00 00
42 # DECIMAL-NEXT: {{0*}}18
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-fill
46 # RUN: od -v -Ax -t x1 %t-pad-fill | FileCheck %s --check-prefix=FILL --ignore-case --match-full-lines
47 # FILL: {{0*}}00 11 22 33 44 55 66 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
48 # FILL-NEXT: {{0*}}10 77 88 99 aa e9 e9 e9 e9
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-filled
53 # RUN: od -v -Ax -t x1 %t-filled | FileCheck %s --check-prefix=REMOVE-SECTION --ignore-case --match-full-lines
54 # REMOVE-SECTION: {{0*}}00 11 22 33 44 55 66 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
55 # REMOVE-SECTION-NEXT: {{0*}}10 e9 e9 e9 e9 e9 e9 e9 e9
56 # REMOVE-SECTION-NEXT: {{0*}}18
70 Content: '112233445566'
77 Flags: [ SHF_WRITE, SHF_ALLOC ]
82 Flags: [ SHF_WRITE, SHF_ALLOC ]
87 Flags: [ SHF_MERGE, SHF_STRINGS ]