Skip to content

Comments

refactor(target_arch): pass arch via feature flags instead#112

Open
kakoc wants to merge 1 commit intoheadcrab-rs:masterfrom
kakoc:refactor/target_arch_to_feature_flags
Open

refactor(target_arch): pass arch via feature flags instead#112
kakoc wants to merge 1 commit intoheadcrab-rs:masterfrom
kakoc:refactor/target_arch_to_feature_flags

Conversation

@kakoc
Copy link

@kakoc kakoc commented Sep 11, 2020

Related to: #102
It's not clear to me: should the new Arch enum be used anywhere now?

lazy_static::lazy_static! {
pub static ref PAGE_SIZE: usize = unsafe { libc::sysconf(libc::_SC_PAGESIZE) as usize };
#[cfg(target_arch="x86_64")]
#[cfg(feature="x86_64")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ptrace can only work with the local arch, so using target_arch makes more sense to me. Also enabling the x86_64 feature on other archs won't compile, as libc won't jave a u_debugreg field for the libc::user struct.

@@ -1,5 +1,5 @@
// FIXME make this work on other systems too.
#![cfg(all(target_arch = "x86_64", target_os = "linux"))]
#![cfg(all(feature = "x86_64", target_os = "linux"))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

headcrab_inject directly uses the rip and rsp fields of libc::user_regs, so it won't compile for other archs.

@bjorn3
Copy link
Contributor

bjorn3 commented Sep 11, 2020

headcrab_inject could be made to work with multiple archs, but that would likely require #87 first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants