[stdc++] Mark global new/delete operators as weak symbols

Romain Geissler romain.geissler@gmail.com
Tue Aug 20 06:23:00 GMT 2013


Hi,

According to the C++ standard §17.4.3.4(2,3) the global new and delete
operator implementation can be replaced by the program. For example,
tcmalloc does redefine them. On ELF targets, it is currently OK if you
link libstc++ dynamically. However, if you try to link both tcmalloc
and stdc++ statically, then the linker will complain about multiple
symbol definition.

This patch fixes this by marking the global new/delete operator as
weaks for linux. I may be extended to all ELF targets. Bootstrapped
and tested on SLES 11 SP1 x86_64.

Cheers,
Romain

/libstc++-v3/

2013-08-20  Romain Geissler  <romain.geissler@gmail.com>

    * config/os/gnu-linux/os_defines.h: (_GLIBCXX_WEAK_DEFINITION): Define.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Define-global-new-delete-operators-as-weak-symbols.patch
Type: application/octet-stream
Size: 939 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20130820/7ca0a76c/attachment.obj>


More information about the Libstdc++ mailing list