From 6dc97f27157ba42ee12f73b74313efbf1bd9c580 Mon Sep 17 00:00:00 2001 From: Martin Stiemerling <mls.ietf@gmail.com> Date: Tue, 17 Nov 2020 16:24:05 +0100 Subject: [PATCH] logic to load sbi plugins --- nucleus/sbi-general.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 nucleus/sbi-general.go diff --git a/nucleus/sbi-general.go b/nucleus/sbi-general.go new file mode 100644 index 000000000..0795a6653 --- /dev/null +++ b/nucleus/sbi-general.go @@ -0,0 +1,41 @@ +package nucleus + +import ( + "fmt" + "os" + "plugin" +) + +type SBIGreeter interface { + SBIHello() +} + +func SBILoader () { + modPath := "/Users/mls/go/src/code.fbi.h-da.de/cocsn/byowsbi/byowsbi.o" + + // open the so file that contains the SBI-plugin as step before loading the symbols + plug, err := plugin.Open(modPath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + // loading the symbols + sbiModule, err := plug.Lookup("SBIGreeter") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + // Assert the loaded symbol + var sbigreeter SBIGreeter + sbigreeter, ok := sbiModule.(SBIGreeter) + if !ok { + fmt.Println("unexpected type from module symbol") + os.Exit(1) + } + + // use me! + sbigreeter.SBIHello() +} + -- GitLab