Giter Club home page Giter Club logo

universal's Introduction

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!

universal's People

Contributors

awgh avatar lesnuages avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.