summaryrefslogtreecommitdiff
path: root/src/dl/dlsym_reserved.go
blob: 081e0120e7aeeb3694ec25dca2600ac84d217de6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 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 <mtk.manpages@gmail.com>.
// Copyright 2015 Luke Shumaker <lukeshu@sbcglobal.net>.
//
// 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
// <http://www.gnu.org/licenses/>.

package dl

import "unsafe"

//#define _GNU_SOURCE
//#include <stdint.h>
//#include <dlfcn.h>
//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}
}