1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3# RUN: echo "SECTIONS { \
4# RUN:  . = 1000h;              \
5# RUN:  .hex1 : { *(.hex.1) }   \
6# RUN:  . = 1010H;              \
7# RUN:  .hex2 : { *(.hex.2) }   \
8# RUN:  . = 10k;                \
9# RUN:  .kilo1 : { *(.kilo.1) } \
10# RUN:  . = 11K;                \
11# RUN:  .kilo2 : { *(.kilo.2) } \
12# RUN:  . = 1m;                 \
13# RUN:  .mega1 : { *(.mega.1) } \
14# RUN:  . = 2M;                 \
15# RUN:  .mega2 : { *(.mega.2) } \
16# RUN: }" > %t.script
17# RUN: ld.lld %t --script %t.script -o %t2
18# RUN: llvm-objdump --section-headers %t2 | FileCheck %s
19
20# CHECK:     Sections:
21# CHECK-NEXT: Idx Name          Size     VMA
22# CHECK-NEXT:   0               00000000 0000000000000000
23# CHECK-NEXT:   1 .hex1         00000008 0000000000001000
24# CHECK-NEXT:   2 .hex2         00000008 0000000000001010
25# CHECK-NEXT:   3 .kilo1        00000008 0000000000002800
26# CHECK-NEXT:   4 .kilo2        00000008 0000000000002c00
27# CHECK-NEXT:   5 .mega1        00000008 0000000000100000
28# CHECK-NEXT:   6 .mega2        00000008 0000000000200000
29
30## Mailformed number errors.
31# RUN: echo "SECTIONS { . = 0x11h; }" > %t2.script
32# RUN: not ld.lld %t --script %t2.script -o /dev/null 2>&1 | \
33# RUN:  FileCheck --check-prefix=ERR1 %s
34# ERR1: malformed number: 0x11h
35
36# RUN: echo "SECTIONS { . = 0x11k; }" > %t3.script
37# RUN: not ld.lld %t --script %t3.script -o /dev/null 2>&1 | \
38# RUN:  FileCheck --check-prefix=ERR2 %s
39# ERR2: malformed number: 0x11k
40
41# RUN: echo "SECTIONS { . = 0x11m; }" > %t4.script
42# RUN: not ld.lld %t --script %t4.script -o /dev/null 2>&1 | \
43# RUN:  FileCheck --check-prefix=ERR3 %s
44# ERR3: malformed number: 0x11m
45
46# RUN: echo "SECTIONS { . = 1zh; }" > %t5.script
47# RUN: not ld.lld %t --script %t5.script -o /dev/null 2>&1 | \
48# RUN:  FileCheck --check-prefix=ERR4 %s
49# ERR4: malformed number: 1zh
50
51# RUN: echo "SECTIONS { . = 1zk; }" > %t6.script
52# RUN: not ld.lld %t --script %t6.script -o /dev/null 2>&1 | \
53# RUN:  FileCheck --check-prefix=ERR5 %s
54# ERR5: malformed number: 1zk
55
56# RUN: echo "SECTIONS { . = 1zm; }" > %t7.script
57# RUN: not ld.lld %t --script %t7.script -o /dev/null 2>&1 | \
58# RUN:  FileCheck --check-prefix=ERR6 %s
59# ERR6: malformed number: 1zm
60
61## Make sure that numbers can be followed by a ":" with and without a space,
62## e.g. "0x100 :" or "0x100:"
63# RUN: echo "SECTIONS { \
64# RUN:  .hex1 0x400 : { *(.hex.1) } \
65# RUN:  .hex2 0x500:{ *(.hex.2) } \
66# RUN: }" > %t8.script
67# RUN: ld.lld %t --script %t8.script -o %t6
68# RUN: llvm-objdump --section-headers %t6 | FileCheck --check-prefix=SECADDR %s
69# SECADDR:     Sections:
70# SECADDR-NEXT: Idx Name          Size     VMA
71# SECADDR-NEXT:   0               00000000 0000000000000000
72# SECADDR-NEXT:   1 .hex1         00000008 0000000000000400
73# SECADDR-NEXT:   2 .hex2         00000008 0000000000000500
74
75.globl _start
76_start:
77nop
78
79.section .hex.1, "a"
80.quad 0
81
82.section .kilo.1, "a"
83.quad 0
84
85.section .mega.1, "a"
86.quad 0
87
88.section .hex.2, "a"
89.quad 0
90
91.section .kilo.2, "a"
92.quad 0
93
94.section .mega.2, "a"
95.quad 0
96