[cfe-dev] libc++ ABI versioning

Jorgen Tjerno jorgen at uberent.com
Mon Jun 9 18:32:35 PDT 2014


I've noticed that Xcode 4.6 and Xcode 5.1 ship with headers that have
different layouts for std::ifstream. sizeof(std::ifstream) is 448 for
4.6, and 576 on 5.1. You can see my test case here:
https://gist.github.com/anonymous/bd0db5e4bcb307b70506

How does clang/libc++ ensure that the executable runs with the right
libc++ version for headers it was built with? I can run the binaries
produced by Xcode 4.6 on a machine that has a newer libc++, and I can
run the binaries produced by 5.1 on a machine that has an older
libc++. I would assume that if I built with headers that give me a
smaller size than what is expected by libc++, that would be cause the
newer libc++ to trash memory beyond the end of my object. Am I missing
something?

I was unable to find any resources on how libc++ ABI versioning works
other than the "major ABI version" -- which is 1.

The specific problem I'm seeing is that it seems that when I link with
a static library that was built with the older libc++ version, a
translation unit built with the new libc++ ends up using the wrong
(old) value for the construction symbol at runtime
(__ZTCNSt3__114basic_ifstreamIcNS_11char_traitsIcEEEE0_NS_13basic_istreamIcS2_EE,
or '
   construction vtable for std::__1::basic_istream<char,
std::__1::char_traits<char> >-in-std::__1::basic_ifstream<char,
std::__1::char_traits<char> >' according to c++filt).

- Jørgen.




More information about the cfe-dev mailing list