Files
FEX-Emu--FEX/ThunkLibs/libfex_malloc_loader/Guest.cpp
T
Ryan Houdek 29debcda3d Thunks: Adds FEX malloc libraries
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
2021-10-02 18:12:07 -07:00

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);
}
}