blob: e335b7140998d993b318508b8210917d68c00bd8 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001 .file "initfini.c"
2
3#include <bits/arm_asm.h>
4 .section .init
5 .global _init
6 .type _init, %function
7#if defined __thumb__
8 .align 1
9 .thumb
10 .thumb_func
11_init:
12 push {r4-r7, lr}
13#else
14 .align 2
15 .arm
16_init:
17 @ gcc 3.3.2 didn't create a stack frame, gcc 3.4.4 does -
18 @ presumably 3.4.4 can put stuff into .init which requires
19 @ the arguments to be saved. This code is copied from 3.4.4
20 mov ip, sp
21 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc}
22 sub fp, ip, #4
23#endif
24
25
26 .section .fini
27 .global _fini
28 .type _fini, %function
29#if defined __thumb__
30 .align 1
31 .thumb
32 .thumb_func
33_fini:
34 push {r4-r7, lr}
35#else
36 .align 2
37 .arm
38_fini:
39 mov ip, sp
40 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc}
41 sub fp, ip, #4
42#endif
43
44
45#if (defined __thumb__ || defined __THUMB_INTERWORK__) && (defined __ARM_ARCH_4T__ || defined __ARM_ARCH_5T__ || defined __ARM_ARCH_5TE__)
46 @ To support thumb code it is currently necessary to have the _call_via_rX
47 @ functions exposed to the linker for any program or shared library. PLT
48 @ references are inadequate - the PLT zaps ip and therefore breaks _call_via_ip
49 @ (and the compiler does generate this). It is simpler to put all the
50 @ required code in here - it only amounts to 60 bytes overhead.
51 @NOTE: it would be better to have the compiler generate this stuff as
52 @ required...
53 .section ".text"
54 .align 0
55 .force_thumb
56
57.macro call_via register
58 .global _call_via_\register
59 .type _call_via_\register, %function
60 .weak _call_via_\register
61 .hidden _call_via_\register
62 .thumb_func
63_call_via_\register:
64 bx \register
65 nop
66 .size _call_via_\register, . - _call_via_\register
67.endm
68
69 @ and calls for the 15 general purpose registers (2 bytes each).
70 call_via r0
71 call_via r1
72 call_via r2
73 call_via r3
74 call_via r4
75 call_via r5
76 call_via r6
77 call_via r7
78 call_via r8
79 call_via r9
80 call_via sl
81 call_via fp
82 call_via ip
83 call_via sp
84 call_via lr
85#endif
86
87 .ident "GCC: (GNU) 3.3.2 20031005 (Debian prerelease)"