aboutsummaryrefslogtreecommitdiffstats
path: root/test/ELF/linkerscript/data-commands.s
blob: 5a5655620dd95320ad6c06396acb450077b4d3d4 (plain) (blame)
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
# REQUIRES: x86,mips
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: echo "SECTIONS                \
# RUN:  {                            \
# RUN:    .foo : {                   \
# RUN:      *(.foo.1)                \
# RUN:      BYTE(0x11)               \
# RUN:      *(.foo.2)                \
# RUN:      SHORT(0x1122)            \
# RUN:      *(.foo.3)                \
# RUN:      LONG(0x11223344)         \
# RUN:      *(.foo.4)                \
# RUN:      QUAD(0x1122334455667788) \
# RUN:    }                          \
# RUN:    .bar : {                   \
# RUN:      *(.bar.1)                \
# RUN:      BYTE(a + 1)              \
# RUN:      *(.bar.2)                \
# RUN:      SHORT(b)                 \
# RUN:      *(.bar.3)                \
# RUN:      LONG(c + 2)              \
# RUN:      *(.bar.4)                \
# RUN:      QUAD(d)                  \
# RUN:    }                          \
# RUN:  }" > %t.script
# RUN: ld.lld -o %t %t.o --script %t.script
# RUN: llvm-objdump -s %t | FileCheck %s

# CHECK:      Contents of section .foo:
# CHECK-NEXT:   ff11ff22 11ff4433 2211ff88 77665544
# CHECK-NEXT:   332211

# CHECK:      Contents of section .bar:
# CHECK-NEXT:   ff12ff22 11ff4633 2211ff88 77665544
# CHECK-NEXT:   332211

# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %tmips64be
# RUN: ld.lld --script %t.script %tmips64be -o %t2
# RUN: llvm-objdump -s %t2 | FileCheck %s --check-prefix=BE
# BE:      Contents of section .foo:
# BE-NEXT:   ff11ff11 22ff1122 3344ff11 22334455
# BE-NEXT:   667788
# BE-NEXT: Contents of section .bar:
# BE-NEXT:   ff12ff11 22ff1122 3346ff11 22334455
# BE-NEXT:   667788

# RUN: echo "MEMORY {                \
# RUN:     rom (rwx) : ORIGIN = 0x00, LENGTH = 2K \
# RUN:  }                            \
# RUN:  SECTIONS {                   \
# RUN:    .foo : {                   \
# RUN:      *(.foo.1)                \
# RUN:      BYTE(0x11)               \
# RUN:      *(.foo.2)                \
# RUN:      SHORT(0x1122)            \
# RUN:      *(.foo.3)                \
# RUN:      LONG(0x11223344)         \
# RUN:      *(.foo.4)                \
# RUN:      QUAD(0x1122334455667788) \
# RUN:    } > rom                    \
# RUN:    .bar : {                   \
# RUN:      *(.bar.1)                \
# RUN:      BYTE(a + 1)              \
# RUN:      *(.bar.2)                \
# RUN:      SHORT(b)                 \
# RUN:      *(.bar.3)                \
# RUN:      LONG(c + 2)              \
# RUN:      *(.bar.4)                \
# RUN:      QUAD(d)                  \
# RUN:    } > rom                    \
# RUN:  }" > %t-memory.script
# RUN: ld.lld -o %t-memory %t.o --script %t-memory.script
# RUN: llvm-objdump -s %t-memory | FileCheck %s --check-prefix=MEM

# MEM:      Contents of section .foo:
# MEM-NEXT:   0000 ff11ff22 11ff4433 2211ff88 77665544
# MEM-NEXT:   0010 332211

# MEM:      Contents of section .bar:
# MEM-NEXT:   0013 ff12ff22 11ff4633 2211ff88 77665544
# MEM-NEXT:   0023 332211

.global a
a = 0x11

.global b
b = 0x1122

.global c
c = 0x11223344

.global d
d = 0x1122334455667788

.section .foo.1, "a"
 .byte 0xFF

.section .foo.2, "a"
 .byte 0xFF

.section .foo.3, "a"
 .byte 0xFF

.section .foo.4, "a"
 .byte 0xFF

.section .bar.1, "a"
 .byte 0xFF

.section .bar.2, "a"
 .byte 0xFF

.section .bar.3, "a"
 .byte 0xFF

.section .bar.4, "a"
 .byte 0xFF