From 17dc60eb66906731a194cc4256fce0cb2a28567d Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Thu, 18 Oct 2012 04:57:40 +0200 Subject: [PATCH] cxx: make 'operator delete(void *)' a weak symbol The 'delete (void *)' operator gets referenced by compiler generated code, so it must be publicly defined in the 'cxx' library. These compiler generated calls seem to get executed only subsequently to explicit 'delete (void *)' calls in application code, which are not supported by the 'cxx' library, so the 'delete (void *)' implementation in the 'cxx' library does not have to do anything. Applications should use the 'delete (void *)' implementation of the 'stdcxx' library instead. To make this possible, the 'delete (void *)' implementation in the 'cxx' library must be 'weak'. Fixes #419. --- base/src/base/cxx/new_delete.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/base/src/base/cxx/new_delete.cc b/base/src/base/cxx/new_delete.cc index b5cc4b2357..0af2553095 100644 --- a/base/src/base/cxx/new_delete.cc +++ b/base/src/base/cxx/new_delete.cc @@ -42,3 +42,19 @@ void operator delete (void *ptr, Genode::Allocator *alloc) PERR("C++ runtime: delete called with unsafe allocator, leaking memory"); } + +/* + * The 'delete (void *)' operator gets referenced by compiler generated code, + * so it must be publicly defined in the 'cxx' library. These compiler + * generated calls seem to get executed only subsequently to explicit + * 'delete (void *)' calls in application code, which are not supported by the + * 'cxx' library, so the 'delete (void *)' implementation in the 'cxx' library + * does not have to do anything. Applications should use the 'delete (void *)' + * implementation of the 'stdcxx' library instead. To make this possible, the + * 'delete (void *)' implementation in the 'cxx' library must be 'weak'. + */ +__attribute__((weak)) void operator delete (void *) +{ + PERR("cxx: operator delete (void *) called - not implemented. " + "A working implementation is available in the 'stdcxx' library."); +}