From 134f8f6f00a99d59bfd6080579fcb0ea3ec0690d Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Mon, 1 Apr 2019 16:30:21 -0700 Subject: [PATCH] Make libc_scudo always go first. In addition, add Shared_libs to malloc_not_svelte. Bug: 123689570 Test: Verified that libc_scudo is first wherever it is added. Change-Id: Ibdc5dbd019a382630a727c270f846aa4446f8d99 Merged-In: Ibdc5dbd019a382630a727c270f846aa4446f8d99 --- android/variable.go | 3 ++- cc/linker.go | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/android/variable.go b/android/variable.go index aa8c80493..56ca666fa 100644 --- a/android/variable.go +++ b/android/variable.go @@ -43,7 +43,8 @@ type variableProperties struct { } `android:"arch_variant"` Malloc_not_svelte struct { - Cflags []string `android:"arch_variant"` + Cflags []string `android:"arch_variant"` + Shared_libs []string `android:"arch_variant"` } `android:"arch_variant"` Safestack struct { diff --git a/cc/linker.go b/cc/linker.go index fd958ba8e..b279c0654 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -255,6 +255,17 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { } } + if inList("libc_scudo", deps.SharedLibs) { + // libc_scudo is an alternate implementation of all + // allocation functions (malloc, free), that uses + // the scudo allocator instead of the default native + // allocator. If this library is in the list, make + // sure it's first so it properly overrides the + // allocation functions of all other shared libraries. + _, deps.SharedLibs = removeFromList("libc_scudo", deps.SharedLibs) + deps.SharedLibs = append([]string{"libc_scudo"}, deps.SharedLibs...) + } + // If libc and libdl are both in system_shared_libs make sure libdl comes after libc // to avoid loading libdl before libc. if inList("libdl", systemSharedLibs) && inList("libc", systemSharedLibs) &&