Skip to content
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

Add arm64 image header bindings #118

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static_assertions = "1.1.0"
libc = "0.2.100"

[package.metadata.docs.rs]
features = ["default", "bootparam", "btrfs", "elf_uapi", "ioctl", "landlock", "netlink", "io_uring", "if_arp", "if_ether", "if_packet", "net", "ptrace", "prctl", "elf", "xdp", "mempolicy", "system", "loop_device"]
features = ["default", "bootparam", "btrfs", "elf_uapi", "image", "ioctl", "landlock", "netlink", "io_uring", "if_arp", "if_ether", "if_packet", "net", "ptrace", "prctl", "elf", "xdp", "mempolicy", "system", "loop_device"]
targets = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"]

[lints.rust.unexpected_cfgs]
Expand All @@ -40,6 +40,7 @@ general = []
if_arp = []
if_ether = []
if_packet = []
image = []
io_uring = []
ioctl = []
landlock = []
Expand Down
4 changes: 4 additions & 0 deletions gen/modules/image.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#if defined(__aarch64__)
#include <linux/types.h>
#include <asm/image.h>
#endif
9 changes: 9 additions & 0 deletions gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,15 @@ fn make_headers_install(linux_arch: &str, linux_headers: &Path) {
.status()
.unwrap()
.success());

// HACK: Header missing from kernel installation - likely an upstream bug that needs to be reported
if linux_arch == "arm64" {
fs::copy(
"linux/arch/arm64/include/asm/image.h",
linux_headers.join("include/asm/image.h"),
)
.expect("Missing headers");
}
morr0ne marked this conversation as resolved.
Show resolved Hide resolved
}

