Hi, 2016-12-14 10:23 GMT+03:00 Park Kit <[email protected]>:
> Hi Maxim, > > Sorry for a slow response since I took some time to check ASAN's working > on a target platform. Thanks to your help, have managed to build ASAN with > uclibc and builds fine. However, gets a seg fault when runs it on a target: > > #1 0x2aabf414 in __pthread_initialize_minimal_internal () from > /home/xxx/asan/mips-libs-from-build/libpthread.so.0 > #2 0x2ab36874 in __uClibc_init () from /home/xxx/asan/mips-libs-from- > build/libc.so.0 > > Tried different uclibc version but no luck yet. Will try more and keep you > updated on that. > > Hm, I don't know whether anyone tried to use ASan with uclibc before (AFAIK sanitizer runtime quite tightly connected to Glibc internals). I suggest you to use Glibc. If this isn't an option for you, then... good luck! > Many thanks and > > *Щастлива Коледа* > > Merry Christmas! :) -Maxim > > > Kit > > > > Many thanks, > Kit > https://kitpark.slack.com/ > ------ > Sorry for a terse reply or typo as sent from a mobile. > > 2016-11-28 15:46 GMT+00:00 Park Kit <[email protected]>: > >> Ah, sorry for that since I have missed that. Will give it try and update >> you on that. >> >> Many thanks, >> Kit >> https://kitpark.slack.com/ >> ------ >> Sorry for a terse reply or typo as sent from a mobile. >> >> 2016-11-28 14:42 GMT+00:00 Maxim Ostapenko <[email protected]>: >> >>> >>> >>> 2016-11-28 17:38 GMT+03:00 Park Kit <[email protected]>: >>> >>>> Hi Maxim, >>>> >>>> Once done 3) make - j12 from step 3, run 'make install' which is >>>> different from step 2 in the reference. Have set rpath to dismiss link >>>> errors: >>>> >>>> /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/../../../../mips-linux/bin/ld: warning: libpthread.so.0, >>>> needed by /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4. >>>> 8.2/../../../../mips-linux/lib/libasan.so, not found (try using -rpath >>>> or -rpath-link) >>>> /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/../../../../mips-linux/bin/ld: warning: libdl.so.2, needed >>>> by /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/. >>>> ./../../../mips-linux/lib/libasan.so, not found (try using -rpath or >>>> -rpath-link) >>>> /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/../../../../mips-linux/bin/ld: warning: libstdc++.so.6, >>>> needed by /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8 >>>> .2/../../../../mips-linux/lib/libasan.so, not found (try using -rpath >>>> or -rpath-link) >>>> /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/../../../../mips-linux/bin/ld: warning: libm.so.6, needed >>>> by /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/.. >>>> /../../../mips-linux/lib/libasan.so, not found (try using -rpath or >>>> -rpath-link) >>>> /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/../../../../mips-linux/lib/libasan.so: undefined reference >>>> to `pthread_attr_getstack@GLIBC_2.2' >>>> /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/../../../../mips-linux/lib/libasan.so: undefined reference >>>> to `pthread_setspecific@GLIBC_2.0' >>>> /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/../../../../mips-linux/lib/libasan.so: undefined reference >>>> to `dlsym@GLIBC_2.0' >>>> /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/../../../../mips-linux/lib/libasan.so: undefined reference >>>> to `pthread_key_create@GLIBC_2.0' >>>> /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/../../../../mips-linux/lib/libasan.so: undefined reference >>>> to `pthread_getspecific@GLIBC_2.0' >>>> /home/NDS-UK/kyoupark/asn/install-4.8.2/bin/../lib/gcc/mips- >>>> linux/4.8.2/../../../../mips-linux/lib/libasan.so: undefined reference >>>> to `pthread_getattr_np@GLIBC_2.2.3' >>>> collect2: error: ld returned 1 exit status >>>> >>>> However, still gets this when do: >>>> >>>> $ ./bin/mips-linux-gcc-4.8.2 -fsanitize=address >>>> -Wl,-rpath=/home/NDS-UK/kyoupark/asn/install-4.8.2/mips-linux/lib >>>> ~/asn/x.c >>>> */home/nds-uk/kyoupark/asn/x.c:1:0: warning: -fsanitize=address not >>>> supported for this target [enabled by default]* >>>> #include <stdio.h> >>>> ^ >>>> $ >>>> >>> >>> Yes, as I mentioned earlier in mail just add *-fstack-protector *flag*:* >>> >>> > This is weird, but for some reason GCC folks use this flag to control >>> *FRAME_GROWS_DOWNWARD *macro om MIPS. >>> > GCC's ASan doesn't support targets with *FRAME_GROWS_DOWNWARD == 0 *so >>> I just added *-fstack-protector *as a workaround. >>> >>> >>> >>>> >>>> Anything I have missed here? >>>> Kit >>>> >>>> >>>> Many thanks, >>>> Kit >>>> https://kitpark.slack.com/ >>>> ------ >>>> Sorry for a terse reply or typo as sent from a mobile. >>>> >>>> 2016-11-28 14:10 GMT+00:00 Maxim Ostapenko <[email protected]>: >>>> >>>>> 2016-11-28 16:31 GMT+03:00 Park Kit <[email protected]>: >>>>> >>>>>> Hi Maxim, >>>>>> >>>>> >>>>> Hi, >>>>> >>>>> >>>>>> >>>>>> You're right. Have managed to have ASAN in build step. Very >>>>>> appreciated for your advice up until now. However, found two things to >>>>>> check: >>>>>> >>>>>> 1. You said you used GCC trunk and I am trying out GCC 4.8.2. See >>>>>> differences between them in applying patches you sent and build error >>>>>> such >>>>>> as >>>>>> >>>>>> ../../../../gcc-4.8.2/libsanitizer/asan/asan_linux.cc:90:3: error: >>>>>> #error "Unsupported arch" >>>>>> # error "Unsupported arch" >>>>>> ^ >>>>>> But think can do "back-port" this part from the trunk or 4.9.2. >>>>>> >>>>> >>>>> Oh, right. >>>>> >>>>> >>>>>> >>>>>> 2. As advised, when done build again in step 3 to build ASAN, shall I >>>>>> run the rest step again to install all such as step 4-7 as the reference >>>>>> or >>>>>> do install only in step 3? Checking before doing the former, full steps >>>>>> afterwards. >>>>>> >>>>> >>>>> You need just step 3 at this point, no need to do 4-7 stuff again. >>>>> >>>>> >>>>>> >>>>>> >>>>>> Many thanks again and it's almost there although need to do more to >>>>>> have uclibc with gcc. :-) >>>>>> Kit >>>>>> >>>>>> Many thanks, >>>>>> Kit >>>>>> https://kitpark.slack.com/ >>>>>> ------ >>>>>> Sorry for a terse reply or typo as sent from a mobile. >>>>>> >>>>>> 2016-11-25 18:59 GMT+00:00 Maxim Ostapenko <[email protected]>: >>>>>> >>>>>>> >>>>>>> 25 Ноя 2016 г. 21:41 пользователь "Park Kit" <[email protected]> >>>>>>> написал: >>>>>>> > >>>>>>> > Hi Maxim, >>>>>>> > >>>>>>> > Still didn't build. The problem as far as I see, is "libgcc" since >>>>>>> it should done in later steps(according to the reference) and it fails >>>>>>> to >>>>>>> build but when use all-gcc target, it didn't build libgcc so not a >>>>>>> problem >>>>>>> in this case. But "make" tries to build libgcc and failed. >>>>>>> >>>>>>> Ah, no, you should do all 7 steps from the reference and just after >>>>>>> that rebuild GCC like this: >>>>>>> >>>>>>> 1) rm - rf * >>>>>>> 2) configure ... (from step 3) >>>>>>> 3) make - j12 >>>>>>> >>>>>>> You should not have problems with libgcc on that step (after you did >>>>>>> all 7 steps from the reference). >>>>>>> >>>>>>> > >>>>>>> > The steps I did are: >>>>>>> > >>>>>>> > 946 2016-11-25 17:26:18 export PATH=~/asn/install-4.8.2/bin:$PATH >>>>>>> # to add binutil to the path >>>>>>> > 947 2016-11-25 17:26:29 rm -rf * >>>>>>> > 949 2016-11-25 17:26:42 ../gcc-4.8.2/configure -C >>>>>>> --prefix=/xx/asn/install-4.8.2 --target=mips-linux >>>>>>> --enable-languages=c,c++ >>>>>>> --disable-multilib --enable-libsanitizer >>>>>>> > 951 2016-11-25 17:26:57 make -j12 >>>>>>> > >>>>>>> > Of course, have a tweak in configure.tgt. >>>>>>> > >>>>>>> > From configure log, ASAN wasn't filtered out but didn't get built. >>>>>>> > >>>>>>> > *** This configuration is not supported in the following >>>>>>> subdirectories: >>>>>>> > target-libitm gnattools target-libada target-libgfortran >>>>>>> target-libgo target-libffi target-libbacktrace target-zlib >>>>>>> target-libjava >>>>>>> target-libobjc target-boehm-gc >>>>>>> > (Any other directories should still work fine.) >>>>>>> > >>>>>>> > BTW, what did you mean by "rebuild GCC from the scratch"? Since >>>>>>> use a separate build directory, step 1 and 2 in your reply would >>>>>>> suffice. >>>>>>> Anything missed or you meant something different? >>>>>>> > >>>>>>> >>>>>>> I mean you can do step 3 replacing ' make -j4 all-gcc' with 'make >>>>>>> -j4'. >>>>>>> >>>>>>> > Many thanks >>>>>>> > Kit >>>>>>> > >>>>>>> > >>>>>>> > Many thanks, >>>>>>> > Kit >>>>>>> > https://kitpark.slack.com/ >>>>>>> > ------ >>>>>>> > Sorry for a terse reply or typo as sent from a mobile. >>>>>>> > >>>>>>> > 2016-11-25 16:32 GMT+00:00 Maxim Ostapenko <[email protected]>: >>>>>>> >> >>>>>>> >> >>>>>>> >> 25 Ноя 2016 г. 20:23 пользователь "Park Kit" < >>>>>>> [email protected]> написал: >>>>>>> >> > >>>>>>> >> > Hi Maxim, >>>>>>> >> >>>>>>> >> Hi >>>>>>> >> >>>>>>> >> > >>>>>>> >> > Really appreciated for the link which works for me when follows >>>>>>> exactly. However, I am seeing two differences from you when trying to >>>>>>> build >>>>>>> ASAN: >>>>>>> >> > >>>>>>> >> > 1. Used the same glibc version but no error on a machine I use. >>>>>>> >> > 2. When either use a libsanitizer/configure.tgt tweak or >>>>>>> --enable-libsanitizer, "make all-gcc" doesn't build "libsanitizer >>>>>>> >> >>>>>>> >> Try to do "make -j12" instead of "make all-gcc". If that doesn't >>>>>>> work, rebuild GCC from the scratch: >>>>>>> >> >>>>>>> >> 1) rm -rf * >>>>>>> >> 2) configure ... >>>>>>> >> 3) make -j12 >>>>>>> >> >>>>>>> >> Make sure you added 'mips-linux' entry in configure.tgt. >>>>>>> >> >>>>>>> >> > >>>>>>> >> > May need to look into Makefile.in and need to figure out. Will >>>>>>> updated on that and many thanks again. >>>>>>> >> > >>>>>>> >> > Kit >>>>>>> >> > >>>>>>> >> > >>>>>>> >> > Many thanks, >>>>>>> >> > Kit >>>>>>> >> > https://kitpark.slack.com/ >>>>>>> >> > ------ >>>>>>> >> > Sorry for a terse reply or typo as sent from a mobile. >>>>>>> >> > >>>>>>> >> > 2016-11-24 7:59 GMT+00:00 Maxim Ostapenko <[email protected]>: >>>>>>> >> >> >>>>>>> >> >> Hi, >>>>>>> >> >> >>>>>>> >> >> вторник, 22 ноября 2016 г., 17:48:21 UTC+3 пользователь Park >>>>>>> Kit написал: >>>>>>> >> >>> >>>>>>> >> >>> Hi Sagar, Maxim, >>>>>>> >> >>> >>>>>>> >> >>> Appreciated for your try and comments. >>>>>>> >> >>> >>>>>>> >> >>> @Sagar, your steps are bit different from what I followed so >>>>>>> will give it a try to build. This confirms at least ASAN works for >>>>>>> cross-compile on MIPS and which is great. >>>>>>> >> >>> >>>>>>> >> >>> @Maxim, you're right on 2) and that's what I did. Have you >>>>>>> used the buildroot to build cross-compile GCC on MIPS or used GCC >>>>>>> package >>>>>>> only? What version have you used? Would you mind showing command lines >>>>>>> to >>>>>>> configure and to build it? >>>>>>> >> >> >>>>>>> >> >> >>>>>>> >> >> Yes, I've used cross buildroot. It can be quite simply built >>>>>>> manually, I've used this pretty nice instruction: >>>>>>> http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/. >>>>>>> >> >> The components I used: >>>>>>> >> >> * current trunk GCC >>>>>>> >> >> * current trunk binutils >>>>>>> >> >> * current trunk Linux headers >>>>>>> >> >> * Glibc 2.20 >>>>>>> >> >> >>>>>>> >> >> The only difference I've needed is a local patch for Glibc (I >>>>>>> used 2.20) to fix build error (the patch is attached). >>>>>>> >> >> >>>>>>> >> >> I'm also attaching the patch I used to enable ASan in GCC for >>>>>>> MIPS (you can apply it on step 7). >>>>>>> >> >> >>>>>>> >> >> Once you've built toolchain, you can simple test: >>>>>>> >> >> >>>>>>> >> >> $ mips-linux-gcc -fsanitize=address >>>>>>> <gcc_tree_location>/gcc/testsuite/c-c++-common/asan/heap-overflow-1.c >>>>>>> -fstack-protector >>>>>>> >> >> $ qemu-mips -L $SYSROOT -R 0 ./a.out >>>>>>> >> >> >>>>>>> >> >> ============================================================ >>>>>>> ===== >>>>>>> >> >> ==9453==ERROR: AddressSanitizer: heap-buffer-overflow on >>>>>>> address 0x42c007ba at pc 0x00400a94 bp 0x407ffca0 sp 0x407ffcc8 >>>>>>> >> >> READ of size 1 at 0x42c007ba thread T0 >>>>>>> >> >> #0 0x400a8c (/home/max/build/mips/gcc/a.out+0x400a8c) >>>>>>> >> >> #1 0x40e5a36c (/opt/cross/mips//mips-linux/ >>>>>>> lib/libc.so.6+0x1936c) >>>>>>> >> >> >>>>>>> >> >> 0x42c007ba is located 0 bytes to the right of 10-byte region >>>>>>> [0x42c007b0,0x42c007ba) >>>>>>> >> >> allocated by thread T0 here: >>>>>>> >> >> #0 0x4093fe9c (/opt/cross/mips//mips-linux/ >>>>>>> lib/libasan.so.4+0x107e9c) >>>>>>> >> >> #1 0x4009e4 (/home/max/build/mips/gcc/a.out+0x4009e4) >>>>>>> >> >> #2 0x40e5a36c (/opt/cross/mips//mips-linux/ >>>>>>> lib/libc.so.6+0x1936c) >>>>>>> >> >> >>>>>>> >> >> SUMMARY: AddressSanitizer: heap-buffer-overflow >>>>>>> (/home/max/build/mips/gcc/a.out+0x400a8c) >>>>>>> >> >> Shadow bytes around the buggy address: >>>>>>> >> >> 0x130200a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >> 0x130200b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >> 0x130200c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >> 0x130200d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >> 0x130200e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >> =>0x130200f0: fa fa fa fa fa fa 00[02]fa fa fa fa fa fa fa fa >>>>>>> >> >> 0x13020100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >> 0x13020110: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >> 0x13020120: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >> 0x13020130: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >> 0x13020140: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >> Shadow byte legend (one shadow byte represents 8 application >>>>>>> bytes): >>>>>>> >> >> Addressable: 00 >>>>>>> >> >> Partially addressable: 01 02 03 04 05 06 07 >>>>>>> >> >> Heap left redzone: fa >>>>>>> >> >> Freed heap region: fd >>>>>>> >> >> Stack left redzone: f1 >>>>>>> >> >> Stack mid redzone: f2 >>>>>>> >> >> Stack right redzone: f3 >>>>>>> >> >> Stack after return: f5 >>>>>>> >> >> Stack use after scope: f8 >>>>>>> >> >> Global redzone: f9 >>>>>>> >> >> Global init order: f6 >>>>>>> >> >> Poisoned by user: f7 >>>>>>> >> >> Container overflow: fc >>>>>>> >> >> Array cookie: ac >>>>>>> >> >> Intra object redzone: bb >>>>>>> >> >> ASan internal: fe >>>>>>> >> >> Left alloca redzone: ca >>>>>>> >> >> Right alloca redzone: cb >>>>>>> >> >> ==9453==ABORTING >>>>>>> >> >> >>>>>>> >> >> Note that I've added -fstack-protector flag to avoid "cc1: >>>>>>> warning: -fsanitize=address and -fsanitize=kernel-address are not >>>>>>> supported >>>>>>> for this target" error on compilation step. This is weird, but for some >>>>>>> reason GCC folks use this flag to control FRAME_GROWS_DOWNWARD macro om >>>>>>> MIPS. >>>>>>> >> >> GCC's ASan doesn't support targets with FRAME_GROWS_DOWNWARD >>>>>>> == 0 so I just added -fstack-protector as a workaround. >>>>>>> >> >> >>>>>>> >> >> >>>>>>> >> >>> >>>>>>> >> >>> >>>>>>> >> >>> Keep you posted on further tries. Many thanks >>>>>>> >> >>> Kit >>>>>>> >> >>> >>>>>>> >> >>> 2016년 11월 19일 토요일 오전 11시 19분 34초 UTC, [email protected] >>>>>>> 님의 말: >>>>>>> >> >>>> >>>>>>> >> >>>> Hi Park, >>>>>>> >> >>>> >>>>>>> >> >>>> Following are the steps for building LLVM and compiler-rt >>>>>>> for target MIPS (Host=x86, Target=MIPS): >>>>>>> >> >>>> Install prerequisites with "sudo apt-get install cmake >>>>>>> ninja-build gcc-5-mipsel-linux-gnu g++-5-mipsel-linux-gnu >>>>>>> gcc-5-multilib-mipsel-linux-gnu g++-5-multilib-mipsel-linux-gnu >>>>>>> binutils-mipsel-linux-gnu libgcc1-mipsel-cross libstdc++6-mipsel-cross" >>>>>>> >> >>>> Checkout llvm. >>>>>>> >> >>>> Checkout clang in /llvm/tools/ >>>>>>> >> >>>> Build LLVM cross compiler which targets MIPS. >>>>>>> >> >>>> Run "cmake -G Ninja ../llvm >>>>>>> >> >>>> -DCMAKE_INSTALL_PREFIX=<path-to-install-dir> >>>>>>> -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=<install-dir> >>>>>>> -DLLVM_DEFAULT_TARGET_TRIPLE=mipsel-linux-gnu >>>>>>> -DLLVM_TARGET_ARCH=Mips -DLLVM_TARGETS_TO_BUILD=Mips" in a build >>>>>>> directory. >>>>>>> >> >>>> Run "ninja; ninja install" >>>>>>> >> >>>> Checkout compiler-rt >>>>>>> >> >>>> Build compiler-rt in a separate build directory using the >>>>>>> just built llvm cross compiler. >>>>>>> >> >>>> Run "cmake -G Ninja ../compiler-rt/ >>>>>>> -DCMAKE_C_COMPILER=<path-to-where-llvm-was-installed>/bin/clang >>>>>>> -DCMAKE_CXX_COMPILER=<path-to-where-llvm-was-installed>/bin/clang++ >>>>>>> -DCMAKE_BUILD_TYPE=Release -DLLVM_CONFIG_PATH=<path-to-wh >>>>>>> ere-llvm-was-installed>//bin/llvm-config >>>>>>> -DCOMPILER_RT_INSTALL_PATH=<path-to-where-llvm-was-installed>//lib/clang/4.0.0 >>>>>>> -DCMAKE_C_FLAGS="-I/usr/mipsel-linux-gnu/include/ >>>>>>> -Wl,-L/usr/mipsel-linux-gnu/lib/" >>>>>>> -DCMAKE_CXX_FLAGS="-I/usr/mipsel-linux-gnu/include/ >>>>>>> -Wl,-L/usr/mipsel-linux-gnu/lib/"" in a separate build directory. >>>>>>> >> >>>> Run "ninja; ninja install" >>>>>>> >> >>>> You can also use the GCC cross tool chain instead of the >>>>>>> just built LLVM cross tool chain to build the compiler-rt sources. >>>>>>> >> >>>> >>>>>>> >> >>>> Running a simple test from the ASAN test suite: >>>>>>> >> >>>> >>>>>>> >> >>>> $ <path-to-where-llvm-was-installed>/bin/clang >>>>>>> -fsanitize=address >>>>>>> -Wl,--dynamic-linker=/usr/mipsel-linux-gnu/lib/ld.so.1 >>>>>>> use-after-free.cc >>>>>>> >> >>>> >>>>>>> >> >>>> $ qemu-mipsel -cpu 74Kf -E >>>>>>> >> >>>> LD_LIBRARY_PATH=/usr/mipsel-linux-gnu/lib/ >>>>>>> a.out >>>>>>> >> >>>> ============================================================ >>>>>>> ===== >>>>>>> >> >>>> ==1487==ERROR: AddressSanitizer: heap-use-after-free on >>>>>>> address 0x74d007b5 at pc 0x0052d518 bp 0x76fff5c0 sp 0x76fff5e4 >>>>>>> >> >>>> READ of size 1 at 0x74d007b5 thread T0 >>>>>>> >> >>>> #0 0x52d510 (/home/slt/Tests/a.out+0x52d510) >>>>>>> >> >>>> #1 0x76535bd4 (/usr/mipsel-linux-gnu/lib/lib >>>>>>> c.so.6+0x19bd4) >>>>>>> >> >>>> >>>>>>> >> >>>> 0x74d007b5 is located 5 bytes inside of 10-byte region >>>>>>> [0x74d007b0,0x74d007ba) >>>>>>> >> >>>> freed by thread T0 here: >>>>>>> >> >>>> #0 0x4f4124 (/home/slt/Tests/a.out+0x4f4124) >>>>>>> >> >>>> #1 0x52d4a8 (/home/slt/Tests/a.out+0x52d4a8) >>>>>>> >> >>>> #2 0x76535bd4 (/usr/mipsel-linux-gnu/lib/lib >>>>>>> c.so.6+0x19bd4) >>>>>>> >> >>>> >>>>>>> >> >>>> previously allocated by thread T0 here: >>>>>>> >> >>>> #0 0x4f4580 (/home/slt/Tests/a.out+0x4f4580) >>>>>>> >> >>>> #1 0x52d498 (/home/slt/Tests/a.out+0x52d498) >>>>>>> >> >>>> #2 0x76535bd4 (/usr/mipsel-linux-gnu/lib/lib >>>>>>> c.so.6+0x19bd4) >>>>>>> >> >>>> >>>>>>> >> >>>> SUMMARY: AddressSanitizer: heap-use-after-free >>>>>>> (/home/slt/Tests/a.out+0x52d510) >>>>>>> >> >>>> Shadow bytes around the buggy address: >>>>>>> >> >>>> 0x194400a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >>>> 0x194400b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >>>> 0x194400c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >>>> 0x194400d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >>>> 0x194400e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >>>> =>0x194400f0: fa fa fa fa fa fa[fd]fd fa fa fa fa fa fa fa fa >>>>>>> >> >>>> 0x19440100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >>>> 0x19440110: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >>>> 0x19440120: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >>>> 0x19440130: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >>>> 0x19440140: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa >>>>>>> >> >>>> Shadow byte legend (one shadow byte represents 8 application >>>>>>> bytes): >>>>>>> >> >>>> Addressable: 00 >>>>>>> >> >>>> Partially addressable: 01 02 03 04 05 06 07 >>>>>>> >> >>>> Heap left redzone: fa >>>>>>> >> >>>> Freed heap region: fd >>>>>>> >> >>>> Stack left redzone: f1 >>>>>>> >> >>>> Stack mid redzone: f2 >>>>>>> >> >>>> Stack right redzone: f3 >>>>>>> >> >>>> Stack after return: f5 >>>>>>> >> >>>> Stack use after scope: f8 >>>>>>> >> >>>> Global redzone: f9 >>>>>>> >> >>>> Global init order: f6 >>>>>>> >> >>>> Poisoned by user: f7 >>>>>>> >> >>>> Container overflow: fc >>>>>>> >> >>>> Array cookie: ac >>>>>>> >> >>>> Intra object redzone: bb >>>>>>> >> >>>> ASan internal: fe >>>>>>> >> >>>> Left alloca redzone: ca >>>>>>> >> >>>> Right alloca redzone: cb >>>>>>> >> >>>> ==1487==ABORTING >>>>>>> >> >>>> >>>>>>> >> >>>> To cross build a complete LLVM toolchain which will run on >>>>>>> MIPS and target to MIPS (Host=MIPS, Target=MIPS): >>>>>>> >> >>>> Install prerequisites with "sudo apt-get install cmake >>>>>>> ninja-build gcc-5-mipsel-linux-gnu g++-5-mipsel-linux-gnu >>>>>>> gcc-5-multilib-mipsel-linux-gnu g++-5-multilib-mipsel-linux-gnu >>>>>>> binutils-mipsel-linux-gnu libgcc1-mipsel-cross libstdc++6-mipsel-cross" >>>>>>> >> >>>> Checkout llvm >>>>>>> >> >>>> Checkout clang in /llvm/tools/ >>>>>>> >> >>>> Checkout compiler-rt in /llvm/projects/ >>>>>>> >> >>>> Run "cmake -G Ninja ../llvm >>>>>>> >> >>>> -DCMAKE_INSTALL_PREFIX=<path-to-install-dir> >>>>>>> -DCMAKE_BUILD_TYPE=Release -DCMAKE_CROSSCOMPILING=True >>>>>>> -DLLVM_TABLEGEN=<path-to-host-bin>/llvm-tblgen >>>>>>> -DCLANG_TABLEGEN=<path-to-host-bin>/clang-tblgen >>>>>>> -DLLVM_HOST_TRIPLE=mipsel-linux-gnu >>>>>>> -DLLVM_DEFAULT_TARGET_TRIPLE=mipsel-linux-gnu >>>>>>> -DLLVM_TARGET_ARCH=Mips -DLLVM_TARGETS_TO_BUILD=Mips >>>>>>> -DCMAKE_C_COMPILER="/usr/bin/mipsel-linux-gnu-gcc-5" >>>>>>> -DCMAKE_CXX_COMPILER="/usr/bin/mipsel-linux-gnu-g++-5" >>>>>>> -DCMAKE_ASM_COMPILER="/usr/bin/mipsel-linux-gnu-gcc-5" >>>>>>> -DCMAKE_C_FLAGS="-mips32 -mabi=32" -DCMAKE_CXX_FLAGS="-mips32 >>>>>>> -mabi=32"" in >>>>>>> a build directory. >>>>>>> >> >>>> Run "ninja; ninja install" >>>>>>> >> >>>> >>>>>>> >> >>>> But "ninja install" does not copy the sanitizer runtime libs >>>>>>> in the install directory. So you will have to copy them to the install >>>>>>> directory manually. >>>>>>> >> >>>> >>>>>>> >> >>>> >>>>>>> >> >>>> Regarding GCC's ASAN support for MIPS, as Maxim said we will >>>>>>> have to add support for it following the steps he mentioned. >>>>>>> >> >>>> >>>>>>> >> >>>> >>>>>>> >> >>>> Regards, >>>>>>> >> >>>> >>>>>>> >> >>>> Sagar >>>>>>> >> >>>> >>>>>>> >> >>>> >>>>>>> >> >>>> >>>>>>> >> >>>> On Wednesday, November 16, 2016 at 1:13:06 PM UTC+5:30, Park >>>>>>> Kit wrote: >>>>>>> >> >>>>> >>>>>>> >> >>>>> Hi Sagar, >>>>>>> >> >>>>> >>>>>>> >> >>>>> Many thanks for a reply. Although I am seeking to have GCC >>>>>>> cross compile working, it would be great to know that ASAN builds for >>>>>>> mips >>>>>>> on clang. >>>>>>> >> >>>>> >>>>>>> >> >>>>> Looking forward to good news on that. >>>>>>> >> >>>>> >>>>>>> >> >>>>> Many thanks >>>>>>> >> >>>>> Kit >>>>>>> >> >>>>> >>>>>>> >> >>>>> 2016년 11월 15일 화요일 오후 6시 56분 48초 UTC, [email protected] >>>>>>> 님의 말: >>>>>>> >> >>>>>> >>>>>>> >> >>>>>> Hi Park, >>>>>>> >> >>>>>> >>>>>>> >> >>>>>> Sorry for the delay. >>>>>>> >> >>>>>> >>>>>>> >> >>>>>> In order to run ASAN on mips, we always did a native build >>>>>>> of compiler-rt on a real mips hardware. We never tried the cross build >>>>>>> of >>>>>>> compiler-rt. >>>>>>> >> >>>>>> >>>>>>> >> >>>>>> However, since you need the cross build, I will give it a >>>>>>> try and get back to you as soon as I get success. >>>>>>> >> >>>>>> >>>>>>> >> >>>>>> Regards, >>>>>>> >> >>>>>> Sagar >>>>>>> >> >>>>>> >>>>>>> >> >>>>>> On Tuesday, November 15, 2016 at 1:59:15 PM UTC+5:30, Park >>>>>>> Kit wrote: >>>>>>> >> >>>>>>> >>>>>>> >> >>>>>>> Hi all, >>>>>>> >> >>>>>>> >>>>>>> >> >>>>>>> Could anyone please give me some pointers to try? >>>>>>> >> >>>>>>> >>>>>>> >> >>>>>>> 2016년 10월 15일 토요일 오전 1시 21분 6초 UTC+1, kcc 님의 말: >>>>>>> >> >>>>>>>> >>>>>>> >> >>>>>>>> Sagar, Simon, >>>>>>> >> >>>>>>>> Could you please consult on ASAN for MIPS? >>>>>>> >> >>>>>>>> >>>>>>> >> >>>>>>>> On Fri, Oct 14, 2016 at 3:04 PM, Park Kit < >>>>>>> [email protected]> wrote: >>>>>>> >> >>>>>>>>> >>>>>>> >> >>>>>>>>> Correction. ASN means ASAN of course. :-) >>>>>>> >> >>>>>>>>> >>>>>>> >> >>>>>>>>> -- >>>>>>> >> >>>>>>>>> You received this message because you are subscribed to >>>>>>> the Google Groups "address-sanitizer" group. >>>>>>> >> >>>>>>>>> To unsubscribe from this group and stop receiving >>>>>>> emails from it, send an email to [email protected]. >>>>>>> >> >>>>>>>>> For more options, visit https://groups.google.com/d/op >>>>>>> tout. >>>>>>> >> >>>>>>>> >>>>>>> >> >>>>>>>> >>>>>>> >> >> -- >>>>>>> >> >> You received this message because you are subscribed to a >>>>>>> topic in the Google Groups "address-sanitizer" group. >>>>>>> >> >> To unsubscribe from this topic, visit >>>>>>> https://groups.google.com/d/topic/address-sanitizer/A5iPCUDa >>>>>>> 7YM/unsubscribe. >>>>>>> >> >> To unsubscribe from this group and all its topics, send an >>>>>>> email to [email protected]. >>>>>>> >> >> >>>>>>> >> >> For more options, visit https://groups.google.com/d/optout. >>>>>>> >> > >>>>>>> >> > >>>>>>> > >>>>>>> > >>>>>>> >>>>>> >>>>>> >>>>> >>>> >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "address-sanitizer" group. >>> To unsubscribe from this topic, visit https://groups.google.com/d/to >>> pic/address-sanitizer/A5iPCUDa7YM/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> > -- > You received this message because you are subscribed to the Google Groups > "address-sanitizer" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "address-sanitizer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
