aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Berchet <berchet@google.com>2022-04-08 20:49:16 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-04-08 20:49:16 +0000
commit37cd5ff96fda2eb3db622ffc3e708ddf271a6241 (patch)
treed85756c0cb4f59d470257a98a0628cf6bc449ee4
parentab3f39c366bb533f06704843fbe02db14b81a4ed (diff)
parent58cd1ac1ce556a51a2dc4f1332383f9f702f9f92 (diff)
downloadchre-37cd5ff96fda2eb3db622ffc3e708ddf271a6241.tar.gz
Revert changes to the nanoapp loader am: 58cd1ac1ce
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/chre/+/17658355 Change-Id: Icda678a717e0ba42b7dc86836516033304e647ac Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--platform/shared/nanoapp_loader.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/platform/shared/nanoapp_loader.cc b/platform/shared/nanoapp_loader.cc
index b69b96b3..fa0e11b3 100644
--- a/platform/shared/nanoapp_loader.cc
+++ b/platform/shared/nanoapp_loader.cc
@@ -53,6 +53,24 @@ NanoappLoader *gCurrentlyLoadingNanoapp = nullptr;
//! Indicates whether a failure occurred during static initialization.
bool gStaticInitFailure = false;
+// The new operator is used by singleton.h which causes the delete operator to
+// be undefined in nanoapp binaries even though it's unused. Define this in case
+// a nanoapp actually tries to use the operator.
+void deleteOverride(void *ptr) {
+ FATAL_ERROR("Nanoapp tried to free %p through delete operator", ptr);
+}
+
+// From C++17, a call to the overloaded delete operator aimed at safely freeing
+// over-aligned allocations maybe present in the nanoapp binary even though it
+// is unused. Since all memory allocations/deallocations are managed by CHRE,
+// signal a fatal error if the nanoapp tries to use this version of the delete
+// operator.
+void deleteAlignedOverride(void *ptr, std::align_val_t alignment) {
+ UNUSED_VAR(alignment);
+
+ FATAL_ERROR("Nanoapp tried to free aligned %p via the delte operator", ptr);
+}
+
// atexit is used to register functions that must be called when a binary is
// removed from the system.
int atexitOverride(void (*function)(void)) {
@@ -162,7 +180,8 @@ const ExportedData gExportedData[] = {
/* libc overrides and symbols */
ADD_EXPORTED_C_SYMBOL(__cxa_pure_virtual),
ADD_EXPORTED_SYMBOL(atexitOverride, "atexit"),
-
+ ADD_EXPORTED_SYMBOL(deleteOverride, "_ZdlPv"),
+ ADD_EXPORTED_SYMBOL(deleteAlignedOverride, "_ZdlPvSt11align_val_t"),
ADD_EXPORTED_C_SYMBOL(dlsym),
ADD_EXPORTED_C_SYMBOL(isgraph),
ADD_EXPORTED_C_SYMBOL(memcmp),