[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] [PATCH] Add support for using address-sanitizer to run th

From: Yichun Zhang (agentzh)
Subject: [Tinycc-devel] [PATCH] Add support for using address-sanitizer to run the test suite
Date: Wed, 5 Dec 2018 22:43:07 -0800

When building tcc with

    ./configure --extra-cflags='-Wall -g -O2 -fsanitize=address' \

Then the test suite can be run with gcc's address-sanitizer enabled:

    make test

The address-sanitizer can also successfully catch the use-after-free bug
revealed by valgrind and fixed here:

 tests/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile b/tests/Makefile
index 5f6777d..fd843c7 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -134,7 +134,7 @@ dlltest:
        ./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c
 ifndef CONFIG_WIN32
        @echo ------------ $@ with PIC ------------
+       $(CC) $(filter-out -f%,$(CFLAGS)) -fPIC $(NATIVE_DEFINES) 
-DLIBTCC_AS_DLL -c $(TOPSRC)/libtcc.c
        $(TCC) libtcc.o $(LIBS) -shared -o libtcc2$(DLLSUF)
        $(TCC) $(NATIVE_DEFINES) -DONE_SOURCE=0 $(TOPSRC)/tcc.c 
libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF)
        ./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c

reply via email to

[Prev in Thread] Current Thread [Next in Thread]