1 /** 2 * D header file for POSIX. 3 * 4 * Copyright: Copyright Sean Kelly 2005 - 2009. 5 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 * Authors: Sean Kelly, Alex Rønne Petersen 7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition 8 */ 9 10 /* Copyright Sean Kelly 2005 - 2009. 11 * Distributed under the Boost Software License, Version 1.0. 12 * (See accompanying file LICENSE or copy at 13 * http://www.boost.org/LICENSE_1_0.txt) 14 */ 15 module core.sys.posix.dlfcn; 16 17 import core.sys.posix.config; 18 19 version (OSX) 20 version = Darwin; 21 else version (iOS) 22 version = Darwin; 23 else version (TVOS) 24 version = Darwin; 25 else version (WatchOS) 26 version = Darwin; 27 28 version (ARM) version = ARM_Any; 29 version (AArch64) version = ARM_Any; 30 version (HPPA) version = HPPA_Any; 31 version (MIPS32) version = MIPS_Any; 32 version (MIPS64) version = MIPS_Any; 33 version (PPC) version = PPC_Any; 34 version (PPC64) version = PPC_Any; 35 version (RISCV32) version = RISCV_Any; 36 version (RISCV64) version = RISCV_Any; 37 version (S390) version = IBMZ_Any; 38 version (SPARC) version = SPARC_Any; 39 version (SPARC64) version = SPARC_Any; 40 version (SystemZ) version = IBMZ_Any; 41 version (X86) version = X86_Any; 42 version (X86_64) version = X86_Any; 43 44 version (Posix): 45 extern (C): 46 nothrow: 47 @nogc: 48 49 // 50 // XOpen (XSI) 51 // 52 /* 53 RTLD_LAZY 54 RTLD_NOW 55 RTLD_GLOBAL 56 RTLD_LOCAL 57 58 int dlclose(void*); 59 char* dlerror(); 60 void* dlopen(const scope char*, int); 61 void* dlsym(void*, const scope char*); 62 */ 63 64 version (CRuntime_Glibc) 65 { 66 version (X86_Any) 67 { 68 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h 69 enum RTLD_LAZY = 0x00001; 70 enum RTLD_NOW = 0x00002; 71 enum RTLD_BINDING_MASK = 0x3; 72 enum RTLD_NOLOAD = 0x00004; 73 enum RTLD_DEEPBIND = 0x00008; 74 enum RTLD_GLOBAL = 0x00100; 75 enum RTLD_LOCAL = 0x00000; 76 enum RTLD_NODELETE = 0x01000; 77 } 78 else version (HPPA_Any) 79 { 80 // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/hppa/bits/dlfcn.h 81 enum RTLD_LAZY = 0x0001; 82 enum RTLD_NOW = 0x0002; 83 enum RTLD_BINDING_MASK = 0x3; 84 enum RTLD_NOLOAD = 0x00004; 85 enum RTLD_DEEPBIND = 0x00008; 86 enum RTLD_GLOBAL = 0x0100; 87 enum RTLD_LOCAL = 0; 88 enum RTLD_NODELETE = 0x01000; 89 } 90 else version (MIPS_Any) 91 { 92 // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/mips/bits/dlfcn.h 93 enum RTLD_LAZY = 0x0001; 94 enum RTLD_NOW = 0x0002; 95 enum RTLD_BINDING_MASK = 0x3; 96 enum RTLD_NOLOAD = 0x00008; 97 enum RTLD_DEEPBIND = 0x00010; 98 enum RTLD_GLOBAL = 0x0004; 99 enum RTLD_LOCAL = 0; 100 enum RTLD_NODELETE = 0x01000; 101 } 102 else version (PPC_Any) 103 { 104 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h 105 enum RTLD_LAZY = 0x00001; 106 enum RTLD_NOW = 0x00002; 107 enum RTLD_BINDING_MASK = 0x3; 108 enum RTLD_NOLOAD = 0x00004; 109 enum RTLD_DEEPBIND = 0x00008; 110 enum RTLD_GLOBAL = 0x00100; 111 enum RTLD_LOCAL = 0; 112 enum RTLD_NODELETE = 0x01000; 113 } 114 else version (ARM_Any) 115 { 116 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h 117 enum RTLD_LAZY = 0x00001; 118 enum RTLD_NOW = 0x00002; 119 enum RTLD_BINDING_MASK = 0x3; 120 enum RTLD_NOLOAD = 0x00004; 121 enum RTLD_DEEPBIND = 0x00008; 122 enum RTLD_GLOBAL = 0x00100; 123 enum RTLD_LOCAL = 0; 124 enum RTLD_NODELETE = 0x01000; 125 } 126 else version (RISCV_Any) 127 { 128 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h 129 enum RTLD_LAZY = 0x00001; 130 enum RTLD_NOW = 0x00002; 131 enum RTLD_BINDING_MASK = 0x3; 132 enum RTLD_NOLOAD = 0x00004; 133 enum RTLD_DEEPBIND = 0x00008; 134 enum RTLD_GLOBAL = 0x00100; 135 enum RTLD_LOCAL = 0; 136 enum RTLD_NODELETE = 0x01000; 137 } 138 else version (SPARC_Any) 139 { 140 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h 141 enum RTLD_LAZY = 0x00001; 142 enum RTLD_NOW = 0x00002; 143 enum RTLD_BINDING_MASK = 0x3; 144 enum RTLD_NOLOAD = 0x00004; 145 enum RTLD_DEEPBIND = 0x00008; 146 enum RTLD_GLOBAL = 0x00100; 147 enum RTLD_LOCAL = 0; 148 enum RTLD_NODELETE = 0x01000; 149 150 } 151 else version (IBMZ_Any) 152 { 153 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h 154 enum RTLD_LAZY = 0x00001; 155 enum RTLD_NOW = 0x00002; 156 enum RTLD_BINDING_MASK = 0x3; 157 enum RTLD_NOLOAD = 0x00004; 158 enum RTLD_DEEPBIND = 0x00008; 159 enum RTLD_GLOBAL = 0x00100; 160 enum RTLD_LOCAL = 0; 161 enum RTLD_NODELETE = 0x01000; 162 } 163 else 164 static assert(0, "unimplemented"); 165 166 int dlclose(void*); 167 char* dlerror(); 168 void* dlopen(const scope char*, int); 169 void* dlsym(void*, const scope char*); 170 int dladdr(const scope void*, Dl_info*); 171 172 struct Dl_info 173 { 174 const(char)* dli_fname; 175 void* dli_fbase; 176 const(char)* dli_sname; 177 void* dli_saddr; 178 } 179 } 180 else 181 version (CRuntime_Musl) 182 { 183 enum RTLD_LAZY = 1; 184 enum RTLD_NOW = 2; 185 enum RTLD_NOLOAD = 4; 186 enum RTLD_NODELETE = 4096; 187 enum RTLD_GLOBAL = 256; 188 enum RTLD_LOCAL = 0; 189 190 enum RTLD_NEXT = cast(void *)-1; 191 enum RTLD_DEFAULT = cast(void *)0; 192 193 enum RTLD_DI_LINKMAP = 2; 194 195 int dlclose(void *); 196 char *dlerror(); 197 void *dlopen(const(char) *, int); 198 199 pragma(mangle, muslRedirTime64Mangle!("dlsym", "__dlsym_time64")) 200 void *dlsym(void *__restrict, const(char) *__restrict); 201 202 struct Dl_info 203 { 204 const(char)* dli_fname; 205 void* dli_fbase; 206 const(char)* dli_sname; 207 void* dli_saddr; 208 } 209 int dladdr(const(void) *, Dl_info *); 210 int dlinfo(void *, int, void *); 211 } 212 else version (Darwin) 213 { 214 enum RTLD_LAZY = 0x00001; 215 enum RTLD_NOW = 0x00002; 216 enum RTLD_NOLOAD = 0x10; 217 enum RTLD_NODELETE = 0x80; 218 enum RTLD_GLOBAL = 0x00100; 219 enum RTLD_LOCAL = 0x00000; 220 enum RTLD_FIRST = 0x100; 221 222 int dlclose(void*); 223 char* dlerror(); 224 void* dlopen(const scope char*, int); 225 void* dlsym(void*, const scope char*); 226 int dladdr(scope const void* addr, Dl_info* info); 227 228 struct Dl_info 229 { 230 const(char)* dli_fname; 231 void* dli_fbase; 232 const(char)* dli_sname; 233 void* dli_saddr; 234 } 235 } 236 else version (FreeBSD) 237 { 238 enum RTLD_LAZY = 1; 239 enum RTLD_NOW = 2; 240 enum RTLD_MODEMASK = 0x3; 241 enum RTLD_GLOBAL = 0x100; 242 enum RTLD_LOCAL = 0; 243 enum RTLD_TRACE = 0x200; 244 enum RTLD_NODELETE = 0x01000; 245 enum RTLD_NOLOAD = 0x02000; 246 247 int dlclose(void*); 248 char* dlerror(); 249 void* dlopen(const scope char*, int); 250 void* dlsym(void*, const scope char*); 251 int dladdr(const(void)* addr, Dl_info* info); 252 253 struct Dl_info 254 { 255 const(char)* dli_fname; 256 void* dli_fbase; 257 const(char)* dli_sname; 258 void* dli_saddr; 259 } 260 } 261 else version (NetBSD) 262 { 263 enum RTLD_LAZY = 1; 264 enum RTLD_NOW = 2; 265 enum RTLD_GLOBAL = 0x100; 266 enum RTLD_LOCAL = 0x200; 267 enum RTLD_NODELETE = 0x01000; /* Do not remove members. */ 268 enum RTLD_NOLOAD = 0x02000; 269 270 int dlclose(void*); 271 char* dlerror(); 272 void* dlopen(const scope char*, int); 273 void* dlsym(void*, const scope char*); 274 int dladdr(const(void)* addr, Dl_info* info); 275 276 struct Dl_info 277 { 278 const(char)* dli_fname; 279 void* dli_fbase; 280 const(char)* dli_sname; 281 void* dli_saddr; 282 } 283 } 284 else version (OpenBSD) 285 { 286 enum RTLD_LAZY = 1; 287 enum RTLD_NOW = 2; 288 enum RTLD_GLOBAL = 0x100; 289 enum RTLD_LOCAL = 0; 290 enum RTLD_TRACE = 0x200; 291 enum RTLD_NODELETE = 0x400; 292 293 int dlclose(void*); 294 char* dlerror(); 295 void* dlopen(const scope char*, int); 296 void* dlsym(void*, const scope char*); 297 int dladdr(const(void)* addr, Dl_info* info); 298 299 struct Dl_info 300 { 301 const(char)* dli_fname; 302 void* dli_fbase; 303 const(char)* dli_sname; 304 void* dli_saddr; 305 } 306 } 307 else version (DragonFlyBSD) 308 { 309 enum RTLD_LAZY = 1; 310 enum RTLD_NOW = 2; 311 enum RTLD_MODEMASK = 0x3; 312 enum RTLD_GLOBAL = 0x100; 313 enum RTLD_LOCAL = 0; 314 enum RTLD_TRACE = 0x200; 315 enum RTLD_NODELETE = 0x01000; 316 enum RTLD_NOLOAD = 0x02000; 317 318 int dlclose(void*); 319 char* dlerror(); 320 void* dlopen(const scope char*, int); 321 void* dlsym(void*, const scope char*); 322 int dladdr(const(void)* addr, Dl_info* info); 323 324 struct Dl_info 325 { 326 const(char)* dli_fname; 327 void* dli_fbase; 328 const(char)* dli_sname; 329 void* dli_saddr; 330 } 331 } 332 else version (Solaris) 333 { 334 enum RTLD_LAZY = 1; 335 enum RTLD_NOW = 2; 336 enum RTLD_NOLOAD = 0x00004; 337 enum RTLD_DEEPBIND = 0x00008; 338 enum RTLD_GLOBAL = 0x100; 339 enum RTLD_LOCAL = 0; 340 enum RTLD_PARENT = 0x00200; 341 enum RTLD_GROUP = 0x00400; 342 enum RTLD_WORLD = 0x00800; 343 enum RTLD_NODELETE = 0x01000; 344 enum RTLD_FIRST = 0x02000; 345 enum RTLD_CONFGEN = 0x10000; 346 347 int dlclose(void*); 348 char* dlerror(); 349 void* dlopen(const scope char*, int); 350 void* dlsym(void*, const scope char*); 351 int dladdr(const(void)* addr, Dl_info* info); 352 353 struct Dl_info 354 { 355 const(char)* dli_fname; 356 void* dli_fbase; 357 const(char)* dli_sname; 358 void* dli_saddr; 359 } 360 } 361 else version (CRuntime_Bionic) 362 { 363 enum 364 { 365 RTLD_NOW = 0, 366 RTLD_LAZY = 1, 367 RTLD_LOCAL = 0, 368 RTLD_GLOBAL = 2 369 } 370 371 int dladdr(const scope void*, Dl_info*); 372 int dlclose(void*); 373 const(char)* dlerror(); 374 void* dlopen(const scope char*, int); 375 void* dlsym(void*, const scope char*); 376 377 struct Dl_info 378 { 379 const(char)* dli_fname; 380 void* dli_fbase; 381 const(char)* dli_sname; 382 void* dli_saddr; 383 } 384 } 385 else version (CRuntime_Musl) 386 { 387 enum { 388 RTLD_LAZY = 1, 389 RTLD_NOW = 2, 390 RTLD_NOLOAD = 4, 391 RTLD_NODELETE = 4096, 392 RTLD_GLOBAL = 256, 393 RTLD_LOCAL = 0, 394 } 395 int dlclose(void*); 396 const(char)* dlerror(); 397 void* dlopen(const scope char*, int); 398 void* dlsym(void*, const scope char*); 399 400 int dladdr(scope const void *addr, Dl_info *info); 401 struct Dl_info 402 { 403 const(char)* dli_fname; 404 void* dli_fbase; 405 const(char)* dli_sname; 406 void* dli_saddr; 407 } 408 } 409 else version (CRuntime_UClibc) 410 { 411 version (X86_Any) 412 { 413 enum RTLD_LAZY = 0x0001; 414 enum RTLD_NOW = 0x0002; 415 enum RTLD_BINDING_MASK = 0x3; 416 enum RTLD_NOLOAD = 0x00004; 417 enum RTLD_GLOBAL = 0x00100; 418 enum RTLD_LOCAL = 0; 419 enum RTLD_NODELETE = 0x01000; 420 } 421 else version (MIPS_Any) 422 { 423 enum RTLD_LAZY = 0x0001; 424 enum RTLD_NOW = 0x0002; 425 enum RTLD_BINDING_MASK = 0x3; 426 enum RTLD_NOLOAD = 0x00008; 427 enum RTLD_GLOBAL = 0x0004; 428 enum RTLD_LOCAL = 0; 429 enum RTLD_NODELETE = 0x01000; 430 } 431 else version (ARM) 432 { 433 enum RTLD_LAZY = 0x0001; 434 enum RTLD_NOW = 0x0002; 435 enum RTLD_BINDING_MASK = 0x3; 436 enum RTLD_NOLOAD = 0x00004; 437 enum RTLD_GLOBAL = 0x00100; 438 enum RTLD_LOCAL = 0; 439 enum RTLD_NODELETE = 0x01000; 440 } 441 else 442 static assert(0, "unimplemented"); 443 444 int dlclose(void*); 445 char* dlerror(); 446 void* dlopen(const scope char*, int); 447 void* dlsym(void*, const scope char*); 448 int dladdr(const scope void*, Dl_info*); 449 450 struct Dl_info 451 { 452 const(char)* dli_fname; 453 void* dli_fbase; 454 const(char)* dli_sname; 455 void* dli_saddr; 456 } 457 }