Skip to content

Commit ea795c5

Browse files
committed
crt?.S: fix the build with macOS
1 parent a8970f8 commit ea795c5

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/arch/amd64/crti.S

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
/* sections */
99
/* init */
10+
#ifdef __APPLE__
11+
.section __TEXT,__text
12+
#else
1013
.section .init
14+
#endif
1115
.global _init
1216
#ifndef __clang__
1317
.type _init, @function
@@ -16,13 +20,29 @@ _init:
1620
push %rbp
1721
mov %rsp, %rbp
1822

23+
#ifdef __APPLE__
24+
.section __DATA,__mod_init_func,mod_init_funcs
25+
.p2align 3
26+
.quad _init
27+
#endif
28+
1929

2030
/* fini */
31+
#ifdef __APPLE__
32+
.section __TEXT,__text
33+
#else
2134
.section .fini
35+
#endif
2236
.global _fini
2337
#ifndef __clang__
2438
.type _fini, @function
2539
#endif
2640
_fini:
2741
push %rbp
2842
mov %rsp, %rbp
43+
44+
#ifdef __APPLE__
45+
.section __DATA,__mod_term_func,mod_term_funcs
46+
.p2align 3
47+
.quad _fini
48+
#endif

src/arch/amd64/crtn.S

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,36 @@
77

88
/* sections */
99
/* init */
10+
#ifdef __APPLE__
11+
.section __TEXT,__text
12+
.global _crtn_init
13+
_crtn_init:
14+
#else
1015
.section .init
16+
#endif
1117
pop %rbp
1218
ret
1319

20+
#ifdef __APPLE__
21+
.section __DATA,__mod_init_func,mod_init_funcs
22+
.p2align 3
23+
.quad _crtn_init
24+
#endif
25+
1426

1527
/* fini */
28+
#ifdef __APPLE__
29+
.section __TEXT,__text
30+
.global _crtn_fini
31+
_crtn_fini:
32+
#else
1633
.section .fini
34+
#endif
1735
pop %rbp
1836
ret
37+
38+
#ifdef __APPLE__
39+
.section __DATA,__mod_term_func,mod_term_funcs
40+
.p2align 3
41+
.quad _crtn_fini
42+
#endif

0 commit comments

Comments
 (0)