The RTLD_GROUP flag to dlopen comes from Solaris. It makes the symbol resolution for dlopen not use the global symbols from the current team (anything that's already loaded). The loaded object must be explicitly linked against any symbol it needs to use (or it can use dlsym to search symbols in the global scope explicitly). This is also how symbol resolution worked in BeOS, meaning we already have the code to do this, and just need to enable it. This can be used in dosemu, where DOS-like executable are linked against their own C library and should not use symbols from libroot. Fixes #19674. Change-Id: I8d127c7812a31e231edb1e44edf70b868c2670e7 Reviewed-on: https://review.haiku-os.org/c/haiku/+/9450 Reviewed-by: waddlesplash <[email protected]>
49 lines
1.4 KiB
C
49 lines
1.4 KiB
C
/*
|
|
* Copyright 2003-2012 Haiku, Inc. All Rights Reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _DLFCN_H
|
|
#define _DLFCN_H
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
#define RTLD_LAZY 0 /* relocations are performed as needed */
|
|
#define RTLD_NOW 1 /* the file gets relocated at load time */
|
|
#define RTLD_LOCAL 0 /* symbols are not available for relocating any other object */
|
|
#define RTLD_GLOBAL 2 /* all symbols are available */
|
|
#define RTLD_NOLOAD 4 /* do not load any new object */
|
|
#define RTLD_GROUP 8 /* do not lookup symbols in the global symbol table */
|
|
|
|
/* not-yet-POSIX extensions (dlsym() handles) */
|
|
#define RTLD_DEFAULT ((void*)0)
|
|
/* find the symbol in the global scope */
|
|
#define RTLD_NEXT ((void*)-1L)
|
|
/* find the next definition of the symbol */
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* This is a gnu extension for the dladdr function */
|
|
typedef struct {
|
|
const char *dli_fname; /* Filename of defining object */
|
|
void *dli_fbase; /* Load address of that object */
|
|
const char *dli_sname; /* Name of nearest lower symbol */
|
|
void *dli_saddr; /* Exact value of nearest symbol */
|
|
} Dl_info_t;
|
|
typedef Dl_info_t Dl_info;
|
|
|
|
extern int dlclose(void *image);
|
|
extern char *dlerror(void);
|
|
extern void *dlopen(const char *path, int mode);
|
|
extern void *dlsym(void *image, const char *symbolName);
|
|
extern int dladdr(const void *addr, Dl_info_t *info);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _DLFCN_H */
|