// The documentation for RTLD_DEFAULT and RTLD_NEXT is taken from the // Linux Programmer's Manual page for dlsym(3). // // Copyright 1995 Yggdrasil Computing, Incorporated. // Copyright 2003, 2015 Michael Kerrisk . // Copyright 2015 Luke Shumaker . // // This is free documentation; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // The GNU General Public License's references to "object code" // and "executables" are to be interpreted as the output of any // document formatting or typesetting system, including // intermediate and printed output. // // This manual is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public // License along with this manual; if not, see // . package dl import "unsafe" //#define _GNU_SOURCE //#include //#include //const uintptr_t rtld_next = (uintptr_t)RTLD_NEXT; //const uintptr_t rtld_default = (uintptr_t)RTLD_DEFAULT; import "C" // These constant values for Handles are reserved by POSIX for future // use with these meanings. They are available in GNU libdl if // _GNU_SOURCE is defined. var ( // This Handle represents the default default shared object // search order. The search will include global symbols in // the executable and its dependencies, as well as symbols in // shared objects that were dynamically loaded with the // RTLD_GLOBAL flag. RTLD_DEFAULT Handle // This Handle represents the shared object search order after // the current object. This allows one to provide a wrapper // around a function in another shared object, so that, for // example, the definition of a function in a preloaded shared // object (see LD_PRELOAD in ld.so(8)) can find and invoke the // "real" function provided in another shared object (or for // that matter, the "next" definition of the function in cases // where there are multiple layers of preloading). RTLD_NEXT Handle ) func init() { RTLD_DEFAULT = Handle{c: unsafe.Pointer(uintptr(C.rtld_default)), o: 2} RTLD_DEFAULT = Handle{c: unsafe.Pointer(uintptr(C.rtld_next)), o: 2} }