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

haiku dl_phdr_iterate addition (supports since beta3). #2534

Merged
merged 1 commit into from Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/unix/haiku/b32.rs
@@ -1,3 +1,20 @@
pub type c_long = i32;
pub type c_ulong = u32;
pub type time_t = i32;

pub type Elf_Addr = ::Elf32_Addr;
pub type Elf_Half = ::Elf32_Half;
pub type Elf_Phdr = ::Elf32_Phdr;

s! {
pub struct Elf32_Phdr {
pub p_type: ::Elf32_Word,
pub p_offset: ::Elf32_Off,
pub p_vaddr: ::Elf32_Addr,
pub p_paddr: ::Elf32_Addr,
pub p_filesz: ::Elf32_Word,
pub p_memsz: ::Elf32_Word,
pub p_flags: ::Elf32_Word,
pub p_align: ::Elf32_Word,
}
}
17 changes: 17 additions & 0 deletions src/unix/haiku/b64.rs
@@ -1,3 +1,20 @@
pub type c_ulong = u64;
pub type c_long = i64;
pub type time_t = i64;

pub type Elf_Addr = ::Elf64_Addr;
pub type Elf_Half = ::Elf64_Half;
pub type Elf_Phdr = ::Elf64_Phdr;

s! {
pub struct Elf64_Phdr {
pub p_type: ::Elf64_Word,
pub p_flags: ::Elf64_Word,
pub p_offset: ::Elf64_Off,
pub p_vaddr: ::Elf64_Addr,
pub p_paddr: ::Elf64_Addr,
pub p_filesz: ::Elf64_Xword,
pub p_memsz: ::Elf64_Xword,
pub p_align: ::Elf64_Xword,
}
}
38 changes: 38 additions & 0 deletions src/unix/haiku/mod.rs
Expand Up @@ -31,6 +31,22 @@ pub type id_t = i32;
pub type idtype_t = ::c_uint;
pub type fd_mask = u32;

pub type Elf32_Addr = u32;
pub type Elf32_Half = u16;
pub type Elf32_Lword = u64;
pub type Elf32_Off = u32;
pub type Elf32_Sword = i32;
pub type Elf32_Word = u32;

pub type Elf64_Addr = u64;
pub type Elf64_Half = u16;
pub type Elf64_Lword = u64;
pub type Elf64_Off = u64;
pub type Elf64_Sword = i32;
pub type Elf64_Sxword = i64;
pub type Elf64_Word = u32;
pub type Elf64_Xword = u64;

#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
impl ::Copy for timezone {}
Expand Down Expand Up @@ -343,6 +359,17 @@ s! {
pub sdl_slen: u8,
pub sdl_data: [u8; 46],
}

pub struct dl_phdr_info {
pub dlpi_addr: Elf_Addr,
pub dlpi_name: *const ::c_char,
pub dlpi_phdr: *const Elf_Phdr,
pub dlpi_phnum: Elf_Half,
pub dlpi_adds: ::c_ulonglong,
pub dlpi_subs: ::c_ulonglong,
pub dlpi_tls_modid: usize,
pub dlpi_tls_data: *mut ::c_void,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -1650,6 +1677,17 @@ extern "C" {
pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
pub fn setutxent();
pub fn endutxent();

pub fn dl_iterate_phdr(
callback: ::Option<
unsafe extern "C" fn(
info: *mut dl_phdr_info,
size: usize,
data: *mut ::c_void,
) -> ::c_int,
>,
data: *mut ::c_void,
) -> ::c_int;
}

cfg_if! {
Expand Down