fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers
Log | Files | Refs | README | LICENSE

Makefile (6497B)


      1 CFLAGS+=-I../include/ -D_FORTIFY_SOURCE=3 -static -O2 -DFORTIFY_PEDANTIC_CHECKS -Wno-format -Werror=pointer-arith
      2 
      3 COMPTIME_TARGETS= \
      4 	test_memcpy_overwrite_under  \
      5 	test_memcpy_static_write     \
      6 
      7 
      8 RUNTIME_TARGETS= \
      9 	test_FD_CLR_SETSIZE          \
     10 	test_FD_CLR_negative         \
     11 	test_FD_SET_SETSIZE          \
     12 	test_FD_SET_negative         \
     13 	test_FD_ISSET_SETSIZE        \
     14 	test_FD_ISSET_negative       \
     15 	test_asprintf                \
     16 	test_bcopy_dynamic_read      \
     17 	test_bcopy_dynamic_write     \
     18 	test_bcopy_static_read       \
     19 	test_bcopy_static_write      \
     20 	test_bzero_dynamic_write     \
     21 	test_bzero_static_write      \
     22 	test_compile                 \
     23 	test_confstr_dynamic         \
     24 	test_confstr_static          \
     25 	test_fgets_dynamic           \
     26 	test_fgets_static            \
     27 	test_fgetws_dynamic          \
     28 	test_fgetws_static           \
     29 	test_fprintf                 \
     30 	test_fread_int_overflow      \
     31 	test_fread_overwrite_dynamic \
     32 	test_fread_overwrite_static  \
     33 	test_fwrite_int_overflow     \
     34 	test_fwrite_overwrite_dynamic \
     35 	test_fwrite_overwrite_static \
     36 	test_getcwd_dynamic          \
     37 	test_getcwd_static           \
     38 	test_getdomainname_dynamic   \
     39 	test_getdomainname_static    \
     40 	test_getgroups_dynamic       \
     41 	test_getgroups_static        \
     42 	test_gethostname_dynamic     \
     43 	test_gethostname_static      \
     44 	test_getlogin_r_dynamic      \
     45 	test_getlogin_r_static       \
     46 	test_issue57                 \
     47 	test_issue57_strcpy          \
     48 	test_mbsrtowcs_dynamic       \
     49 	test_mbsrtowcs_static        \
     50 	test_mbstowcs_dynamic        \
     51 	test_mbstowcs_static         \
     52 	test_memchr_dynamic_read     \
     53 	test_memchr_static_read      \
     54 	test_memchr_null             \
     55 	test_memcpy_dynamic_read     \
     56 	test_memcpy_dynamic_write    \
     57 	test_memcpy_overwrite_over   \
     58 	test_memcpy_static_read      \
     59 	test_memcpy_null_src         \
     60 	test_memcpy_null_dst         \
     61 	test_memmove_null_src        \
     62 	test_memmove_null_dst        \
     63 	test_memmove_dynamic_read    \
     64 	test_memmove_dynamic_write   \
     65 	test_memmove_static_read     \
     66 	test_memmove_static_write    \
     67 	test_mempcpy_dynamic_read    \
     68 	test_mempcpy_dynamic_write   \
     69 	test_mempcpy_static_read     \
     70 	test_mempcpy_static_write    \
     71 	test_memset_dynamic_write    \
     72 	test_memset_static_write     \
     73 	test_memset_null             \
     74 	test_poll_dynamic            \
     75 	test_poll_static             \
     76 	test_ppoll_dynamic           \
     77 	test_ppoll_static            \
     78 	test_pread_dynamic           \
     79 	test_pread_static            \
     80 	test_printf                  \
     81 	test_pwrite_dynamic          \
     82 	test_pwrite_static           \
     83 	test_qsort_dynamic           \
     84 	test_qsort_static            \
     85 	test_read_dynamic            \
     86 	test_read_static             \
     87 	test_readlink_dynamic        \
     88 	test_readlink_static         \
     89 	test_recv_dynamic            \
     90 	test_recv_static             \
     91 	test_recvfrom_dynamic        \
     92 	test_recvfrom_static         \
     93 	test_select_dynamic          \
     94 	test_select_static           \
     95 	test_send_dynamic            \
     96 	test_send_static             \
     97 	test_sendto_dynamic          \
     98 	test_sendto_static           \
     99 	test_sprintf                 \
    100 	test_sprintf_62              \
    101 	test_stpcpy_dynamic_write    \
    102 	test_stpcpy_overwrite_over   \
    103 	test_stpcpy_overwrite_under  \
    104 	test_stpcpy_static_write     \
    105 	test_stpncpy_dynamic_write   \
    106 	test_stpncpy_overwrite_over  \
    107 	test_stpncpy_overwrite_under \
    108 	test_stpncpy_static_write    \
    109 	test_strlen_static_read      \
    110 	test_strcat_static_write     \
    111 	test_strchr_dynamic_read     \
    112 	test_strchr_static_read      \
    113 	test_strcpy_dynamic_write    \
    114 	test_strcpy_overwrite_over   \
    115 	test_strcpy_overwrite_under  \
    116 	test_strcpy_static_write     \
    117 	test_strlcat_dynamic_write   \
    118 	test_strlcat_static_write    \
    119 	test_strlcpy_dynamic_write   \
    120 	test_strlcpy_static_write    \
    121 	test_strncat_dynamic_write   \
    122 	test_strncat_static_write    \
    123 	test_strncpy_dynamic_write   \
    124 	test_strncpy_overwrite_over  \
    125 	test_strncpy_overwrite_under \
    126 	test_strncpy_static_write    \
    127 	test_strrchr_dynamic_read    \
    128 	test_strrchr_static_read     \
    129 	test_ttyname_r_dynamic       \
    130 	test_ttyname_r_static        \
    131 	test_umask                   \
    132 	test_vasprintf               \
    133 	test_vfprintf                \
    134 	test_vprintf                 \
    135 	test_vsnprintf_dynamic       \
    136 	test_vsnprintf_static        \
    137 	test_vsprintf                \
    138 	test_wcscat_static_write     \
    139 	test_wcscpy_static_write     \
    140 	test_wcsncat_static_write    \
    141 	test_wcsncpy_static_write    \
    142 	test_wmemcpy_dynamic_write   \
    143 	test_wmemcpy_static_write    \
    144 	test_wmemmove_dynamic_write  \
    145 	test_wmemmove_static_write   \
    146 	test_wmemset_dynamic         \
    147 	test_wmemset_static          \
    148 	test_write_dynamic           \
    149 	test_write_static            \
    150 
    151 .SILENT:
    152 
    153 gcc: CC=../x86_64-linux-musl-native/bin/gcc
    154 gcc: $(RUNTIME_TARGETS)
    155 
    156 clang: CC=clang
    157 clang: CFLAGS+=-I/usr/include/x86_64-linux-musl
    158 clang: CFLAGS+=-I../x86_64-linux-musl-native/include/
    159 clang: CFLAGS+=-Ix86_64-linux-musl-native/include/
    160 clang: CFLAGS+=-nostdinc
    161 clang: CXX=clang++
    162 clang: CXXFLAGS+=-I/usr/include/x86_64-linux-musl
    163 clang: CXXFLAGS+=-I../x86_64-linux-musl-native/include/
    164 clang: CXXFLAGS+=-Ix86_64-linux-musl-native/include/
    165 clang: CXXFLAGS+=-nostdinc
    166 clang: comptime $(RUNTIME_TARGETS) cpp
    167 
    168 coverage: CFLAGS += -fprofile-arcs -ftest-coverage
    169 coverage: CC=../x86_64-linux-musl-native/bin/gcc
    170 coverage: GCOV=../x86_64-linux-musl-native/bin/gcov
    171 coverage: $(RUNTIME_TARGETS) run
    172 	$(GCOV) *.c
    173 	lcov --capture --directory . --output-file coverage.info
    174 	lcov --remove ./coverage.info "*/tests/*" --output-file cleaned-coverage.info
    175 	genhtml cleaned-coverage.info --output-directory coverage
    176 
    177 all: gcc
    178 
    179 
    180 $(RUNTIME_TARGETS): %: %.c
    181 	$(CC) $(CFLAGS) -o $@ $<
    182 
    183 cpp: test_compile.cc
    184 	$(CXX) $(CXXFLAGS) test_compile.cc -o ./test_compile_cc
    185 	timeout 1s ./test_compile_cc 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \
    186 
    187 run: $(RUNTIME_TARGETS)
    188 	$(foreach EXE, $(RUNTIME_TARGETS), \
    189 		timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \
    190 	)
    191 
    192 comptime:  # only works on clang, as gcc doesn't have the diagnose_if attribute
    193 	$(foreach EXE, $(COMPTIME_TARGETS), \
    194 		($(CC) $(CFLAGS) -o ./$(EXE) ./$(EXE).c 1>/dev/null 2>/dev/null && echo "$(EXE) FAIL" || echo "$(EXE) OK") || true ;\
    195 	)
    196 
    197 clean:
    198 	$(foreach EXE, $(RUNTIME_TARGETS) $(COMPTIME_TARGETS), \
    199 		rm -f ./$(EXE) \
    200 	)
    201 	rm -f ./test_compile_cc
    202 	rm -rf ./*.gcno ./*.gcda ./*.gcov ./coverage.info ./coverage
    203