fn rust_arches(linux_arch: &str) -> &[&str] {
Expand Down
80 changes: 80 additions & 0 deletions src/aarch64/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* automatically generated by rust-bindgen 0.70.1 */

pub type __s8 = crate::ctypes::c_schar;
pub type __u8 = crate::ctypes::c_uchar;
pub type __s16 = crate::ctypes::c_short;
pub type __u16 = crate::ctypes::c_ushort;
pub type __s32 = crate::ctypes::c_int;
pub type __u32 = crate::ctypes::c_uint;
pub type __s64 = crate::ctypes::c_longlong;
pub type __u64 = crate::ctypes::c_ulonglong;
pub type __kernel_key_t = crate::ctypes::c_int;
pub type __kernel_mqd_t = crate::ctypes::c_int;
pub type __kernel_old_uid_t = crate::ctypes::c_ushort;
pub type __kernel_old_gid_t = crate::ctypes::c_ushort;
pub type __kernel_long_t = crate::ctypes::c_long;
pub type __kernel_ulong_t = crate::ctypes::c_ulong;
pub type __kernel_ino_t = __kernel_ulong_t;
pub type __kernel_mode_t = crate::ctypes::c_uint;
pub type __kernel_pid_t = crate::ctypes::c_int;
pub type __kernel_ipc_pid_t = crate::ctypes::c_int;
pub type __kernel_uid_t = crate::ctypes::c_uint;
pub type __kernel_gid_t = crate::ctypes::c_uint;
pub type __kernel_suseconds_t = __kernel_long_t;
pub type __kernel_daddr_t = crate::ctypes::c_int;
pub type __kernel_uid32_t = crate::ctypes::c_uint;
pub type __kernel_gid32_t = crate::ctypes::c_uint;
pub type __kernel_old_dev_t = crate::ctypes::c_uint;
pub type __kernel_size_t = __kernel_ulong_t;
pub type __kernel_ssize_t = __kernel_long_t;
pub type __kernel_ptrdiff_t = __kernel_long_t;
pub type __kernel_off_t = __kernel_long_t;
pub type __kernel_loff_t = crate::ctypes::c_longlong;
pub type __kernel_old_time_t = __kernel_long_t;
pub type __kernel_time_t = __kernel_long_t;
pub type __kernel_time64_t = crate::ctypes::c_longlong;
pub type __kernel_clock_t = __kernel_long_t;
pub type __kernel_timer_t = crate::ctypes::c_int;
pub type __kernel_clockid_t = crate::ctypes::c_int;
pub type __kernel_caddr_t = *mut crate::ctypes::c_char;
pub type __kernel_uid16_t = crate::ctypes::c_ushort;
pub type __kernel_gid16_t = crate::ctypes::c_ushort;
pub type __s128 = i128;
pub type __u128 = u128;
pub type __le16 = __u16;
pub type __be16 = __u16;
pub type __le32 = __u32;
pub type __be32 = __u32;
pub type __le64 = __u64;
pub type __be64 = __u64;
pub type __sum16 = __u16;
pub type __wsum = __u32;
pub type __poll_t = crate::ctypes::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct arm64_image_header {
pub code0: __le32,
pub code1: __le32,
pub text_offset: __le64,
pub image_size: __le64,
pub flags: __le64,
pub res2: __le64,
pub res3: __le64,
pub res4: __le64,
pub magic: __le32,
pub res5: __le32,
}
pub const __BITS_PER_LONG_LONG: u32 = 64;
pub const ARM64_IMAGE_MAGIC: &[u8; 5] = b"ARMd\0";
pub const ARM64_IMAGE_FLAG_BE_SHIFT: u32 = 0;
pub const ARM64_IMAGE_FLAG_PAGE_SIZE_SHIFT: u32 = 1;
pub const ARM64_IMAGE_FLAG_PHYS_BASE_SHIFT: u32 = 3;
pub const ARM64_IMAGE_FLAG_BE_MASK: u32 = 1;
pub const ARM64_IMAGE_FLAG_PAGE_SIZE_MASK: u32 = 3;
pub const ARM64_IMAGE_FLAG_PHYS_BASE_MASK: u32 = 1;
pub const ARM64_IMAGE_FLAG_LE: u32 = 0;
pub const ARM64_IMAGE_FLAG_BE: u32 = 1;
pub const ARM64_IMAGE_FLAG_PAGE_SIZE_4K: u32 = 1;
pub const ARM64_IMAGE_FLAG_PAGE_SIZE_16K: u32 = 2;
pub const ARM64_IMAGE_FLAG_PAGE_SIZE_64K: u32 = 3;
pub const ARM64_IMAGE_FLAG_PHYS_BASE: u32 = 1;
3 changes: 3 additions & 0 deletions src/arm/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/csky/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


72 changes: 72 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ pub mod if_ether;
#[cfg(target_arch = "arm")]
#[path = "arm/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "arm")]
#[path = "arm/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "arm")]
#[path = "arm/io_uring.rs"]
Expand Down Expand Up @@ -317,6 +321,10 @@ pub mod if_ether;
#[cfg(target_arch = "aarch64")]
#[path = "aarch64/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "aarch64")]
#[path = "aarch64/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "aarch64")]
#[path = "aarch64/io_uring.rs"]
Expand Down Expand Up @@ -393,6 +401,10 @@ pub mod if_ether;
#[cfg(target_arch = "csky")]
#[path = "csky/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "csky")]
#[path = "csky/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "csky")]
#[path = "csky/io_uring.rs"]
Expand Down Expand Up @@ -469,6 +481,10 @@ pub mod if_ether;
#[cfg(target_arch = "loongarch64")]
#[path = "loongarch64/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "loongarch64")]
#[path = "loongarch64/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "loongarch64")]
#[path = "loongarch64/io_uring.rs"]
Expand Down Expand Up @@ -545,6 +561,10 @@ pub mod if_ether;
#[cfg(target_arch = "mips")]
#[path = "mips/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "mips")]
#[path = "mips/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "mips")]
#[path = "mips/io_uring.rs"]
Expand Down Expand Up @@ -621,6 +641,10 @@ pub mod if_ether;
#[cfg(target_arch = "mips64")]
#[path = "mips64/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "mips64")]
#[path = "mips64/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "mips64")]
#[path = "mips64/io_uring.rs"]
Expand Down Expand Up @@ -697,6 +721,10 @@ pub mod if_ether;
#[cfg(target_arch = "mips32r6")]
#[path = "mips32r6/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "mips32r6")]
#[path = "mips32r6/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "mips32r6")]
#[path = "mips32r6/io_uring.rs"]
Expand Down Expand Up @@ -773,6 +801,10 @@ pub mod if_ether;
#[cfg(target_arch = "mips64r6")]
#[path = "mips64r6/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "mips64r6")]
#[path = "mips64r6/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "mips64r6")]
#[path = "mips64r6/io_uring.rs"]
Expand Down Expand Up @@ -849,6 +881,10 @@ pub mod if_ether;
#[cfg(target_arch = "powerpc")]
#[path = "powerpc/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "powerpc")]
#[path = "powerpc/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "powerpc")]
#[path = "powerpc/io_uring.rs"]
Expand Down Expand Up @@ -925,6 +961,10 @@ pub mod if_ether;
#[cfg(target_arch = "powerpc64")]
#[path = "powerpc64/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "powerpc64")]
#[path = "powerpc64/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "powerpc64")]
#[path = "powerpc64/io_uring.rs"]
Expand Down Expand Up @@ -1001,6 +1041,10 @@ pub mod if_ether;
#[cfg(target_arch = "riscv32")]
#[path = "riscv32/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "riscv32")]
#[path = "riscv32/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "riscv32")]
#[path = "riscv32/io_uring.rs"]
Expand Down Expand Up @@ -1077,6 +1121,10 @@ pub mod if_ether;
#[cfg(target_arch = "riscv64")]
#[path = "riscv64/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "riscv64")]
#[path = "riscv64/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "riscv64")]
#[path = "riscv64/io_uring.rs"]
Expand Down Expand Up @@ -1153,6 +1201,10 @@ pub mod if_ether;
#[cfg(target_arch = "s390x")]
#[path = "s390x/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "s390x")]
#[path = "s390x/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "s390x")]
#[path = "s390x/io_uring.rs"]
Expand Down Expand Up @@ -1229,6 +1281,10 @@ pub mod if_ether;
#[cfg(target_arch = "sparc")]
#[path = "sparc/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "sparc")]
#[path = "sparc/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "sparc")]
#[path = "sparc/io_uring.rs"]
Expand Down Expand Up @@ -1305,6 +1361,10 @@ pub mod if_ether;
#[cfg(target_arch = "sparc64")]
#[path = "sparc64/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "sparc64")]
#[path = "sparc64/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "sparc64")]
#[path = "sparc64/io_uring.rs"]
Expand Down Expand Up @@ -1381,6 +1441,10 @@ pub mod if_ether;
#[cfg(target_arch = "x86")]
#[path = "x86/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(target_arch = "x86")]
#[path = "x86/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(target_arch = "x86")]
#[path = "x86/io_uring.rs"]
Expand Down Expand Up @@ -1457,6 +1521,10 @@ pub mod if_ether;
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
#[path = "x86_64/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
#[path = "x86_64/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
#[path = "x86_64/io_uring.rs"]
Expand Down Expand Up @@ -1533,6 +1601,10 @@ pub mod if_ether;
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
#[path = "x32/if_packet.rs"]
pub mod if_packet;
#[cfg(feature = "image")]
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
#[path = "x32/image.rs"]
pub mod image;
#[cfg(feature = "io_uring")]
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
#[path = "x32/io_uring.rs"]
Expand Down
3 changes: 3 additions & 0 deletions src/loongarch64/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/mips/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/mips32r6/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/mips64/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/mips64r6/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/powerpc/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/powerpc64/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/riscv32/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/riscv64/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/s390x/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/sparc/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/sparc64/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/x32/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/x86/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


3 changes: 3 additions & 0 deletions src/x86_64/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* automatically generated by rust-bindgen 0.70.1 */


Loading