Re: Switching between interfaces without knowing derived object.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks John,

Your hint made me look into the symbol information exposed by a library. I found out that by giving -rdynamic flag to the linker while building the application, resolved the problem. It includes the dynamic symbol information into the executable. See below the email. For this sample program it does increase the executable size by 500 bytes.

Can someone comment on cons of passing this flag to the linker. 
Does it increase search time in look-up tables? 
Should i even worry about it ?

Thanks
-hardy


objdump -T -C ./test

./test:     file format elf32-i386

DYNAMIC SYMBOL TABLE:
08048c7c  w   DO .rodata    00000008  Base        typeinfo for Itf1
00000000      DF *UND*    00000582  GLIBCXX_3.4 std::ios_base::Init::Init()
08049e80 g    DO .bss    0000008c  GLIBCXX_3.4 std::cout
08049d44 g    DO *ABS*    00000000  Base        _DYNAMIC
08048c84  w   DO .rodata    00000006  Base        typeinfo name for Itf1
08048c64 g    DO .rodata    00000004  Base        _fp_hw
00000000      DF *UND*    0000008a  GLIBC_2.0   dlsym
00000000      DF *UND*    0000026a  GLIBCXX_3.4 std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
08048bd0 g    DF .text    0000004c  Base        __libc_csu_fini
00000000      DF *UND*    0000003b  GLIBC_2.1.3 __cxa_atexit
0804883c g    DF .init    00000000  Base        _init
08049f10  w   DO .bss    0000002c  CXXABI_1.3  vtable for __cxxabiv1::__class_type_info
08048c6c  w   DO .rodata    00000008  Base        typeinfo for Itf2
08048950 g    DF .text    00000000  Base        _start
08048c74  w   DO .rodata    00000006  Base        typeinfo name for Itf2
08048b70 g    DF .text    00000053  Base        __libc_csu_init
08049e80 g    D  *ABS*    00000000  Base        __bss_start
08048a60 g    DF .text    00000105  Base        main
00000000      DF *UND*    00000259  GLIBC_2.0   dlerror
00000000      DF *UND*    000000cc  GLIBC_2.0   __libc_start_main
08049e74  w   D  .data    00000000  Base        data_start
08048c48 g    DF .fini    00000000  Base        _fini
00000000      DF *UND*    00000045  GLIBC_2.0   dlclose
00000000      DF *UND*    000000db  GLIBC_2.0   exit
08049e80 g    D  *ABS*    00000000  Base        _edata
08049f44 g    D  *ABS*    00000000  Base        _end
00000000      DF *UND*    00000117  CXXABI_1.3  __dynamic_cast
08048c68 g    DO .rodata    00000004  Base        _IO_stdin_used
00000000      DF *UND*    00000054  GLIBCXX_3.4 std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
08049e74 g    D  .data    00000000  Base        __data_start
00000000  w   D  *UND*    00000000              _Jv_RegisterClasses
08048904      DF *UND*    00000410  CXXABI_1.3  __gxx_personality_v0
00000000      DF *UND*    0000009d  GLIBCXX_3.4 std::ios_base::Init::~Init()
00000000  w   D  *UND*    00000000              __gmon_start__
00000000      DF *UND*    0000005e  GLIBC_2.1   dlopen



________________________________
From: John (Eljay) Love-Jensen <eljay@xxxxxxxxx>
To: Hardeep Singh <hardy_hardeep@xxxxxxxxxxx>; GCC-help <gcc-help@xxxxxxxxxxx>
Sent: Wednesday, 19 August, 2009 10:27:43 AM
Subject: Re: Switching between interfaces without knowing derived object.

Hi Hardeep,

Just a guess...

The cause of the problem *MAY* be that there may be multiple copies of the
RTTI information.

But the operator== of the RTTI information, as used by dynamic_cast, only
compares the pointers as being the same, it does not compare the RTTI
structure for equality.

If that is the issue, it may be fixed by making sure you have exported all
the relevant RTTI information, by decorating the classes with
__attribute__((visibility("default"))), or by using the -fvisibility=default
switch as a sweeping first-stab fix.

You may also need to make sure you are not using early binding.

HTH,
--Eljay

DISCLAIMER: I don't have Mandriva Linux release 2006 (although I was a big
Mandrake fan back in the day).


      Love Cricket? Check out live scores, photos, video highlights and more. Click here http://cricket.yahoo.com


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux