Skip to content

Commit 338eebb

Browse files
committed
Auto merge of #1967 - tsidea:master, r=JohnTitor
Adding dl_iterate_phdr function to uclibc Adding dl_iterate_phdr function and related structs and types to the uclibc module as per the file include/link.h found in the uClibc-ng repository as of version 1.0.36. This is necessary in order for rust to work with a new target armv7-unknown-linux-uclibceabihf.
2 parents 4c0a7e5 + f3aab7a commit 338eebb

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

src/unix/uclibc/mod.rs

+68
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ pub type msglen_t = ::c_ulong;
2121
pub type nfds_t = ::c_ulong;
2222
pub type nl_item = ::c_int;
2323
pub type idtype_t = ::c_uint;
24+
pub type Elf32_Half = u16;
25+
pub type Elf32_Word = u32;
26+
pub type Elf32_Off = u32;
27+
pub type Elf32_Addr = u32;
28+
pub type Elf64_Half = u16;
29+
pub type Elf64_Word = u32;
30+
pub type Elf64_Off = u64;
31+
pub type Elf64_Addr = u64;
32+
pub type Elf64_Xword = u64;
33+
pub type Elf64_Sxword = i64;
2434

2535
#[cfg_attr(feature = "extra_traits", derive(Debug))]
2636
pub enum fpos64_t {} // FIXME: fill this out with a struct
@@ -289,6 +299,54 @@ s! {
289299
pub msgseg: ::c_ushort,
290300
}
291301

302+
pub struct Elf32_Phdr {
303+
pub p_type: Elf32_Word,
304+
pub p_offset: Elf32_Off,
305+
pub p_vaddr: Elf32_Addr,
306+
pub p_paddr: Elf32_Addr,
307+
pub p_filesz: Elf32_Word,
308+
pub p_memsz: Elf32_Word,
309+
pub p_flags: Elf32_Word,
310+
pub p_align: Elf32_Word,
311+
}
312+
313+
pub struct Elf64_Phdr {
314+
pub p_type: Elf64_Word,
315+
pub p_flags: Elf64_Word,
316+
pub p_offset: Elf64_Off,
317+
pub p_vaddr: Elf64_Addr,
318+
pub p_paddr: Elf64_Addr,
319+
pub p_filesz: Elf64_Xword,
320+
pub p_memsz: Elf64_Xword,
321+
pub p_align: Elf64_Xword,
322+
}
323+
324+
pub struct dl_phdr_info {
325+
#[cfg(target_pointer_width = "64")]
326+
pub dlpi_addr: Elf64_Addr,
327+
#[cfg(target_pointer_width = "32")]
328+
pub dlpi_addr: Elf32_Addr,
329+
pub dlpi_name: *const ::c_char,
330+
#[cfg(target_pointer_width = "64")]
331+
pub dlpi_phdr: *const Elf64_Phdr,
332+
#[cfg(target_pointer_width = "32")]
333+
pub dlpi_phdr: *const Elf32_Phdr,
334+
#[cfg(target_pointer_width = "64")]
335+
pub dlpi_phnum: Elf64_Half,
336+
#[cfg(target_pointer_width = "32")]
337+
pub dlpi_phnum: Elf32_Half,
338+
// As of uClibc 1.0.36, the following fields are
339+
// gated behind a "#if 0" block which always evaluates
340+
// to false. So I'm just commenting these out and if uClibc changes
341+
// the #if block in the future to include the following fields, these
342+
// will probably need including here. tsidea
343+
//
344+
// pub dlpi_adds: ::c_ulonglong,
345+
// pub dlpi_subs: ::c_ulonglong,
346+
// pub dlpi_tls_modid: ::size_t,
347+
// pub dlpi_tls_data: *mut ::c_void,
348+
}
349+
292350
pub struct ucred {
293351
pub pid: ::pid_t,
294352
pub uid: ::uid_t,
@@ -2247,6 +2305,16 @@ extern "C" {
22472305
f: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
22482306
value: *mut ::c_void,
22492307
) -> ::c_int;
2308+
pub fn dl_iterate_phdr(
2309+
callback: ::Option<
2310+
unsafe extern "C" fn(
2311+
info: *mut ::dl_phdr_info,
2312+
size: ::size_t,
2313+
data: *mut ::c_void,
2314+
) -> ::c_int,
2315+
>,
2316+
data: *mut ::c_void,
2317+
) -> ::c_int;
22502318
pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
22512319
pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
22522320
pub fn uname(buf: *mut ::utsname) -> ::c_int;

0 commit comments

Comments
 (0)