1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 //go:build !windows && !static && (!darwin || (!internal_pie && !arm64))
8 // +build !darwin !internal_pie,!arm64
10 // Excluded in darwin internal linking PIE mode, as dynamic export is not
12 // Excluded in internal linking mode on darwin/arm64, as it is always PIE.
19 #cgo linux LDFLAGS: -ldl
21 extern uintptr_t dlopen4029(char*, int);
22 extern uintptr_t dlsym4029(uintptr_t, char*);
23 extern int dlclose4029(uintptr_t);
25 extern void call4029(uintptr_t arg);
40 //export IMPInitWithFrame
41 func IMPInitWithFrame() {
50 //export IMPWindowResize
51 func IMPWindowResize() {
55 func test4029(t *testing.T) {
56 loadThySelf(t, "IMPWindowResize")
57 loadThySelf(t, "IMPDrawRect")
58 loadThySelf(t, "IMPInitWithFrame")
59 loadThySelf(t, "IMPIsOpaque")
61 t.Errorf("got %d callbacks, expected 4", callbacks)
65 func loadThySelf(t *testing.T, symbol string) {
66 this_process := C.dlopen4029(nil, C.RTLD_NOW)
67 if this_process == 0 {
68 t.Error("dlopen:", C.GoString(C.dlerror()))
71 defer C.dlclose4029(this_process)
73 symbol_address := C.dlsym4029(this_process, C.CString(symbol))
74 if symbol_address == 0 {
75 t.Error("dlsym:", C.GoString(C.dlerror()))
78 t.Log(symbol, symbol_address)
79 C.call4029(symbol_address)