Skip to content

Commit 5e48129

Browse files
committed
Add dl_iterate_phdr for netbsd
1 parent 5519bbe commit 5e48129

File tree

1 file changed

+79
-0
lines changed
  • src/unix/bsd/netbsdlike/netbsd

1 file changed

+79
-0
lines changed

src/unix/bsd/netbsdlike/netbsd/mod.rs

+79
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,36 @@ pub type vm_size_t = ::uintptr_t;
1111
pub type lwpid_t = ::c_uint;
1212
pub type shmatt_t = ::c_uint;
1313

14+
// elf.h
15+
16+
pub type Elf32_Addr = u32;
17+
pub type Elf32_Half = u16;
18+
pub type Elf32_Lword = u64;
19+
pub type Elf32_Off = u32;
20+
pub type Elf32_Sword = i32;
21+
pub type Elf32_Word = u32;
22+
23+
pub type Elf64_Addr = u64;
24+
pub type Elf64_Half = u16;
25+
pub type Elf64_Lword = u64;
26+
pub type Elf64_Off = u64;
27+
pub type Elf64_Sword = i32;
28+
pub type Elf64_Sxword = i64;
29+
pub type Elf64_Word = u32;
30+
pub type Elf64_Xword = u64;
31+
32+
cfg_if! {
33+
if #[cfg(target_pointer_width = "64")] {
34+
type Elf_Addr = Elf64_Addr;
35+
type Elf_Half = Elf64_Half;
36+
type Elf_Phdr = Elf64_Phdr;
37+
} else if #[cfg(target_pointer_width = "32")] {
38+
type Elf_Addr = Elf32_Addr;
39+
type Elf_Half = Elf32_Half;
40+
type Elf_Phdr = Elf32_Phdr;
41+
}
42+
}
43+
1444
impl siginfo_t {
1545
pub unsafe fn si_value(&self) -> ::sigval {
1646
#[repr(C)]
@@ -341,6 +371,42 @@ s! {
341371
pub time_state: ::c_int,
342372
}
343373

374+
// elf.h
375+
376+
pub struct Elf32_Phdr {
377+
pub p_type: Elf32_Word,
378+
pub p_offset: Elf32_Off,
379+
pub p_vaddr: Elf32_Addr,
380+
pub p_paddr: Elf32_Addr,
381+
pub p_filesz: Elf32_Word,
382+
pub p_memsz: Elf32_Word,
383+
pub p_flags: Elf32_Word,
384+
pub p_align: Elf32_Word,
385+
}
386+
387+
pub struct Elf64_Phdr {
388+
pub p_type: Elf64_Word,
389+
pub p_flags: Elf64_Word,
390+
pub p_offset: Elf64_Off,
391+
pub p_vaddr: Elf64_Addr,
392+
pub p_paddr: Elf64_Addr,
393+
pub p_filesz: Elf64_Xword,
394+
pub p_memsz: Elf64_Xword,
395+
pub p_align: Elf64_Xword,
396+
}
397+
398+
// link.h
399+
400+
pub struct dl_phdr_info {
401+
pub dlpi_addr: Elf64_Addr,
402+
pub dlpi_name: *const ::c_char,
403+
pub dlpi_phdr: *const Elf64_Phdr,
404+
pub dlpi_phnum: Elf64_Half,
405+
pub dlpi_adds: ::c_ulonglong,
406+
pub dlpi_subs: ::c_ulonglong,
407+
pub dlpi_tls_modid: usize,
408+
pub dlpi_tls_data: *mut ::c_void,
409+
}
344410
}
345411

346412
s_no_extra_traits! {
@@ -2002,6 +2068,19 @@ extern "C" {
20022068
needle: *const ::c_void,
20032069
needlelen: ::size_t,
20042070
) -> *mut ::c_void;
2071+
2072+
// link.h
2073+
2074+
pub fn dl_iterate_phdr(
2075+
callback: ::Option<
2076+
unsafe extern "C" fn(
2077+
info: *mut dl_phdr_info,
2078+
size: usize,
2079+
data: *mut ::c_void,
2080+
) -> ::c_int,
2081+
>,
2082+
data: *mut ::c_void,
2083+
) -> ::c_int;
20052084
}
20062085

20072086
#[link(name = "util")]

0 commit comments

Comments
 (0)