The OpenD Programming Language

1 /**
2  * D header file for Solaris.
3  *
4  * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/head/link.h, illumos link.h)
5  */
6 module core.sys.solaris.link;
7 
8 version (Solaris):
9 extern (C):
10 nothrow:
11 
12 import core.stdc.stdint;
13 import core.sys.solaris.dlfcn;
14 import core.sys.solaris.libelf;
15 import core.sys.solaris.sys.elf;
16 import core.sys.solaris.sys.link;
17 
18 uint ld_version(uint);
19 void ld_input_done(uint*);
20 
21 void ld_start(const scope char*, const Elf32_Half, const scope char*);
22 void ld_atexit(int);
23 void ld_open(const scope char**, const scope char**, int*, int, Elf**, Elf*, size_t, const Elf_Kind);
24 void ld_file(const scope char*, const Elf_Kind, int, Elf*);
25 void ld_input_section(const scope char*, Elf32_Shdr**, Elf32_Word, Elf_Data*, Elf*, uint*);
26 void ld_section(const scope char*, Elf32_Shdr*, Elf32_Word, Elf_Data*, Elf*);
27 
28 version (D_LP64)
29 {
30     void ld_start64(const scope char*, const Elf64_Half, const scope char*);
31     void ld_atexit64(int);
32     void ld_open64(const scope char**, const scope char**, int*, int, Elf**, Elf*, size_t, const Elf_Kind);
33     void ld_file64(const scope char*, const Elf_Kind, int, Elf*);
34     void ld_input_section64(const scope char*, Elf64_Shdr**, Elf64_Word, Elf_Data*, Elf*, uint*);
35     void ld_section64(const scope char*, Elf64_Shdr*, Elf64_Word, Elf_Data*, Elf*);
36 }
37 
38 enum LD_SUP_VNONE    = 0;
39 enum LD_SUP_VERSION1 = 1;
40 enum LD_SUP_VERSION2 = 2;
41 enum LD_SUP_VERSION3 = 3;
42 enum LD_SUP_VCURRENT = LD_SUP_VERSION3;
43 
44 enum LD_SUP_DERIVED   = 0x1;
45 enum LD_SUP_INHERITED = 0x2;
46 enum LD_SUP_EXTRACTED = 0x4;
47 
48 enum LM_ID_BASE = 0x00;
49 enum LM_ID_LDSO = 0x01;
50 enum LM_ID_NUM  = 2;
51 
52 enum LM_ID_BRAND = 0xfd;
53 enum LM_ID_NONE  = 0xfe;
54 enum LM_ID_NEWLM = 0xff;
55 
56 enum LAV_NONE     = 0;
57 enum LAV_VERSION1 = 1;
58 enum LAV_VERSION2 = 2;
59 enum LAV_VERSION3 = 3;
60 enum LAV_VERSION4 = 4;
61 enum LAV_VERSION5 = 5;
62 enum LAV_CURRENT  = LAV_VERSION5;
63 enum LAV_NUM      = 6;
64 
65 enum LA_FLG_BINDTO   = 0x0001;
66 enum LA_FLG_BINDFROM = 0x0002;
67 
68 enum LA_SYMB_NOPLTENTER = 0x0001;
69 enum LA_SYMB_NOPLTEXIT  = 0x0002;
70 enum LA_SYMB_STRUCTCALL = 0x0004;
71 enum LA_SYMB_DLSYM      = 0x0008;
72 enum LA_SYMB_ALTVALUE   = 0x0010;
73 
74 enum LA_SER_ORIG    = 0x001;
75 enum LA_SER_LIBPATH = 0x002;
76 enum LA_SER_RUNPATH = 0x004;
77 enum LA_SER_CONFIG  = 0x008;
78 enum LA_SER_DEFAULT = 0x040;
79 enum LA_SER_SECURE  = 0x080;
80 
81 enum LA_SER_MASK    = 0xfff;
82 
83 enum LA_ACT_CONSISTENT = 0x00;
84 enum LA_ACT_ADD        = 0x01;
85 enum LA_ACT_DELETE     = 0x02;
86 enum LA_ACT_MAX        = 3;
87 
88 version (D_LP64)
89     alias long lagreg_t;
90 else
91     alias int lagreg_t;
92 
93 struct _la_sparc_regs
94 {
95     lagreg_t  lr_rego0;
96     lagreg_t  lr_rego1;
97     lagreg_t  lr_rego2;
98     lagreg_t  lr_rego3;
99     lagreg_t  lr_rego4;
100     lagreg_t  lr_rego5;
101     lagreg_t  lr_rego6;
102     lagreg_t  lr_rego7;
103 }
104 
105 version (D_LP64)
106 {
107     alias _la_sparc_regs La_sparcv9_regs;
108     struct La_amd64_regs
109     {
110         lagreg_t  lr_rsp;
111         lagreg_t  lr_rbp;
112         lagreg_t  lr_rdi;
113         lagreg_t  lr_rsi;
114         lagreg_t  lr_rdx;
115         lagreg_t  lr_rcx;
116         lagreg_t  lr_r8;
117         lagreg_t  lr_r9;
118     }
119 }
120 else
121 {
122     alias _la_sparc_regs La_sparcv8_regs;
123     struct La_i86_regs
124     {
125         lagreg_t  lr_esp;
126         lagreg_t  lr_ebp;
127     }
128 }
129 
130 uint la_version(uint);
131 void la_activity(uintptr_t*, uint);
132 void la_preinit(uintptr_t*);
133 char* la_objsearch(const scope char*, uintptr_t*, uint);
134 uint la_objopen(Link_map*, Lmid_t, uintptr_t*);
135 uint la_objclose(uintptr_t*);
136 int la_objfilter(uintptr_t*, const scope char*, uintptr_t*, uint);
137 
138 version (D_LP64)
139 {
140     uintptr_t la_amd64_pltenter(Elf64_Sym*, uint, uintptr_t*, uintptr_t*,
141                                 La_amd64_regs*, uint*, const scope char*);
142     uintptr_t la_symbind64(Elf64_Sym*, uint, uintptr_t*, uintptr_t*, uint*, const scope char*);
143     uintptr_t la_sparcv9_pltenter(Elf64_Sym*, uint, uintptr_t*, uintptr_t*,
144                                   La_sparcv9_regs*, uint*, const scope char*);
145     uintptr_t la_pltexit64(Elf64_Sym*, uint, uintptr_t*, uintptr_t*, uintptr_t, const scope char*);
146 }
147 else
148 {
149     uintptr_t la_symbind32(Elf32_Sym*, uint, uintptr_t*, uintptr_t*, uint*);
150     uintptr_t la_sparcv8_pltenter(Elf32_Sym*, uint, uintptr_t*, uintptr_t*,
151                                   La_sparcv8_regs*, uint*);
152     uintptr_t la_i86_pltenter(Elf32_Sym*, uint, uintptr_t*, uintptr_t*,
153                               La_i86_regs*, uint*);
154     uintptr_t la_pltexit(Elf32_Sym*, uint, uintptr_t*, uintptr_t*, uintptr_t);
155 }
156 
157 template ElfW(string type)
158 {
159     version (D_LP64)
160         mixin("alias Elf64_"~type~" ElfW;");
161     else
162         mixin("alias Elf32_"~type~" ElfW;");
163 }
164 
165 struct dl_phdr_info
166 {
167     ElfW!"Addr"        dlpi_addr;
168     char*              dlpi_name;
169     ElfW!"Phdr"*       dlpi_phdr;
170     ElfW!"Half"        dlpi_phnum;
171     uint64_t           dlpi_adds;
172     uint64_t           dlpi_subs;
173     size_t             dlpi_tls_modid;  // since Solaris 11.5
174     void*              dlpi_tls_data;   // since Solaris 11.5
175 }
176 
177 private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb;
178 private alias extern(C) int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc;
179 extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data);
180 extern int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc;