Dynamic Libraries

Marek Prochazka Marek.Prochazka at scisys.co.uk
Mon Sep 11 09:36:26 UTC 2006


Till,

I'm having a problem linking in the file generated by xsyms. Here is
what I do. I have a Loader application and then a TestApp which I want
to load at runtime.

test: Loader.o TestAoo.o
	@echo --------- Linking Loader application - first pass
	$(CC) $(CFLAGS) Loader.o $(CEXP_LDFLAGS) $(CEXP_LIBS) $(LDFLAGS)
$(LDLIBS) -o Loader
	@echo --------- Generating SYSTEM symbol table
	$(XSYMS) -C Loader Symbols.c
	@echo --------- Compiling SYSTEM symbol table
	$(CC) $(CFLAGS) -c -fomit-frame-pointer -fasm -O Symbols.c
	@echo --------- Linking Loader application - second pass
	$(CC) $(CFLAGS) Symbols.o Loader.o $(CEXP_LDFLAGS) $(CEXP_LIBS)
$(LDFLAGS) $(LDLIBS) -o Loader 

I successfully generate  system table from the Loader executable in
Symbols.c, but then when I'm linking Symbols.o I got the following error
messages:
Symbols.o(.data+0x4): undefined reference to `__cexp__dummy_alias_0'
Symbols.o(.data+0x1c): undefined reference to `__cexp__dummy_alias_1'
Symbols.o(.data+0x34): undefined reference to `__cexp__dummy_alias_2'
...
Symbols.o(.data+0x1fc): undefined reference to `__cexp__dummy_alias_21'
Symbols.o(.data+0x214): undefined reference to `__cexp__dummy_alias_22'
collect2: ld returned 1 exit status

It is true that Symbols.c contains for every "dummy alias" an asm line,
but not for aliases 0-22:

#include <cexpsyms.h>
extern int __cexp__dummy_alias_0;
extern int __cexp__dummy_alias_1;
extern int __cexp__dummy_alias_2;
...
extern int __cexp__dummy_alias_20;
extern int __cexp__dummy_alias_21;
extern int __cexp__dummy_alias_22;
extern int __cexp__dummy_alias_1083;
asm(".set __cexp__dummy_alias_1083,_bfd_elf_sizeof_headers\n");
extern int __cexp__dummy_alias_1084;
asm(".set __cexp__dummy_alias_1084,del_GetLine\n");
extern int __cexp__dummy_alias_1085;
...

Any hints, please?

Thanks,
Marek

> -----Original Message-----
> From: Till Straumann [mailto:strauman at slac.stanford.edu] 
> Sent: 05 September 2006 18:28
> To: Marek Prochazka
> Cc: Chris Johns; rtems-users at rtems.com
> Subject: Re: Dynamic Libraries
> 
> Marek Prochazka wrote:
> > Hi Till,
> >
> > thanks for your quick response. So, after I call cexpInit() 
> This initializes the library but before you can use 
> 'cexpModuleLoad' you
> must have the application's symbol table loaded (aka 'system 
> symbol table').
> You can either (see README)
>   a) compile this in: E.g., using the 'xsyms' or 'ldep' tool 
> you create a
>      symbol table '.c' file which is then compiled and linked with the
>     application.
>   b) use 'cexpModuleLoad()' to load symbols from an object (ELF) file.
>      If no system symbol table is present when cexpModuleLoad is
>      executed then cexpModuleLoad assumes it should just use 
> the symbol
>      table of the argument file to construct the system symbol table.
> > and load a
> > module using cexpModuleLoad(),
> yes
> >  I can look for a function symbol using
> > cexpSymLookup().
> yes
> >  This way I get CexpSym. Given that the symbol was a
> > function, is the way to call this function to consider 
> > CexpSymRec_.value.tv as TFuncP (or TDFuncP?),
> you should use cexpSymValue(CexpSym) to obtain the value
> of the symbol (function or variable address). You then cast
> the void* returned by cexpSymValue() to the correct type
> (up to you to know what type that is).
> >  cast this value to a
> > function pointer and call it?
> Yes.
> 
> HTH
> -- Till
> >  Or is there a cext_ function which I
> > missed to be used?
> >
> > Many thanks,
> > Marek
> >
> >
> >   
> >> -----Original Message-----
> >> From: Till Straumann [mailto:strauman at slac.stanford.edu] 
> >> Sent: 05 September 2006 16:25
> >> To: Marek Prochazka
> >> Cc: Chris Johns; rtems-users at rtems.com
> >> Subject: Re: Dynamic Libraries
> >>
> >> Marek Prochazka wrote:
> >>
> >>     
> >>> Hi,
> >>>
> >>> cexp seems quite interesting, but I do not see any guide how 
> >>>       
> >> to use the
> >>     
> >>> dynamic loader without the interpreter. I want to run my 
> >>>       
> >> code and then
> >>     
> >>> at some point use cexpModuleLoad etc. To do that I need some 
> >>>       
> >> basic cexp
> >>     
> >>> API documentation.
> >>>
> >>>       
> >> Consult the header 'cexp.h'. You can call cexpModuleLoad() 
> etc. from 
> >> ordinary C-code.
> >>
> >>     
> >>> Thanks,
> >>> Marek
> >>>
> >>>  
> >>>
> >>>       
> >>>> Check out cexp:
> >>>>
> >>>> http://www.slac.stanford.edu/comp/unix/package/rtems/src/ssrlA
> >>>> pps/cexp/README
> >>>>
> >>>> The code can be found here:
> >>>>
> >>>> ftp://www.rtems.org/pub/rtems/4.6.99.3/contrib/cexp
> >>>>
> >>>>         
> >> You should always download from the cexp home page (i.e., 
> the stanford
> >> site) to make sure you got the latest version. rtems.org 
> >> usually lags a bit
> >> behind...
> >>
> >> HTH
> >> -- Till
> >>
> >>     
> >>>> Regards
> >>>> Chris
> >>>>
> >>>>    
> >>>>
> >>>>         
> >>>  
> >>>
> >>>       
> >>
> >>     
> >
> >   
> 
> 




More information about the users mailing list