Skip to content

Commit

Permalink
Merge pull request #1188 from avdgrinten/managarm-riscv
Browse files Browse the repository at this point in the history
sysdeps/managarm: make RISC-V compile and link
  • Loading branch information
Dennisbonke authored Nov 17, 2024
2 parents c906cb5 + 7ec9250 commit d5feade
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 1 deletion.
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");
}

0 comments on commit d5feade

Please sign in to comment.