[llvm-commits] [compiler-rt] r153431 - /compiler-rt/trunk/lib/asan/asan_linux.cc

Kostya Serebryany kcc at google.com
Mon Mar 26 08:42:28 PDT 2012


On Mon, Mar 26, 2012 at 8:31 AM, Evgeniy Stepanov <eugeni.stepanov at gmail.com
> wrote:

> On Mon, Mar 26, 2012 at 7:12 PM, Joerg Sonnenberger
> <joerg at britannica.bec.de> wrote:
> > On Mon, Mar 26, 2012 at 09:48:41AM -0000, Evgeniy Stepanov wrote:
> >> Modified: compiler-rt/trunk/lib/asan/asan_linux.cc
> >> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=153431&r1=153430&r2=153431&view=diff
> >>
> ==============================================================================
> >> --- compiler-rt/trunk/lib/asan/asan_linux.cc (original)
> >> +++ compiler-rt/trunk/lib/asan/asan_linux.cc Mon Mar 26 04:48:41 2012
> >> @@ -25,7 +25,6 @@
> >>  #include <sys/syscall.h>
> >>  #include <sys/types.h>
> >>  #include <fcntl.h>
> >> -#include <link.h>
> >>  #include <pthread.h>
> >>  #include <stdio.h>
> >>  #include <unistd.h>
> >> @@ -36,6 +35,8 @@
> >>  #include <sys/ucontext.h>
> >>  #endif
> >>
> >> +extern "C" void* _DYNAMIC;
> >> +
> >>  namespace __asan {
> >>
> >>  void *AsanDoesNotSupportStaticLinkage() {
> >>
> >>
> >
> > This is wrong, it forces an UNDEF reference. You really want to use
> >
> > static int my_DYNAMIC __attribute__((__weakref__(_DYNAMIC)));
> >
> > or so if it is supposed to work for static linked binaries.
>
> That's the point, we don't want it to work for static binaries. That's
> why the function is called AsanDoesNotSupportStaticLinkage.
>
>
asan run-time simply doesn't work for static binaries because we rely on
dlsym.
W/o this hack asan crashes at run-time with hard to explain errors if the
binary is linked statically.
With this hack static linkage fails at link time with descriptive message.

--kcc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120326/52fb03af/attachment.html>


More information about the llvm-commits mailing list