Initial building of the vdso.
Not actually integrating with the kernel yet.
This commit is contained in:
67
src/arch/x86_64/vdso.ld
Normal file
67
src/arch/x86_64/vdso.ld
Normal file
@@ -0,0 +1,67 @@
|
||||
PHDRS {
|
||||
rodata PT_LOAD FLAGS(4) FILEHDR PHDRS ;
|
||||
text PT_LOAD FLAGS(5) ;
|
||||
dynamic PT_DYNAMIC FLAGS(4) ;
|
||||
note PT_NOTE ;
|
||||
eh_frame PT_GNU_EH_FRAME ;
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
. = SIZEOF_HEADERS;
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.got*)
|
||||
*(.plt*)
|
||||
*(.note.*)
|
||||
*(.hash*)
|
||||
}
|
||||
|
||||
.illegal.relocations : {
|
||||
*(.rel*)
|
||||
}
|
||||
|
||||
.illegal.writeable : {
|
||||
*(.data*)
|
||||
*(.bss*)
|
||||
}
|
||||
|
||||
.rodata : {
|
||||
*(.rodata*)
|
||||
} :rodata
|
||||
|
||||
.dynamic : {
|
||||
*(.dynamic)
|
||||
} :dynamic
|
||||
|
||||
.dynsym : {
|
||||
*(.dynsym*)
|
||||
} :rodata :dynamic
|
||||
|
||||
.dynstr : {
|
||||
*(.dynstr*)
|
||||
} :rodata :dynamic
|
||||
|
||||
.gnu.hash : {
|
||||
*(.gnu.hash*)
|
||||
} :rodata
|
||||
|
||||
.eh_frame_hdr : {
|
||||
__eh_frame_start = .;
|
||||
KEEP(*(.eh_frame))
|
||||
__eh_frame_end = .;
|
||||
|
||||
KEEP(*(.eh_frame_hdr))
|
||||
} :eh_frame
|
||||
|
||||
.text ALIGN(0x1000) : {
|
||||
*(.text*)
|
||||
*(.init*)
|
||||
*(.fini*)
|
||||
. = ALIGN(0x1000);
|
||||
} :text
|
||||
|
||||
ASSERT(SIZEOF(.illegal.relocations) == 0,
|
||||
"Code has introduced relocations into the VDSO")
|
||||
ASSERT(SIZEOF(.illegal.writeable) == 0,
|
||||
"Code has introduced writeable data into the VDSO")
|
||||
}
|
||||
@@ -2,8 +2,8 @@ SYSCALL(0x00, object_noop, void)
|
||||
SYSCALL(0x01, object_wait, j6_handle_t, j6_signal_t, j6_signal_t *)
|
||||
|
||||
SYSCALL(0x11, process_exit, int64_t)
|
||||
SYSCALL(0x12, process_fork, pid_t*)
|
||||
SYSCALL(0x13, process_getpid, pid_t*)
|
||||
//SYSCALL(0x12, process_fork, j6_koid_t*)
|
||||
//SYSCALL(0x13, process_getpid, j6_koid_t*)
|
||||
SYSCALL(0x14, process_log, const char *)
|
||||
SYSCALL(0x15, process_pause, void)
|
||||
SYSCALL(0x16, process_sleep, uint64_t)
|
||||
17
src/vdso/overrides.cpp
Normal file
17
src/vdso/overrides.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <j6/errors.h>
|
||||
#include <j6/types.h>
|
||||
#include "vdso_internal.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
j6_status_t j6_object_noop() {
|
||||
// Skip the kernel
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
// An example of overriding a weak default symbol with a custom function
|
||||
j6_status_t j6_object_wait(j6_handle_t target, j6_signal_t signals, j6_signal_t *triggered) {
|
||||
return __sys_j6_object_wait(target, signals, triggered);
|
||||
}
|
||||
|
||||
}
|
||||
17
src/vdso/syscalls.cpp
Normal file
17
src/vdso/syscalls.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <j6/errors.h>
|
||||
#include <j6/types.h>
|
||||
#include "vdso_internal.h"
|
||||
|
||||
#define SYSCALL(num, name, ...) \
|
||||
j6_status_t __sys_j6_##name (__VA_ARGS__) { \
|
||||
j6_status_t result = 0; \
|
||||
__asm__ __volatile__ ( "syscall" : "=a"(result) : "a"(num) ); \
|
||||
return result; \
|
||||
} \
|
||||
j6_status_t j6_ ## name(__VA_ARGS__) __weak_alias("__sys_j6_" #name);
|
||||
|
||||
extern "C" {
|
||||
#include "syscalls.inc"
|
||||
}
|
||||
|
||||
#undef SYSCALL
|
||||
16
src/vdso/vdso_internal.h
Normal file
16
src/vdso/vdso_internal.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
/// \file vdso_internal.h
|
||||
/// VDSO syscall forward-declares and linker utils
|
||||
|
||||
#define __weak_alias(name) __attribute__((weak, alias(name)));
|
||||
#define __local __attribute__((__visibility__("hidden")))
|
||||
|
||||
#define SYSCALL(num, name, ...) \
|
||||
j6_status_t __sys_j6_ ## name (__VA_ARGS__) __local; \
|
||||
|
||||
extern "C" {
|
||||
#include "syscalls.inc"
|
||||
}
|
||||
|
||||
#undef SYSCALL
|
||||
|
||||
Reference in New Issue
Block a user