MCPcopy Index your code
hub / github.com/Binject/universal

github.com/Binject/universal @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
56 symbols 177 edges 20 files 21 documented · 38% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

The Universal Loader

This loader provides a unified Go interface for loading shared libraries from memory on Windows, OSX, and Linux.

Also included is a cross-platform Call() implementation that lets you call into exported symbols from those libraries without stress.

Basic Usage

libraryPath set to lib.so for Linux, lib.dyld for OSX, or lib.DLL for Windows, then:

    image, err = ioutil.ReadFile(libraryPath)
    ...

    loader, err := universal.NewLoader()
    ...

    library, err := loader.LoadLibrary("main", &image)
    ...

    val, err := library.Call("Runme", 7)
    ...

Complete working examples of usage can be found in the examples/ folder in this repo.

Features and Limitations

  • OSX backend uses the system loader, so multiple interdependent libraries can be loaded.
  • OSX backend automatically adds the underscore prefix for you, so you can refer to symbols the same way on Linux, Windows, and OSX.
  • Linux and Windows backends do not use the system loader, so interdependent libraries cannot be loaded.
  • Linux backend does not use memfd!
    I believe this is the first Golang Linux loader that does not use memfd!

Supported Architectures

  • OSX arm64 M1 Apple Chip (tested)
    This is the first loader I've seen, Golang or not, that works on the M1!
  • OSX amd64 (tested)
  • Windows amd64 (tested)
  • Windows 386 (untested, should work)
  • Linux amd64 (tested)
  • Linux 386 (untested, should work)
  • Other POSIX systems on 386, amd64, or arm64 (untested, should work)

If you try this on any untested platforms, whether it works or not, let me know!

Core symbols most depended-on inside this repo

put32be
called by 18
codesign_darwin.go
NewLoader
called by 12
universal.go
LoadLibrary
called by 12
universal.go
Call
called by 8
loader_linux.go
Call
called by 4
loader_darwin.go
put64be
called by 4
codesign_darwin.go
put8
called by 4
codesign_darwin.go
FindProc
called by 4
universal.go

Shape

Function 37
Struct 10
Method 9

Languages

Go95%
C++5%

Modules by API surface

codesign_darwin.go15 symbols
loader_darwin.go9 symbols
universal.go6 symbols
windows_test.go5 symbols
types_darwin.go4 symbols
loader_windows.go4 symbols
darwin_test.go3 symbols
loader_linux.go2 symbols
linux_test.go2 symbols
test/src/main_dll/main.cpp1 symbols
test/src/TestDLL/TestDLL/dllmain.cpp1 symbols
test/src/TestDLL/TestDLL/Test.cpp1 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add universal \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact