-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds weak exports for the POSIX `dlopen`, `dlsym`, `dlclose`, and `dlerror` functions, allowing code which uses those features to compile. The implementations are stubs which always fail since there is currently no official standard for runtime dynamic linking. Since the symbols are weak, they can be overriden with useful, runtime-specific implementations, e.g. based on host functions or statically-generated tables (see https://github.com/dicej/component-linking-demo for an example of the latter). Signed-off-by: Joel Dice <joel.dice@fermyon.com>
- Loading branch information
Showing
8 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -573,6 +573,10 @@ difftime | |
dirfd | ||
dirname | ||
div | ||
dlclose | ||
dlerror | ||
dlopen | ||
dlsym | ||
dprintf | ||
drand48 | ||
drem | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -509,6 +509,10 @@ difftime | |
dirfd | ||
dirname | ||
div | ||
dlclose | ||
dlerror | ||
dlopen | ||
dlsym | ||
dprintf | ||
drand48 | ||
drem | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <dlfcn.h> | ||
|
||
#define EXPORT __attribute__((visibility("default"))) __attribute__((used)) | ||
#define WEAK __attribute__((__weak__)) | ||
|
||
static const char *error = 0; | ||
|
||
EXPORT WEAK int dlclose(void *library) { | ||
error = "dlclose not implemented"; | ||
return -1; | ||
} | ||
|
||
EXPORT WEAK char *dlerror(void) { | ||
const char *var = error; | ||
error = 0; | ||
return (char*) var; | ||
} | ||
|
||
EXPORT WEAK void *dlopen(const char *name, int flags) { | ||
error = "dlopen not implemented"; | ||
return 0; | ||
} | ||
|
||
EXPORT WEAK void *dlsym(void *library, const char *name) { | ||
error = "dlsym not implemented"; | ||
return 0; | ||
} |