Skip to content

Commit 541c153

Browse files
committed
openkal-musl: give the four names something to name on the third object format
1 parent b54682f commit 541c153

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

port/src/okm_format.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,26 @@
2929
* differ in the directive that names a section and in whether a C name carries
3030
* a leading underscore, and in nothing else. */
3131
#if defined(__APPLE__)
32+
/* The word after the four labels is not padding.
33+
*
34+
* This format's linker divides a section into atoms and an atom is what a
35+
* symbol names; a section with no content has no atom, and the four names go
36+
* with it. The link then reports them as undefined while the object that
37+
* defines them is sitting in front of it. One word of content gives the four
38+
* names something to name, and the four still share one address, which is what
39+
* makes the loops that walk between them run zero times. */
3240
__asm__(
3341
".section __DATA,__const\n"
3442
".p2align 3\n"
35-
".globl ___init_array_start\n___init_array_start:\n"
36-
".globl ___init_array_end\n___init_array_end:\n"
37-
".globl ___fini_array_start\n___fini_array_start:\n"
38-
".globl ___fini_array_end\n___fini_array_end:\n"
43+
".globl ___init_array_start\n"
44+
".globl ___init_array_end\n"
45+
".globl ___fini_array_start\n"
46+
".globl ___fini_array_end\n"
47+
"___init_array_start:\n"
48+
"___init_array_end:\n"
49+
"___fini_array_start:\n"
50+
"___fini_array_end:\n"
51+
".quad 0\n"
3952
".text\n");
4053
#else
4154
__asm__(

0 commit comments

Comments
 (0)