1 /**
2  * D header file for Solaris.
3  *
4  * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/link.h, illumos sys/link.h)
5  */
6 module core.sys.solaris.sys.link;
7 
8 version (Solaris):
9 extern (C):
10 nothrow:
11 
12 public import core.sys.solaris.sys.elftypes;
13 import core.stdc.config;
14 
15 struct Elf32_Dyn
16 {
17     Elf32_Sword d_tag;
18     union _d_un
19     {
20         Elf32_Word d_val;
21         Elf32_Addr d_ptr;
22         Elf32_Off  d_off;
23     } _d_un d_un;
24 }
25 
26 struct Elf64_Dyn
27 {
28     Elf64_Xword d_tag;
29     union _d_un
30     {
31         Elf64_Xword d_val;
32         Elf64_Addr  d_ptr;
33     } _d_un d_un;
34 }
35 
36 enum DT_NULL         = 0;
37 enum DT_NEEDED       = 1;
38 enum DT_PLTRELSZ     = 2;
39 enum DT_PLTGOT       = 3;
40 enum DT_HASH         = 4;
41 enum DT_STRTAB       = 5;
42 enum DT_SYMTAB       = 6;
43 enum DT_RELA         = 7;
44 enum DT_RELASZ       = 8;
45 enum DT_RELAENT      = 9;
46 enum DT_STRSZ        = 10;
47 enum DT_SYMENT       = 11;
48 enum DT_INIT         = 12;
49 enum DT_FINI         = 13;
50 enum DT_SONAME       = 14;
51 enum DT_RPATH        = 15;
52 enum DT_SYMBOLIC     = 16;
53 enum DT_REL          = 17;
54 enum DT_RELSZ        = 18;
55 enum DT_RELENT       = 19;
56 enum DT_PLTREL       = 20;
57 enum DT_DEBUG        = 21;
58 enum DT_TEXTREL      = 22;
59 enum DT_JMPREL       = 23;
60 enum DT_BIND_NOW     = 24;
61 enum DT_INIT_ARRAY   = 25;
62 enum DT_FINI_ARRAY   = 26;
63 enum DT_INIT_ARRAYSZ = 27;
64 enum DT_FINI_ARRAYSZ = 28;
65 enum DT_RUNPATH      = 29;
66 enum DT_FLAGS        = 30;
67 
68 enum DT_ENCODING        = 32;
69 enum DT_PREINIT_ARRAY   = 32;
70 enum DT_PREINIT_ARRAYSZ = 33;
71 
72 enum DT_MAXPOSTAGS = 34;
73 
74 enum DT_LOOS           = 0x6000000d;
75 enum DT_SUNW_AUXILIARY = 0x6000000d;
76 enum DT_SUNW_RTLDINF   = 0x6000000e;
77 enum DT_SUNW_FILTER    = 0x6000000f;
78 enum DT_SUNW_CAP       = 0x60000010;
79 enum DT_SUNW_SYMTAB    = 0x60000011;
80 enum DT_SUNW_SYMSZ     = 0x60000012;
81 
82 enum DT_SUNW_ENCODING    = 0x60000013;
83 enum DT_SUNW_SORTENT     = 0x60000013;
84 enum DT_SUNW_SYMSORT     = 0x60000014;
85 enum DT_SUNW_SYMSORTSZ   = 0x60000015;
86 enum DT_SUNW_TLSSORT     = 0x60000016;
87 enum DT_SUNW_TLSSORTSZ   = 0x60000017;
88 enum DT_SUNW_CAPINFO     = 0x60000018;
89 enum DT_SUNW_STRPAD      = 0x60000019;
90 enum DT_SUNW_CAPCHAIN    = 0x6000001a;
91 enum DT_SUNW_LDMACH      = 0x6000001b;
92 enum DT_SUNW_CAPCHAINENT = 0x6000001d;
93 enum DT_SUNW_CAPCHAINSZ  = 0x6000001f;
94 
95 enum DT_HIOS = 0x6ffff000;
96 
97 enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001;
98 
99 enum DT_VALRNGLO = 0x6ffffd00;
100 
101 enum DT_GNU_PRELINKED  = 0x6ffffdf5;
102 enum DT_GNU_CONFLICTSZ = 0x6ffffdf6;
103 enum DT_GNU_LIBLISTSZ  = 0x6ffffdf7;
104 enum DT_CHECKSUM       = 0x6ffffdf8;
105 enum DT_PLTPADSZ       = 0x6ffffdf9;
106 enum DT_MOVEENT        = 0x6ffffdfa;
107 enum DT_MOVESZ         = 0x6ffffdfb;
108 enum DT_FEATURE_1      = 0x6ffffdfc;
109 enum DT_POSFLAG_1      = 0x6ffffdfd;
110 enum DT_SYMINSZ        = 0x6ffffdfe;
111 enum DT_SYMINENT       = 0x6ffffdff;
112 enum DT_VALRNGHI       = 0x6ffffdff;
113 
114 enum DT_ADDRRNGLO = 0x6ffffe00;
115 
116 enum DT_GNU_HASH     = 0x6ffffef5;
117 enum DT_TLSDESC_PLT  = 0x6ffffef6;
118 enum DT_TLSDESC_GOT  = 0x6ffffef7;
119 enum DT_GNU_CONFLICT = 0x6ffffef8;
120 enum DT_GNU_LIBLIST  = 0x6ffffef9;
121 
122 enum DT_CONFIG    = 0x6ffffefa;
123 enum DT_DEPAUDIT  = 0x6ffffefb;
124 enum DT_AUDIT     = 0x6ffffefc;
125 enum DT_PLTPAD    = 0x6ffffefd;
126 enum DT_MOVETAB   = 0x6ffffefe;
127 enum DT_SYMINFO   = 0x6ffffeff;
128 enum DT_ADDRRNGHI = 0x6ffffeff;
129 
130 enum DT_VERSYM = 0x6ffffff0;
131 
132 enum DT_RELACOUNT  = 0x6ffffff9;
133 enum DT_RELCOUNT   = 0x6ffffffa;
134 enum DT_FLAGS_1    = 0x6ffffffb;
135 enum DT_VERDEF     = 0x6ffffffc;
136 enum DT_VERDEFNUM  = 0x6ffffffd;
137 enum DT_VERNEED    = 0x6ffffffe;
138 enum DT_VERNEEDNUM = 0x6fffffff;
139 
140 enum DT_LOPROC    = 0x70000000;
141 enum DT_AUXILIARY = 0x7ffffffd;
142 enum DT_USED      = 0x7ffffffe;
143 enum DT_FILTER    = 0x7fffffff;
144 enum DT_HIPROC    = 0x7fffffff;
145 
146 enum DF_ORIGIN     = 0x00000001;
147 enum DF_SYMBOLIC   = 0x00000002;
148 enum DF_TEXTREL    = 0x00000004;
149 enum DF_BIND_NOW   = 0x00000008;
150 enum DF_STATIC_TLS = 0x00000010;
151 
152 enum DF_P1_LAZYLOAD  = 0x00000001;
153 enum DF_P1_GROUPPERM = 0x00000002;
154 enum DF_P1_DEFERRED  = 0x00000004;
155 
156 enum DF_1_NOW        = 0x00000001;
157 enum DF_1_GLOBAL     = 0x00000002;
158 enum DF_1_GROUP      = 0x00000004;
159 enum DF_1_NODELETE   = 0x00000008;
160 enum DF_1_LOADFLTR   = 0x00000010;
161 enum DF_1_INITFIRST  = 0x00000020;
162 enum DF_1_NOOPEN     = 0x00000040;
163 enum DF_1_ORIGIN     = 0x00000080;
164 enum DF_1_DIRECT     = 0x00000100;
165 enum DF_1_TRANS      = 0x00000200;
166 enum DF_1_INTERPOSE  = 0x00000400;
167 enum DF_1_NODEFLIB   = 0x00000800;
168 enum DF_1_NODUMP     = 0x00001000;
169 enum DF_1_CONFALT    = 0x00002000;
170 enum DF_1_ENDFILTEE  = 0x00004000;
171 enum DF_1_DISPRELDNE = 0x00008000;
172 enum DF_1_DISPRELPND = 0x00010000;
173 enum DF_1_NODIRECT   = 0x00020000;
174 enum DF_1_IGNMULDEF  = 0x00040000;
175 enum DF_1_NOKSYMS    = 0x00080000;
176 enum DF_1_NOHDR      = 0x00100000;
177 enum DF_1_EDITED     = 0x00200000;
178 enum DF_1_NORELOC    = 0x00400000;
179 enum DF_1_SYMINTPOSE = 0x00800000;
180 enum DF_1_GLOBAUDIT  = 0x01000000;
181 enum DF_1_SINGLETON  = 0x02000000;
182 
183 enum DTF_1_PARINIT = 0x00000001;
184 enum DTF_1_CONFEXP = 0x00000002;
185 
186 struct Elf32_Verdef
187 {
188     Elf32_Half  vd_version;
189     Elf32_Half  vd_flags;
190     Elf32_Half  vd_ndx;
191     Elf32_Half  vd_cnt;
192     Elf32_Word  vd_hash;
193     Elf32_Word  vd_aux;
194     Elf32_Word  vd_next;
195 }
196 
197 struct Elf32_Verdaux
198 {
199     Elf32_Word  vda_name;
200     Elf32_Word  vda_next;
201 }
202 
203 struct Elf32_Verneed
204 {
205     Elf32_Half  vn_version;
206     Elf32_Half  vn_cnt;
207     Elf32_Word  vn_file;
208     Elf32_Word  vn_aux;
209     Elf32_Word  vn_next;
210 }
211 
212 struct Elf32_Vernaux
213 {
214     Elf32_Word  vna_hash;
215     Elf32_Half  vna_flags;
216     Elf32_Half  vna_other;
217     Elf32_Word  vna_name;
218     Elf32_Word  vna_next;
219 }
220 
221 alias Elf32_Half  Elf32_Versym;
222 
223 struct Elf32_Syminfo
224 {
225     Elf32_Half  si_boundto;
226     Elf32_Half  si_flags;
227 }
228 
229 struct Elf64_Verdef
230 {
231     Elf64_Half  vd_version;
232     Elf64_Half  vd_flags;
233     Elf64_Half  vd_ndx;
234     Elf64_Half  vd_cnt;
235     Elf64_Word  vd_hash;
236     Elf64_Word  vd_aux;
237     Elf64_Word  vd_next;
238 }
239 
240 struct Elf64_Verdaux
241 {
242     Elf64_Word  vda_name;
243     Elf64_Word  vda_next;
244 }
245 
246 struct Elf64_Verneed
247 {
248     Elf64_Half  vn_version;
249     Elf64_Half  vn_cnt;
250     Elf64_Word  vn_file;
251     Elf64_Word  vn_aux;
252     Elf64_Word  vn_next;
253 }
254 
255 struct Elf64_Vernaux
256 {
257     Elf64_Word  vna_hash;
258     Elf64_Half  vna_flags;
259     Elf64_Half  vna_other;
260     Elf64_Word  vna_name;
261     Elf64_Word  vna_next;
262 }
263 
264 alias Elf64_Half  Elf64_Versym;
265 
266 struct Elf64_Syminfo
267 {
268     Elf64_Half  si_boundto;
269     Elf64_Half  si_flags;
270 }
271 
272 enum VER_NDX_LOCAL     = 0;
273 enum VER_NDX_GLOBAL    = 1;
274 enum VER_NDX_LORESERVE = 0xff00;
275 enum VER_NDX_ELIMINATE = 0xff01;
276 
277 enum VER_FLG_BASE = 0x1;
278 enum VER_FLG_WEAK = 0x2;
279 enum VER_FLG_INFO = 0x4;
280 
281 enum VER_DEF_NONE    = 0;
282 enum VER_DEF_CURRENT = 1;
283 enum VER_DEF_NUM     = 2;
284 
285 enum VER_NEED_NONE    = 0;
286 enum VER_NEED_CURRENT = 1;
287 enum VER_NEED_NUM     = 2;
288 
289 enum SYMINFO_FLG_DIRECT      = 0x0001;
290 enum SYMINFO_FLG_FILTER      = 0x0002;
291 enum SYMINFO_FLG_PASSTHRU    = SYMINFO_FLG_FILTER;
292 enum SYMINFO_FLG_COPY        = 0x0004;
293 enum SYMINFO_FLG_LAZYLOAD    = 0x0008;
294 enum SYMINFO_FLG_DIRECTBIND  = 0x0010;
295 enum SYMINFO_FLG_NOEXTDIRECT = 0x0020;
296 enum SYMINFO_FLG_AUXILIARY   = 0x0040;
297 enum SYMINFO_FLG_INTERPOSE   = 0x0080;
298 enum SYMINFO_FLG_CAP         = 0x0100;
299 enum SYMINFO_FLG_DEFERRED    = 0x0200;
300 
301 enum SYMINFO_BT_SELF       = 0xffff;
302 enum SYMINFO_BT_PARENT     = 0xfffe;
303 enum SYMINFO_BT_NONE       = 0xfffd;
304 enum SYMINFO_BT_EXTERN     = 0xfffc;
305 enum SYMINFO_BT_LOWRESERVE = 0xff00;
306 
307 enum SYMINFO_NONE    = 0;
308 enum SYMINFO_CURRENT = 1;
309 enum SYMINFO_NUM     = 2;
310 
311 alias link_map Link_map;
312 
313 struct link_map
314 {
315     c_ulong  l_addr;
316     char*    l_name;
317     version (D_LP64)
318         Elf64_Dyn*  l_ld;
319     else
320         Elf32_Dyn*  l_ld;
321     Link_map*  l_next;
322     Link_map*  l_prev;
323     char*      l_refname;
324 }
325 
version(_SYSCALL32)326 version (_SYSCALL32)
327 {
328 alias link_map32 Link_map32;
329 
330 struct link_map32
331 {
332     Elf32_Word  l_addr;
333     Elf32_Addr  l_name;
334     Elf32_Addr  l_ld;
335     Elf32_Addr  l_next;
336     Elf32_Addr  l_prev;
337     Elf32_Addr  l_refname;
338 }
339 }
340 
341 enum r_state_e
342 {
343     RT_CONSISTENT,
344     RT_ADD,
345     RT_DELETE
346 }
347 
348 enum rd_flags_e
349 {
350     RD_FL_NONE = 0,
351     RD_FL_ODBG = (1<<0),
352     RD_FL_DBG  = (1<<1)
353 }
354 
355 enum rd_event_e
356 {
357     RD_NONE = 0,
358     RD_PREINIT,
359     RD_POSTINIT,
360     RD_DLACTIVITY
361 }
362 
363 struct r_debug
364 {
365     int         r_version;
366     Link_map*   r_map;
367     c_ulong     r_brk;
368     r_state_e   r_state;
369     c_ulong     r_ldbase;
370     Link_map*   r_ldsomap;
371     rd_event_e  r_rdevent;
372     rd_flags_e  r_flags;
373 }
374 
375 version (_SYSCALL32)
376 {
377 struct r_debug32
378 {
379     Elf32_Word  r_version;
380     Elf32_Addr  r_map;
381     Elf32_Word  r_brk;
382     r_state_e   r_state;
383     Elf32_Word  r_ldbase;
384     Elf32_Addr  r_ldsomap;
385     rd_event_e  r_rdevent;
386     rd_flags_e  r_flags;
387 }
388 }
389 
390 enum R_DEBUG_VERSION = 2;
391 
392 struct Elf32_Boot
393 {
394     Elf32_Sword eb_tag;
395     union eb_un
396     {
397         Elf32_Word eb_val;
398         Elf32_Addr eb_ptr;
399         Elf32_Off  eb_off;
400     }
401 }
402 
403 struct Elf64_Boot
404 {
405     Elf64_Xword eb_tag;
406     union eb_un
407     {
408         Elf64_Xword eb_val;
409         Elf64_Addr eb_ptr;
410         Elf64_Off eb_off;
411     }
412 }
413 
414 enum EB_NULL       = 0;
415 enum EB_DYNAMIC    = 1;
416 enum EB_LDSO_BASE  = 2;
417 enum EB_ARGV       = 3;
418 enum EB_ENVP       = 4;
419 enum EB_AUXV       = 5;
420 enum EB_DEVZERO    = 6;
421 enum EB_PAGESIZE   = 7;
422 enum EB_MAX        = 8;
423 enum EB_MAX_SIZE32 = 64;
424 enum EB_MAX_SIZE64 = 128;
425 
426 void _ld_libc(void *);
427