1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00
Achilleas Anagnostopoulos d17f582c0b Reserve space for redirect table and install trampolines
The rt0_64 code reserves space for _rt0_redirect_table using the output
from the redirect tool's "count" command as a hint to the size of the
table. The table itself is located in the .goredirectstbl section which
the linker moves to a dedicated section in the final ELF image.

When the kernel boots, the _rt0_install_redirect_trampolines function
iterates the _rt0_redirect_table entries (populated as a post-link step)
and overwrite the original function code with a trampoline that
redirects control to the destination function.

The trampoline is implemented as a 14-byte instruction that exploits
rip-relative addressing to ensure that no registers are made dirty. The
actual trampoline code looks like this:

jmp [rip+0]                 ; 6-bytes
dq abs_address_to_jump_to   ; 8-bytes

The _rt0_install_redirect_trampolines function sets up the abs_address
to "dst" for each (src, dst) tuple and then copies the trampoline to
"src". After the trampoline is installed, any calls to "src" will be
transparently redirected to "dst". This hack (modifying code in the
.text section) is only possible because the code runs in supervisor mode
before memory protection is enabled.
2017-06-25 21:39:20 +01:00
2017-03-23 06:50:13 +00:00
2017-05-15 06:55:14 +01:00
2017-05-15 07:30:49 +01:00
2017-03-23 06:50:13 +00:00
2017-03-26 09:51:38 +01:00

gopheros

Build Status codecov Go Report Card

Let's write an experimental OS in Go!

Description
A proof of concept OS kernel written in Go
Readme 773 KiB
Languages
Go 84.9%
ASL 10.2%
Assembly 4%
Makefile 0.9%