hardened_malloc/Android.bp
Daniel Micay e0891c8cfc implement the option of large size classes
This extends the size class scheme used for slab allocations to large
allocations. This drastically improves performance for many real world
programs using incremental realloc growth instead of using proper growth
factors. There are 4 size classes for every doubling in size, resulting
in a worst case of ~20% extra virtual memory being reserved and a huge
increase in performance for pathological cases. For example, growing
from 4MiB to 8MiB by calling realloc in increments of 32 bytes will only
need to do work beyond looking up the size 4 times instead of 1024 times
with 4096 byte granularity.
2019-04-07 08:52:17 -04:00

59 lines
1.3 KiB
Plaintext

common_cflags = [
"-O3",
//"-flto",
"-fPIC",
"-fvisibility=hidden",
//"-fno-plt",
"-pipe",
"-Wall",
"-Wextra",
"-Wcast-align",
"-Wcast-qual",
"-Wwrite-strings",
"-DH_MALLOC_PREFIX",
"-DZERO_ON_FREE=true",
"-DWRITE_AFTER_FREE_CHECK=true",
"-DSLOT_RANDOMIZE=true",
"-DSLAB_CANARY=true",
"-DSLAB_QUARANTINE_RANDOM_LENGTH=1",
"-DSLAB_QUARANTINE_QUEUE_LENGTH=1",
"-DCONFIG_LARGE_SIZE_CLASSES=true",
"-DGUARD_SLABS_INTERVAL=1",
"-DGUARD_SIZE_DIVISOR=2",
"-DREGION_QUARANTINE_RANDOM_LENGTH=128",
"-DREGION_QUARANTINE_QUEUE_LENGTH=1024",
"-DREGION_QUARANTINE_SKIP_THRESHOLD=33554432", // 32MiB
"-DFREE_SLABS_QUARANTINE_RANDOM_LENGTH=32",
"-DCONFIG_CLASS_REGION_SIZE=1073741824", // 1GiB
"-DN_ARENA=1",
"-DSTATS=false",
]
cc_defaults {
name: "hardened_malloc_defaults",
defaults: ["linux_bionic_supported"],
cflags: common_cflags,
conlyflags: ["-std=c11", "-Wmissing-prototypes"],
stl: "none",
}
lib_src_files = [
"chacha.c",
"h_malloc.c",
"memory.c",
"pages.c",
"random.c",
"util.c",
]
cc_library_static {
name: "libhardened_malloc",
defaults: ["hardened_malloc_defaults"],
srcs: lib_src_files,
product_variables: {
debuggable: {
cflags: ["-DLABEL_MEMORY"],
},
},
}