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