summaryrefslogtreecommitdiff
path: root/dl/dl_gnu.go
blob: e694980cd5e4efe5d32a9fdcf7d56d8c44c0a23d (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// The code in this file is trivial, and not eligable for copyright.
//
// The documentation in this file is taken from the Linux Programmer's
// Manual page for dlopen(3).
//
// Copyright 1995 Yggdrasil Computing, Incorporated.
// written by Adam J. Richter (adam@yggdrasil.com),
// with typesetting help from Daniel Quinlan (quinlan@yggdrasil.com).
// and Copyright 2003, 2015 Michael Kerrisk (mtk.manpages@gmail.com).
//
// 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/>.
//
// Modified by David A. Wheeler <dwheeler@dwheeler.com> 2000-11-28.
// Applied patch by Terran Melconian, aeb, 2001-12-14.
// Modified by Hacksaw <hacksaw@hacksaw.org> 2003-03-13.
// Modified by Matt Domsch, 2003-04-09: _init and _fini obsolete
// Modified by Michael Kerrisk <mtk.manpages@gmail.com> 2003-05-16.
// Modified by Walter Harms: dladdr, dlvsym
// Modified by Petr Baudis <pasky@suse.cz>, 2008-12-04: dladdr caveat

package dl

//#define _GNU_SOURCE
//#include <dlfcn.h>
import "C"

// These flags to Open() are GNU libc extensions.
const (
	// Do not unload the shared object during Close().
	// Consequently, the object's static variables are not
	// reinitialized if the object is reloaded with Open() at a
	// later time.
	RTLD_NODELETE Flag = C.RTLD_NODELETE // (since glibc 2.2, also present on Solaris)

	// Don't load the shared object.  This can be used to test if
	// the object is already resident (Open() returns nil if it
	// is not, or the object's handle if it is resident).  This
	// flag can also be used to promote the flags on a shared
	// object that is already loaded.  For example, a shared
	// object that was previously loaded with RTLD_LOCAL can be
	// reopened with RTLD_NOLOAD | RTLD_GLOBAL.
	RTLD_NOLOAD Flag = C.RTLD_NOLOAD // (since glibc 2.2, also present on Solaris)

	// Place the lookup scope of the symbols in this shared object
	// ahead of the global scope.  This means that a
	// self-contained object will use its own symbols in
	// preference to global symbols with the same name contained
	// in objects that have already been loaded.
	RTLD_DEEPBIND Flag = C.RTLD_DEEPBIND // (since glibc 2.3.4)
)

// BUG(lukeshu) GNU extension flags are implemented, but GNU extension
// functions are not.

// TODO: dlmopen
// TODO: dlvsym
// TODO: dladdr
//     - dladdr1
// TODO: dlinfo
//     - RTLD_DI_LMID
//     - RTLD_DI_LINKMAP
//     - RTLD_DI_ORIGIN
//     - RTLD_DI_SERINFO
//     - RTLD_DI_SERINFOSIZE
//     - RTLD_DI_MODID
//     - RTLD_DI_DATA
// TODO: dl_iterate_phdr
// TODO: rtld-audit(7)