mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
Initial building of the vdso.
Not actually integrating with the kernel yet.
This commit is contained in:
11
modules.yaml
11
modules.yaml
@@ -9,6 +9,7 @@ modules:
|
|||||||
- elf
|
- elf
|
||||||
- initrd
|
- initrd
|
||||||
- kutil
|
- kutil
|
||||||
|
- vdso
|
||||||
includes:
|
includes:
|
||||||
- src/kernel
|
- src/kernel
|
||||||
source:
|
source:
|
||||||
@@ -64,6 +65,16 @@ modules:
|
|||||||
- src/boot/reloc.cpp
|
- src/boot/reloc.cpp
|
||||||
- src/boot/utility.cpp
|
- src/boot/utility.cpp
|
||||||
|
|
||||||
|
vdso:
|
||||||
|
kind: exe
|
||||||
|
target: host
|
||||||
|
output: libvdso.so
|
||||||
|
extra:
|
||||||
|
- src/arch/x86_64/vdso.ld
|
||||||
|
source:
|
||||||
|
- src/vdso/syscalls.cpp
|
||||||
|
- src/vdso/overrides.cpp
|
||||||
|
|
||||||
nulldrv:
|
nulldrv:
|
||||||
kind: exe
|
kind: exe
|
||||||
target: user
|
target: user
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ ccflags = $
|
|||||||
$warnflags
|
$warnflags
|
||||||
|
|
||||||
asflags = $
|
asflags = $
|
||||||
|
-I${srcroot}/src/include $
|
||||||
-DVERSION_MAJOR={{ version_major }} $
|
-DVERSION_MAJOR={{ version_major }} $
|
||||||
-DVERSION_MINOR={{ version_minor }} $
|
-DVERSION_MINOR={{ version_minor }} $
|
||||||
-DVERSION_PATCH={{ version_patch }} $
|
-DVERSION_PATCH={{ version_patch }} $
|
||||||
|
|||||||
9
scripts/templates/exe.vdso.j2
Normal file
9
scripts/templates/exe.vdso.j2
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{% extends "exe.default.j2" %}
|
||||||
|
{% block variables %}
|
||||||
|
{{ super() }}
|
||||||
|
ccflags = $ccflags -fPIC -mcmodel=large
|
||||||
|
ldflags = $ldflags -shared -znotext -T ${srcroot}/src/arch/x86_64/vdso.ld
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||||
|
|
||||||
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(0x01, object_wait, j6_handle_t, j6_signal_t, j6_signal_t *)
|
||||||
|
|
||||||
SYSCALL(0x11, process_exit, int64_t)
|
SYSCALL(0x11, process_exit, int64_t)
|
||||||
SYSCALL(0x12, process_fork, pid_t*)
|
//SYSCALL(0x12, process_fork, j6_koid_t*)
|
||||||
SYSCALL(0x13, process_getpid, pid_t*)
|
//SYSCALL(0x13, process_getpid, j6_koid_t*)
|
||||||
SYSCALL(0x14, process_log, const char *)
|
SYSCALL(0x14, process_log, const char *)
|
||||||
SYSCALL(0x15, process_pause, void)
|
SYSCALL(0x15, process_pause, void)
|
||||||
SYSCALL(0x16, process_sleep, uint64_t)
|
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