1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
# RUN: yaml2obj --docnum=1 %s -o %t
# RUN: not llvm-objcopy --gap-fill 1 %t 2>&1 | FileCheck %s --check-prefix=NOT-BINARY
# NOT-BINARY: error: '--gap-fill' is only supported for binary output
# RUN: not llvm-objcopy -O binary --gap-fill= %t %t.bin 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT
# BAD-FORMAT: error: --gap-fill: bad number:
# RUN: not llvm-objcopy -O binary --gap-fill=x %t %t.bin 2>&1 | FileCheck %s --check-prefix=BAD-INPUT
# BAD-INPUT: error: --gap-fill: bad number: x
# RUN: not llvm-objcopy -O binary --gap-fill=0x %t %t.bin 2>&1 | FileCheck %s --check-prefix=BAD-INPUT2
# BAD-INPUT2: error: --gap-fill: bad number: 0x
# RUN: not llvm-objcopy -O binary --gap-fill=0x1G %t %t.bin 2>&1 | FileCheck %s --check-prefix=BAD-INPUT3
# BAD-INPUT3: error: --gap-fill: bad number: 0x1G
# RUN: not llvm-objcopy -O binary --gap-fill=ff %t %t.bin 2>&1 | FileCheck %s --check-prefix=BAD-INPUT4
# BAD-INPUT4: error: --gap-fill: bad number: ff
# RUN: not llvm-objcopy -O binary --gap-fill=0x1122 %t %t-val16 2>&1 | FileCheck %s --check-prefix=TRUNCATED-ERR
# TRUNCATED-ERR: error: gap-fill value 0x1122 is out of range (0 to 0xff)
## Test no gap fill with all allocatable output sections.
# RUN: llvm-objcopy -O binary %t %t-default
# RUN: od -v -Ax -t x1 %t-default | FileCheck %s --check-prefix=DEFAULT --ignore-case --match-full-lines
# DEFAULT: {{0*}}00 ee ff 11 22 33 44 aa bb cc dd fe dc ba 00 a1 b2
# DEFAULT-NEXT: {{0*}}10 c3 d4 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# DEFAULT-NEXT: {{0*}}20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# DEFAULT-NEXT: {{0*}}30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# DEFAULT-NEXT: {{0*}}40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# DEFAULT-NEXT: {{0*}}50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# DEFAULT-NEXT: {{0*}}60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# DEFAULT-NEXT: {{0*}}70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# DEFAULT-NEXT: {{0*}}80 00 00 89 ab cd ef
# DEFAULT-NEXT: {{0*}}86
## Test gap fill with all allocatable output sections.
# RUN: llvm-objcopy -O binary --gap-fill=0xe9 %t %t-filled
# RUN: od -v -Ax -t x1 %t-filled | FileCheck %s --check-prefix=FULL --ignore-case --match-full-lines
# FULL: {{0*}}00 ee ff 11 22 33 44 aa bb cc dd fe dc ba e9 a1 b2
# FULL-NEXT: {{0*}}10 c3 d4 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# FULL-NEXT: {{0*}}20 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# FULL-NEXT: {{0*}}30 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# FULL-NEXT: {{0*}}40 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# FULL-NEXT: {{0*}}50 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# FULL-NEXT: {{0*}}60 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# FULL-NEXT: {{0*}}70 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# FULL-NEXT: {{0*}}80 e9 e9 89 ab cd ef
# FULL-NEXT: {{0*}}86
## Test gap fill with a decimal value.
# RUN: llvm-objcopy -O binary --gap-fill=99 %t %t-filled-decimal
# RUN: od -v -Ax -t x1 %t-filled-decimal | FileCheck %s --check-prefix=DEC --ignore-case --match-full-lines
# DEC: {{0*}}00 ee ff 11 22 33 44 aa bb cc dd fe dc ba 63 a1 b2
# DEC-NEXT: {{0*}}10 c3 d4 63 63 63 63 63 63 63 63 63 63 63 63 63 63
# DEC-NEXT: {{0*}}20 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63
# DEC-NEXT: {{0*}}30 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63
# DEC-NEXT: {{0*}}40 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63
# DEC-NEXT: {{0*}}50 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63
# DEC-NEXT: {{0*}}60 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63
# DEC-NEXT: {{0*}}70 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63
# DEC-NEXT: {{0*}}80 63 63 89 ab cd ef
# DEC-NEXT: {{0*}}86
## Test gap fill with the last section removed, should be truncated.
# RUN: llvm-objcopy -O binary --gap-fill=0xe9 --remove-section=.foo %t %t-filled
# RUN: od -v -Ax -t x1 %t-filled | FileCheck %s --check-prefix=REMOVE-LAST-SECTION --ignore-case --match-full-lines
# REMOVE-LAST-SECTION: {{0*}}00 ee ff 11 22 33 44 aa bb cc dd fe dc ba e9 a1 b2
# REMOVE-LAST-SECTION-NEXT: {{0*}}10 c3 d4
# REMOVE-LAST-SECTION-NEXT: {{0*}}12
## Test gap fill with the middle section removed, should be filled.
# RUN: llvm-objcopy -O binary --gap-fill=0xe9 --remove-section=.gap2 %t %t-filled
# RUN: od -v -Ax -t x1 %t-filled | FileCheck %s --check-prefix=REMOVE-MIDDLE-SECTION --ignore-case --match-full-lines
# REMOVE-MIDDLE-SECTION: {{0*}}00 ee ff 11 22 33 44 aa bb cc dd fe dc ba e9 e9 e9
# REMOVE-MIDDLE-SECTION-NEXT: {{0*}}10 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# REMOVE-MIDDLE-SECTION-NEXT: {{0*}}20 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# REMOVE-MIDDLE-SECTION-NEXT: {{0*}}30 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# REMOVE-MIDDLE-SECTION-NEXT: {{0*}}40 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# REMOVE-MIDDLE-SECTION-NEXT: {{0*}}50 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# REMOVE-MIDDLE-SECTION-NEXT: {{0*}}60 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# REMOVE-MIDDLE-SECTION-NEXT: {{0*}}70 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9 e9
# REMOVE-MIDDLE-SECTION-NEXT: {{0*}}80 e9 e9 89 ab cd ef
# REMOVE-MIDDLE-SECTION-NEXT: {{0*}}86
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .space1
Type: Fill
Pattern: 'ABCD'
Size: 0x2
- Name: .nogap
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x0102
Size: 0x6
Content: 'EEFF11223344'
- Name: .gap1
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x0108
Content: 'AABBCCDDFEDCBA'
- Name: .zero_size
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x0110
Size: 0
- Name: .space2
Type: Fill
Pattern: 'DC'
Size: 1
- Name: .gap2
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x0110
Content: 'A1B2C3D4'
- Name: .space3
Type: Fill
Pattern: 'FE'
Size: 0x1
- Name: .nobit_tbss
Type: SHT_NOBITS
Flags: [ SHF_WRITE, SHF_ALLOC, SHF_TLS ]
Address: 0x0180
Size: 0x0018
- Name: .space4
Type: Fill
Pattern: '01234567'
Size: 0x4
- Name: .foo
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
Address: 0x0184
Content: '89ABCDEF'
- Name: .nobit_bss
Type: SHT_NOBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
Address: 0x018A
Size: 0x0008
- Name: .comment
Type: SHT_PROGBITS
Flags: [ SHF_MERGE, SHF_STRINGS ]
EntSize: 0x0001
Content: 4743433A
## In this test, output sections are defined out of order with respect to their
## load addresses. Verify that gaps are still correctly filled.
# RUN: yaml2obj --docnum=2 %s -o %t.2
# RUN: llvm-objcopy -O binary --gap-fill=0xe9 %t.2 %t.2.filled
# RUN: od -v -Ax -t x1 %t.2.filled | FileCheck --ignore-case --match-full-lines %s
# CHECK: {{0*}}00 aa bb cc dd e9 e9 e9 e9 11 22 33 44
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .bss
Type: SHT_NOBITS
Flags: [ SHF_ALLOC, SHF_WRITE ]
Address: 0x0104
Size: 4
- Name: .section1
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_WRITE ]
Address: 0x0108
Content: '11223344'
- Name: .section3
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_WRITE ]
Address: 0x0100
Content: 'AABBCCDD'
|