-
Notifications
You must be signed in to change notification settings - Fork 250
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
Invalid ELF header size or alignment #24
Comments
@tw4452852 i think you should align you array of bytes.
What works for me: macro_rules! include_bytes_align_as {
($align_ty:ty, $path:literal) => {{
#[repr(C)]
pub struct AlignedAs<Align, Bytes: ?Sized> {
pub _align: [Align; 0],
pub bytes: Bytes,
}
static ALIGNED: &AlignedAs<$align_ty, [u8]> = &AlignedAs {
_align: [],
bytes: *include_bytes!($path),
};
&ALIGNED.bytes
}};
}
static PROGRAM_DATA: &'static [u8] = include_bytes_align_as!(
u32,
"../../target/bpfel-unknown-none/release/libpq-tracer-bpf"
);
// ..
let mut bpf = Bpf::load(PROGRAM_DATA.into(), None)?; I copied the |
Wow, thanks @ecarrara , Now it's clear now. |
Just an FYI for folks coming here from their favourite search engine: As of #76 we will have |
A weird issue occurred today that puzzled me a lot. When I used
load_file(xxx)
, everything worked fine. But if I usedload(include_bytes!(xxx), None)
, it produced this error:Anyone knows why? Thanks in advance.
The text was updated successfully, but these errors were encountered: