Skip to content

Commit

Permalink
refactor: define our own target arch variable
Browse files Browse the repository at this point in the history
Don't use what the compiler would typically define, but instead define our own ones.
  • Loading branch information
kxxt committed Oct 12, 2024
1 parent 4384049 commit 9889fe2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fn main() {
.join("tracexec_system.skel.rs");
let arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH not set");
let arch_define = OsStr::new(match arch.as_str() {
"x86_64" => "__x86_64__",
"riscv64" => "__riscv64__",
"aarch64" => "__aarch64__",
"x86_64" => "TRACEXEC_TARGET_X86_64",
"riscv64" => "TRACEXEC_TARGET_RISCV64",
"aarch64" => "TRACEXEC_TARGET_AARCH64",
_ => panic!("Arch {arch} is not supported for now"),
});
let max_cpus = 64;
Expand Down
6 changes: 3 additions & 3 deletions include/vmlinux.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/bpf/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ extern void bpf_rcu_read_unlock(void) __ksym;

// Architecture Specific Definitions

#ifdef __x86_64__
#ifdef TRACEXEC_TARGET_X86_64
#define SYSCALL_PREFIX "x64"
#define SYSCALL_COMPAT_PREFIX "ia32_compat"
#elif __aarch64__
#elif TRACEXEC_TARGET_AARCH64
#define SYSCALL_PREFIX "arm64"
#elif __riscv64__
#elif TRACEXEC_TARGET_RISCV64
#define SYSCALL_PREFIX "riscv"
#endif

#ifdef __x86_64__
#ifdef TRACEXEC_TARGET_X86_64

#define COMPAT_PT_REGS_PARM1_CORE(x) ((u32)(BPF_CORE_READ(__PT_REGS_CAST(x), bx)))
#define COMPAT_PT_REGS_PARM2_CORE(x) ((u32)(BPF_CORE_READ(__PT_REGS_CAST(x), cx)))
Expand Down

0 comments on commit 9889fe2

Please sign in to comment.