[cfe-dev] Linking executable containing global operator new replacement and -fsanitize=address

Kostya Serebryany kcc at google.com
Thu May 8 07:58:35 PDT 2014


On Thu, May 8, 2014 at 5:27 PM, Stephan Bergmann <sbergman at redhat.com>wrote:

> At least on Linux,
>
>  clang++ -fsanitize=address test.cc
>>
>
> on
>
>  #include <cstddef>
>> #include <new>
>> void * operator new(std::size_t) throw (std::bad_alloc) { return 0; }
>> int main() {}
>>
>
> fails for me with
>
>  /tmp/test-d17df6.o: In function `operator new(unsigned long)':
>> test.cc:(.text+0x0): multiple definition of `operator new(unsigned long)'
>> /home/sbergman/clang/trunk/inst/bin/../lib/clang/3.5.0/
>> lib/linux/libclang_rt.asan-x86_64.a(asan_new_delete.o):/
>> home/sbergman/clang/trunk/src/projects/compiler-rt/lib/asan/asan_new_delete.cc:62:
>> first defined here
>> clang: error: linker command failed with exit code 1 (use -v to see
>> invocation)
>>
>
> Is that a known problem?


Yes, http://llvm.org/bugs/show_bug.cgi?id=19660


>  I assume there is no good way around it


Yes. :(

--kcc


> as the asan code is linked -whole-archive into the executable from a
> static archive (instead of using a dynamic library as GCC appears to do it,
> which also avoids the incompatibility with -z defs).
>
> Stephan
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140508/50fdf1e6/attachment.html>


More information about the cfe-dev mailing list