1## Check for basic functionality using an input file with 2## various section types, adresses, data, and no segments. 3# RUN: yaml2obj %s --docnum=1 -o %t 4# RUN: llvm-objcopy -O srec %t - | \ 5# RUN: FileCheck --match-full-lines --strict-whitespace %s --check-prefix=SREC 6 7## The record type for the header should be S0 with a 2 byte address 8## of 0. For an output file named "-" the header data field should contain "2D". 9## The byte count field should therefore have a value of 4: 2 bytes for address, 10## 1 byte for output file and 1 byte for checksum. 11 # SREC:S00400002DCE 12# SREC-NEXT:S31500001000000102030405060708090A0B0C0D0E0F62 13# SREC-NEXT:S30A0000101010111213147B 14# SREC-NEXT:S30F00EFFFFF1111111111111111111159 15# SREC-NEXT:S31000FFFFF83031323334353637383940AC 16# SREC-NEXT:S30A8000100000010203045B 17# SREC-NEXT:S70500000000FA 18 19## Terminator should contain the entry point. 20# RUN: llvm-objcopy -O srec --set-start=0xF0000000 %t --only-section=.dummy - 2>&1 | \ 21# RUN: FileCheck --match-full-lines --strict-whitespace %s --check-prefix=ENTRY 22## Sign-extended entry point is OK. 23# RUN: llvm-objcopy -O srec --set-start=0xFFFFFFFFF0000000 %t --only-section=.dummy - 2>&1 | \ 24# RUN: FileCheck --match-full-lines --strict-whitespace %s --check-prefix=ENTRY 25 26 # ENTRY:S00400002DCE 27# ENTRY-NEXT:S705F00000000A 28 29## Start address which exceeds 32 bit range triggers an error. 30# RUN: not llvm-objcopy -O srec --set-start=0xF00000000 %t - 2>&1 | \ 31# RUN: FileCheck %s --check-prefix=BAD_START 32 33# BAD_START: entry point address 0xf00000000 overflows 32 bits 34 35## Sign-extended start address which exceeds 32 bit range triggers an error. 36# RUN: not llvm-objcopy -O srec --set-start=0xFFFFFFFF0F000000 %t - 2>&1 | \ 37# RUN: FileCheck %s --check-prefix=BAD_EXTENDED_START 38 39# BAD_EXTENDED_START: entry point address 0xffffffff0f000000 overflows 32 bits 40 41--- !ELF 42FileHeader: 43 Class: ELFCLASS64 44 Data: ELFDATA2LSB 45 Type: ET_EXEC 46 Machine: EM_X86_64 47Sections: 48 - Name: .data1 49## Records for this section should come last. 50 Type: SHT_PROGBITS 51 Flags: [ SHF_ALLOC ] 52 Content: "11111111111111111111" 53 Address: 0xEFFFFF 54 - Name: .data2 55## This section overlaps 24-bit address boundary, so we expect 56## its record type to be S3. 57 Type: SHT_PROGBITS 58 Flags: [ SHF_ALLOC ] 59 Content: "3031323334353637383940" 60 Address: 0xFFFFF8 61## Sign-extended addresses are OK. 62 - Name: .data3 63 Type: SHT_PROGBITS 64 Flags: [ SHF_ALLOC ] 65 Address: 0xFFFFFFFF80001000 66 Content: "0001020304" 67 - Name: .text 68## This section's contents exceed default line length of 16 bytes 69## so we expect two lines created for it. Records for this section 70## should appear before records for the previous section. 71 Type: SHT_PROGBITS 72 Flags: [ SHF_ALLOC ] 73 Address: 0x1000 74 Content: "000102030405060708090A0B0C0D0E0F1011121314" 75 - Name: .bss 76## NOBITS sections are not written. 77 Type: SHT_NOBITS 78 Flags: [ SHF_ALLOC ] 79 Address: 0x10100 80 Size: 0x1000 81 - Name: .dummy 82## Non-allocatable sections are not written. 83 Type: SHT_PROGBITS 84 Flags: [ ] 85 Address: 0x20FFF8 86 Size: 65536 87 88## Check for various error cases. 89 90## Check that section address range overlapping 32 bit range 91## triggers an error. 92# RUN: yaml2obj %s --docnum=2 -o %t.err 93# RUN: not llvm-objcopy -O srec --only-section=.text1 %t.err - 2>&1 | \ 94# RUN: FileCheck %s --check-prefix=BAD-ADDR 95# RUN: not llvm-objcopy -O srec --only-section=.text2 %t.err - 2>&1 | \ 96# RUN: FileCheck %s --check-prefix=BAD-ADDR2 97 98# BAD-ADDR: section '.text1' address range [0xfffffff8, 0x100000000] is not 32 bit 99# BAD-ADDR2: section '.text2' address range [0xffffffff0, 0xffffffff4] is not 32 bit 100 101## Check that zero length section is not written. 102# RUN: llvm-objcopy -O srec --only-section=.text %t.err - | \ 103# RUN: FileCheck --match-full-lines --strict-whitespace --implicit-check-not={{.}} %s --check-prefix=ZERO_SIZE_SEC 104 105## There should be no records besides header and terminator. 106# ZERO_SIZE_SEC:S00400002DCE 107# ZERO_SIZE_SEC-NEXT:S9030000FC 108 109--- !ELF 110FileHeader: 111 Class: ELFCLASS64 112 Data: ELFDATA2LSB 113 Type: ET_EXEC 114 Machine: EM_X86_64 115Sections: 116 - Name: .text1 117## Part of section data is in 32-bit address range and part isn't. 118 Type: SHT_PROGBITS 119 Flags: [ SHF_ALLOC] 120 Address: 0xFFFFFFF8 121 Content: "000102030405060708" 122 - Name: .text2 123 ## Entire secion is outside of 32-bit range. 124 Type: SHT_PROGBITS 125 Flags: [ SHF_ALLOC ] 126 Address: 0xFFFFFFFF0 127 Content: "0001020304" 128 129## This tests an input file with segments and expects 130## physical addresses instead of virtual addresses. 131# RUN: yaml2obj %s --docnum=3 -o %t.seg 132# RUN: llvm-objcopy -O srec %t.seg - | \ 133# RUN: FileCheck --match-full-lines --strict-whitespace %s --check-prefix=PADDR 134 135 # PADDR:S00400002DCE 136# PADDR-NEXT:S214100000000102030405060708090A0B0C0D0E0F63 137# PADDR-NEXT:S20910001010111213147C 138# PADDR-NEXT:S20F10001530313233343536373839407E 139# PADDR-NEXT:S20810002040414243C1 140# PADDR-NEXT:S20F10002450515253545556575859600F 141# PADDR-NEXT:S20720FFF8000000E1 142# PADDR-NEXT:S804100000EB 143 144--- !ELF 145## This file has a non-contiguous section layout with large gaps. 146## These sections are all tightly packed into one PT_LOAD segment 147## starting at physical address 0x100000. Records should use physical addresses. 148FileHeader: 149 Class: ELFCLASS64 150 Data: ELFDATA2LSB 151 Type: ET_EXEC 152 Machine: EM_X86_64 153 Entry: 0x100000 154Sections: 155 - Name: .text 156 Type: SHT_PROGBITS 157 Flags: [ SHF_ALLOC ] 158 Address: 0x0 159 Content: "000102030405060708090A0B0C0D0E0F1011121314" 160 - Name: .data1 161 Type: SHT_PROGBITS 162 Flags: [ SHF_ALLOC ] 163 Content: "3031323334353637383940" 164 Address: 0xFFF8 165 - Name: .data2 166 Type: SHT_PROGBITS 167 Flags: [ SHF_ALLOC ] 168 Content: "40414243" 169 Address: 0x10100 170 - Name: .data3 171 Type: SHT_PROGBITS 172 Flags: [ SHF_ALLOC ] 173 Content: "5051525354555657585960" 174 Address: 0x10FFF8 175 - Name: .bss 176 Type: SHT_NOBITS 177 Flags: [ SHF_ALLOC ] 178 Address: 0x10100 179 Size: 0x1000 180 - Name: .dummy 181 Type: SHT_PROGBITS 182 Flags: [ SHF_ALLOC ] 183 Address: 0x20FFF8 184 Size: 3 185 - Name: .nonalloc 186 Type: SHT_PROGBITS 187 Flags: [ ] 188 Address: 0x300000 189 Size: 1 190ProgramHeaders: 191 - Type: PT_LOAD 192 Flags: [ PF_X, PF_R ] 193 VAddr: 0xF00000000 194 PAddr: 0x100000 195 FirstSec: .text 196 LastSec: .bss 197