2018-12-05 01:44:43 -05:00
|
|
|
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",
|
2019-01-02 14:59:19 -05:00
|
|
|
"-DSLAB_QUARANTINE_RANDOM_LENGTH=1",
|
|
|
|
"-DSLAB_QUARANTINE_QUEUE_LENGTH=1",
|
2019-04-07 08:04:06 -04:00
|
|
|
"-DCONFIG_LARGE_SIZE_CLASSES=true",
|
2018-12-05 01:44:43 -05:00
|
|
|
"-DGUARD_SLABS_INTERVAL=1",
|
|
|
|
"-DGUARD_SIZE_DIVISOR=2",
|
2019-01-02 13:40:02 -05:00
|
|
|
"-DREGION_QUARANTINE_RANDOM_LENGTH=128",
|
|
|
|
"-DREGION_QUARANTINE_QUEUE_LENGTH=1024",
|
2018-12-05 09:23:05 -05:00
|
|
|
"-DREGION_QUARANTINE_SKIP_THRESHOLD=33554432", // 32MiB
|
2019-01-02 13:40:02 -05:00
|
|
|
"-DFREE_SLABS_QUARANTINE_RANDOM_LENGTH=32",
|
2018-12-05 09:23:05 -05:00
|
|
|
"-DCONFIG_CLASS_REGION_SIZE=1073741824", // 1GiB
|
2019-03-25 14:49:50 -04:00
|
|
|
"-DN_ARENA=1",
|
2019-04-07 09:06:03 -04:00
|
|
|
"-DCONFIG_STATS=false",
|
2018-12-05 01:44:43 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
cc_defaults {
|
|
|
|
name: "hardened_malloc_defaults",
|
|
|
|
defaults: ["linux_bionic_supported"],
|
|
|
|
cflags: common_cflags,
|
2018-12-06 12:04:42 -05:00
|
|
|
conlyflags: ["-std=c11", "-Wmissing-prototypes"],
|
2018-12-05 01:44:43 -05:00
|
|
|
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,
|
2019-03-20 14:11:06 -04:00
|
|
|
product_variables: {
|
|
|
|
debuggable: {
|
|
|
|
cflags: ["-DLABEL_MEMORY"],
|
|
|
|
},
|
|
|
|
},
|
2018-12-05 01:44:43 -05:00
|
|
|
}
|