mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-18 00:12:03 +00:00
sm: update to excise unnecessary library code
This commit is contained in:
parent
7d61cab01c
commit
32f487abfb
7 changed files with 47 additions and 6 deletions
|
@ -34,7 +34,8 @@ export CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
|
|||
-Wl,--wrap,_Unwind_Resume \
|
||||
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
|
||||
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
|
||||
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
|
||||
-Wl,--wrap,_ZNSt11logic_errorC2EPKc \
|
||||
-Wl,--wrap,exit
|
||||
|
||||
export LDFLAGS = -specs=$(ATMOSPHERE_LIBRARIES_DIR)/libstratosphere/stratosphere.specs -specs=$(DEVKITPRO)/libnx/switch.specs $(SETTINGS) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
|
|
|
@ -124,6 +124,7 @@ $(OFILES_SRC) : $(HFILES_BIN)
|
|||
|
||||
ams_environment_weak.o: CXXFLAGS += -fno-lto
|
||||
pm_info_api_weak.o: CXXFLAGS += -fno-lto
|
||||
hos_stratosphere_api.o: CXXFLAGS += -fno-lto
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%_bin.h %.bin.o : %.bin
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
extern "C" void NORETURN __real_exit(int rc);
|
||||
|
||||
namespace ams {
|
||||
|
||||
WEAK_SYMBOL void *Malloc(size_t size) {
|
||||
|
@ -37,6 +39,11 @@ namespace ams {
|
|||
return std::free(ptr);
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void NORETURN Exit(int rc) {
|
||||
__real_exit(rc);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
@ -46,4 +53,6 @@ extern "C" {
|
|||
WRAP_ABORT_FUNC(__cxa_pure_virtual)
|
||||
#undef WRAP_ABORT_FUNC
|
||||
|
||||
void NORETURN __wrap_exit(int rc) { ::ams::Exit(rc); __builtin_unreachable(); }
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "hos_version_api_private.hpp"
|
||||
#include "../os/impl/os_rng_manager.hpp"
|
||||
|
||||
namespace ams::os {
|
||||
|
||||
|
@ -22,6 +23,15 @@ namespace ams::os {
|
|||
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* Provide libnx address space allocation shim. */
|
||||
uintptr_t __libnx_virtmem_rng(void) {
|
||||
return static_cast<uintptr_t>(::ams::os::impl::GetRngManager().GenerateRandomU64());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace ams::hos {
|
||||
|
||||
void InitializeForStratosphere() {
|
||||
|
|
|
@ -21,12 +21,12 @@ namespace ams::os::impl {
|
|||
class RngManager {
|
||||
private:
|
||||
util::TinyMT mt;
|
||||
os::Mutex lock;
|
||||
os::SdkMutex lock;
|
||||
bool initialized;
|
||||
private:
|
||||
void Initialize();
|
||||
public:
|
||||
constexpr RngManager() : mt(), lock(false), initialized() { /* ... */ }
|
||||
constexpr RngManager() : mt(), lock(), initialized() { /* ... */ }
|
||||
public:
|
||||
u64 GenerateRandomU64();
|
||||
};
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace ams::os {
|
|||
|
||||
namespace {
|
||||
|
||||
util::TinyMT g_random;
|
||||
os::Mutex g_random_mutex(false);
|
||||
bool g_initialized_random;
|
||||
constinit util::TinyMT g_random;
|
||||
constinit os::SdkMutex g_random_mutex;
|
||||
constinit bool g_initialized_random;
|
||||
|
||||
template<typename T>
|
||||
inline T GenerateRandomTImpl(T max) {
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
extern "C" {
|
||||
extern u32 __start__;
|
||||
|
||||
extern int __system_argc;
|
||||
extern char** __system_argv;
|
||||
|
||||
u32 __nx_applet_type = AppletType_None;
|
||||
|
||||
#define INNER_HEAP_SIZE 0x0
|
||||
|
@ -26,6 +29,7 @@ extern "C" {
|
|||
char nx_inner_heap[INNER_HEAP_SIZE];
|
||||
|
||||
void __libnx_initheap(void);
|
||||
void argvSetup(void);
|
||||
void __appInit(void);
|
||||
void __appExit(void);
|
||||
|
||||
|
@ -39,10 +43,20 @@ extern "C" {
|
|||
void __libnx_free(void *mem);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
constinit char *g_empty_argv = nullptr;
|
||||
|
||||
}
|
||||
|
||||
namespace ams {
|
||||
|
||||
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Sm;
|
||||
|
||||
void NORETURN Exit(int rc) {
|
||||
AMS_ABORT("Exit called by immortal process");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using namespace ams;
|
||||
|
@ -64,6 +78,12 @@ void __libnx_initheap(void) {
|
|||
fake_heap_end = (char*)addr + size;
|
||||
}
|
||||
|
||||
void argvSetup(void) {
|
||||
/* We don't need argc/argv, so set them to empty defaults. */
|
||||
__system_argc = 0;
|
||||
__system_argv = std::addressof(g_empty_argv);
|
||||
}
|
||||
|
||||
void __appInit(void) {
|
||||
hos::InitializeForStratosphere();
|
||||
|
||||
|
|
Loading…
Reference in a new issue