2018-12-05 12:14:43 +05:30
|
|
|
common_cflags = [
|
|
|
|
"-O3",
|
|
|
|
//"-flto",
|
|
|
|
"-fPIC",
|
|
|
|
"-fvisibility=hidden",
|
|
|
|
//"-fno-plt",
|
|
|
|
"-pipe",
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Wcast-align",
|
|
|
|
"-Wcast-qual",
|
|
|
|
"-Wwrite-strings",
|
2019-08-18 12:01:05 +05:30
|
|
|
"-Werror",
|
2018-12-05 12:14:43 +05:30
|
|
|
"-DH_MALLOC_PREFIX",
|
|
|
|
"-DZERO_ON_FREE=true",
|
|
|
|
"-DWRITE_AFTER_FREE_CHECK=true",
|
|
|
|
"-DSLOT_RANDOMIZE=true",
|
|
|
|
"-DSLAB_CANARY=true",
|
2019-01-03 01:29:19 +05:30
|
|
|
"-DSLAB_QUARANTINE_RANDOM_LENGTH=1",
|
|
|
|
"-DSLAB_QUARANTINE_QUEUE_LENGTH=1",
|
2018-09-16 22:56:59 +05:30
|
|
|
"-DCONFIG_EXTENDED_SIZE_CLASSES=true",
|
2019-04-07 17:34:06 +05:30
|
|
|
"-DCONFIG_LARGE_SIZE_CLASSES=true",
|
2018-12-05 12:14:43 +05:30
|
|
|
"-DGUARD_SLABS_INTERVAL=1",
|
|
|
|
"-DGUARD_SIZE_DIVISOR=2",
|
2021-03-18 15:57:46 +05:30
|
|
|
"-DREGION_QUARANTINE_RANDOM_LENGTH=256",
|
2019-01-03 00:10:02 +05:30
|
|
|
"-DREGION_QUARANTINE_QUEUE_LENGTH=1024",
|
2018-12-05 19:53:05 +05:30
|
|
|
"-DREGION_QUARANTINE_SKIP_THRESHOLD=33554432", // 32MiB
|
2019-01-03 00:10:02 +05:30
|
|
|
"-DFREE_SLABS_QUARANTINE_RANDOM_LENGTH=32",
|
2019-03-26 00:19:50 +05:30
|
|
|
"-DN_ARENA=1",
|
2019-04-11 02:42:17 +05:30
|
|
|
"-DCONFIG_STATS=true",
|
2018-12-05 12:14:43 +05:30
|
|
|
]
|
|
|
|
|
|
|
|
cc_defaults {
|
|
|
|
name: "hardened_malloc_defaults",
|
|
|
|
defaults: ["linux_bionic_supported"],
|
|
|
|
cflags: common_cflags,
|
2021-05-12 14:41:30 +05:30
|
|
|
arch: {
|
|
|
|
arm64: {
|
|
|
|
cflags: ["-DCONFIG_CLASS_REGION_SIZE=2147483648"] // 2GiB
|
|
|
|
},
|
|
|
|
x86_64: {
|
|
|
|
cflags: ["-DCONFIG_CLASS_REGION_SIZE=34359738368"] // 32GiB
|
|
|
|
},
|
|
|
|
},
|
2022-01-14 01:18:56 +05:30
|
|
|
conlyflags: ["-std=c17", "-Wmissing-prototypes"],
|
2018-12-05 12:14:43 +05:30
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
|
|
|
|
lib_src_files = [
|
|
|
|
"chacha.c",
|
|
|
|
"h_malloc.c",
|
|
|
|
"memory.c",
|
|
|
|
"pages.c",
|
|
|
|
"random.c",
|
|
|
|
"util.c",
|
|
|
|
]
|
|
|
|
|
2019-09-08 03:29:08 +05:30
|
|
|
cc_library {
|
2018-12-05 12:14:43 +05:30
|
|
|
name: "libhardened_malloc",
|
2020-09-13 14:26:39 +05:30
|
|
|
ramdisk_available: true,
|
2021-08-18 20:12:14 +05:30
|
|
|
vendor_ramdisk_available: true,
|
2019-09-08 03:08:43 +05:30
|
|
|
recovery_available: true,
|
2018-12-05 12:14:43 +05:30
|
|
|
defaults: ["hardened_malloc_defaults"],
|
|
|
|
srcs: lib_src_files,
|
2020-09-14 14:40:27 +05:30
|
|
|
export_include_dirs: ["include"],
|
2020-10-19 16:55:15 +05:30
|
|
|
static_libs: ["libasync_safe"],
|
2019-09-08 03:29:08 +05:30
|
|
|
target: {
|
|
|
|
android: {
|
|
|
|
shared: {
|
|
|
|
enabled: false,
|
|
|
|
},
|
|
|
|
system_shared_libs: [],
|
|
|
|
},
|
|
|
|
linux_bionic: {
|
|
|
|
system_shared_libs: [],
|
|
|
|
},
|
|
|
|
},
|
2019-03-20 23:41:06 +05:30
|
|
|
product_variables: {
|
|
|
|
debuggable: {
|
|
|
|
cflags: ["-DLABEL_MEMORY"],
|
|
|
|
},
|
|
|
|
},
|
2018-12-05 12:14:43 +05:30
|
|
|
}
|