Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

get symbol entry in symbol table

361 views
Skip to first unread message

Laurent Mealares

unread,
Feb 22, 2002, 6:02:48 AM2/22/02
to
Hello,
I am tring to get the entry point of a routine (pointer) in the symbol
table of VxWorks.
I am doing this because of dynamically loaded modules in my system.
I do know the name of the function (symbol) and I want to retrieve its
pointer.
I have tried the symFindByName() function which returns me a successfull
status so it has found the symbol.
The problem is: I don't know where to "jump" to call this function?

Does anybody has implemented such thing in the past? Any clue would be
helpfull.

Thanks in advance,
Kind regards.

Laurent Mealares.


laurent.mealares.vcf

Michael Lawnick

unread,
Feb 22, 2002, 7:47:43 AM2/22/02
to
Hi Laurent,
try like this:
if ((symFindByName(sysSymTbl,fName,&addr,&type)==OK)&&(type==SYM_TEXT)
addr(param1,...);

--
Mit freundlichen Grüßen,
Michael Lawnick
==============================================
SOFTEC GmbH Tel +49-731-96600-0
Promenade 17 Fax +49-731-96600-23
D-89073 Ulm Michael Lawnick
Germany law...@softec.de
==============================================

"Laurent Mealares" <laurent....@csem.ch> schrieb im Newsbeitrag
news:3C762558...@csem.ch...

Daniel Haines

unread,
Feb 22, 2002, 10:35:54 AM2/22/02
to
Try the lkup command. It will return the address of the function.

Danial

Laurent Mealares <laurent....@csem.ch> wrote in message news:<3C762558...@csem.ch>...

> --

Werner Schiendl

unread,
Feb 22, 2002, 1:01:28 PM2/22/02
to
Hi Laurent,

yes, you need to cast the char * to whatever you need; in your case a
function pointer.
Further, you may need to change the name of the symbol; e. g. for x86
target, a underscore is prefixed.

See the following function, that actually loads a module and returns the
pointer to the given function name:
(for pc486, VxWorks 5.4)

dl_funcptr GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname)
{
char funcname[258];
int fdModule;
MODULE_ID hModule;
STATUS result;

char *pResult;
SYM_TYPE type;

fdModule = open(pathname, O_RDONLY, 0);
if (fdModule == ERROR) return 0;

hModule = loadModule(fdModule, LOAD_GLOBAL_SYMBOLS);
close(fdModule);

if (hModule == NULL) return 0;

sprintf(funcname, "_%.200s", shortname);
result = symFindByNameAndType(sysSymTbl, funcname, &pResult, &type,
SYM_GLOBAL | SYM_TEXT, SYM_GLOBAL | SYM_TEXT);
if (result != OK) return 0;
return (dl_funcptr) pResult;
}

I used symFindByNameAndType in that example, which allows to specify the
desired type as well as the name.

hth
Werner


"Laurent Mealares" <laurent....@csem.ch> wrote in message

news:3C765701...@csem.ch...
Thanks very much for your help Michael but what are the types of fname and
addr?

The prototype of symFindByName requires a char** for parameter3 and you mean
you can use a function pointer?


Thanks,
Laurent Mealares.

Michael Lawnick wrote:

Hi Laurent,try like this:if


((symFindByName(sysSymTbl,fName,&addr,&type)==OK)&&(type==SYM_TEXT)
addr(param1,...);--Mit freundlichen Grüßen,Michael

Lawnick============================================== SOFTEC GmbH


Tel +49-731-96600-0 Promenade 17 Fax +49-731-96600-23
D-89073 Ulm Michael Lawnick Germany
law...@softec.de =============================================="Laurent
Mealares" <laurent....@csem.ch> schrieb im
Newsbeitragnews:3C762558...@csem.ch...

Hello,I am tring to get the entry point of a routine (pointer) in the
symboltable of VxWorks.I am doing this because of dynamically loaded modules
in my system.I do know the name of the function (symbol) and I want to
retrieve itspointer.I have tried the symFindByName() function which returns
me a successfullstatus so it has found the symbol.The problem is: I don't
know where to "jump" to call this function?Does anybody has implemented such

Dave Korn

unread,
Feb 25, 2002, 1:47:23 PM2/25/02
to
"Laurent Mealares" <laurent....@csem.ch> wrote in message
news:3C7661D3...@csem.ch...
> Hello,
> just a correction...
> I havent correctly check the status returned by symFindByName()... not
> seriously tested.
> It returns an error code actually (it must be symbol not found)...
> NB: The module that contains this function is previously loaded with
> loadModule.
> The fName string is initialized with the exact name of the function
> char fName[] = "c2_function1"
> It does not work...
>
> I have tried my example with char fName[] = "fprintf", It works,
> symFindByName returns an OK code.
>
> Does anybody see a problem?

Is this because c2_function1 is in a C++ file and the name has been
encoded by the compiler (name mangling) ? If so, you would have to declare
it extern "C" (or get your code to search for the mangled name".

DaveK
--
moderator of
alt.talk.rec.soc.biz.news.comp.humanities.meow.misc.moderated.meow
Burn your ID card! http://www.optional-identity.org.uk/
Help support the campaign, copy this into your .sig!
Proud Member of the Exclusive "I have been plonked by Davee because he
thinks I'm interesting" List Member #<insert number here>
Master of Many Meowing Minions
Holder of the exhalted PF Chang's Crab Wonton Award for kook spankage above
and beyond the call of hilarity.


0 new messages