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
diff --git a/cc/linker.go b/cc/linker.go
index fd958ba..b279c06 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -255,6 +255,17 @@
}
}
+ 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) &&