<br><br><div class="gmail_quote">On Mon, Mar 26, 2012 at 8:31 AM, Evgeniy Stepanov <span dir="ltr"><<a href="mailto:eugeni.stepanov@gmail.com">eugeni.stepanov@gmail.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="HOEnZb"><div class="h5">On Mon, Mar 26, 2012 at 7:12 PM, Joerg Sonnenberger<br>
<<a href="mailto:joerg@britannica.bec.de">joerg@britannica.bec.de</a>> wrote:<br>
> On Mon, Mar 26, 2012 at 09:48:41AM -0000, Evgeniy Stepanov wrote:<br>
>> Modified: compiler-rt/trunk/lib/asan/asan_linux.cc<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=153431&r1=153430&r2=153431&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=153431&r1=153430&r2=153431&view=diff</a><br>

>> ==============================================================================<br>
>> --- compiler-rt/trunk/lib/asan/asan_linux.cc (original)<br>
>> +++ compiler-rt/trunk/lib/asan/asan_linux.cc Mon Mar 26 04:48:41 2012<br>
>> @@ -25,7 +25,6 @@<br>
>>  #include <sys/syscall.h><br>
>>  #include <sys/types.h><br>
>>  #include <fcntl.h><br>
>> -#include <link.h><br>
>>  #include <pthread.h><br>
>>  #include <stdio.h><br>
>>  #include <unistd.h><br>
>> @@ -36,6 +35,8 @@<br>
>>  #include <sys/ucontext.h><br>
>>  #endif<br>
>><br>
>> +extern "C" void* _DYNAMIC;<br>
>> +<br>
>>  namespace __asan {<br>
>><br>
>>  void *AsanDoesNotSupportStaticLinkage() {<br>
>><br>
>><br>
><br>
> This is wrong, it forces an UNDEF reference. You really want to use<br>
><br>
> static int my_DYNAMIC __attribute__((__weakref__(_DYNAMIC)));<br>
><br>
> or so if it is supposed to work for static linked binaries.<br>
<br>
</div></div>That's the point, we don't want it to work for static binaries. That's<br>
why the function is called AsanDoesNotSupportStaticLinkage.<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div>asan run-time simply doesn't work for static binaries because we rely on dlsym. </div><div>W/o this hack asan crashes at run-time with hard to explain errors if the binary is linked statically.</div>
<div>With this hack static linkage fails at link time with descriptive message. </div><div> </div><div>--kcc </div></div>