[rtems-users] C++ Virtual Functions

Chris Johns chrisj at rtems.org
Tue Feb 1 21:03:09 UTC 2005


Smith, Gene wrote:
> I am having some problems running code containing C++ virtual functions in
> rtems. When the code tries to branch to a virtual function address using
> "bctrl" instruction, the address (in ctr) is way out of range and results in
> a machine check exception.
> 
> Is there anything I need to do special in rtems for virtual functions to
> work? Is anyone using virtual functions, pure or impure, in rtems? I am
> still using rtems 4.6.1 and my ppc40x-derived bsp.
> 

Yes all the time.

A simple check of your application's ELF image is to:

  $ powerpc-rtems-nm --demangle myapp.elf | grep vtable

(I assume the tools are powerpc-rtems-*)

You should be able to find the address of the table in question and be 
able to make sure it is ok when the application is loaded.

Each object gets a pointer to its vtable so an overwrite of an object 
can result in the vtable pointer becoming corrupt.


-- 
  Chris Johns



More information about the users mailing list