@@ -14,6 +14,38 @@ pub type nl_item = ::c_int;
14
14
pub type id_t = i64 ;
15
15
pub type vm_size_t = :: uintptr_t ;
16
16
17
+ // elf.h
18
+
19
+ pub type Elf32_Addr = u32 ;
20
+ pub type Elf32_Half = u16 ;
21
+ pub type Elf32_Lword = u64 ;
22
+ pub type Elf32_Off = u32 ;
23
+ pub type Elf32_Sword = i32 ;
24
+ pub type Elf32_Word = u32 ;
25
+
26
+ pub type Elf64_Addr = u64 ;
27
+ pub type Elf64_Half = u16 ;
28
+ pub type Elf64_Lword = u64 ;
29
+ pub type Elf64_Off = u64 ;
30
+ pub type Elf64_Sword = i32 ;
31
+ pub type Elf64_Sxword = i64 ;
32
+ pub type Elf64_Word = u32 ;
33
+ pub type Elf64_Xword = u64 ;
34
+
35
+ cfg_if ! {
36
+ if #[ cfg( target_pointer_width = "64" ) ] {
37
+ type Elf_Addr = Elf64_Addr ;
38
+ type Elf_Half = Elf64_Half ;
39
+ type Elf_Phdr = Elf64_Phdr ;
40
+ } else if #[ cfg( target_pointer_width = "32" ) ] {
41
+ type Elf_Addr = Elf32_Addr ;
42
+ type Elf_Half = Elf32_Half ;
43
+ type Elf_Phdr = Elf32_Phdr ;
44
+ }
45
+ }
46
+
47
+ // link.h
48
+
17
49
#[ cfg_attr( feature = "extra_traits" , derive( Debug ) ) ]
18
50
pub enum timezone { }
19
51
impl :: Copy for timezone { }
@@ -233,6 +265,43 @@ s! {
233
265
pub piod_addr: * mut :: c_void,
234
266
pub piod_len: :: size_t,
235
267
}
268
+
269
+ // elf.h
270
+
271
+ pub struct Elf32_Phdr {
272
+ pub p_type: Elf32_Word ,
273
+ pub p_offset: Elf32_Off ,
274
+ pub p_vaddr: Elf32_Addr ,
275
+ pub p_paddr: Elf32_Addr ,
276
+ pub p_filesz: Elf32_Word ,
277
+ pub p_memsz: Elf32_Word ,
278
+ pub p_flags: Elf32_Word ,
279
+ pub p_align: Elf32_Word ,
280
+ }
281
+
282
+ pub struct Elf64_Phdr {
283
+ pub p_type: Elf64_Word ,
284
+ pub p_flags: Elf64_Word ,
285
+ pub p_offset: Elf64_Off ,
286
+ pub p_vaddr: Elf64_Addr ,
287
+ pub p_paddr: Elf64_Addr ,
288
+ pub p_filesz: Elf64_Xword ,
289
+ pub p_memsz: Elf64_Xword ,
290
+ pub p_align: Elf64_Xword ,
291
+ }
292
+
293
+ // link.h
294
+
295
+ pub struct dl_phdr_info {
296
+ pub dlpi_addr: Elf_Addr ,
297
+ pub dlpi_name: * const :: c_char,
298
+ pub dlpi_phdr: * const Elf_Phdr ,
299
+ pub dlpi_phnum: Elf_Half ,
300
+ pub dlpi_adds: :: c_ulonglong,
301
+ pub dlpi_subs: :: c_ulonglong,
302
+ pub dlpi_tls_modid: usize ,
303
+ pub dlpi_tls_data: * mut :: c_void,
304
+ }
236
305
}
237
306
238
307
s_no_extra_traits ! {
@@ -1514,6 +1583,18 @@ extern "C" {
1514
1583
1515
1584
pub fn ntp_adjtime ( buf : * mut timex ) -> :: c_int ;
1516
1585
pub fn ntp_gettime ( buf : * mut ntptimeval ) -> :: c_int ;
1586
+
1587
+ // #include <link.h>
1588
+ pub fn dl_iterate_phdr (
1589
+ callback : :: Option <
1590
+ unsafe extern "C" fn (
1591
+ info : * mut dl_phdr_info ,
1592
+ size : usize ,
1593
+ data : * mut :: c_void ,
1594
+ ) -> :: c_int ,
1595
+ > ,
1596
+ data : * mut :: c_void ,
1597
+ ) -> :: c_int ;
1517
1598
}
1518
1599
1519
1600
#[ link( name = "rt" ) ]
0 commit comments