detached ee8dcec

dlfcn: add RTLD_DEFAULT macro value (#135)

Closes #134

---------

Signed-off-by: Eliott Bouhana <eliott.bouhana@datadoghq.com>
commit
ee8dcecc618f5b729ba8f987cfb385e23c5d8568
author
Eliott Bouhana · · 2023-05-19 10:30 UTC
committer
GitHub · · 2023-05-19 10:30 UTC
parent
d888bce
signature
GPG Unverified4AEE18F83AFDEB23 The key is unknown
3 files · +16 -8
M dlfcn_darwin.go +5 -4
@@ -6,10 +6,11 @@ package purego
66 // Source for constants: https://opensource.apple.com/source/dyld/dyld-360.14/include/dlfcn.h.auto.html
77
88 const (
9- RTLD_LAZY = 0x1 // Relocations are performed at an implementation-dependent time.
10- RTLD_NOW = 0x2 // Relocations are performed when the object is loaded.
11- RTLD_LOCAL = 0x4 // All symbols are not made available for relocation processing by other modules.
12- RTLD_GLOBAL = 0x8 // All symbols are available for relocation processing of other modules.
9+ RTLD_DEFAULT = ^uintptr(0) - 1 // Pseudo-handle for dlsym so search for any loaded symbol
10+ RTLD_LAZY = 0x1 // Relocations are performed at an implementation-dependent time.
11+ RTLD_NOW = 0x2 // Relocations are performed when the object is loaded.
12+ RTLD_LOCAL = 0x4 // All symbols are not made available for relocation processing by other modules.
13+ RTLD_GLOBAL = 0x8 // All symbols are available for relocation processing of other modules.
1314 )
1415
1516 //go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib"
@@ -6,10 +6,11 @@ package purego
6 // Source for constants: https://opensource.apple.com/source/dyld/dyld-360.14/include/dlfcn.h.auto.html6 // Source for constants: https://opensource.apple.com/source/dyld/dyld-360.14/include/dlfcn.h.auto.html
7 7
8 const (8 const (
9- RTLD_LAZY = 0x1 // Relocations are performed at an implementation-dependent time.9+ RTLD_DEFAULT = ^uintptr(0) - 1 // Pseudo-handle for dlsym so search for any loaded symbol
10- RTLD_NOW = 0x2 // Relocations are performed when the object is loaded.10+ RTLD_LAZY = 0x1 // Relocations are performed at an implementation-dependent time.
11- RTLD_LOCAL = 0x4 // All symbols are not made available for relocation processing by other modules.11+ RTLD_NOW = 0x2 // Relocations are performed when the object is loaded.
12- RTLD_GLOBAL = 0x8 // All symbols are available for relocation processing of other modules.12+ RTLD_LOCAL = 0x4 // All symbols are not made available for relocation processing by other modules.
13+ RTLD_GLOBAL = 0x8 // All symbols are available for relocation processing of other modules.
13 )14 )
14 15
15 //go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib"16 //go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib"
M dlfcn_linux.go +5 -4
@@ -6,8 +6,9 @@ package purego
66 // Source for constants: https://codebrowser.dev/glibc/glibc/bits/dlfcn.h.html
77
88 const (
9- RTLD_LAZY = 0x00001 // Relocations are performed at an implementation-dependent time.
10- RTLD_NOW = 0x00002 // Relocations are performed when the object is loaded.
11- RTLD_LOCAL = 0x00000 // All symbols are not made available for relocation processing by other modules.
12- RTLD_GLOBAL = 0x00100 // All symbols are available for relocation processing of other modules.
9+ RTLD_DEFAULT = 0x00000 // Pseudo-handle for dlsym so search for any loaded symbol
10+ RTLD_LAZY = 0x00001 // Relocations are performed at an implementation-dependent time.
11+ RTLD_NOW = 0x00002 // Relocations are performed when the object is loaded.
12+ RTLD_LOCAL = 0x00000 // All symbols are not made available for relocation processing by other modules.
13+ RTLD_GLOBAL = 0x00100 // All symbols are available for relocation processing of other modules.
1314 )
@@ -6,8 +6,9 @@ package purego
6 // Source for constants: https://codebrowser.dev/glibc/glibc/bits/dlfcn.h.html6 // Source for constants: https://codebrowser.dev/glibc/glibc/bits/dlfcn.h.html
7 7
8 const (8 const (
9- RTLD_LAZY = 0x00001 // Relocations are performed at an implementation-dependent time.9+ RTLD_DEFAULT = 0x00000 // Pseudo-handle for dlsym so search for any loaded symbol
10- RTLD_NOW = 0x00002 // Relocations are performed when the object is loaded.10+ RTLD_LAZY = 0x00001 // Relocations are performed at an implementation-dependent time.
11- RTLD_LOCAL = 0x00000 // All symbols are not made available for relocation processing by other modules.11+ RTLD_NOW = 0x00002 // Relocations are performed when the object is loaded.
12- RTLD_GLOBAL = 0x00100 // All symbols are available for relocation processing of other modules.12+ RTLD_LOCAL = 0x00000 // All symbols are not made available for relocation processing by other modules.
13+ RTLD_GLOBAL = 0x00100 // All symbols are available for relocation processing of other modules.
13 )14 )
M dlfcn_test.go +6 -0
@@ -18,6 +18,12 @@ import (
1818 "github.com/ebitengine/purego"
1919 )
2020
21+func TestSimpleDlsym(t *testing.T) {
22+ if _, err := purego.Dlsym(purego.RTLD_DEFAULT, "dlsym"); err != nil {
23+ t.Errorf("Dlsym with RTLD_DEFAULT failed: %v", err)
24+ }
25+}
26+
2127 func TestNestedDlopenCall(t *testing.T) {
2228 libFileName := filepath.Join(t.TempDir(), "libdlnested.so")
2329 t.Logf("Build %v", libFileName)
@@ -18,6 +18,12 @@ import (
18 "github.com/ebitengine/purego"18 "github.com/ebitengine/purego"
19 )19 )
20 20
21+func TestSimpleDlsym(t *testing.T) {
22+ if _, err := purego.Dlsym(purego.RTLD_DEFAULT, "dlsym"); err != nil {
23+ t.Errorf("Dlsym with RTLD_DEFAULT failed: %v", err)
24+ }
25+}
26+
21 func TestNestedDlopenCall(t *testing.T) {27 func TestNestedDlopenCall(t *testing.T) {
22 libFileName := filepath.Join(t.TempDir(), "libdlnested.so")28 libFileName := filepath.Join(t.TempDir(), "libdlnested.so")
23 t.Logf("Build %v", libFileName)29 t.Logf("Build %v", libFileName)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close