Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_call_arm32_thumb_apple.s @ 533:71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
* integration of aggregate-by-value (struct, union) support patch for x64 (win and sysv)
* windows/x64 asm additions to specify how stack unwinds (help for debuggers, exception handling, etc.)
* see Changelog for details
- new calling convention modes for thiscalls (platform agnostic, was specific before)
* new signature character for platform agnostic thiscalls ('*' / DC_SIGCHAR_CC_THISCALL)
- dcCallF(), dcVCallF(), dcArgF() and dcVArgF():
* added support for aggregates-by-value (wasn't part of patch)
* change that those functions don't implicitly call dcReset() anymore, which was unflexible (breaking change)
- added macros to feature test implementation for aggregate-by-value and syscall support
- changed libdyncall_s.lib and libdyncallback_s.lib order in callback test makefiles, as some toolchains are picky about order
- doc:
* man page updates to describe aggregate interface
* manual overview changes to highlight platforms with aggregate-by-value support
- test/plain: replaced tests w/ old/stale sctruct interface with new aggregate one
author | Tassilo Philipp |
---|---|
date | Thu, 21 Apr 2022 13:35:47 +0200 |
parents | 351bb41d3bb1 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncall | |
5 File: dyncall/dyncall_call_arm32_thumb_apple.s | |
6 Description: ARM Thumb call kernel implementation for apple assembler. | |
7 License: | |
8 | |
9 Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>, | |
10 Tassilo Philipp <tphilipp@potion-studios.com> | |
11 | |
12 Permission to use, copy, modify, and distribute this software for any | |
13 purpose with or without fee is hereby granted, provided that the above | |
14 copyright notice and this permission notice appear in all copies. | |
15 | |
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
23 | |
24 */ | |
25 | |
26 | |
27 .text | |
28 .thumb | |
29 .code 16 | |
30 .globl _dcCall_arm32_thumb | |
31 | |
32 /* Main dyncall call. */ | |
33 .thumb_func | |
34 _dcCall_arm32_thumb: | |
35 | |
36 /* Prolog. This function never needs to spill inside its prolog, so just store the permanent registers. */ | |
37 push {r4-r7, r14} /* Frame ptr, permanent registers, link register -> save area on stack. */ | |
38 mov r7, r13 /* Set frame ptr. */ | |
39 | |
40 /* Call. */ | |
41 mov r4, r0 /* Move 'fptr' to r4 (1st argument is passed in r0). */ | |
42 | |
43 /* Disable 'thumb' address forcing... */ | |
44 | |
45 /* mov r0, #1 */ /* Assure that LSB is set to 1 (THUMB call). - Not Required and not useful for interworking calls */ | |
46 /* orr r4, r0 */ | |
47 | |
48 mov r5, r1 /* Move 'args' to r5 (2nd argument is passed in r1). */ | |
49 mov r6, r2 /* Move 'size' to r6 (3rd argument is passed in r2). */ | |
50 | |
51 cmp r6, #16 /* Jump to call if no more than 4 arguments. */ | |
52 ble call | |
53 | |
54 sub r6, #16 /* Size of remaining arguments. */ | |
55 mov r0, r13 /* Set stack pointer to top of stack. */ | |
56 sub r0, r0, r6 | |
57 lsr r0, #3 /* Align stack on 8 byte boundaries. */ | |
58 lsl r0, #3 | |
59 mov r13, r0 | |
60 | |
61 add r1, #16 /* Let r1 point to remaining arguments. */ | |
62 mov r2, #0 /* Init byte counter to 0. */ | |
63 .thumb_func | |
64 pushArgs: | |
65 ldrb r3, [r1, r2] /* Load a byte into r3. */ | |
66 strb r3, [r0, r2] /* Push byte onto stack. */ | |
67 add r2, r2, #1 /* Increment byte counter. */ | |
68 cmp r2, r6 | |
69 bne pushArgs | |
70 .thumb_func | |
71 call: | |
72 ldmia r5!, {r0-r3} /* Load first 4 arguments for new call into r0-r3. */ | |
73 | |
406
351bb41d3bb1
- removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents:
0
diff
changeset
|
74 /* 'blx r4' workaround for ARMv4t in THUMB: */ |
0 | 75 blx r4 /* Branch and force THUMB-mode return (LR bit 0 set). */ |
76 | |
77 /* Epilog. */ | |
78 mov r13, r7 /* Reset stack ptr. */ | |
79 pop {r4-r7, r15} /* Restore permanent registers and program counter. (Force a stay in THUMB in ARMv4, whether ARMv5 can return in ARM or THUMB depending on the bit 0. */ | |
80 |