<br><br><div class="gmail_quote">On Thu, Oct 18, 2012 at 7:00 PM, Carsten Mattner <span dir="ltr"><<a href="mailto:carstenmattner@gmail.com" target="_blank">carstenmattner@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="im">On Thu, Oct 18, 2012 at 4:49 PM, Kostya Serebryany <<a href="mailto:kcc@google.com">kcc@google.com</a>> wrote:<br>
> You are linking a shared object, asan.a should not be linked to it.<br>
<br>
</div>What should happen instead?<br></blockquote><div><br></div><div>nothing. asan.a should be linked only to the main executable. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im"><br>
> Are these all the flags passed to ld?<br>
<br>
</div>Yes it's all minus project-specific -l and *.a and *.o args<br>
I have omitted for the email.<br></blockquote><div><br></div><div>don't you have something like -Wl,-z,defs ?</div><div>The problem you describe was seen before in the presence of -Wl,-z,defs, which forces the definitions of all symbols in .so (and __asan* symbols are not defined). </div>
<div>The solution was to remove -Wl,-z,defs. </div><div><br></div><div>--kcc </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
> On Thu, Oct 18, 2012 at 6:23 PM, Carsten Mattner <<a href="mailto:carstenmattner@gmail.com">carstenmattner@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On Thu, Oct 18, 2012 at 3:36 PM, Alexander Potapenko <<a href="mailto:glider@google.com">glider@google.com</a>><br>
>> wrote:<br>
>> > Can you append -v at the place it's being invoked to check whether the<br>
>> > contents of LDFLAGS are being actually passed?<br>
>><br>
>> $ clang <INPUT_OBJECTS> -lstdc++ -v -faddress-sanitizer -shared<br>
>> <PROJECT_FLAGS> -o <SO_FILE><br>
>> clang<br>
>> version 3.2 (<a href="http://llvm.org/git/clang.git" target="_blank">http://llvm.org/git/clang.git</a><br>
>> 278eafa2cd8296f8128d13c6466a0ace3d03a872)<br>
>> (<a href="http://llvm.org/git/llvm.git" target="_blank">http://llvm.org/git/llvm.git</a><br>
>> 2360b7ad99eedecaae512373e7be49c2143550cf)<br>
>> Target: i386-pc-linux-gnu<br>
>> Thread model: posix<br>
>><br>
>> "/usr/bin/ld" --eh-frame-hdr -m elf_i386 -shared -o <SO_FILE><br>
>> /usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../crti.o<br>
>> /usr/lib/gcc/i686-pc-linux-gnu/4.7.2/crtbeginS.o<br>
>> -L/usr/lib/gcc/i686-pc-linux-gnu/4.7.2<br>
>> -L/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../.. -L/lib -L/usr/lib<br>
>> <INPUT_OBJECTS> -lstdc++ -lgcc --as-needed -lgcc_s --no-as-needed -lc<br>
>> -lgcc --as-needed -lgcc_s --no-as-needed<br>
>> /usr/lib/gcc/i686-pc-linux-gnu/4.7.2/crtendS.o<br>
>> /usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../crtn.o<br>
>><br>
>> I guess the libasan archive should be part of the above call to ld.<br>
>><br>
>> > On Thu, Oct 18, 2012 at 5:33 PM, Carsten Mattner<br>
>> > <<a href="mailto:carstenmattner@gmail.com">carstenmattner@gmail.com</a>> wrote:<br>
>> >> On Thu, Oct 18, 2012 at 3:29 PM, Alexander Potapenko wrote:<br>
>> >>> Are you linking with ld or clang?<br>
>> >>> -faddress-sanitizer is a Clang flag, so if you're running `ld $LDFLAGS<br>
>> >>> ...` to link your program, it won't work.<br>
>> >><br>
>> >> clang.<br>
>> >><br>
>> >>> On Thu, Oct 18, 2012 at 5:12 PM, Carsten Mattner<br>
>> >>> <<a href="mailto:carstenmattner@gmail.com">carstenmattner@gmail.com</a>> wrote:<br>
>> >>>> On Thu, Oct 18, 2012 at 12:27 AM, Eli Friedman wrote:<br>
>> >>>>> On Wed, Oct 17, 2012 at 1:43 PM, Carsten Mattner<br>
>> >>>>> <<a href="mailto:carstenmattner@gmail.com">carstenmattner@gmail.com</a>> wrote:<br>
>> >>>>>> Is it expected that -faddress-sanitizer  does not work on i386 and<br>
>> >>>>>> fails<br>
>> >>>>>> to properly link resulting in errors like 'undefined symbol:<br>
>> >>>>>> __asan_init'<br>
>> >>>>>> at runtime?<br>
>> >>>>>><br>
>> >>>>>> I have ./lib/clang/3.2/lib/linux/libclang_rt.asan-i386.a in llvm's<br>
>> >>>>>> installation,<br>
>> >>>>>> but it doesn't look like it's linked automatically into the<br>
>> >>>>>> executable.<br>
>> >>>>>><br>
>> >>>>>> CFLAGS:<br>
>> >>>>>> -faddress-sanitizer -O1 -fno-omit-frame-pointer -g $PROJECT_FLAGS<br>
>> >>>>><br>
>> >>>>> You need to pass in -faddress-sanitizer both when compiling and when<br>
>> >>>>> linking an application.  Try something like<br>
>> >>>>> "LDFLAGS=-faddress-sanitizer".<br>
>> >>>><br>
>> >>>> Oh that makes a lot of sense and is kind of obvious in hindsight.<br>
>> >>>> Yet it didn't work in a quick test. Any options I flags to pass for<br>
>> >>>> verbose printfs to see what's happening you can suggest?<br>
>> >>>> In the next test I'll also try to explicitly link the libasan archive<br>
>> >>>> manually for ruling out issues with that archive.<br>
>> >>>> _______________________________________________<br>
>> >>>> cfe-dev mailing list<br>
>> >>>> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
>> >>>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
>> >>><br>
>> >>><br>
>> >>><br>
>> >>> --<br>
>> >>> Alexander Potapenko<br>
>> >>> Software Engineer<br>
>> >>> Google Moscow<br>
>> ><br>
>> ><br>
>> ><br>
>> > --<br>
>> > Alexander Potapenko<br>
>> > Software Engineer<br>
>> > Google Moscow<br>
>> _______________________________________________<br>
>> cfe-dev mailing list<br>
>> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
><br>
><br>
</div></div></blockquote></div><br>