[cfe-dev] Should a "typeinfo" variable be "linkonce_odr constant" or just "constant"

Kostya Serebryany kcc at google.com
Tue Aug 5 07:06:25 PDT 2014

Hello Clang folks,

I have a question about typeinfo variables:

% cat a1.cc
struct AAA {
  virtual ~ AAA ();
AAA::~AAA() { }
void foo () { throw AAA (); }

% clang++ a1.cc -S -o - -emit-llvm    | grep '_ZTI3AAA.=.[^{]*' -o
_ZTI3AAA = constant

% clang++ a1.cc -S -o - -emit-llvm  -fno-rtti  | grep '_ZTI3AAA.=.[^{]*' -o
_ZTI3AAA = linkonce_odr constant

As you can see, depending on the compilation mode (-fno-rtti) the
definition of _ZTI3AAA
(typeinfo for AAA) is different.  Is that expected?

This difference causes problem for AddressSanitizer, if one part of the
code is built with
-fno-rtti and another part w/o -fno-rtti.
asan instruments global constants but can not instrument linkonce_odr
as a result we mix an instrumented and a non-instrumented global in the
same binary.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140805/fdfa956e/attachment.html>

More information about the cfe-dev mailing list