/
arm.asm
612 lines (553 loc) · 21.5 KB
/
arm.asm
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
/* **********************************************************
* Copyright (c) 2014-2016 Google, Inc. All rights reserved.
* ********************************************************** */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Google, Inc. nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL VMWARE, INC. OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
/*
* ARM-specific assembly and trampoline code
*/
#include "../asm_defines.asm"
START_FILE
#include "include/syscall.h"
DECL_EXTERN(dynamorio_app_take_over_helper)
#if defined(UNIX)
DECL_EXTERN(master_signal_handler_C)
DECL_EXTERN(dr_setjmp_sigmask)
#endif
DECL_EXTERN(relocate_dynamorio)
DECL_EXTERN(privload_early_inject)
DECL_EXTERN(exiting_thread_count)
DECL_EXTERN(initstack)
DECL_EXTERN(initstack_mutex)
#define RESTORE_FROM_DCONTEXT_VIA_REG(reg,offs,dest) ldr dest, PTRSZ [reg, POUND (offs)]
#define SAVE_TO_DCONTEXT_VIA_REG(reg,offs,src) str src, PTRSZ [reg, POUND (offs)]
/* offsetof(dcontext_t, dstack) */
#define dstack_OFFSET 0x16c
/* offsetof(dcontext_t, is_exiting) */
#define is_exiting_OFFSET (dstack_OFFSET+1*ARG_SZ)
#ifdef X64
# define NUM_SIMD_SLOTS 32
# define SIMD_REG_SIZE 16
# define NUM_GPR_SLOTS 33 /* incl flags */
# define GPR_REG_SIZE 8
#else
# define NUM_SIMD_SLOTS 16
# define SIMD_REG_SIZE 16
# define NUM_GPR_SLOTS 17 /* incl flags */
# define GPR_REG_SIZE 4
#endif
#define PRE_SIMD_PADDING 0
#define PRIV_MCXT_SIMD_SIZE (PRE_SIMD_PADDING + NUM_SIMD_SLOTS*SIMD_REG_SIZE)
#define PRIV_MCXT_SIZE (NUM_GPR_SLOTS*GPR_REG_SIZE + PRIV_MCXT_SIMD_SIZE)
#define PRIV_MCXT_SP_FROM_SIMD (-(4*GPR_REG_SIZE)) /* flags, pc, lr, then sp */
#define PRIV_MCXT_PC_FROM_SIMD (-(2*GPR_REG_SIZE)) /* flags, then pc */
#ifndef UNIX
# error Non-Unix is not supported
#endif
/* all of the CPUID registers are only accessible in privileged modes */
DECLARE_FUNC(cpuid_supported)
GLOBAL_LABEL(cpuid_supported:)
mov r0, #0
bx lr
END_FUNC(cpuid_supported)
/* void call_switch_stack(void *func_arg, // REG_R0
* byte *stack, // REG_R1
* void (*func)(void *arg), // REG_R2
* void *mutex_to_free, // REG_R3
* bool return_on_return) // [REG_SP]
*/
DECLARE_FUNC(call_switch_stack)
GLOBAL_LABEL(call_switch_stack:)
/* we need a callee-saved reg across our call so save it onto stack */
push {REG_R4, lr}
/* check mutex_to_free */
cmp ARG4, #0
beq call_dispatch_alt_stack_no_free
/* release the mutex */
mov REG_R4, #0
str REG_R4, [ARG4]
call_dispatch_alt_stack_no_free:
/* switch stack */
mov REG_R4, sp
mov sp, ARG2
/* call func */
blx ARG3
/* switch stack back */
mov sp, REG_R4
/* load ARG5 (return_on_return) from stack after the push at beginning */
/* after call, so we can use REG_R3 as the scratch register */
ldr REG_R3, [sp, #8/* r4, lr */] /* ARG5 */
cmp REG_R3, #0
beq GLOBAL_REF(unexpected_return)
/* restore and return */
pop {REG_R4, pc}
END_FUNC(call_switch_stack)
#ifdef CLIENT_INTERFACE
/*
* Calls the specified function 'func' after switching to the DR stack
* for the thread corresponding to 'drcontext'.
* Passes in 8 arguments. Uses the C calling convention, so 'func' will work
* just fine even if if takes fewer than 8 args.
* Swaps the stack back upon return and returns the value returned by 'func'.
*
* void * dr_call_on_clean_stack(void *drcontext, //
* void *(*func)(arg1...arg8), // 0*ARG_SZ+r4
* void *arg1, // 1*ARG_SZ+r4
* void *arg2, // 2*ARG_SZ+r4
* void *arg3, // 6*ARG_SZ+r4
* void *arg4, // 7*ARG_SZ+r4
* void *arg5, // 8*ARG_SZ+r4
* void *arg6, // 9*ARG_SZ+r4
* void *arg7, //10*ARG_SZ+r4
* void *arg8) //11*ARG_SZ+r4
*/
DECLARE_EXPORTED_FUNC(dr_call_on_clean_stack)
GLOBAL_LABEL(dr_call_on_clean_stack:)
/* We need a callee-saved reg across the call: we use r4. */
push {REG_R1-REG_R5, lr}
mov REG_R4, REG_SP /* save sp across the call */
mov REG_R5, ARG2 /* save function in non-param reg */
/* Swap stacks */
RESTORE_FROM_DCONTEXT_VIA_REG(REG_R0, dstack_OFFSET, REG_SP)
/* Set up args */
sub REG_SP, #(4*ARG_SZ)
ldr REG_R0, [REG_R4, #(11*ARG_SZ)]
str REG_R0, ARG8
ldr REG_R0, [REG_R4, #(10*ARG_SZ)]
str REG_R0, ARG7
ldr REG_R0, [REG_R4, #(9*ARG_SZ)]
str REG_R0, ARG6
ldr REG_R0, [REG_R4, #(8*ARG_SZ)]
str REG_R0, ARG5
ldr ARG4, [REG_R4, #(7*ARG_SZ)]
ldr ARG3, [REG_R4, #(6*ARG_SZ)]
ldr ARG2, [REG_R4, #(2*ARG_SZ)]
ldr ARG1, [REG_R4, #(1*ARG_SZ)]
blx REG_R5
mov REG_SP, REG_R4
pop {REG_R1-REG_R5, pc} /* don't need r1-r3 values but this is simplest */
END_FUNC(dr_call_on_clean_stack)
#endif /* CLIENT_INTERFACE */
#ifndef NOT_DYNAMORIO_CORE_PROPER
/* FIXME i#1551: NYI on ARM */
/*
* dr_app_start - Causes application to run under Dynamo control
*/
#ifdef DR_APP_EXPORTS
DECLARE_EXPORTED_FUNC(dr_app_start)
GLOBAL_LABEL(dr_app_start:)
/* FIXME i#1551: NYI on ARM */
bl GLOBAL_REF(unexpected_return)
END_FUNC(dr_app_start)
/*
* dr_app_take_over - For the client interface, we'll export 'dr_app_take_over'
* for consistency with the dr_ naming convention of all exported functions.
* We'll keep 'dynamorio_app_take_over' for compatibility with the preinjector.
*/
DECLARE_EXPORTED_FUNC(dr_app_take_over)
GLOBAL_LABEL(dr_app_take_over:)
/* FIXME i#1551: NYI on ARM */
b GLOBAL_REF(dynamorio_app_take_over)
END_FUNC(dr_app_take_over)
/* dr_app_running_under_dynamorio - Indicates whether the current thread
* is running within the DynamoRIO code cache.
* Returns false (not under dynamorio) by default.
* The function is mangled by dynamorio to return true instead when
* it is brought into the code cache.
*/
DECLARE_EXPORTED_FUNC(dr_app_running_under_dynamorio)
GLOBAL_LABEL(dr_app_running_under_dynamorio:)
/* FIXME i#1551: NYI on ARM */
mov r0, #0
bl GLOBAL_REF(unexpected_return)
END_FUNC(dr_app_running_under_dynamorio)
#endif /* DR_APP_EXPORTS */
/*
* dynamorio_app_take_over - Causes application to run under DR
* control. DR never releases control.
*/
DECLARE_EXPORTED_FUNC(dynamorio_app_take_over)
GLOBAL_LABEL(dynamorio_app_take_over:)
push {lr}
vstmdb sp!, {d16-d31}
vstmdb sp!, {d0-d15}
mrs REG_R0, cpsr /* r0 is scratch */
push {REG_R0}
/* We can't push all regs w/ writeback */
stmdb sp, {REG_R0-r15}
str lr, [sp, #(PRIV_MCXT_PC_FROM_SIMD+4)] /* +4 b/c we pushed cpsr */
/* we need the sp at function entry */
mov REG_R0, sp
add REG_R0, REG_R0, #(PRIV_MCXT_SIMD_SIZE + 8) /* offset simd,cpsr,lr */
str REG_R0, [sp, #(PRIV_MCXT_SP_FROM_SIMD+4)] /* +4 b/c we pushed cpsr */
sub sp, sp, #(PRIV_MCXT_SIZE-PRIV_MCXT_SIMD_SIZE-4) /* simd,cpsr */
mov REG_R0, sp
CALLC1(GLOBAL_REF(dynamorio_app_take_over_helper), REG_R0)
/* if we get here, DR is not taking over */
add sp, sp, #PRIV_MCXT_SIZE
pop {pc}
END_FUNC(dynamorio_app_take_over)
/*
* cleanup_and_terminate(dcontext_t *dcontext, // 0*ARG_SZ+sp
* int sysnum, // 1*ARG_SZ+sp = syscall #
* int sys_arg1/param_base, // 2*ARG_SZ+sp = arg1 for syscall
* int sys_arg2, // 3*ARG_SZ+sp = arg2 for syscall
* bool exitproc, // 4*ARG_SZ+sp
* (2 more args that are ignored: Mac-only))
*
* See decl in arch_exports.h for description.
*/
DECLARE_FUNC(cleanup_and_terminate)
GLOBAL_LABEL(cleanup_and_terminate:)
push {REG_R0-REG_R3}
/* inc exiting_thread_count to avoid being killed once off all_threads list */
/* We use the following multi-instr and multi-stored-data sequence to maintain
* PIC code. Note that using "ldr r0, SYMREF(exiting_thread_count)" does
* NOT result in PIC code: it uses a stored absolute address.
*/
ldr REG_R2, .Lgot0
add REG_R2, REG_R2, pc
ldr REG_R0, .Lexiting_thread_count
.LPIC0: ldr REG_R0, [REG_R0, REG_R2]
mov REG_R2, #1
CALLC2(atomic_add, REG_R0, REG_R2)
/* save dcontext->dstack for freeing later and set dcontext->is_exiting */
ldr REG_R4, PTRSZ [sp, #(0*ARG_SZ)] /* dcontext */
mov REG_R1, #1
SAVE_TO_DCONTEXT_VIA_REG(REG_R4, is_exiting_OFFSET, REG_R1)
CALLC1(GLOBAL_REF(is_currently_on_dstack), REG_R4) /* r4 is callee-saved */
cmp REG_R0, #0
bne cat_save_dstack
mov REG_R4, #0 /* save 0 for dstack to avoid double-free */
b cat_done_saving_dstack
cat_save_dstack:
RESTORE_FROM_DCONTEXT_VIA_REG(REG_R4, dstack_OFFSET, REG_R4)
cat_done_saving_dstack:
CALLC0(GLOBAL_REF(get_cleanup_and_terminate_global_do_syscall_entry))
mov REG_R5, REG_R0
ldrb REG_R0, BYTE [sp, #(4*ARG_SZ)] /* exitproc */
cmp REG_R0, #0
beq cat_thread_only
CALLC0(GLOBAL_REF(dynamo_process_exit))
b cat_no_thread
cat_thread_only:
CALLC0(GLOBAL_REF(dynamo_thread_exit))
cat_no_thread:
/* switch to initstack for cleanup of dstack */
/* we use r6, r7, and r8 here so that atomic_swap doesn't clobber them */
mov REG_R6, #1
ldr REG_R8, .Lgot1
add REG_R8, REG_R8, pc
ldr REG_R7, .Linitstack_mutex
.LPIC1: ldr REG_R7, [REG_R7, REG_R8]
cat_spin:
CALLC2(atomic_swap, REG_R7, REG_R6)
cmp REG_R0, #0
beq cat_have_lock
yield
b cat_spin
cat_have_lock:
/* need to grab everything off dstack first */
ldr REG_R7, [sp, #(1*ARG_SZ)] /* sysnum */
ldr REG_R6, [sp, #(2*ARG_SZ)] /* sys_arg1 */
ldr REG_R8, [sp, #(3*ARG_SZ)] /* sys_arg2 */
/* swap stacks */
ldr REG_R2, .Lgot2
add REG_R2, REG_R2, pc
ldr REG_R3, .Linitstack
.LPIC2: ldr REG_R3, [REG_R3, REG_R2]
ldr sp, [REG_R3]
/* free dstack and call the EXIT_DR_HOOK */
CALLC1(GLOBAL_REF(dynamo_thread_stack_free_and_exit), REG_R4) /* pass dstack */
/* give up initstack mutex */
ldr REG_R2, .Lgot3
add REG_R2, REG_R2, pc
ldr REG_R3, .Linitstack_mutex
.LPIC3: ldr REG_R3, [REG_R3, REG_R2]
mov REG_R2, #0
str REG_R2, [REG_R3]
/* dec exiting_thread_count (allows another thread to kill us) */
ldr REG_R2, .Lgot4
add REG_R2, REG_R2, pc
ldr REG_R3, .Lexiting_thread_count
.LPIC4: ldr REG_R3, [REG_R3, REG_R2]
mov REG_R2, #-1
CALLC2(atomic_add, REG_R3, REG_R2)
/* finally, execute the termination syscall */
mov REG_R0, REG_R6 /* sys_arg1 */
mov REG_R1, REG_R8 /* sys_arg2 */
/* sysnum is in r7 already */
bx REG_R5 /* go do the syscall! */
END_FUNC(cleanup_and_terminate)
/* Data for PIC code above */
.Lgot0:
.long _GLOBAL_OFFSET_TABLE_-.LPIC0
.Lgot1:
.long _GLOBAL_OFFSET_TABLE_-.LPIC1
.Lgot2:
.long _GLOBAL_OFFSET_TABLE_-.LPIC2
.Lgot3:
.long _GLOBAL_OFFSET_TABLE_-.LPIC3
.Lgot4:
.long _GLOBAL_OFFSET_TABLE_-.LPIC4
.Lexiting_thread_count:
.word exiting_thread_count(GOT)
.Linitstack:
.word initstack(GOT)
.Linitstack_mutex:
.word initstack_mutex(GOT)
#endif /* NOT_DYNAMORIO_CORE_PROPER */
/* Pass in the pointer-sized address to modify in ARG1 and the val to add in ARG2. */
DECLARE_FUNC(atomic_add)
GLOBAL_LABEL(atomic_add:)
1: ldrex REG_R2, [ARG1]
add REG_R2, REG_R2, ARG2
strex REG_R3, REG_R2, [ARG1]
cmp REG_R3, #0
bne 1b
bx lr
END_FUNC(atomic_add)
DECLARE_FUNC(global_do_syscall_int)
GLOBAL_LABEL(global_do_syscall_int:)
/* FIXME i#1551: NYI on ARM */
svc #0
END_FUNC(global_do_syscall_int)
DECLARE_GLOBAL(safe_read_asm_pre)
DECLARE_GLOBAL(safe_read_asm_mid)
DECLARE_GLOBAL(safe_read_asm_post)
DECLARE_GLOBAL(safe_read_asm_recover)
/* i#350: We implement safe_read in assembly and save the PCs that can fault.
* If these PCs fault, we return from the signal handler to the epilog, which
* can recover. We return the source pointer from ARG2, and the caller uses this
* to determine how many bytes were copied and whether it matches size.
*
* FIXME i#1551: NYI: we need to save the PC's that can fault and have
* is_safe_read_pc() identify them.
*
* FIXME i#1551: we should optimize this as it can be on the critical path.
*
* void *
* safe_read_asm(void *dst, const void *src, size_t n);
*/
DECLARE_FUNC(safe_read_asm)
GLOBAL_LABEL(safe_read_asm:)
cmp ARG3, #0
1: beq safe_read_asm_recover
ADDRTAKEN_LABEL(safe_read_asm_pre:)
ldrb REG_R3, [ARG2]
ADDRTAKEN_LABEL(safe_read_asm_mid:)
ADDRTAKEN_LABEL(safe_read_asm_post:)
strb REG_R3, [ARG1]
subs ARG3, ARG3, #1
add ARG2, ARG2, #1
add ARG1, ARG1, #1
b 1b
ADDRTAKEN_LABEL(safe_read_asm_recover:)
mov REG_R0, ARG2
bx lr
END_FUNC(safe_read_asm)
#ifdef UNIX
/* i#46: Private memcpy and memset for libc isolation. Xref comment in x86.asm.
*/
/* Private memcpy.
* FIXME i#1551: we should optimize this as it can be on the critical path.
*/
DECLARE_FUNC(memcpy)
GLOBAL_LABEL(memcpy:)
cmp ARG3, #0
mov REG_R12/*scratch reg*/, ARG1
1: beq 2f
ldrb REG_R3, [ARG2]
strb REG_R3, [ARG1]
subs ARG3, ARG3, #1
add ARG2, ARG2, #1
add ARG1, ARG1, #1
b 1b
2: mov REG_R0, REG_R12
bx lr
END_FUNC(memcpy)
/* Private memset.
* FIXME i#1551: we should optimize this as it can be on the critical path.
*/
DECLARE_FUNC(memset)
GLOBAL_LABEL(memset:)
cmp ARG3, #0
mov REG_R12/*scratch reg*/, ARG1
1: beq 2f
strb ARG2, [ARG1]
subs ARG3, ARG3, #1
add ARG1, ARG1, #1
b 1b
2: mov REG_R0, REG_R12
bx lr
END_FUNC(memset)
/* See x86.asm notes about needing these to avoid gcc invoking *_chk */
.global __memcpy_chk
.hidden __memcpy_chk
.set __memcpy_chk,memcpy
.global __memset_chk
.hidden __memset_chk
.set __memset_chk,memset
#endif /* UNIX */
#ifdef CLIENT_INTERFACE
/* Xref x86.asm dr_try_start about calling dr_setjmp without a call frame.
*
* int dr_try_start(try_except_context_t *cxt) ;
*/
DECLARE_EXPORTED_FUNC(dr_try_start)
GLOBAL_LABEL(dr_try_start:)
add ARG1, ARG1, #TRY_CXT_SETJMP_OFFS
b GLOBAL_REF(dr_setjmp)
END_FUNC(dr_try_start)
/* We save only the callee-saved registers: R4-R11, SP, LR, D8-D15:
* a total of 26 reg_t (32-bit) slots. See definition of dr_jmp_buf_t.
*
* int dr_setjmp(dr_jmp_buf_t *buf);
*/
DECLARE_FUNC(dr_setjmp)
GLOBAL_LABEL(dr_setjmp:)
mov REG_R2, ARG1
stm REG_R2!, {REG_R4-REG_R11, sp, lr}
vst1.64 {d8-d11},[REG_R2]!
vst1.64 {d12-d15},[REG_R2]!
push {r12,lr} /* save two registers for SP-alignment */
CALLC1(GLOBAL_REF(dr_setjmp_sigmask), ARG1)
mov REG_R0, #0
pop {r12,pc}
END_FUNC(dr_setjmp)
/* int dr_longjmp(dr_jmp_buf *buf, int retval);
*/
DECLARE_FUNC(dr_longjmp)
GLOBAL_LABEL(dr_longjmp:)
mov REG_R2, ARG1
mov REG_R0, ARG2
ldm REG_R2!, {REG_R4-REG_R11, sp, lr}
vld1.64 {d8-d11},[REG_R2]!
vld1.64 {d12-d15},[REG_R2]!
bx lr
END_FUNC(dr_longjmp)
/* int atomic_swap(volatile int *addr, int value)
* return current contents of addr and replace contents with value.
*/
DECLARE_FUNC(atomic_swap)
GLOBAL_LABEL(atomic_swap:)
1: ldrex REG_R2, [ARG1]
strex REG_R3, ARG2, [ARG1]
cmp REG_R3, #0
bne 1b
mov REG_R0, REG_R2
bx lr
END_FUNC(atomic_swap)
DECLARE_FUNC(our_cpuid)
GLOBAL_LABEL(our_cpuid:)
/* FIXME i#1551: NYI on ARM */
bl GLOBAL_REF(unexpected_return)
END_FUNC(our_cpuid)
#endif /* CLIENT_INTERFACE */
#ifdef UNIX
DECLARE_FUNC(client_int_syscall)
GLOBAL_LABEL(client_int_syscall:)
/* FIXME i#1551: NYI on ARM */
svc #0
blx lr
END_FUNC(client_int_syscall)
DECLARE_FUNC(native_plt_call)
GLOBAL_LABEL(native_plt_call:)
/* FIXME i#1551: NYI on ARM */
bl GLOBAL_REF(unexpected_return)
END_FUNC(native_plt_call)
DECLARE_FUNC(_dynamorio_runtime_resolve)
GLOBAL_LABEL(_dynamorio_runtime_resolve:)
/* FIXME i#1551: NYI on ARM */
bl GLOBAL_REF(unexpected_return)
END_FUNC(_dynamorio_runtime_resolve)
#endif /* UNIX */
#ifdef LINUX
DECLARE_FUNC(dynamorio_clone)
GLOBAL_LABEL(dynamorio_clone:)
/* FIXME i#1551: NYI on ARM */
mov r0, #0
bl GLOBAL_REF(unexpected_return)
END_FUNC(dynamorio_clone)
DECLARE_FUNC(dynamorio_sigreturn)
GLOBAL_LABEL(dynamorio_sigreturn:)
mov r7, #SYS_rt_sigreturn
svc 0
bl GLOBAL_REF(unexpected_return)
END_FUNC(dynamorio_sigreturn)
DECLARE_FUNC(dynamorio_nonrt_sigreturn)
GLOBAL_LABEL(dynamorio_nonrt_sigreturn:)
mov r7, #SYS_sigreturn
svc 0
bl GLOBAL_REF(unexpected_return)
END_FUNC(dynamorio_nonrt_sigreturn)
/* we need to exit without using any stack, to support
* THREAD_SYNCH_TERMINATED_AND_CLEANED.
*/
DECLARE_FUNC(dynamorio_sys_exit)
GLOBAL_LABEL(dynamorio_sys_exit:)
mov r0, #0 /* exit code: hardcoded */
mov r7, #SYS_exit
svc 0
bl GLOBAL_REF(unexpected_return)
END_FUNC(dynamorio_sys_exit)
#ifndef NOT_DYNAMORIO_CORE_PROPER
#ifndef HAVE_SIGALTSTACK
# error NYI
#endif
DECLARE_FUNC(master_signal_handler)
GLOBAL_LABEL(master_signal_handler:)
mov ARG4, sp /* pass as extra arg */
b GLOBAL_REF(master_signal_handler_C)
/* master_signal_handler_C will do the ret */
bl GLOBAL_REF(unexpected_return)
END_FUNC(master_signal_handler)
#endif /* LINUX */
#endif /* NOT_DYNAMORIO_CORE_PROPER */
/* void hashlookup_null_handler(void)
* PR 305731: if the app targets NULL, it ends up here, which indirects
* through hashlookup_null_target to end up in an ibl miss routine.
*/
DECLARE_FUNC(hashlookup_null_handler)
GLOBAL_LABEL(hashlookup_null_handler:)
ldr pc, [pc, #-4]
nop /* will be replaced w/ target */
END_FUNC(hashlookup_null_handler)
DECLARE_FUNC(back_from_native_retstubs)
GLOBAL_LABEL(back_from_native_retstubs:)
/* FIXME i#1582: NYI on ARM */
DECLARE_GLOBAL(back_from_native_retstubs_end)
ADDRTAKEN_LABEL(back_from_native_retstubs_end:)
bl GLOBAL_REF(unexpected_return)
END_FUNC(back_from_native_retstubs)
DECLARE_FUNC(back_from_native)
GLOBAL_LABEL(back_from_native:)
/* FIXME i#1582: NYI on ARM */
bl GLOBAL_REF(unexpected_return)
END_FUNC(back_from_native)
END_FILE