[LLVMdev] -fvisibility=hidden, and typeinfo, and type-erasure

Joerg Sonnenberger joerg at britannica.bec.de
Fri Jun 6 03:24:37 PDT 2014


On Wed, Jun 04, 2014 at 07:43:35PM -0400, Rafael Avila de Espindola wrote:
> 
> 
> Sent from my iPhone
> 
> > On Jun 4, 2014, at 19:08, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:
> > 
> >> On Wed, Jun 04, 2014 at 06:32:35PM -0400, Rafael EspĂ­ndola wrote:
> >> I think the difference is actually in the c++ library. It looks like
> >> libstdc++ changed to always use strcmp of the typeinfo names:
> >> 
> >> https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=149964
> >> 
> >> Should we do the same with libc++?
> > 
> > No. It pessimizes correctly behaving code to work around code that
> > violates the ELF ABI. Consider an application that loads plugins with
> > RTLD_LOCAL. Two plugins implement a (hidden) type called "Plugin". The
> > GCC change now makes this completely separate types identical for all
> > RTTI purposes. That makes no sense at all.
> > 
> 
> That is an interesting argument, in particular because RTLD_LOCAL seems
> to be the reason why libstdc++ switched :-)

I think the most common cause was lack of -rdynamic when linking the main
program. Let's say you have a type defined in your main program. It is
not used by any of the shared libraries, so it doesn't get exported with
a copy relocation. Now you have a plugin that also uses this type. The
dynamic loader can't unify the types, even if the instance in the plugin
is public, because the instance in the main program is hidden from it.

Joerg



More information about the llvm-dev mailing list