1# RUN: yaml2obj %p/Inputs/ihex-elf-sections.yaml -o %t
2# RUN: llvm-objcopy -O ihex %t - | FileCheck %s
3
4# Check ihex output, when we have segments in ELF file
5# In such case only sections in PT_LOAD segments will
6# be exported and their physical addresses will be used
7# RUN: yaml2obj %p/Inputs/ihex-elf-segments.yaml -o %t-segs
8# RUN: llvm-objcopy -O ihex %t-segs - | FileCheck %s --check-prefix=SEGMENTS
9
10# Check that non-load segments are ignored:
11# RUN: yaml2obj %p/Inputs/ihex-elf-pt-null.yaml -o %t2-segs
12# RUN: llvm-objcopy -O ihex %t2-segs - | FileCheck %s --check-prefix=PT_NULL
13
14# Check that sign-extended 32-bit section addresses are processed
15# correctly
16# RUN: yaml2obj %p/Inputs/ihex-elf-sections2.yaml -o %t-sec2
17# RUN: llvm-objcopy -O ihex --only-section=.text1 %t-sec2 - | FileCheck %s --check-prefix=SIGN_EXTENDED
18
19# Check that section address range overlapping 32 bit range
20# triggers an error
21# RUN: not llvm-objcopy -O ihex --only-section=.text2 %t-sec2 %t-sec2-2.hex 2>&1 | FileCheck %s --check-prefix=BAD-ADDR
22# RUN: not llvm-objcopy -O ihex --only-section=.text3 %t-sec2 %t-sec2-3.hex 2>&1 | FileCheck %s --check-prefix=BAD-ADDR2
23
24# Check that zero length section is not written
25# RUN: llvm-objcopy -O ihex --only-section=.text %t-sec2 - | FileCheck %s --check-prefix=ZERO_SIZE_SEC
26
27# Check 80x86 start address record. It is created for start
28# addresses less than 0x100000
29# RUN: llvm-objcopy -O ihex --set-start=0xFFFF %t - | FileCheck %s --check-prefix=START1
30
31# Check i386 start address record (05). It is created for
32# start addresses which doesn't fit 20 bits
33# RUN: llvm-objcopy -O ihex --set-start=0x100000 %t - | FileCheck %s --check-prefix=START2
34
35# We allow sign extended 32 bit start addresses as well.
36# RUN: llvm-objcopy -O ihex --set-start=0xFFFFFFFF80001000 %t - | FileCheck %s --check-prefix=START3
37
38# Start address which exceeds 32 bit range triggers an error
39# RUN: not llvm-objcopy -O ihex --set-start=0xF00000000 %t %t6.hex 2>&1 | FileCheck %s --check-prefix=BAD-START
40
41# CHECK:      :10000000000102030405060708090A0B0C0D0E0F78
42# CHECK-NEXT: :05001000101112131491
43# CHECK-NEXT: :08FFF800303132333435363765
44# CHECK-NEXT: :020000021000EC
45# CHECK-NEXT: :030000003839404C
46# CHECK-NEXT: :0401000040414243F5
47# CHECK-NEXT: :020000020000FC
48# CHECK-NEXT: :020000040010EA
49# CHECK-NEXT: :08FFF800505152535455565765
50# CHECK-NEXT: :020000040011E9
51# CHECK-NEXT: :03000000585960EC
52# CHECK-NEXT: :00000001FF
53
54# SEGMENTS:       :020000040010EA
55# SEGMENTS-NEXT:  :10000000000102030405060708090A0B0C0D0E0F78
56# SEGMENTS-NEXT:  :05001000101112131491
57# SEGMENTS-NEXT:  :0B001800303132333435363738394090
58# SEGMENTS-NEXT:  :0400280040414243CE
59# SEGMENTS-NEXT:  :0B003000505152535455565758596018
60# SEGMENTS-NEXT:  :0400000500100000E7
61# SEGMENTS-NEXT:  :00000001FF
62
63# 'ExtendedAddr' (04) record shouldn't be created
64# PT_NULL-NOT: :02000004
65
66# SIGN_EXTENDED:      :0200000480007A
67# SIGN_EXTENDED-NEXT: :051000000001020304E1
68# SIGN_EXTENDED-NEXT: :00000001FF
69
70# BAD-ADDR: error: {{.*}}: Section '.text2' address range [0x{{.*}}, 0x{{.*}}] is not 32 bit
71# BAD-ADDR2: error: {{.*}}: Section '.text3' address range [0x{{.*}}, 0x{{.*}}] is not 32 bit
72
73# There shouldn't be 'ExtendedAddr' nor 'Data' records
74# ZERO_SIZE_SEC-NOT:  :02000004
75# ZERO_SIZE_SEC-NOT:  :00FFFF00
76# ZERO_SIZE_SEC:      :00000001FF
77
78# START1: :040000030000FFFFFB
79# START2: :0400000500100000E7
80# START3: :040000058000100067
81# BAD-START: error: {{.*}}: Entry point address 0x{{.*}} overflows 32 bits
82