Skip to content

Add common abstractions for x86 Segments #258

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

Merged
merged 10 commits into from
Jun 14, 2021
30 changes: 30 additions & 0 deletions src/asm/asm.s
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,36 @@ _x86_64_asm_load_gs:
mov %di, %gs
retq

.global _x86_64_asm_get_ss
.p2align 4
_x86_64_asm_get_ss:
mov %ss, %ax
retq

.global _x86_64_asm_get_ds
.p2align 4
_x86_64_asm_get_ds:
mov %ds, %ax
retq

.global _x86_64_asm_get_es
.p2align 4
_x86_64_asm_get_es:
mov %es, %ax
retq

.global _x86_64_asm_get_fs
.p2align 4
_x86_64_asm_get_fs:
mov %fs, %ax
retq

.global _x86_64_asm_get_gs
.p2align 4
_x86_64_asm_get_gs:
mov %gs, %ax
retq

.global _x86_64_asm_swapgs
.p2align 4
_x86_64_asm_swapgs:
Expand Down
30 changes: 30 additions & 0 deletions src/asm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,36 @@ extern "C" {
)]
pub(crate) fn x86_64_asm_load_gs(sel: u16);

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_get_ss"
)]
pub(crate) fn x86_64_asm_get_ss() -> u16;

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_get_ds"
)]
pub(crate) fn x86_64_asm_get_ds() -> u16;

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_get_es"
)]
pub(crate) fn x86_64_asm_get_es() -> u16;

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_get_fs"
)]
pub(crate) fn x86_64_asm_get_fs() -> u16;

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_get_gs"
)]
pub(crate) fn x86_64_asm_get_gs() -> u16;

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_swapgs"
Expand Down
Loading