Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1104)

Side by Side Diff: src/trusted/service_runtime/arch/arm/nacl_text_pad_test.S

Issue 8826003: Modify ARM .S code so it can be processed by both gnu-as and llvm-mc. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pnacl/driver/pnacl-as.py ('k') | src/trusted/service_runtime/nacl.scons » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 The Native Client Authors. All rights reserved. 2 * Copyright 2010 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be found in the LICENSE file.
5 */ 5 */
6 #include "native_client/src/trusted/service_runtime/include/bits/nacl_syscalls.h " 6 #include "native_client/src/trusted/service_runtime/include/bits/nacl_syscalls.h "
7 #include "native_client/src/trusted/service_runtime/nacl_config.h" 7 #include "native_client/src/trusted/service_runtime/nacl_config.h"
8 8
9 /* 9 #define halt 0xe1266676
10
11 /*
jvoung - send to chromium... 2011/12/07 18:39:02 space to re-align the /*
robertm 2011/12/07 19:24:33 Done.
10 * Code to test various address layout boundary conditions. 12 * Code to test various address layout boundary conditions.
11 * This is a translation from the x86-{32,64} code, and is 13 * This is a translation from the x86-{32,64} code, and is
12 * not intended to be super efficent, just good enough to 14 * not intended to be super efficent, just good enough to
13 * print out the values that are designed, while maintaining 15 * print out the values that are designed, while maintaining
14 * strict control over the address space layout. 16 * strict control over the address space layout.
15 */ 17 */
16 18
17 .cpu cortex-a8
jvoung - send to chromium... 2011/12/07 18:39:02 doesn't movw/movt require some cpu baseline? Is t
robertm 2011/12/07 19:24:33 llvm-mc does not like this pseudo and gnu-as does
18
19 .text 19 .text
20 start_of_text: 20 start_of_text:
21 /* 21 /*
22 * write_num_10 omitted. __aeabi_udivmod is too long/complex 22 * write_num_10 omitted. __aeabi_udivmod is too long/complex
23 * to replicate, we cannot link against glibc to get _udivsi3.o 23 * to replicate, we cannot link against glibc to get _udivsi3.o
24 * and pick up transitive dependencies. Plus, we don't actually 24 * and pick up transitive dependencies. Plus, we don't actually
25 * use decimal output (yet). 25 * use decimal output (yet).
26 * 26 *
27 * One alternative would be to link using: 27 * One alternative would be to link using:
28 * 28 *
(...skipping 28 matching lines...) Expand all
57 ble do_digit_not_upper 57 ble do_digit_not_upper
58 add r4, r4, #('a'-'0'-10) 58 add r4, r4, #('a'-'0'-10)
59 59
60 do_digit_not_upper: 60 do_digit_not_upper:
61 bic r3, r3, #0xc0000000 61 bic r3, r3, #0xc0000000
62 strb r4, [r3] 62 strb r4, [r3]
63 lsrs r1, r1, #4 63 lsrs r1, r1, #4
64 bne do_digit_16 64 bne do_digit_16
65 65
66 mov r1, r3 66 mov r1, r3
67 movw r3, #:lower16:NACL_SYSCALL_ADDR(NACL_sys_write) 67 movw r3, :lower16:(NACL_SYSCALL_ADDR(NACL_sys_write))
68 movt r3, #:upper16:NACL_SYSCALL_ADDR(NACL_sys_write) 68 movt r3, :upper16:(NACL_SYSCALL_ADDR(NACL_sys_write))
69 nop 69 nop
70 70
71 nop 71 nop
72 nop 72 nop
73 bic r3, r3, #0xc000000f 73 bic r3, r3, #0xc000000f
74 blx r3 74 blx r3
75 75
76 add sp, sp, #0x10 76 add sp, sp, #0x10
77 bic sp, sp, #0xc0000000 77 bic sp, sp, #0xc0000000
78 pop {r4, lr} 78 pop {r4, lr}
79 nop 79 nop
80 80
81 bic lr, lr, #0xc000000f 81 bic lr, lr, #0xc000000f
82 bx lr 82 bx lr
83 83
84 .p2align 4 84 .p2align 4
85 /* 85 /*
86 * r0 is descriptor number, r1 is character to write 86 * r0 is descriptor number, r1 is character to write
87 */ 87 */
88 write_char: 88 write_char:
89 push {lr} 89 push {lr}
90 sub sp, sp, #0x10 90 sub sp, sp, #0x10
91 bic sp, sp, #0xc0000000 91 bic sp, sp, #0xc0000000
92 strb r1, [sp] 92 strb r1, [sp]
93 93
94 mov r1, sp 94 mov r1, sp
95 mov r2, #1 95 mov r2, #1
96 movw r3, #:lower16:NACL_SYSCALL_ADDR(NACL_sys_write) 96 movw r3, :lower16:(NACL_SYSCALL_ADDR(NACL_sys_write))
97 movt r3, #:upper16:NACL_SYSCALL_ADDR(NACL_sys_write) 97 movt r3, :upper16:(NACL_SYSCALL_ADDR(NACL_sys_write))
98 98
99 nop 99 nop
100 nop 100 nop
101 bic r3, r3, #0xc000000f 101 bic r3, r3, #0xc000000f
102 blx r3 102 blx r3
103 103
104 add sp, sp, #0x10 104 add sp, sp, #0x10
105 bic sp, sp, #0xc0000000 105 bic sp, sp, #0xc0000000
106 pop {lr} 106 pop {lr}
107 nop 107 nop
108 108
109 bic lr, lr, #0xc000000f 109 bic lr, lr, #0xc000000f
110 bx lr 110 bx lr
111 111
112 .p2align 4 112 .p2align 4
113 .globl _start 113 .globl _start
114 _start: 114 _start:
115 /* basic I/O test */ 115 /* basic I/O test */
116 mov r0, #1 116 mov r0, #1
117 movw r1, #0xbeef 117 movw r1, #0xbeef
118 movt r1, #0xdead 118 movt r1, #0xdead
119 bl write_num_16 119 bl write_num_16
120 120
121 mov r0, #1 121 mov r0, #1
122 mov r1, #'\n' 122 mov r1, #'\n'
123 nop 123 nop
124 bl write_char 124 bl write_char
125 125
126 movw r1, #:lower16:end_of_text 126 movw r1, :lower16:(end_of_text)
jvoung - send to chromium... 2011/12/07 18:39:02 Shouldn't there be a #? This could be a bug in the
robertm 2011/12/07 19:24:33 gnu-as seems happy without it and llvm-mc dies not
jvoung - send to chromium... 2011/12/07 20:32:12 Sure, :lower16: is special and generates a relocat
127 movt r1, #:upper16:end_of_text 127 movt r1, :upper16:(end_of_text)
128 mov r0, #1 128 mov r0, #1
129 bl write_num_16 129 bl write_num_16
130 130
131 mov r0, #1 131 mov r0, #1
132 mov r1, #'\n' 132 mov r1, #'\n'
133 nop 133 nop
134 bl write_char 134 bl write_char
135 135
136 mov r0, #0 136 mov r0, #0
137 movw r3, #:lower16:NACL_SYSCALL_ADDR(NACL_sys_sysbrk) 137 movw r3, :lower16:(NACL_SYSCALL_ADDR(NACL_sys_sysbrk))
138 movt r3, #:upper16:NACL_SYSCALL_ADDR(NACL_sys_sysbrk) 138 movt r3, :upper16:(NACL_SYSCALL_ADDR(NACL_sys_sysbrk))
139 nop 139 nop
140 140
141 nop 141 nop
142 nop 142 nop
143 bic r3, r3, #0xc000000f 143 bic r3, r3, #0xc000000f
144 blx r3 144 blx r3
145 145
146 mov r4, r0 /* save a copy of break addr */ 146 mov r4, r0 /* save a copy of break addr */
147 mov r1, r0 147 mov r1, r0
148 mov r0, #1 148 mov r0, #1
149 bl write_num_16 149 bl write_num_16
150 150
151 mov r0, #1 151 mov r0, #1
152 mov r1, #'\n' 152 mov r1, #'\n'
153 nop 153 nop
154 bl write_char 154 bl write_char
155 155
156 mov r5, #0 /* r5 holds eventual exit status */ 156 mov r5, #0 /* r5 holds eventual exit status */
157 movw r1, #:lower16:EXPECTED_BREAK 157 movw r1, :lower16:(EXPECTED_BREAK)
158 movt r1, #:upper16:EXPECTED_BREAK 158 movt r1, :upper16:(EXPECTED_BREAK)
159 cmp r1, r4 159 cmp r1, r4
160 160
161 movne r5, #1 161 movne r5, #1
162 mov r0, #1 /* r1 still has EXPECTED_BREAK */ 162 mov r0, #1 /* r1 still has EXPECTED_BREAK */
163 nop 163 nop
164 bl write_num_16 164 bl write_num_16
165 165
166 mov r1, #'\n' 166 mov r1, #'\n'
167 mov r0, #1 167 mov r0, #1
168 nop 168 nop
169 bl write_char 169 bl write_char
170 170
171 #if EXPECTED_RODATA != 0 171 #if EXPECTED_RODATA != 0
172 mov r2, #12 172 mov r2, #12
173 movw r1, #:lower16:ro_str 173 movw r1, :lower16:(ro_str)
174 movt r1, #:upper16:ro_str 174 movt r1, :upper16:(ro_str)
175 mov r0, #1 175 mov r0, #1
176 176
177 movw r3, #:lower16:NACL_SYSCALL_ADDR(NACL_sys_write) 177 movw r3, :lower16:(NACL_SYSCALL_ADDR(NACL_sys_write))
178 movt r3, #:upper16:NACL_SYSCALL_ADDR(NACL_sys_write) 178 movt r3, :upper16:(NACL_SYSCALL_ADDR(NACL_sys_write))
179 bic r3, r3, #0xc000000f 179 bic r3, r3, #0xc000000f
180 blx r3 180 blx r3
181 181
182 movw r1, #:lower16:ro_str 182 movw r1, :lower16:(ro_str)
183 movt r1, #:upper16:ro_str 183 movt r1, :upper16:(ro_str)
184 mov r0, #1 184 mov r0, #1
185 bl write_num_16 185 bl write_num_16
186 186
187 mov r1, #'\n' 187 mov r1, #'\n'
188 mov r0, #1 188 mov r0, #1
189 nop 189 nop
190 bl write_char 190 bl write_char
191 191
192 movw r1, #:lower16:EXPECTED_RODATA 192 movw r1, :lower16:(EXPECTED_RODATA)
193 movt r1, #:upper16:EXPECTED_RODATA 193 movt r1, :upper16:(EXPECTED_RODATA)
194 movw r2, #:lower16:ro_str 194 movw r2, :lower16:(ro_str)
195 movt r2, #:upper16:ro_str 195 movt r2, :upper16:(ro_str)
196 196
197 cmp r1, r2 197 cmp r1, r2
198 movne r5, #1 198 movne r5, #1
199 mov r0, #1 /* r1 still has EXPECTED_RODATA */ 199 mov r0, #1 /* r1 still has EXPECTED_RODATA */
200 bl write_num_16 200 bl write_num_16
201 201
202 mov r1, #'\n' 202 mov r1, #'\n'
203 mov r0, #1 203 mov r0, #1
204 nop 204 nop
205 bl write_char 205 bl write_char
206 #endif 206 #endif
207 207
208 movw r3, #:lower16:NACL_SYSCALL_ADDR(NACL_sys_exit) 208 movw r3, :lower16:(NACL_SYSCALL_ADDR(NACL_sys_exit))
209 movt r3, #:upper16:NACL_SYSCALL_ADDR(NACL_sys_exit) 209 movt r3, :upper16:(NACL_SYSCALL_ADDR(NACL_sys_exit))
210 mov r0, #0 210 mov r0, #0
211 nop 211 nop
212 212
213 nop 213 nop
214 nop 214 nop
215 bic r3, r3, #0xc000000f 215 bic r3, r3, #0xc000000f
216 blx r3 216 blx r3
217 #if defined(PNACL_AS)
218 /* NOTE: unlike x86 the alignment directive on ARM takes
219 the logarithm of the alignment */
220 #define POW2_BIGGER_THAN_DOT 14
221 .align32 POW2_BIGGER_THAN_DOT, halt
222 .fill (TEXT_EXTEND - (1 << POW2_BIGGER_THAN_DOT))/4, 4, halt
223 #else
224 .fill (TEXT_EXTEND - (. - start_of_text))/4, 4, halt
jvoung - send to chromium... 2011/12/07 18:39:02 is this workaround mostly because the llvm parser
robertm 2011/12/07 19:24:33 This is just a NYI in the llvm asm parser/handler
225 #endif
217 226
218 /* use new proper halt */
219 .fill (TEXT_EXTEND - (. - start_of_text))/4, 4, 0xe1266676
220 end_of_text: 227 end_of_text:
221 228
222 #if EXPECTED_RODATA != 0 229 #if EXPECTED_RODATA != 0
223 .section .rodata 230 .section .rodata
224 ro_str: .ascii "Hello world\n" 231 ro_str: .ascii "Hello world\n"
225 /* 123456789012 */ 232 /* 123456789012 */
226 #endif 233 #endif
OLDNEW
« no previous file with comments | « pnacl/driver/pnacl-as.py ('k') | src/trusted/service_runtime/nacl.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698