diff options
author | Andrew Waterman <waterman@eecs.berkeley.edu> | 2014-01-26 21:50:31 -0800 |
---|---|---|
committer | Andrew Waterman <waterman@eecs.berkeley.edu> | 2014-01-26 21:50:31 -0800 |
commit | 2c1ddd17819e26fdb6a00a9e6de7a6cab2995855 (patch) | |
tree | cd23babaca123691379a7ec5a0abb763f8dbb41a /spike/spike.cc | |
parent | ec30507bf507ed43263804220b550f8a1a9732ed (diff) | |
download | spike-2c1ddd17819e26fdb6a00a9e6de7a6cab2995855.zip spike-2c1ddd17819e26fdb6a00a9e6de7a6cab2995855.tar.gz spike-2c1ddd17819e26fdb6a00a9e6de7a6cab2995855.tar.bz2 |
Enable runtime loading of dynamic library with --extlib
Diffstat (limited to 'spike/spike.cc')
-rw-r--r-- | spike/spike.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/spike/spike.cc b/spike/spike.cc index da564b5..c8b4d7c 100644 --- a/spike/spike.cc +++ b/spike/spike.cc @@ -4,6 +4,7 @@ #include "htif.h" #include "cachesim.h" #include "extension.h" +#include <dlfcn.h> #include <fesvr/option_parser.h> #include <stdio.h> #include <stdlib.h> @@ -24,6 +25,7 @@ static void help() fprintf(stderr, " --dc=<S>:<W>:<B> W ways, and B-byte blocks (with S and\n"); fprintf(stderr, " --l2=<S>:<W>:<B> B both powers of 2).\n"); fprintf(stderr, " --extension=<name> Specify RoCC Extension\n"); + fprintf(stderr, " --extlib=<name> Shared library to load\n"); exit(1); } @@ -51,6 +53,13 @@ int main(int argc, char** argv) fprintf(stderr, "unknown extension %s!\n", s), exit(-1); extension = extensions()[s]; }); + parser.option(0, "extlib", 1, [&](const char *s){ + void *lib = dlopen(s, RTLD_NOW | RTLD_GLOBAL); + if (lib == NULL) { + fprintf(stderr, "Unable to load extlib '%s': %s\n", s, dlerror()); + exit(-1); + } + }); auto argv1 = parser.parse(argv); if (!*argv1) |