我写了一段模块加载和自启动的代码,可是symFindByName()函数无法找到函数入口,哪位高手请指教原因出在哪里,谢谢!
#include "vxWorks.h"
#include "stdio.h"
#include "ioLib.h"
#include "loadLib.h"
#include "symLib.h"
#include "taskLib.h"
#include "nfsLib.h"
#include "nfsDrv.h"
void wxg_test(void);
extern SYMTAB_ID sysSymTbl;
int loadTest()
{
int fd = ERROR;
int status = ERROR;
MODULE_ID hModule;
FUNCPTR taskEntry = NULL;
SYM_TYPE Type;
fd = open("test.o",O_RDONLY,0);
if (fd==ERROR)
{
printf("can not open binary file\n");
return ERROR;
}
else
{
printf("binary file opened!\n");
}
hModule=loadModule(fd,LOAD_ALL_SYMBOLS);
close (fd);
status = symFindByName(sysSymTbl,"wxg_test",(char**)&taskEntry,&Type);%wxg_test为主函数入口,在test.o中
if (status==ERROR)
{
printf("symFindName error\n");
return ERROR;
}
else
printf("taskEntry=0x%x,type=%d\n",(int)taskEntry,(int)Type);
status = taskSpawn("test",100,0,30000,taskEntry,0,0,0,0,0,0,0,0,0,0);
if(status==ERROR)
{
printf("taskSpawn ERROR\n");
return ERROR;
}
return OK;
}