Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysdeps/managarm: make RISC-V compile and link #1188

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sysdeps/managarm/generic/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2560,6 +2560,8 @@ int sys_uname(struct utsname *buf) {
strcpy(buf->machine, "x86_64");
#elif defined (__aarch64__)
strcpy(buf->machine, "aarch64");
#elif defined (__riscv)
strcpy(buf->machine, "riscv64");
#else
# error Unknown architecture
#endif
Expand Down
5 changes: 4 additions & 1 deletion sysdeps/managarm/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ elif host_machine.cpu_family() == 'x86_64'
'x86_64/thread.cpp'
)
elif host_machine.cpu_family() == 'riscv64'
libc_sources += files(
'riscv64/thread.cpp',
)
else
error('Unknown architecture')
endif
Expand Down Expand Up @@ -129,7 +132,7 @@ endif

if not headers_only
crtstuff = ['crt0']
if host_machine.cpu_family() in ['x86_64', 'aarch64']
if host_machine.cpu_family() in ['x86_64', 'aarch64', 'riscv64']
crtstuff += [
'Scrt1',
'crti',
Expand Down
18 changes: 18 additions & 0 deletions sysdeps/managarm/riscv64/crt-src/Scrt1.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.section .text
.global _start
_start:
.weak __global_pointer$
.hidden __global_pointer$
.option push
.option norelax
lla gp, __global_pointer$
.option pop

mv a0, sp
la a1, main
call __mlibc_entry@plt
unimp


.section .note.GNU-stack,"",%progbits

15 changes: 15 additions & 0 deletions sysdeps/managarm/riscv64/crt-src/crt0.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.section .text
.global _start
_start:
.weak __global_pointer$
.hidden __global_pointer$
.option push
.option norelax
lla gp, __global_pointer$
.option pop

mv a0, sp
la a1, main
call __mlibc_entry
.section .note.GNU-stack,"",%progbits

11 changes: 11 additions & 0 deletions sysdeps/managarm/riscv64/crt-src/crti.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.section .init
.global _init
_init:
unimp

.section .fini
.global _fini
_fini:
unimp
.section .note.GNU-stack,"",%progbits

7 changes: 7 additions & 0 deletions sysdeps/managarm/riscv64/crt-src/crtn.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.section .init
unimp

.section .fini
unimp
.section .note.GNU-stack,"",%progbits

9 changes: 9 additions & 0 deletions sysdeps/managarm/riscv64/thread.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <bits/ensure.h>

extern "C" void __mlibc_start_thread() {
__ensure(!"unimplemented");
}

extern "C" void __mlibc_signal_restore() {
__ensure(!"unimplemented");
}
Loading