| 1 |
# Copyright (C) 1991-2026 Free Software Foundation, Inc. |
| 2 |
# This file is part of the GNU C Library. |
| 3 |
|
| 4 |
# The GNU C Library is free software; you can redistribute it and/or |
| 5 |
# modify it under the terms of the GNU Lesser General Public |
| 6 |
# License as published by the Free Software Foundation; either |
| 7 |
# version 2.1 of the License, or (at your option) any later version. |
| 8 |
|
| 9 |
# The GNU C Library is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
# Lesser General Public License for more details. |
| 13 |
|
| 14 |
# You should have received a copy of the GNU Lesser General Public |
| 15 |
# License along with the GNU C Library; if not, see |
| 16 |
# <https://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
# |
| 19 |
# Makefile for malloc routines |
| 20 |
# |
| 21 |
subdir := malloc |
| 22 |
|
| 23 |
include ../Makeconfig |
| 24 |
|
| 25 |
dist-headers := malloc.h |
| 26 |
headers := $(dist-headers) obstack.h mcheck.h |
| 27 |
tests := \ |
| 28 |
mallocbug \ |
| 29 |
tst-aligned-alloc \ |
| 30 |
tst-aligned-alloc-random \ |
| 31 |
tst-aligned-alloc-random-thread \ |
| 32 |
tst-aligned-alloc-random-thread-cross \ |
| 33 |
tst-alloc_buffer \ |
| 34 |
tst-calloc \ |
| 35 |
tst-free-aligned-sized \ |
| 36 |
tst-free-aligned-sized-trace \ |
| 37 |
tst-free-errno \ |
| 38 |
tst-free-sized \ |
| 39 |
tst-free-sized-trace \ |
| 40 |
tst-interpose-nothread \ |
| 41 |
tst-interpose-thread \ |
| 42 |
tst-malloc \ |
| 43 |
tst-malloc-alternate-path \ |
| 44 |
tst-malloc-backtrace \ |
| 45 |
tst-malloc-check \ |
| 46 |
tst-malloc-fork-deadlock \ |
| 47 |
tst-malloc-random \ |
| 48 |
tst-malloc-stats-cancellation \ |
| 49 |
tst-malloc-tcache-leak \ |
| 50 |
tst-malloc-thread-exit \ |
| 51 |
tst-malloc-thread-fail \ |
| 52 |
tst-malloc-too-large \ |
| 53 |
tst-malloc-usable \ |
| 54 |
tst-malloc_info tst-mallinfo2 \ |
| 55 |
tst-mallocalign1 \ |
| 56 |
tst-mallocfork \ |
| 57 |
tst-mallocfork2 \ |
| 58 |
tst-mallocfork3 \ |
| 59 |
tst-mallopt \ |
| 60 |
tst-memalign \ |
| 61 |
tst-memalign-2 \ |
| 62 |
tst-memalign-3 \ |
| 63 |
tst-obstack \ |
| 64 |
tst-posix_memalign \ |
| 65 |
tst-pvalloc \ |
| 66 |
tst-pvalloc-fortify \ |
| 67 |
tst-realloc \ |
| 68 |
tst-reallocarray \ |
| 69 |
tst-safe-linking \ |
| 70 |
tst-tcfree1 tst-tcfree2 tst-tcfree3 tst-tcfree4 \ |
| 71 |
tst-trim1 \ |
| 72 |
tst-valloc \ |
| 73 |
# tests |
| 74 |
|
| 75 |
tests-static := \ |
| 76 |
tst-aligned-alloc-static \ |
| 77 |
tst-interpose-static-nothread \ |
| 78 |
tst-interpose-static-thread \ |
| 79 |
# tests-static |
| 80 |
|
| 81 |
# Test for the malloc_set_state symbol removed in glibc 2.25. |
| 82 |
ifeq ($(have-GLIBC_2.23)$(build-shared),yesyes) |
| 83 |
tests += \ |
| 84 |
tst-compathooks-off \ |
| 85 |
tst-compathooks-on \ |
| 86 |
tst-mallocstate \ |
| 87 |
# tests |
| 88 |
endif |
| 89 |
|
| 90 |
tests-internal := tst-scratch_buffer |
| 91 |
|
| 92 |
# The dynarray framework is only available inside glibc. |
| 93 |
tests-internal += \ |
| 94 |
tst-dynarray \ |
| 95 |
tst-dynarray-at-fail \ |
| 96 |
tst-dynarray-fail \ |
| 97 |
# tests-internal |
| 98 |
|
| 99 |
tests += \ |
| 100 |
tst-malloc-usable-tunables \ |
| 101 |
# tests |
| 102 |
|
| 103 |
tests += $(tests-static) |
| 104 |
test-srcs = tst-mtrace |
| 105 |
|
| 106 |
# These tests either are run with MALLOC_CHECK_=3 by default or do not work |
| 107 |
# with MALLOC_CHECK_=3 because they expect a specific failure. |
| 108 |
tests-exclude-malloc-check = \ |
| 109 |
tst-compathooks-off \ |
| 110 |
tst-compathooks-on \ |
| 111 |
tst-malloc-check \ |
| 112 |
tst-malloc-tcache-leak \ |
| 113 |
tst-malloc-usable \ |
| 114 |
tst-mallocfork2 \ |
| 115 |
tst-mallocfork3 \ |
| 116 |
tst-memalign-2 \ |
| 117 |
tst-memalign-3 \ |
| 118 |
tst-safe-linking \ |
| 119 |
tst-tcfree4 \ |
| 120 |
# tests-exclude-malloc-check |
| 121 |
|
| 122 |
# Run all tests with MALLOC_CHECK_=3 |
| 123 |
tests-malloc-check = $(filter-out $(tests-exclude-malloc-check) \ |
| 124 |
$(tests-static),$(tests)) |
| 125 |
|
| 126 |
# Run all tests with GLIBC_TUNABLES=glibc.malloc.hugetlb={1,2} which check |
| 127 |
# the Transparent Huge Pages support (1) or automatic huge page support (2). |
| 128 |
# We need exclude some tests that define the ENV vars. |
| 129 |
tests-exclude-hugetlb1 = \ |
| 130 |
tst-compathooks-off \ |
| 131 |
tst-compathooks-on \ |
| 132 |
tst-interpose-nothread \ |
| 133 |
tst-interpose-static-nothread \ |
| 134 |
tst-interpose-static-thread \ |
| 135 |
tst-interpose-thread \ |
| 136 |
tst-malloc-tcache-leak \ |
| 137 |
tst-malloc-usable \ |
| 138 |
tst-malloc-usable-tunables \ |
| 139 |
tst-mallocfork2 \ |
| 140 |
tst-mallocfork3 \ |
| 141 |
tst-mallocstate \ |
| 142 |
# tests-exclude-hugetlb1 |
| 143 |
# The tst-free-errno relies on the used malloc page size to mmap an |
| 144 |
# overlapping region. |
| 145 |
tests-exclude-hugetlb2 = \ |
| 146 |
$(tests-exclude-hugetlb1) \ |
| 147 |
tst-free-errno |
| 148 |
tests-malloc-hugetlb1 = \ |
| 149 |
$(filter-out $(tests-exclude-hugetlb1), $(tests)) |
| 150 |
tests-malloc-hugetlb2 = \ |
| 151 |
$(filter-out $(tests-exclude-hugetlb2), $(tests)) |
| 152 |
|
| 153 |
tests-exclude-largetcache = \ |
| 154 |
tst-compathooks-off \ |
| 155 |
tst-compathooks-on \ |
| 156 |
tst-interpose-nothread \ |
| 157 |
tst-interpose-static-nothread \ |
| 158 |
tst-interpose-static-thread \ |
| 159 |
tst-interpose-thread \ |
| 160 |
tst-malloc-backtrace \ |
| 161 |
tst-malloc-usable \ |
| 162 |
tst-malloc-usable-tunables \ |
| 163 |
tst-mallocstate \ |
| 164 |
# tests-exclude-largetcache |
| 165 |
|
| 166 |
tests-malloc-largetcache = \ |
| 167 |
$(filter-out $(tests-exclude-largetcache), $(tests)) |
| 168 |
|
| 169 |
# -lmcheck needs __malloc_initialize_hook, which was deprecated in 2.24. |
| 170 |
ifeq ($(have-GLIBC_2.23)$(build-shared),yesyes) |
| 171 |
# Tests that don't play well with mcheck. They are either bugs in mcheck or |
| 172 |
# the tests expect specific internal behavior that is changed due to linking to |
| 173 |
# libmcheck.a. |
| 174 |
tests-exclude-mcheck = \ |
| 175 |
tst-aligned-alloc-random-thread \ |
| 176 |
tst-aligned-alloc-random-thread-cross \ |
| 177 |
tst-compathooks-off \ |
| 178 |
tst-compathooks-on \ |
| 179 |
tst-malloc-backtrace \ |
| 180 |
tst-malloc-fork-deadlock \ |
| 181 |
tst-malloc-stats-cancellation \ |
| 182 |
tst-malloc-tcache-leak \ |
| 183 |
tst-malloc-thread-exit \ |
| 184 |
tst-malloc-thread-fail \ |
| 185 |
tst-malloc-usable-tunables \ |
| 186 |
tst-malloc_info \ |
| 187 |
tst-mallocfork2 \ |
| 188 |
tst-mallocfork3 \ |
| 189 |
tst-mallocstate \ |
| 190 |
tst-memalign-2 \ |
| 191 |
tst-memalign-3 \ |
| 192 |
tst-safe-linking \ |
| 193 |
# tests-exclude-mcheck |
| 194 |
|
| 195 |
tests-mcheck = $(filter-out $(tests-exclude-mcheck) $(tests-static), $(tests)) |
| 196 |
endif |
| 197 |
|
| 198 |
routines = malloc mcheck mtrace obstack reallocarray \ |
| 199 |
scratch_buffer_grow scratch_buffer_grow_preserve \ |
| 200 |
scratch_buffer_set_array_size \ |
| 201 |
dynarray_at_failure \ |
| 202 |
dynarray_emplace_enlarge \ |
| 203 |
dynarray_finalize \ |
| 204 |
dynarray_resize \ |
| 205 |
dynarray_resize_clear \ |
| 206 |
alloc_buffer_alloc_array \ |
| 207 |
alloc_buffer_allocate \ |
| 208 |
alloc_buffer_copy_bytes \ |
| 209 |
alloc_buffer_copy_string \ |
| 210 |
alloc_buffer_create_failure \ |
| 211 |
|
| 212 |
install-lib := libmcheck.a |
| 213 |
non-lib.a := libmcheck.a |
| 214 |
|
| 215 |
# Additional libraries. |
| 216 |
extra-libs = libmemusage libc_malloc_debug |
| 217 |
extra-libs-others = $(extra-libs) |
| 218 |
|
| 219 |
# Helper objects for some tests. |
| 220 |
extra-test-objs += \ |
| 221 |
tst-aligned_alloc-lib.so \ |
| 222 |
tst-interpose-aux-nothread.o \ |
| 223 |
tst-interpose-aux-thread.o \ |
| 224 |
# extra-test-objs |
| 225 |
|
| 226 |
test-extras = \ |
| 227 |
tst-interpose-aux-nothread \ |
| 228 |
tst-interpose-aux-thread \ |
| 229 |
# test-extras |
| 230 |
|
| 231 |
modules-names = \ |
| 232 |
tst-aligned_alloc-lib |
| 233 |
|
| 234 |
libmemusage-routines = memusage |
| 235 |
libmemusage-inhibit-o = $(filter-out .os,$(object-suffixes)) |
| 236 |
|
| 237 |
libc_malloc_debug-routines = malloc-debug $(sysdep_malloc_debug_routines) |
| 238 |
libc_malloc_debug-inhibit-o = $(filter-out .os,$(object-suffixes)) |
| 239 |
|
| 240 |
tests-link-with-libpthread = \ |
| 241 |
tst-aligned-alloc-random-thread \ |
| 242 |
tst-aligned-alloc-random-thread-cross \ |
| 243 |
tst-aligned-alloc-random-thread-cross-malloc-check \ |
| 244 |
tst-aligned-alloc-random-thread-cross-malloc-hugetlb1 \ |
| 245 |
tst-aligned-alloc-random-thread-cross-malloc-hugetlb2 \ |
| 246 |
tst-aligned-alloc-random-thread-malloc-check \ |
| 247 |
tst-aligned-alloc-random-thread-malloc-hugetlb1 \ |
| 248 |
tst-aligned-alloc-random-thread-malloc-hugetlb2 \ |
| 249 |
tst-interpose-thread \ |
| 250 |
tst-interpose-thread-malloc-check \ |
| 251 |
tst-interpose-thread-mcheck \ |
| 252 |
tst-malloc-backtrace \ |
| 253 |
tst-malloc-backtrace-malloc-check \ |
| 254 |
tst-malloc-backtrace-mcheck \ |
| 255 |
tst-malloc-fork-deadlock \ |
| 256 |
tst-malloc-fork-deadlock-malloc-check \ |
| 257 |
tst-malloc-fork-deadlock-malloc-hugetlb1 \ |
| 258 |
tst-malloc-fork-deadlock-malloc-hugetlb2 \ |
| 259 |
tst-malloc-fork-deadlock-mcheck \ |
| 260 |
tst-malloc-stats-cancellation \ |
| 261 |
tst-malloc-stats-cancellation-malloc-check \ |
| 262 |
tst-malloc-stats-cancellation-malloc-hugetlb1 \ |
| 263 |
tst-malloc-stats-cancellation-malloc-hugetlb2 \ |
| 264 |
tst-malloc-stats-cancellation-mcheck \ |
| 265 |
tst-malloc-tcache-leak \ |
| 266 |
tst-malloc-thread-exit \ |
| 267 |
tst-malloc-thread-exit-malloc-check \ |
| 268 |
tst-malloc-thread-exit-malloc-hugetlb1 \ |
| 269 |
tst-malloc-thread-exit-malloc-hugetlb2 \ |
| 270 |
tst-malloc-thread-exit-mcheck \ |
| 271 |
tst-malloc-thread-fail \ |
| 272 |
tst-malloc-thread-fail-malloc-check \ |
| 273 |
tst-malloc-thread-fail-malloc-hugetlb1 \ |
| 274 |
tst-malloc-thread-fail-malloc-hugetlb2 \ |
| 275 |
tst-malloc-thread-fail-mcheck \ |
| 276 |
tst-malloc_info \ |
| 277 |
tst-malloc_info-malloc-check \ |
| 278 |
tst-malloc_info-malloc-hugetlb1 \ |
| 279 |
tst-malloc_info-malloc-hugetlb2 \ |
| 280 |
tst-malloc_info-mcheck \ |
| 281 |
tst-mallocfork2 \ |
| 282 |
tst-mallocfork2-malloc-check \ |
| 283 |
tst-mallocfork3 \ |
| 284 |
tst-mallocfork3-malloc-check \ |
| 285 |
tst-mallocfork3-mcheck \ |
| 286 |
tst-memalign-3 \ |
| 287 |
tst-memalign-3-malloc-hugetlb1 \ |
| 288 |
tst-memalign-3-malloc-hugetlb2 \ |
| 289 |
# tests-link-with-libpthread |
| 290 |
|
| 291 |
$(addprefix $(objpfx), $(tests-link-with-libpthread)): $(shared-thread-library) |
| 292 |
# Not all these tests are actually built, see tests-exclude-largetcache. |
| 293 |
$(tests-link-with-libpthread:%=$(objpfx)%-malloc-largetcache): \ |
| 294 |
$(shared-thread-library) |
| 295 |
|
| 296 |
# tests-threaded-{main,worker} are variants of base malloc tests that are |
| 297 |
# run in a multi-threaded program. The main variant is run in the main |
| 298 |
# thread while an alternate thread exists, and the worker variant is run in |
| 299 |
# a worker thread while the main thread waits on it. |
| 300 |
|
| 301 |
# List of tests which don't have threaded-{main,worker} copies: |
| 302 |
# already multithreaded tests, |
| 303 |
# static copies of some regular tests, |
| 304 |
# tst-compathooks-on: hook/call counts mismatch due to threading allocations |
| 305 |
# tst-interpose-nothread: interposes malloc without locking |
| 306 |
# tst-mallocfork: calls fork from a signal handler |
| 307 |
# (tst-mallocfork{2,3} already excluded via tests-link-with-libpthread) |
| 308 |
tests-exclude-threaded = \ |
| 309 |
$(tests-link-with-libpthread) \ |
| 310 |
$(tests-static) \ |
| 311 |
tst-compathooks-on \ |
| 312 |
tst-interpose-nothread \ |
| 313 |
tst-mallocfork \ |
| 314 |
# tests-exclude-threaded |
| 315 |
|
| 316 |
tests-threaded-main = $(addsuffix -threaded-main, \ |
| 317 |
$(filter-out $(tests-exclude-threaded), \ |
| 318 |
$(tests))) |
| 319 |
$(addprefix $(objpfx), $(tests-threaded-main)): $(shared-thread-library) |
| 320 |
|
| 321 |
tests-threaded-worker = $(addsuffix -threaded-worker, \ |
| 322 |
$(filter-out $(tests-exclude-threaded), \ |
| 323 |
$(tests))) |
| 324 |
$(addprefix $(objpfx), $(tests-threaded-worker)): $(shared-thread-library) |
| 325 |
|
| 326 |
tests += $(tests-threaded-main) $(tests-threaded-worker) |
| 327 |
|
| 328 |
# This avoids a test combination explosion with two threaded copies of each |
| 329 |
# of these variants: |
| 330 |
tests-exclude-malloc-check += $(tests-threaded-main) $(tests-threaded-worker) |
| 331 |
tests-exclude-mcheck += $(tests-threaded-main) $(tests-threaded-worker) |
| 332 |
tests-exclude-hugetlb1 += $(tests-threaded-main) $(tests-threaded-worker) |
| 333 |
tests-exclude-hugetlb2 += $(tests-threaded-main) $(tests-threaded-worker) |
| 334 |
tests-exclude-largetcache += $(tests-threaded-main) $(tests-threaded-worker) |
| 335 |
|
| 336 |
# These should be removed by `make clean'. |
| 337 |
extra-objs = mcheck-init.o libmcheck.a |
| 338 |
others-extras = mcheck-init.o |
| 339 |
|
| 340 |
# Compile threaded-{main,worker} tests from their corresponding base |
| 341 |
# sources, but with -DTEST_IN_THREAD appropriately defined so that support |
| 342 |
# infrastructure runs them in a multi-threaded program. |
| 343 |
$(objpfx)%-threaded-main.o: CPPFLAGS += -DTEST_IN_THREAD=TEST_THREAD_MAIN |
| 344 |
$(objpfx)%-threaded-main.o: %.c $(before-compile) |
| 345 |
$(compile-command.c) |
| 346 |
$(objpfx)%-threaded-worker.o: CPPFLAGS += -DTEST_IN_THREAD=TEST_THREAD_WORKER |
| 347 |
$(objpfx)%-threaded-worker.o: %.c $(before-compile) |
| 348 |
$(compile-command.c) |
| 349 |
|
| 350 |
# Include the cleanup handler. |
| 351 |
aux := set-freeres thread-freeres |
| 352 |
|
| 353 |
# The Perl script to analyze the output of the mtrace functions. |
| 354 |
install-bin-script = mtrace |
| 355 |
generated += mtrace |
| 356 |
|
| 357 |
# The Perl script will print addresses and to do this nicely we must know |
| 358 |
# whether we are on a 32 or 64 bit machine. |
| 359 |
ifneq ($(findstring wordsize-32,$(config-sysdirs)),) |
| 360 |
address-width=10 |
| 361 |
else |
| 362 |
address-width=18 |
| 363 |
endif |
| 364 |
|
| 365 |
# If the gd library is available we build the `memusagestat' program. |
| 366 |
ifneq ($(LIBGD),no) |
| 367 |
others: $(objpfx)memusage |
| 368 |
others += memusagestat |
| 369 |
install-bin = memusagestat |
| 370 |
install-bin-script += memusage |
| 371 |
generated += memusagestat memusage |
| 372 |
extra-objs += memusagestat.o |
| 373 |
|
| 374 |
# The configure.ac check for libgd and its headers did not use $SYSINCLUDES. |
| 375 |
# The directory specified by --with-headers usually contains only the basic |
| 376 |
# kernel interface headers, not something like libgd. So the simplest thing |
| 377 |
# is to presume that the standard system headers will be ok for this file. |
| 378 |
$(objpfx)memusagestat.o: sysincludes = # nothing |
| 379 |
endif |
| 380 |
|
| 381 |
# Another goal which can be used to override the configure decision. |
| 382 |
.PHONY: do-memusagestat |
| 383 |
do-memusagestat: $(objpfx)memusagestat |
| 384 |
|
| 385 |
memusagestat-modules = memusagestat |
| 386 |
|
| 387 |
cpp-srcs-left := $(memusagestat-modules) |
| 388 |
lib := memusagestat |
| 389 |
include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left)) |
| 390 |
|
| 391 |
LDLIBS-memusagestat = $(libgd-LDFLAGS) -lgd -lpng -lz -lm |
| 392 |
|
| 393 |
ifeq ($(run-built-tests),yes) |
| 394 |
ifeq (yes,$(build-shared)) |
| 395 |
ifneq ($(PERL),no) |
| 396 |
tests-special += $(objpfx)tst-mtrace.out |
| 397 |
tests-special += $(objpfx)tst-dynarray-mem.out |
| 398 |
tests-special += $(objpfx)tst-dynarray-fail-mem.out |
| 399 |
tests-special += $(objpfx)tst-free-aligned-sized-mtrace.out |
| 400 |
tests-special += $(objpfx)tst-free-sized-mtrace.out |
| 401 |
endif |
| 402 |
endif |
| 403 |
endif |
| 404 |
|
| 405 |
include ../Rules |
| 406 |
|
| 407 |
CFLAGS-mcheck-init.c += $(PIC-ccflag) |
| 408 |
CFLAGS-obstack.c += $(uses-callbacks) |
| 409 |
|
| 410 |
$(objpfx)libmcheck.a: $(objpfx)mcheck-init.o |
| 411 |
-rm -f $@ |
| 412 |
$(patsubst %/,cd % &&,$(objpfx)) \ |
| 413 |
$(LN_S) $(<F) $(@F) |
| 414 |
|
| 415 |
lib: $(objpfx)libmcheck.a |
| 416 |
|
| 417 |
ifeq ($(run-built-tests),yes) |
| 418 |
ifeq (yes,$(build-shared)) |
| 419 |
ifneq ($(PERL),no) |
| 420 |
$(objpfx)tst-mtrace.out: tst-mtrace.sh $(objpfx)tst-mtrace |
| 421 |
$(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \ |
| 422 |
'$(run-program-env)' '$(test-program-prefix-after-env)'; \ |
| 423 |
$(evaluate-test) |
| 424 |
endif |
| 425 |
endif |
| 426 |
endif |
| 427 |
|
| 428 |
malloc-check-env = \ |
| 429 |
MALLOC_CHECK_=3 \ |
| 430 |
LD_PRELOAD=$(objpfx)/libc_malloc_debug.so |
| 431 |
|
| 432 |
malloc-check-tunables-env = \ |
| 433 |
GLIBC_TUNABLES=glibc.malloc.check=3 \ |
| 434 |
LD_PRELOAD=$(objpfx)/libc_malloc_debug.so |
| 435 |
|
| 436 |
tst-malloc-check-ENV = $(malloc-check-env) |
| 437 |
tst-malloc-usable-ENV = $(malloc-check-env) |
| 438 |
tst-malloc-usable-threaded-main-ENV = $(malloc-check-env) |
| 439 |
tst-malloc-usable-threaded-worker-ENV = $(malloc-check-env) |
| 440 |
tst-malloc-usable-tunables-ENV = $(malloc-check-tunables-env) |
| 441 |
tst-malloc-usable-tunables-threaded-main-ENV = $(malloc-check-tunables-env) |
| 442 |
tst-malloc-usable-tunables-threaded-worker-ENV = $(malloc-check-tunables-env) |
| 443 |
|
| 444 |
CPPFLAGS-malloc-debug.c += -DUSE_TCACHE=0 |
| 445 |
CPPFLAGS-malloc.c += -DUSE_TCACHE=1 |
| 446 |
# Uncomment this for test releases. For public releases it is too expensive. |
| 447 |
#CPPFLAGS-malloc.o += -DMALLOC_DEBUG=1 |
| 448 |
|
| 449 |
CFLAGS-tst-tcfree3.c += -fno-builtin-malloc -fno-builtin-free |
| 450 |
|
| 451 |
sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,') |
| 452 |
|
| 453 |
$(objpfx)mtrace: mtrace.pl |
| 454 |
rm -f [email protected] |
| 455 |
sed -e 's|@XXX@|$(address-width)|' \ |
| 456 |
-e 's|@VERSION@|$(version)|' \ |
| 457 |
-e 's|@PKGVERSION@|$(PKGVERSION)|' \ |
| 458 |
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > [email protected] \ |
| 459 |
&& rm -f $@ && mv [email protected] $@ && chmod +x $@ |
| 460 |
|
| 461 |
$(objpfx)memusage: memusage.sh |
| 462 |
rm -f [email protected] |
| 463 |
sed -e 's|@VERSION@|$(version)|' -e 's|@SLIBDIR@|$(sLIBdir)|' \ |
| 464 |
-e 's|@BINDIR@|$(bindir)|' -e 's|@PKGVERSION@|$(PKGVERSION)|' \ |
| 465 |
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > [email protected] \ |
| 466 |
&& rm -f $@ && mv [email protected] $@ && chmod +x $@ |
| 467 |
|
| 468 |
# Compile the tests with a flag which suppresses the mallopt call in |
| 469 |
# the test skeleton. |
| 470 |
$(tests:%=$(objpfx)%.o): CPPFLAGS += -DTEST_NO_MALLOPT |
| 471 |
|
| 472 |
$(objpfx)tst-interpose-nothread: $(objpfx)tst-interpose-aux-nothread.o |
| 473 |
$(objpfx)tst-interpose-nothread-mcheck: $(objpfx)tst-interpose-aux-nothread.o |
| 474 |
$(objpfx)tst-interpose-nothread-malloc-check: \ |
| 475 |
$(objpfx)tst-interpose-aux-nothread.o |
| 476 |
$(objpfx)tst-interpose-thread: $(objpfx)tst-interpose-aux-thread.o |
| 477 |
$(objpfx)tst-interpose-thread-mcheck: $(objpfx)tst-interpose-aux-thread.o |
| 478 |
$(objpfx)tst-interpose-thread-malloc-check: $(objpfx)tst-interpose-aux-thread.o |
| 479 |
$(objpfx)tst-interpose-static-nothread: $(objpfx)tst-interpose-aux-nothread.o |
| 480 |
$(objpfx)tst-interpose-static-thread: \ |
| 481 |
$(objpfx)tst-interpose-aux-thread.o $(static-thread-library) |
| 482 |
|
| 483 |
tst-dynarray-ENV = MALLOC_TRACE=$(objpfx)tst-dynarray.mtrace \ |
| 484 |
LD_PRELOAD=$(objpfx)libc_malloc_debug.so |
| 485 |
$(objpfx)tst-dynarray-mem.out: $(objpfx)tst-dynarray.out |
| 486 |
$(common-objpfx)malloc/mtrace $(objpfx)tst-dynarray.mtrace > $@; \ |
| 487 |
$(evaluate-test) |
| 488 |
|
| 489 |
tst-dynarray-fail-ENV = MALLOC_TRACE=$(objpfx)tst-dynarray-fail.mtrace \ |
| 490 |
LD_PRELOAD=$(objpfx)libc_malloc_debug.so |
| 491 |
$(objpfx)tst-dynarray-fail-mem.out: $(objpfx)tst-dynarray-fail.out |
| 492 |
$(common-objpfx)malloc/mtrace $(objpfx)tst-dynarray-fail.mtrace > $@; \ |
| 493 |
$(evaluate-test) |
| 494 |
|
| 495 |
tst-compathooks-on-ENV = LD_PRELOAD=$(objpfx)libc_malloc_debug.so |
| 496 |
tst-compathooks-on-mcheck-ENV = LD_PRELOAD=$(objpfx)libc_malloc_debug.so |
| 497 |
tst-compathooks-on-malloc-check-ENV = \ |
| 498 |
LD_PRELOAD=$(objpfx)libc_malloc_debug.so |
| 499 |
tst-mallocstate-ENV = LD_PRELOAD=$(objpfx)libc_malloc_debug.so |
| 500 |
tst-mallocstate-malloc-check-ENV = LD_PRELOAD=$(objpfx)libc_malloc_debug.so |
| 501 |
|
| 502 |
# The test needs malloc_get_state/malloc_set_state which is in |
| 503 |
# libc_malloc_debug.so. |
| 504 |
$(objpfx)tst-mallocstate: $(objpfx)libc_malloc_debug.so |
| 505 |
$(objpfx)tst-mallocstate-malloc-check: $(objpfx)libc_malloc_debug.so |
| 506 |
tst-mallocstate-threaded-main-ENV = LD_PRELOAD=$(objpfx)libc_malloc_debug.so |
| 507 |
$(objpfx)tst-mallocstate-threaded-main: $(objpfx)libc_malloc_debug.so |
| 508 |
tst-mallocstate-threaded-worker-ENV = LD_PRELOAD=$(objpfx)libc_malloc_debug.so |
| 509 |
$(objpfx)tst-mallocstate-threaded-worker: $(objpfx)libc_malloc_debug.so |
| 510 |
|
| 511 |
$(objpfx)tst-aligned-alloc-random.out: $(objpfx)tst-aligned_alloc-lib.so |
| 512 |
$(objpfx)tst-aligned-alloc-random-thread.out: $(objpfx)tst-aligned_alloc-lib.so |
| 513 |
$(objpfx)tst-aligned-alloc-random-thread-cross.out: $(objpfx)tst-aligned_alloc-lib.so |
| 514 |
$(objpfx)tst-malloc-random.out: $(objpfx)tst-aligned_alloc-lib.so |
| 515 |
|
| 516 |
tst-aligned-alloc-random-ENV = LD_PRELOAD=$(objpfx)tst-aligned_alloc-lib.so |
| 517 |
tst-aligned-alloc-random-thread-ENV = LD_PRELOAD=$(objpfx)tst-aligned_alloc-lib.so |
| 518 |
tst-aligned-alloc-random-thread-cross-ENV = LD_PRELOAD=$(objpfx)tst-aligned_alloc-lib.so |
| 519 |
tst-malloc-random-ENV = LD_PRELOAD=$(objpfx)tst-aligned_alloc-lib.so |
| 520 |
|
| 521 |
tst-free-aligned-sized-trace-ENV = MALLOC_TRACE=$(objpfx)tst-free-aligned-sized-mem.mtrace \ |
| 522 |
LD_PRELOAD=$(objpfx)libc_malloc_debug.so |
| 523 |
$(objpfx)tst-free-aligned-sized-mtrace.out: $(objpfx)tst-free-aligned-sized-trace.out |
| 524 |
$(common-objpfx)malloc/mtrace $(objpfx)tst-free-aligned-sized-mem.mtrace > $@; \ |
| 525 |
$(evaluate-test) |
| 526 |
|
| 527 |
tst-free-sized-trace-ENV = MALLOC_TRACE=$(objpfx)tst-free-sized-mem.mtrace \ |
| 528 |
LD_PRELOAD=$(objpfx)libc_malloc_debug.so |
| 529 |
$(objpfx)tst-free-sized-mtrace.out: $(objpfx)tst-free-sized-trace.out |
| 530 |
$(common-objpfx)malloc/mtrace $(objpfx)tst-free-sized-mem.mtrace > $@; \ |
| 531 |
$(evaluate-test) |