[TTC-11] Embed UBSan into ASan runtime 63/158063/5 accepted/tizen/base/20171215.171112 submit/tizen_base/20171208.084018
authorMaxim Ostapenko <m.ostapenko@samsung.com>
Fri, 27 Oct 2017 12:14:27 +0000 (15:14 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Fri, 8 Dec 2017 08:37:21 +0000 (17:37 +0900)
commitc135181e3aee094be79134585645b6049ed133f3
treedede1008adc85513f546bf3b81dad59015d7def8
parent8ac9c3d09f4d2d0c162ccb0a4d695a0804e8c53b
[TTC-11] Embed UBSan into ASan runtime

Change the way we use ASan and UBSan together. Instead of keeping two
separate runtimes (libasan.so and libubsan.so), embed UBSan into ASan.
UBSan initialization code (e.g. flag parsing) is directly called
from ASan initialization, so we are able to enforce correct
initialization order.

This mirrors the approach we already use for ASan+LSan. This change
doesn't modify the way we use standalone UBSan.

gcc/
* config/gnu-user.h: append -lstdc++ if we link against ASan
runtime.
* gcc.c: Do not link against libubsan.so if
-fsanitize=address,undefined is used.

gcc/testsuite/
* c-c++-common/asan/asan_and_ubsan-1.c: New test.

libsanitizer/

* Makefile.am: Build UBSan strictly before ASan.
* Makefile.in: Regenerate.
* asan/Makefile.am: Embed UBSan into ASan runtime.
* asan/Makefile.in: Regenerate.
* configure.ac: Configure UBSan strictly before ASan.
* configure: Regenerate.
ubsan/ubsan_diag.cc (__sanitizer_print_stack_trace): Move to ...
ubsan/ubsan_diag_standalone.cc: ... here.
* ubsan/Makefile.am: Create a "plugin" library to be embedded
into ASan runtime.
* ubsan/Makefile.in: Regenerate.

Change-Id: Ia848a93929effb4b0ec057243c7343c1bd94fbfb
Signed-off-by: Maxim Ostapenko <m.ostapenko@samsung.com>
14 files changed:
ChangeLog.Tizen
gcc/config/gnu-user.h
gcc/gcc.c
gcc/testsuite/c-c++-common/asan/asan_and_ubsan-1.c [new file with mode: 0644]
libsanitizer/Makefile.am
libsanitizer/Makefile.in
libsanitizer/asan/Makefile.am
libsanitizer/asan/Makefile.in
libsanitizer/configure
libsanitizer/configure.ac
libsanitizer/ubsan/Makefile.am
libsanitizer/ubsan/Makefile.in
libsanitizer/ubsan/ubsan_diag.cc
libsanitizer/ubsan/ubsan_diag_standalone.cc [new file with mode: 0644]