1 /**
2  * D header file for FreeBSD.
3  *
4  * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/link_elf.h?view=markup, sys/link_elf.h)
5  */
6 module core.sys.freebsd.sys.link_elf;
7 
8 version (FreeBSD):
9 extern (C):
10 nothrow:
11 
12 import core.stdc.stdint : uint64_t;
13 import core.sys.freebsd.sys.elf;
14 
15 version (D_LP64)
16     enum __ELF_NATIVE_CLASS = 64;
17 else
18     enum __ELF_NATIVE_CLASS = 32;
19 
20 template ElfW(string type)
21 {
22     mixin("alias Elf"~__ELF_NATIVE_CLASS.stringof~"_"~type~" ElfW;");
23 }
24 
25 enum LA_SER_ORIG =      0x01;
26 enum LA_SER_LIBPATH =   0x02;
27 enum LA_SER_RUNPATH =   0x04;
28 enum LA_SER_CONFIG =    0x08;
29 enum LA_SER_DEFAULT =   0x40;
30 enum LA_SER_SECURE =    0x80;
31 
32 struct link_map
33 {
34     char*           l_addr;
35 
36     version (MIPS32)
37         char*       l_offs;
38     version (MIPS64)
39         char*       l_offs;
40 
41     char*           l_name;
42     void*           l_ld;
43     link_map*       l_next, l_prev;
44 }
45 alias link_map Link_map;
46 
47 enum
48 {
49     RT_CONSISTENT,
50     RT_ADD,
51     RT_DELETE,
52 }
53 
54 struct r_debug
55 {
56     int             r_version;
57     link_map*       r_map;
58     void function(r_debug*, link_map*) r_brk;
59 }
60 
61 struct dl_phdr_info
62 {
63     ElfW!"Addr"     dlpi_addr;
64     char*           dlpi_name;
65     ElfW!"Phdr"*    dlpi_phdr;
66     ElfW!"Half"     dlpi_phnum;
67     uint64_t        dlpi_adds;
68     uint64_t        dlpi_subs;
69     size_t          dlpi_tls_modid;
70     void*           dlpi_tls_data;
71 }
72 
73 
74 private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb;
75 private alias extern(C) int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc;
76 extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data);
77 extern int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc;
78 extern int _rtld_addr_phdr(const void*, dl_phdr_info*) @nogc;
79 extern int _rtld_get_stack_prot() @nogc;