Skip to content

Commit

Permalink
Add FreeBSD x86 support (#3782)
Browse files Browse the repository at this point in the history
Co-authored-by: ptitSeb <sebastien.chev@gmail.com>
  • Loading branch information
jbeich and ptitSeb authored Apr 21, 2023
1 parent b2446c1 commit e45add2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/vm/src/trap/traphandlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ cfg_if::cfg_if! {
))] {
pc = context.uc_mcontext.gregs[libc::REG_EIP as usize] as usize;
sp = context.uc_mcontext.gregs[libc::REG_ESP as usize] as usize;
} else if #[cfg(all(target_os = "freebsd", any(target_arch = "x86", target_arch = "x86_64")))] {
} else if #[cfg(all(target_os = "freebsd", target_arch = "x86"))] {
pc = context.uc_mcontext.mc_eip as usize;
sp = context.uc_mcontext.mc_esp as usize;
} else if #[cfg(all(target_os = "freebsd", target_arch = "x86_64"))] {
pc = context.uc_mcontext.mc_rip as usize;
sp = context.uc_mcontext.mc_rsp as usize;
} else if #[cfg(all(target_vendor = "apple", target_arch = "x86_64"))] {
Expand Down Expand Up @@ -330,6 +333,13 @@ cfg_if::cfg_if! {
(*context.uc_mcontext).__ss.__rbp = rbp;
(*context.uc_mcontext).__ss.__rdi = rdi;
(*context.uc_mcontext).__ss.__rsi = rsi;
} else if #[cfg(all(target_os = "freebsd", target_arch = "x86"))] {
let TrapHandlerRegs { eip, esp, ebp, ecx, edx } = regs;
context.uc_mcontext.mc_eip = eip as libc::register_t;
context.uc_mcontext.mc_esp = esp as libc::register_t;
context.uc_mcontext.mc_ebp = ebp as libc::register_t;
context.uc_mcontext.mc_ecx = ecx as libc::register_t;
context.uc_mcontext.mc_edx = edx as libc::register_t;
} else if #[cfg(all(target_os = "freebsd", target_arch = "x86_64"))] {
let TrapHandlerRegs { rip, rsp, rbp, rdi, rsi } = regs;
context.uc_mcontext.mc_rip = rip as libc::register_t;
Expand Down

0 comments on commit e45add2

Please sign in to comment.