197 lines · plain
1## Check for basic functionality using an input file with2## various section types, adresses, data, and no segments.3# RUN: yaml2obj %s --docnum=1 -o %t4# RUN: llvm-objcopy -O srec %t - | \5# RUN: FileCheck --match-full-lines --strict-whitespace %s --check-prefix=SREC6 7## The record type for the header should be S0 with a 2 byte address8## 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:S00400002DCE12# SREC-NEXT:S31500001000000102030405060708090A0B0C0D0E0F6213# SREC-NEXT:S30A0000101010111213147B14# SREC-NEXT:S30F00EFFFFF111111111111111111115915# SREC-NEXT:S31000FFFFF83031323334353637383940AC16# SREC-NEXT:S30A8000100000010203045B17# SREC-NEXT:S70500000000FA18 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=ENTRY22## 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=ENTRY25 26 # ENTRY:S00400002DCE27# ENTRY-NEXT:S705F00000000A28 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_START32 33# BAD_START: entry point address 0xf00000000 overflows 32 bits34 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_START38 39# BAD_EXTENDED_START: entry point address 0xffffffff0f000000 overflows 32 bits40 41--- !ELF42FileHeader:43 Class: ELFCLASS6444 Data: ELFDATA2LSB45 Type: ET_EXEC46 Machine: EM_X86_6447Sections:48 - Name: .data149## Records for this section should come last.50 Type: SHT_PROGBITS51 Flags: [ SHF_ALLOC ]52 Content: "11111111111111111111"53 Address: 0xEFFFFF54 - Name: .data255## This section overlaps 24-bit address boundary, so we expect56## its record type to be S3.57 Type: SHT_PROGBITS58 Flags: [ SHF_ALLOC ]59 Content: "3031323334353637383940"60 Address: 0xFFFFF861## Sign-extended addresses are OK.62 - Name: .data363 Type: SHT_PROGBITS64 Flags: [ SHF_ALLOC ]65 Address: 0xFFFFFFFF8000100066 Content: "0001020304"67 - Name: .text68## This section's contents exceed default line length of 16 bytes69## so we expect two lines created for it. Records for this section70## should appear before records for the previous section.71 Type: SHT_PROGBITS72 Flags: [ SHF_ALLOC ]73 Address: 0x100074 Content: "000102030405060708090A0B0C0D0E0F1011121314"75 - Name: .bss76## NOBITS sections are not written.77 Type: SHT_NOBITS78 Flags: [ SHF_ALLOC ]79 Address: 0x1010080 Size: 0x100081 - Name: .dummy82## Non-allocatable sections are not written.83 Type: SHT_PROGBITS84 Flags: [ ]85 Address: 0x20FFF886 Size: 6553687 88## Check for various error cases.89 90## Check that section address range overlapping 32 bit range91## triggers an error.92# RUN: yaml2obj %s --docnum=2 -o %t.err93# RUN: not llvm-objcopy -O srec --only-section=.text1 %t.err - 2>&1 | \94# RUN: FileCheck %s --check-prefix=BAD-ADDR95# RUN: not llvm-objcopy -O srec --only-section=.text2 %t.err - 2>&1 | \96# RUN: FileCheck %s --check-prefix=BAD-ADDR297 98# BAD-ADDR: section '.text1' address range [0xfffffff8, 0x100000000] is not 32 bit99# BAD-ADDR2: section '.text2' address range [0xffffffff0, 0xffffffff4] is not 32 bit100 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_SEC104 105## There should be no records besides header and terminator.106# ZERO_SIZE_SEC:S00400002DCE107# ZERO_SIZE_SEC-NEXT:S9030000FC108 109--- !ELF110FileHeader:111 Class: ELFCLASS64112 Data: ELFDATA2LSB113 Type: ET_EXEC114 Machine: EM_X86_64115Sections:116 - Name: .text1117## Part of section data is in 32-bit address range and part isn't.118 Type: SHT_PROGBITS119 Flags: [ SHF_ALLOC]120 Address: 0xFFFFFFF8121 Content: "000102030405060708"122 - Name: .text2123 ## Entire secion is outside of 32-bit range.124 Type: SHT_PROGBITS125 Flags: [ SHF_ALLOC ]126 Address: 0xFFFFFFFF0127 Content: "0001020304"128 129## This tests an input file with segments and expects130## physical addresses instead of virtual addresses.131# RUN: yaml2obj %s --docnum=3 -o %t.seg132# RUN: llvm-objcopy -O srec %t.seg - | \133# RUN: FileCheck --match-full-lines --strict-whitespace %s --check-prefix=PADDR134 135 # PADDR:S00400002DCE136# PADDR-NEXT:S214100000000102030405060708090A0B0C0D0E0F63137# PADDR-NEXT:S20910001010111213147C138# PADDR-NEXT:S20F10001530313233343536373839407E139# PADDR-NEXT:S20810002040414243C1140# PADDR-NEXT:S20F10002450515253545556575859600F141# PADDR-NEXT:S20720FFF8000000E1142# PADDR-NEXT:S804100000EB143 144--- !ELF145## This file has a non-contiguous section layout with large gaps.146## These sections are all tightly packed into one PT_LOAD segment147## starting at physical address 0x100000. Records should use physical addresses.148FileHeader:149 Class: ELFCLASS64150 Data: ELFDATA2LSB151 Type: ET_EXEC152 Machine: EM_X86_64153 Entry: 0x100000154Sections:155 - Name: .text156 Type: SHT_PROGBITS157 Flags: [ SHF_ALLOC ]158 Address: 0x0159 Content: "000102030405060708090A0B0C0D0E0F1011121314"160 - Name: .data1161 Type: SHT_PROGBITS162 Flags: [ SHF_ALLOC ]163 Content: "3031323334353637383940"164 Address: 0xFFF8165 - Name: .data2166 Type: SHT_PROGBITS167 Flags: [ SHF_ALLOC ]168 Content: "40414243"169 Address: 0x10100170 - Name: .data3171 Type: SHT_PROGBITS172 Flags: [ SHF_ALLOC ]173 Content: "5051525354555657585960"174 Address: 0x10FFF8175 - Name: .bss176 Type: SHT_NOBITS177 Flags: [ SHF_ALLOC ]178 Address: 0x10100179 Size: 0x1000180 - Name: .dummy181 Type: SHT_PROGBITS182 Flags: [ SHF_ALLOC ]183 Address: 0x20FFF8184 Size: 3185 - Name: .nonalloc186 Type: SHT_PROGBITS187 Flags: [ ]188 Address: 0x300000189 Size: 1190ProgramHeaders:191 - Type: PT_LOAD192 Flags: [ PF_X, PF_R ]193 VAddr: 0xF00000000194 PAddr: 0x100000195 FirstSec: .text196 LastSec: .bss197