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))
7 // Excluded in darwin internal linking PIE mode, as dynamic export is not
9 // Excluded in internal linking mode on darwin/arm64, as it is always PIE.
16 #cgo linux LDFLAGS: -ldl
18 extern uintptr_t dlopen4029(char*, int);
19 extern uintptr_t dlsym4029(uintptr_t, char*);
20 extern int dlclose4029(uintptr_t);
22 extern void call4029(uintptr_t arg);
37 //export IMPInitWithFrame
38 func IMPInitWithFrame() {
47 //export IMPWindowResize
48 func IMPWindowResize() {
52 func test4029(t *testing.T) {
53 loadThySelf(t, "IMPWindowResize")
54 loadThySelf(t, "IMPDrawRect")
55 loadThySelf(t, "IMPInitWithFrame")
56 loadThySelf(t, "IMPIsOpaque")
58 t.Errorf("got %d callbacks, expected 4", callbacks)
62 func loadThySelf(t *testing.T, symbol string) {
63 this_process := C.dlopen4029(nil, C.RTLD_NOW)
64 if this_process == 0 {
65 t.Error("dlopen:", C.GoString(C.dlerror()))
68 defer C.dlclose4029(this_process)
70 symbol_address := C.dlsym4029(this_process, C.CString(symbol))
71 if symbol_address == 0 {
72 t.Error("dlsym:", C.GoString(C.dlerror()))
75 t.Log(symbol, symbol_address)
76 C.call4029(symbol_address)