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 version (LoongArch64) 164 { 165 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h 166 enum RTLD_LAZY = 0x00001; 167 enum RTLD_NOW = 0x00002; 168 enum RTLD_BINDING_MASK = 0x3; 169 enum RTLD_NOLOAD = 0x00004; 170 enum RTLD_DEEPBIND = 0x00008; 171 enum RTLD_GLOBAL = 0x00100; 172 enum RTLD_LOCAL = 0; 173 enum RTLD_NODELETE = 0x01000; 174 } 175 else 176 static assert(0, "unimplemented"); 177 178 int dlclose(void*); 179 char* dlerror(); 180 void* dlopen(const scope char*, int); 181 void* dlsym(void*, const scope char*); 182 int dladdr(const scope void*, Dl_info*); 183 184 struct Dl_info 185 { 186 const(char)* dli_fname; 187 void* dli_fbase; 188 const(char)* dli_sname; 189 void* dli_saddr; 190 } 191 } 192 else 193 version (CRuntime_Musl) 194 { 195 enum RTLD_LAZY = 1; 196 enum RTLD_NOW = 2; 197 enum RTLD_NOLOAD = 4; 198 enum RTLD_NODELETE = 4096; 199 enum RTLD_GLOBAL = 256; 200 enum RTLD_LOCAL = 0; 201 202 enum RTLD_NEXT = cast(void *)-1; 203 enum RTLD_DEFAULT = cast(void *)0; 204 205 enum RTLD_DI_LINKMAP = 2; 206 207 int dlclose(void *); 208 char *dlerror(); 209 void *dlopen(const(char) *, int); 210 211 pragma(mangle, muslRedirTime64Mangle!("dlsym", "__dlsym_time64")) 212 void *dlsym(void *__restrict, const(char) *__restrict); 213 214 struct Dl_info 215 { 216 const(char)* dli_fname; 217 void* dli_fbase; 218 const(char)* dli_sname; 219 void* dli_saddr; 220 } 221 int dladdr(const(void) *, Dl_info *); 222 int dlinfo(void *, int, void *); 223 } 224 else version (Darwin) 225 { 226 enum RTLD_LAZY = 0x00001; 227 enum RTLD_NOW = 0x00002; 228 enum RTLD_NOLOAD = 0x10; 229 enum RTLD_NODELETE = 0x80; 230 enum RTLD_GLOBAL = 0x00100; 231 enum RTLD_LOCAL = 0x00000; 232 enum RTLD_FIRST = 0x100; 233 234 int dlclose(void*); 235 char* dlerror(); 236 void* dlopen(const scope char*, int); 237 void* dlsym(void*, const scope char*); 238 int dladdr(scope const void* addr, Dl_info* info); 239 240 struct Dl_info 241 { 242 const(char)* dli_fname; 243 void* dli_fbase; 244 const(char)* dli_sname; 245 void* dli_saddr; 246 } 247 } 248 else version (FreeBSD) 249 { 250 enum RTLD_LAZY = 1; 251 enum RTLD_NOW = 2; 252 enum RTLD_MODEMASK = 0x3; 253 enum RTLD_GLOBAL = 0x100; 254 enum RTLD_LOCAL = 0; 255 enum RTLD_TRACE = 0x200; 256 enum RTLD_NODELETE = 0x01000; 257 enum RTLD_NOLOAD = 0x02000; 258 259 int dlclose(void*); 260 char* dlerror(); 261 void* dlopen(const scope char*, int); 262 void* dlsym(void*, const scope char*); 263 int dladdr(const(void)* addr, Dl_info* info); 264 265 struct Dl_info 266 { 267 const(char)* dli_fname; 268 void* dli_fbase; 269 const(char)* dli_sname; 270 void* dli_saddr; 271 } 272 } 273 else version (NetBSD) 274 { 275 enum RTLD_LAZY = 1; 276 enum RTLD_NOW = 2; 277 enum RTLD_GLOBAL = 0x100; 278 enum RTLD_LOCAL = 0x200; 279 enum RTLD_NODELETE = 0x01000; /* Do not remove members. */ 280 enum RTLD_NOLOAD = 0x02000; 281 282 int dlclose(void*); 283 char* dlerror(); 284 void* dlopen(const scope char*, int); 285 void* dlsym(void*, const scope char*); 286 int dladdr(const(void)* addr, Dl_info* info); 287 288 struct Dl_info 289 { 290 const(char)* dli_fname; 291 void* dli_fbase; 292 const(char)* dli_sname; 293 void* dli_saddr; 294 } 295 } 296 else version (OpenBSD) 297 { 298 enum RTLD_LAZY = 1; 299 enum RTLD_NOW = 2; 300 enum RTLD_GLOBAL = 0x100; 301 enum RTLD_LOCAL = 0; 302 enum RTLD_TRACE = 0x200; 303 enum RTLD_NODELETE = 0x400; 304 305 int dlclose(void*); 306 char* dlerror(); 307 void* dlopen(const scope char*, int); 308 void* dlsym(void*, const scope char*); 309 int dladdr(const(void)* addr, Dl_info* info); 310 311 struct Dl_info 312 { 313 const(char)* dli_fname; 314 void* dli_fbase; 315 const(char)* dli_sname; 316 void* dli_saddr; 317 } 318 } 319 else version (DragonFlyBSD) 320 { 321 enum RTLD_LAZY = 1; 322 enum RTLD_NOW = 2; 323 enum RTLD_MODEMASK = 0x3; 324 enum RTLD_GLOBAL = 0x100; 325 enum RTLD_LOCAL = 0; 326 enum RTLD_TRACE = 0x200; 327 enum RTLD_NODELETE = 0x01000; 328 enum RTLD_NOLOAD = 0x02000; 329 330 int dlclose(void*); 331 char* dlerror(); 332 void* dlopen(const scope char*, int); 333 void* dlsym(void*, const scope char*); 334 int dladdr(const(void)* addr, Dl_info* info); 335 336 struct Dl_info 337 { 338 const(char)* dli_fname; 339 void* dli_fbase; 340 const(char)* dli_sname; 341 void* dli_saddr; 342 } 343 } 344 else version (Solaris) 345 { 346 enum RTLD_LAZY = 1; 347 enum RTLD_NOW = 2; 348 enum RTLD_NOLOAD = 0x00004; 349 enum RTLD_DEEPBIND = 0x00008; 350 enum RTLD_GLOBAL = 0x100; 351 enum RTLD_LOCAL = 0; 352 enum RTLD_PARENT = 0x00200; 353 enum RTLD_GROUP = 0x00400; 354 enum RTLD_WORLD = 0x00800; 355 enum RTLD_NODELETE = 0x01000; 356 enum RTLD_FIRST = 0x02000; 357 enum RTLD_CONFGEN = 0x10000; 358 359 int dlclose(void*); 360 char* dlerror(); 361 void* dlopen(const scope char*, int); 362 void* dlsym(void*, const scope char*); 363 int dladdr(const(void)* addr, Dl_info* info); 364 365 struct Dl_info 366 { 367 const(char)* dli_fname; 368 void* dli_fbase; 369 const(char)* dli_sname; 370 void* dli_saddr; 371 } 372 } 373 else version (CRuntime_Bionic) 374 { 375 enum 376 { 377 RTLD_NOW = 0, 378 RTLD_LAZY = 1, 379 RTLD_LOCAL = 0, 380 RTLD_GLOBAL = 2 381 } 382 383 int dladdr(const scope void*, Dl_info*); 384 int dlclose(void*); 385 const(char)* dlerror(); 386 void* dlopen(const scope char*, int); 387 void* dlsym(void*, const scope char*); 388 389 struct Dl_info 390 { 391 const(char)* dli_fname; 392 void* dli_fbase; 393 const(char)* dli_sname; 394 void* dli_saddr; 395 } 396 } 397 else version (CRuntime_Musl) 398 { 399 enum { 400 RTLD_LAZY = 1, 401 RTLD_NOW = 2, 402 RTLD_NOLOAD = 4, 403 RTLD_NODELETE = 4096, 404 RTLD_GLOBAL = 256, 405 RTLD_LOCAL = 0, 406 } 407 int dlclose(void*); 408 const(char)* dlerror(); 409 void* dlopen(const scope char*, int); 410 void* dlsym(void*, const scope char*); 411 412 int dladdr(scope const void *addr, Dl_info *info); 413 struct Dl_info 414 { 415 const(char)* dli_fname; 416 void* dli_fbase; 417 const(char)* dli_sname; 418 void* dli_saddr; 419 } 420 } 421 else version (CRuntime_UClibc) 422 { 423 version (X86_Any) 424 { 425 enum RTLD_LAZY = 0x0001; 426 enum RTLD_NOW = 0x0002; 427 enum RTLD_BINDING_MASK = 0x3; 428 enum RTLD_NOLOAD = 0x00004; 429 enum RTLD_GLOBAL = 0x00100; 430 enum RTLD_LOCAL = 0; 431 enum RTLD_NODELETE = 0x01000; 432 } 433 else version (MIPS_Any) 434 { 435 enum RTLD_LAZY = 0x0001; 436 enum RTLD_NOW = 0x0002; 437 enum RTLD_BINDING_MASK = 0x3; 438 enum RTLD_NOLOAD = 0x00008; 439 enum RTLD_GLOBAL = 0x0004; 440 enum RTLD_LOCAL = 0; 441 enum RTLD_NODELETE = 0x01000; 442 } 443 else version (ARM) 444 { 445 enum RTLD_LAZY = 0x0001; 446 enum RTLD_NOW = 0x0002; 447 enum RTLD_BINDING_MASK = 0x3; 448 enum RTLD_NOLOAD = 0x00004; 449 enum RTLD_GLOBAL = 0x00100; 450 enum RTLD_LOCAL = 0; 451 enum RTLD_NODELETE = 0x01000; 452 } 453 else 454 static assert(0, "unimplemented"); 455 456 int dlclose(void*); 457 char* dlerror(); 458 void* dlopen(const scope char*, int); 459 void* dlsym(void*, const scope char*); 460 int dladdr(const scope void*, Dl_info*); 461 462 struct Dl_info 463 { 464 const(char)* dli_fname; 465 void* dli_fbase; 466 const(char)* dli_sname; 467 void* dli_saddr; 468 } 469 }