Skip to content

Commit

Permalink
Auto merge of #2665 - devnexen:solarish_dl_phdr_api2, r=Amanieu
Browse files Browse the repository at this point in the history
solarish systems dl_iterate_phdr support
  • Loading branch information
bors committed Feb 14, 2022
2 parents 31657a5 + 848a12c commit ea701b2
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ fn test_solarish(target: &str) {
"ifaddrs.h",
"langinfo.h",
"limits.h",
"link.h",
"locale.h",
"mqueue.h",
"net/if.h",
Expand Down
15 changes: 15 additions & 0 deletions src/unix/solarish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2954,6 +2954,18 @@ extern "C" {
sfvcnt: ::c_int,
xferred: *mut ::size_t,
) -> ::ssize_t;
// #include <link.h>
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
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;
pub fn getpagesize() -> ::c_int;
pub fn getpagesizes(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int;
pub fn mmapobj(
Expand Down Expand Up @@ -3033,5 +3045,8 @@ cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
} else if #[cfg(target_arch = "x86")] {
mod x86;
pub use self::x86::*;
}
}
29 changes: 29 additions & 0 deletions src/unix/solarish/x86.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pub type Elf32_Addr = ::c_ulong;
pub type Elf32_Half = ::c_ushort;
pub type Elf32_Off = ::c_ulong;
pub type Elf32_Sword = ::c_long;
pub type Elf32_Word = ::c_ulong;
pub type Elf32_Lword = ::c_ulonglong;
pub type Elf32_Phdr = __c_anonymous_Elf32_Phdr;

s! {
pub struct __c_anonymous_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,
}

pub struct dl_phdr_info {
pub dlpi_addr: ::Elf32_Addr,
pub dlpi_name: *const ::c_char,
pub dlpi_phdr: *const ::Elf32_Phdr,
pub dlpi_phnum: ::Elf32_Half,
pub dlpi_adds: ::c_ulonglong,
pub dlpi_subs: ::c_ulonglong,
}
}
30 changes: 30 additions & 0 deletions src/unix/solarish/x86_64.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
pub type greg_t = ::c_long;

pub type Elf64_Addr = ::c_ulong;
pub type Elf64_Half = ::c_ushort;
pub type Elf64_Off = ::c_ulong;
pub type Elf64_Sword = ::c_int;
pub type Elf64_Sxword = ::c_long;
pub type Elf64_Word = ::c_uint;
pub type Elf64_Xword = ::c_ulong;
pub type Elf64_Lword = ::c_ulong;
pub type Elf64_Phdr = __c_anonymous_Elf64_Phdr;

s! {
pub struct __c_anonymous_fpchip_state {
pub cw: u16,
Expand All @@ -17,6 +27,26 @@ s! {
pub status: u32,
pub xstatus: u32,
}

pub struct __c_anonymous_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,
}

pub struct dl_phdr_info {
pub dlpi_addr: ::Elf64_Addr,
pub dlpi_name: *const ::c_char,
pub dlpi_phdr: *const ::Elf64_Phdr,
pub dlpi_phnum: ::Elf64_Half,
pub dlpi_adds: ::c_ulonglong,
pub dlpi_subs: ::c_ulonglong,
}
}

s_no_extra_traits! {
Expand Down

0 comments on commit ea701b2

Please sign in to comment.