Oh, I mean that asan_new_delete.cc should be a part of asan rtl. <div>Isn't that enough? <br><br><div class="gmail_quote">On Thu, Apr 5, 2012 at 8:46 AM,  <span dir="ltr"><<a href="mailto:samsonov@google.com">samsonov@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 2012/04/04 14:57:48, kcc1 wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'd prefer to move our custom new/delete into asan_new_delete.cc, and<br>
</blockquote>
in<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
that file it would probably be ok to include <new>.<br>
</blockquote>
<br></div>
Yep, that's reasonable, but we have to make sure that resulting<br>
asan_new_delete.o will be loaded from libasan .a file<br>
(otherwise our "new" implementation is just not linked into exe, and<br>
dynamic linker chooses libstdc++ implementation).<br>
<br>
We can<br>
1) add a fake dependency between asan_rtl and asan_new_delete (in this<br>
CL, a bit hacky)<br>
2) hack lib/Driver/Tools.cpp and make sure that flag -lstdc++ is passed<br>
to ld after .a with ASan RT (it is currently passed before). (looks more<br>
hacky)<br>
3) use -Wl,--whole-archive (omg).<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
--kcc<br>
</blockquote><div class="im">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, Apr 4, 2012 at 7:53 AM, <mailto:<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>> wrote:<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> Reviewers: kcc1, timurrrr_at_google_com,<br>
><br>
> Message:<br>
> #include <new> brings a number of system libraries (e.g. <string.h><br>
</blockquote>
on<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> Windows), which is probably unwanted. We (hopefully) can replace<br>
> std::nothrow_t and std::bad_alloc by custom stubs, so that our<br>
</blockquote>
overload<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> of new would still work in a user program.<br>
><br>
><br>
><br>
> Please review this at<br>
</blockquote>
<br>
</div><a href="http://codereview.appspot.com/**5966077/%3Chttp://codereview.appspot.com/5966077/" target="_blank">http://codereview.appspot.com/<u></u>**5966077/%3Chttp://<u></u>codereview.appspot.com/<u></u>5966077/</a>><div class="im">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
><br>
> Affected files:<br>
>  M     asan_interceptors.cc<br>
><br>
><br>
> Index: asan_interceptors.cc<br>
><br>
</blockquote></div>
==============================<u></u>**============================<u></u>==**=======<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> --- asan_interceptors.cc        (revision 154006)<br>
> +++ asan_interceptors.cc        (working copy)<br>
> @@ -22,8 +22,6 @@<br>
>  #include "asan_thread_registry.h"<br>
>  #include "interception/interception.h"<br>
><br>
> -#include <new><br>
> -<br>
>  // Use macro to describe if specific function should be<br>
>  // intercepted on a given platform.<br>
>  #if !defined(_WIN32)<br>
> @@ -331,6 +329,10 @@<br>
>  void *operator new(size_t size) { OPERATOR_NEW_BODY; }<br>
>  void *operator new[](size_t size) { OPERATOR_NEW_BODY; }<br>
>  #else<br>
> +namespace std {<br>
> +class bad_alloc {};<br>
> +class nothrow_t;<br>
> +}  // namespace std<br>
>  void *operator new(size_t size) throw(std::bad_alloc) {<br>
> OPERATOR_NEW_BODY; }<br>
>  void *operator new[](size_t size) throw(std::bad_alloc) {<br>
> OPERATOR_NEW_BODY; }<br>
>  void *operator new(size_t size, std::nothrow_t const&) throw()<br>
><br>
><br>
><br>
</blockquote>
<br>
<br>
<br>
</div><a href="http://codereview.appspot.com/5966077/" target="_blank">http://codereview.appspot.com/<u></u>5966077/</a><br>
</blockquote></div><br></div>