Disable LMID for SunOS

This commit is contained in:
Oleksii Shevchuk 2018-10-08 21:05:49 +03:00
parent 358eb2e672
commit 3747e5b445
1 changed files with 9 additions and 1 deletions

View File

@ -348,12 +348,20 @@ pid_t memexec(const char *buffer, size_t size, const char* const* argv, int stdi
return -1; return -1;
} }
#ifdef LM_ID_NEWLM #if defined(SunOS)
// For some unknown reason malloc doesn't work on newly created LM in Solaris 10
// Fallback to old shitty way of loading libs
// TODO: write own ELF loader
#define _dlopen(path, flags) dlopen(path, flags | RTLD_PARENT | RTLD_GLOBAL)
#elif defined(LM_ID_NEWLM)
static void *_dlopen(const char *path, int flags) { static void *_dlopen(const char *path, int flags) {
static Lmid_t lmid = LM_ID_NEWLM; static Lmid_t lmid = LM_ID_NEWLM;
flags &= ~RTLD_GLOBAL; flags &= ~RTLD_GLOBAL;
if ((flags & RTLD_NOLOAD) && (lmid == LM_ID_NEWLM))
return NULL;
void *handle = dlmopen(lmid, path, flags); void *handle = dlmopen(lmid, path, flags);
if (lmid == LM_ID_NEWLM && handle) { if (lmid == LM_ID_NEWLM && handle) {
dlinfo(handle, RTLD_DI_LMID, &lmid); dlinfo(handle, RTLD_DI_LMID, &lmid);