aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Stange <stange@google.com>2022-04-18 18:27:38 +0000
committerAnthony Stange <stange@google.com>2022-04-18 18:27:38 +0000
commit822d3b750f653d9f85c2e801613db1b4f9b2d68c (patch)
treed8762b851b6e10005e12d9bf64740a5dc3c84400
parenta93287ee5e39a20820d025a0a73144f7daef4ed0 (diff)
downloadchre-822d3b750f653d9f85c2e801613db1b4f9b2d68c.tar.gz
Revert "Revert "Revert changes to the nanoapp loader""
This reverts commit a93287ee5e39a20820d025a0a73144f7daef4ed0. Reason for revert: issue still exists with updated nanoapps. Change-Id: Ia86060bf79eac922e693342c9e2539f563ee5691
-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 0f366c1c..3dd32a71 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)) {
@@ -166,7 +184,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),