Skip to content

Commit 42dce28

Browse files
committed
Add dl_iterate_phdr for openbsd
1 parent 6711eef commit 42dce28

File tree

1 file changed

+73
-0
lines changed
  • src/unix/bsd/netbsdlike/openbsd

1 file changed

+73
-0
lines changed

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

+73
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,36 @@ pub type pthread_rwlock_t = *mut ::c_void;
1616
pub type pthread_rwlockattr_t = *mut ::c_void;
1717
pub type caddr_t = *mut ::c_char;
1818

19+
// elf.h
20+
21+
pub type Elf32_Addr = u32;
22+
pub type Elf32_Half = u16;
23+
pub type Elf32_Lword = u64;
24+
pub type Elf32_Off = u32;
25+
pub type Elf32_Sword = i32;
26+
pub type Elf32_Word = u32;
27+
28+
pub type Elf64_Addr = u64;
29+
pub type Elf64_Half = u16;
30+
pub type Elf64_Lword = u64;
31+
pub type Elf64_Off = u64;
32+
pub type Elf64_Sword = i32;
33+
pub type Elf64_Sxword = i64;
34+
pub type Elf64_Word = u32;
35+
pub type Elf64_Xword = u64;
36+
37+
cfg_if! {
38+
if #[cfg(target_pointer_width = "64")] {
39+
type Elf_Addr = Elf64_Addr;
40+
type Elf_Half = Elf64_Half;
41+
type Elf_Phdr = Elf64_Phdr;
42+
} else if #[cfg(target_pointer_width = "32")] {
43+
type Elf_Addr = Elf32_Addr;
44+
type Elf_Half = Elf32_Half;
45+
type Elf_Phdr = Elf32_Phdr;
46+
}
47+
}
48+
1949
s! {
2050
pub struct glob_t {
2151
pub gl_pathc: ::size_t,
@@ -321,6 +351,38 @@ s! {
321351
__shm_ctimensec: c_long,
322352
pub shm_internal: *mut ::c_void,
323353
}
354+
355+
// elf.h
356+
pub struct Elf32_Phdr {
357+
pub p_type: Elf32_Word,
358+
pub p_offset: Elf32_Off,
359+
pub p_vaddr: Elf32_Addr,
360+
pub p_paddr: Elf32_Addr,
361+
pub p_filesz: Elf32_Word,
362+
pub p_memsz: Elf32_Word,
363+
pub p_flags: Elf32_Word,
364+
pub p_align: Elf32_Word,
365+
}
366+
367+
pub struct Elf64_Phdr {
368+
pub p_type: Elf64_Word,
369+
pub p_flags: Elf64_Word,
370+
pub p_offset: Elf64_Off,
371+
pub p_vaddr: Elf64_Addr,
372+
pub p_paddr: Elf64_Addr,
373+
pub p_filesz: Elf64_Xword,
374+
pub p_memsz: Elf64_Xword,
375+
pub p_align: Elf64_Xword,
376+
}
377+
378+
// link.h
379+
380+
pub struct dl_phdr_info {
381+
pub dlpi_addr: Elf_Addr,
382+
pub dlpi_name: *const ::c_char,
383+
pub dlpi_phdr: *const Elf_Phdr,
384+
pub dlpi_phnum: Elf_Half,
385+
}
324386
}
325387

326388
impl siginfo_t {
@@ -1482,6 +1544,17 @@ extern "C" {
14821544
needle: *const ::c_void,
14831545
needlelen: ::size_t,
14841546
) -> *mut ::c_void;
1547+
// #include <link.h>
1548+
pub fn dl_iterate_phdr(
1549+
callback: ::Option<
1550+
unsafe extern "C" fn(
1551+
info: *mut dl_phdr_info,
1552+
size: usize,
1553+
data: *mut ::c_void,
1554+
) -> ::c_int,
1555+
>,
1556+
data: *mut ::c_void,
1557+
) -> ::c_int;
14851558
}
14861559

14871560
cfg_if! {

0 commit comments

Comments
 (0)