diff --git a/libraries/libstratosphere/source/ams/ams_environment.cpp b/libraries/libstratosphere/source/ams/ams_environment.cpp index 0c92a6434..674dcf0d2 100644 --- a/libraries/libstratosphere/source/ams/ams_environment.cpp +++ b/libraries/libstratosphere/source/ams/ams_environment.cpp @@ -176,7 +176,6 @@ extern "C" { /* Redefine C++ exception handlers. Requires wrap linker flag. */ #define WRAP_ABORT_FUNC(func) void NORETURN __wrap_##func(void) { abort(); __builtin_unreachable(); } - WRAP_ABORT_FUNC(__cxa_pure_virtual) WRAP_ABORT_FUNC(__cxa_throw) WRAP_ABORT_FUNC(__cxa_rethrow) WRAP_ABORT_FUNC(__cxa_allocate_exception) diff --git a/libraries/libstratosphere/source/ams/ams_environment_weak.cpp b/libraries/libstratosphere/source/ams/ams_environment_weak.cpp index b3965e7d9..a4c36a6a8 100644 --- a/libraries/libstratosphere/source/ams/ams_environment_weak.cpp +++ b/libraries/libstratosphere/source/ams/ams_environment_weak.cpp @@ -26,3 +26,12 @@ namespace ams { } } + +extern "C" { + + /* Redefine C++ exception handlers. Requires wrap linker flag. */ + #define WRAP_ABORT_FUNC(func) void NORETURN __wrap_##func(void) { abort(); __builtin_unreachable(); } + WRAP_ABORT_FUNC(__cxa_pure_virtual) + #undef WRAP_ABORT_FUNC + +} diff --git a/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp b/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp index 413cc4ad5..63b954883 100644 --- a/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp +++ b/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp @@ -127,7 +127,7 @@ namespace ams::i2c::driver::impl { auto &device = GetDevice().SafeCastTo<I2cDeviceProperty>(); /* Repeatedly try to execute the transaction. */ - int retry_count; + int retry_count = 0; while (true) { /* Execute the transaction. */ Result result; diff --git a/stratosphere/boot2/source/boot2_main.cpp b/stratosphere/boot2/source/boot2_main.cpp index a7e196b84..522e95a83 100644 --- a/stratosphere/boot2/source/boot2_main.cpp +++ b/stratosphere/boot2/source/boot2_main.cpp @@ -21,7 +21,7 @@ extern "C" { u32 __nx_applet_type = AppletType_None; u32 __nx_fs_num_sessions = 1; - #define INNER_HEAP_SIZE 0x2000 + #define INNER_HEAP_SIZE 0x0 size_t nx_inner_heap_size = INNER_HEAP_SIZE; char nx_inner_heap[INNER_HEAP_SIZE]; @@ -65,9 +65,32 @@ void __libnx_initheap(void) { fake_heap_end = (char*)addr + size; } +namespace { + + + constinit u8 g_fs_heap_memory[2_KB]; + lmem::HeapHandle g_fs_heap_handle; + + void *AllocateForFs(size_t size) { + return lmem::AllocateFromExpHeap(g_fs_heap_handle, size); + } + + void DeallocateForFs(void *p, size_t size) { + return lmem::FreeToExpHeap(g_fs_heap_handle, p); + } + + void InitializeFsHeap() { + g_fs_heap_handle = lmem::CreateExpHeap(g_fs_heap_memory, sizeof(g_fs_heap_memory), lmem::CreateOption_None); + } + +} + void __appInit(void) { hos::InitializeForStratosphere(); + InitializeFsHeap(); + fs::SetAllocator(AllocateForFs, DeallocateForFs); + /* Initialize services we need. */ sm::DoWithSession([&]() { R_ABORT_UNLESS(fsInitialize()); @@ -94,6 +117,26 @@ void __appExit(void) { fsExit(); } +namespace ams { + + void *Malloc(size_t size) { + AMS_ABORT("ams::Malloc was called"); + } + + void Free(void *ptr) { + AMS_ABORT("ams::Free was called"); + } + +} + +void *operator new(size_t size) { + AMS_ABORT("operator new(size_t) was called"); +} + +void operator delete(void *p) { + AMS_ABORT("operator delete(void *) was called"); +} + int main(int argc, char **argv) { /* Set thread name. */