Kernel/LibC: Add support for init_array and fini_array
This commit is contained in:
@@ -22,6 +22,14 @@ _start:
|
||||
# call global constructors
|
||||
call _init
|
||||
|
||||
movq $__init_array_start, %rbx
|
||||
jmp 2f
|
||||
1: movq (%rbx), %rax
|
||||
call *%rax
|
||||
addq $8, %rbx
|
||||
2: cmpq $__init_array_end, %rbx
|
||||
jne 1b
|
||||
|
||||
# call main
|
||||
movq 16(%rsp), %rdi
|
||||
movq 8(%rsp), %rsi
|
||||
|
||||
@@ -14,3 +14,11 @@ _fini:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp
|
||||
/* gcc will nicely put the contents of crtbegin.o's .fini section here. */
|
||||
|
||||
.section .init_array
|
||||
.global __init_array_start
|
||||
__init_array_start:
|
||||
|
||||
.section .fini_array
|
||||
.global __fini_array_start
|
||||
__fini_array_start:
|
||||
|
||||
@@ -8,3 +8,11 @@
|
||||
/* gcc will nicely put the contents of crtend.o's .fini section here. */
|
||||
popq %rbp
|
||||
ret
|
||||
|
||||
.section .init_array
|
||||
.global __init_array_end
|
||||
__init_array_end:
|
||||
|
||||
.section .fini_array
|
||||
.global __fini_array_end
|
||||
__fini_array_end:
|
||||
|
||||
Reference in New Issue
Block a user