Skip to content

Commit ea701b2

Browse files
committed
Auto merge of #2665 - devnexen:solarish_dl_phdr_api2, r=Amanieu
solarish systems dl_iterate_phdr support
2 parents 31657a5 + 848a12c commit ea701b2

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ fn test_solarish(target: &str) {
747747
"ifaddrs.h",
748748
"langinfo.h",
749749
"limits.h",
750+
"link.h",
750751
"locale.h",
751752
"mqueue.h",
752753
"net/if.h",

src/unix/solarish/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,6 +2954,18 @@ extern "C" {
29542954
sfvcnt: ::c_int,
29552955
xferred: *mut ::size_t,
29562956
) -> ::ssize_t;
2957+
// #include <link.h>
2958+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
2959+
pub fn dl_iterate_phdr(
2960+
callback: ::Option<
2961+
unsafe extern "C" fn(
2962+
info: *mut dl_phdr_info,
2963+
size: usize,
2964+
data: *mut ::c_void,
2965+
) -> ::c_int,
2966+
>,
2967+
data: *mut ::c_void,
2968+
) -> ::c_int;
29572969
pub fn getpagesize() -> ::c_int;
29582970
pub fn getpagesizes(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int;
29592971
pub fn mmapobj(
@@ -3033,5 +3045,8 @@ cfg_if! {
30333045
if #[cfg(target_arch = "x86_64")] {
30343046
mod x86_64;
30353047
pub use self::x86_64::*;
3048+
} else if #[cfg(target_arch = "x86")] {
3049+
mod x86;
3050+
pub use self::x86::*;
30363051
}
30373052
}

src/unix/solarish/x86.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
pub type Elf32_Addr = ::c_ulong;
2+
pub type Elf32_Half = ::c_ushort;
3+
pub type Elf32_Off = ::c_ulong;
4+
pub type Elf32_Sword = ::c_long;
5+
pub type Elf32_Word = ::c_ulong;
6+
pub type Elf32_Lword = ::c_ulonglong;
7+
pub type Elf32_Phdr = __c_anonymous_Elf32_Phdr;
8+
9+
s! {
10+
pub struct __c_anonymous_Elf32_Phdr {
11+
pub p_type: ::Elf32_Word,
12+
pub p_offset: ::Elf32_Off,
13+
pub p_vaddr: ::Elf32_Addr,
14+
pub p_paddr: ::Elf32_Addr,
15+
pub p_filesz: ::Elf32_Word,
16+
pub p_memsz: ::Elf32_Word,
17+
pub p_flags: ::Elf32_Word,
18+
pub p_align: ::Elf32_Word,
19+
}
20+
21+
pub struct dl_phdr_info {
22+
pub dlpi_addr: ::Elf32_Addr,
23+
pub dlpi_name: *const ::c_char,
24+
pub dlpi_phdr: *const ::Elf32_Phdr,
25+
pub dlpi_phnum: ::Elf32_Half,
26+
pub dlpi_adds: ::c_ulonglong,
27+
pub dlpi_subs: ::c_ulonglong,
28+
}
29+
}

src/unix/solarish/x86_64.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
pub type greg_t = ::c_long;
22

3+
pub type Elf64_Addr = ::c_ulong;
4+
pub type Elf64_Half = ::c_ushort;
5+
pub type Elf64_Off = ::c_ulong;
6+
pub type Elf64_Sword = ::c_int;
7+
pub type Elf64_Sxword = ::c_long;
8+
pub type Elf64_Word = ::c_uint;
9+
pub type Elf64_Xword = ::c_ulong;
10+
pub type Elf64_Lword = ::c_ulong;
11+
pub type Elf64_Phdr = __c_anonymous_Elf64_Phdr;
12+
313
s! {
414
pub struct __c_anonymous_fpchip_state {
515
pub cw: u16,
@@ -17,6 +27,26 @@ s! {
1727
pub status: u32,
1828
pub xstatus: u32,
1929
}
30+
31+
pub struct __c_anonymous_Elf64_Phdr {
32+
pub p_type: ::Elf64_Word,
33+
pub p_flags: ::Elf64_Word,
34+
pub p_offset: ::Elf64_Off,
35+
pub p_vaddr: ::Elf64_Addr,
36+
pub p_paddr: ::Elf64_Addr,
37+
pub p_filesz: ::Elf64_Xword,
38+
pub p_memsz: ::Elf64_Xword,
39+
pub p_align: ::Elf64_Xword,
40+
}
41+
42+
pub struct dl_phdr_info {
43+
pub dlpi_addr: ::Elf64_Addr,
44+
pub dlpi_name: *const ::c_char,
45+
pub dlpi_phdr: *const ::Elf64_Phdr,
46+
pub dlpi_phnum: ::Elf64_Half,
47+
pub dlpi_adds: ::c_ulonglong,
48+
pub dlpi_subs: ::c_ulonglong,
49+
}
2050
}
2151

2252
s_no_extra_traits! {

0 commit comments

Comments
 (0)