mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 18:00:17 +02:00
These are required to expose FEX's allocators to the guest. Which is required when we are compiled with jemalloc, otherwise the libraries will crash on allocations. This needs to be done in stages otherwise glibc will load the library and as it is setting up symbols, replace malloc, which isn't set currently and cause a crash
18 lines
431 B
C++
18 lines
431 B
C++
/*
|
|
$info$
|
|
tags: thunklibs|fex_malloc_loader
|
|
desc: Delays malloc symbol replacement until it is safe to run constructors
|
|
$end_info$
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <dlfcn.h>
|
|
extern "C" {
|
|
__attribute__((constructor))
|
|
static void loadlib()
|
|
{
|
|
fprintf(stderr, "Time to load mallocs\n");
|
|
dlopen("/mnt/Work/Work/work/FEXNew/Build/Guest/libfex_malloc-guest.so", RTLD_GLOBAL | RTLD_NOW | RTLD_NODELETE | RTLD_DEEPBIND);
|
|
}
|
|
}
|