title: Using system symbol table from VxWorks RTP
body: <p>I have an existing project, originally implemented as a Vxworks 5.5 style kernel module. </p>
  
  <p>This project creates many tasks that act as a "host" to run external code. We do something like this:</p>
  
  <pre><code>void loadAndRun(char* file, char* function)
  {
      //load the module
      int fd = open (file, O_RDONLY,0644);
      loadModule(fdx, LOAD_ALL_SYMBOLS);
  
      SYM_TYPE type;
      FUNCPTR func;
      symFindByName(sysSymTbl, &amp;function , (char**) &amp;func, &amp;type);
  
      while (true)
      { 
          func();
      }   
  }
  </code></pre>
  
  <p>This all works a dream, however, the functions that get called are non-reentrant, with global data all over the place etc. We have a new requirement to be able to run multiple instances of these external modules, and my obvious first thought is to use vxworks RTP to provide memory isolation.</p>
  
  <p>However, no matter what I try, I cannot persuade my new RTP project to compile and link. </p>
  
  <pre><code>error: 'sysSymTbl' undeclared (first use in this function)
  </code></pre>
  
  <p>If I add the correct include:</p>
  
  <pre><code>#include &lt;sysSymTbl.h&gt;
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code> error: sysSymTbl.h: No such file or directory
  </code></pre>
  
  <p>and if i just define it extern:</p>
  
  <pre><code> extern SYMTAB_ID    sysSymTbl;
  </code></pre>
  
  <p>i get:</p>
  
  <pre><code>  error: undefined reference to `sysSymTbl'
  </code></pre>
  
  <p>I havent even begun to start trying to stitch in the actual module load code, at the moment I just want to get the symbol lookup working.</p>
  
  <p>So, is the system symbol table accessible from VxWorks RTP applications? Can moduleLoad be used?</p>
  
  <p><strong>EDIT</strong>
  It appears that what I am trying to do is covered by the Application Programmers Guide in the section on Plugins (section 4.9 for V6.8) (thanks @nos), which is to use dlopen() etc. Like this:</p>
  
  <pre><code> void * hdl=  dlopen("pathname",RTLD_NOW);
   FUNCPTR func = dlsym(hdl,"FunctionName");
   func();
  </code></pre>
  
  <p>However, i still end up in linker-hell, even when i specify -Xbind-lazy -non-static to the compiler.</p>
  
  <pre><code>undefined reference to `_rtld_dlopen'
  undefined reference to `_rtld_dlsym'
  </code></pre>