user: implement mlibc as the libc, finally.

It's finally done..

Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
kaguya
2026-05-02 03:31:49 -04:00
parent 2fa39ad85a
commit 9a9b91c940
2387 changed files with 152741 additions and 315 deletions
@@ -0,0 +1,30 @@
.weak __global_pointer$
.hidden __global_pointer$
.section .text
.global _start
_start:
# Load gp.
.option push
.option norelax
lla gp, __global_pointer$
.option pop
mv a0, sp
la a1, main
call __mlibc_entry@plt
unimp
# Load gp from .preinit_array since it may be used by the executable's .init_array.
# We still load it in _start to account for static binaries. This matches glibc's behavior.
load_gp:
.option push
.option norelax
lla gp, __global_pointer$
.option pop
ret
.section .preinit_array,"aw"
.dword load_gp
.section .note.GNU-stack,"",%progbits
@@ -0,0 +1,30 @@
.weak __global_pointer$
.hidden __global_pointer$
.section .text
.global _start
_start:
# Load gp.
.option push
.option norelax
lla gp, __global_pointer$
.option pop
mv a0, sp
la a1, main
call __mlibc_entry
unimp
# Load gp from .preinit_array since it may be used by the executable's .init_array.
# We still load it in _start to account for static binaries. This matches glibc's behavior.
load_gp:
.option push
.option norelax
lla gp, __global_pointer$
.option pop
ret
.section .preinit_array,"aw"
.dword load_gp
.section .note.GNU-stack,"",%progbits
@@ -0,0 +1,14 @@
.section .init
.global _init
_init:
addi sp, sp, -16
sd ra, 8(sp)
.section .fini
.global _fini
.type _fini, @function
_fini:
addi sp, sp, -16
sd ra, 8(sp)
.section .note.GNU-stack,"",%progbits
@@ -0,0 +1,9 @@
.section .init
ld ra, 8(sp)
addi sp, sp, 16
.section .fini
ld ra, 8(sp)
addi sp, sp, 16
.section .note.GNU-stack,"",%progbits
@@ -0,0 +1,12 @@
.section .text
.global __mlibc_start_thread
__mlibc_start_thread:
ld a0, 0(sp)
ld a1, 8(sp)
ld a2, 16(sp)
addi sp, sp, 16
andi sp, sp, -16
call __mlibc_enter_thread
unimp
.section .note.GNU-stack,"",%progbits