diff options
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r-- | firmware/target/hosted/lc-unix.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/firmware/target/hosted/lc-unix.c b/firmware/target/hosted/lc-unix.c index 8a265de066..6e5f15ec99 100644 --- a/firmware/target/hosted/lc-unix.c +++ b/firmware/target/hosted/lc-unix.c | |||
@@ -20,24 +20,44 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include <string.h> /* size_t */ | 22 | #include <string.h> /* size_t */ |
23 | #include <dlfcn.h> | ||
24 | #include "debug.h" | ||
23 | #include "load_code.h" | 25 | #include "load_code.h" |
24 | 26 | ||
25 | /* unix specific because WIN32 wants UCS instead of UTF-8, so filenames | ||
26 | * need to be converted */ | ||
27 | |||
28 | /* plain wrappers , nothing to do */ | ||
29 | void *lc_open(const char *filename, unsigned char *buf, size_t buf_size) | 27 | void *lc_open(const char *filename, unsigned char *buf, size_t buf_size) |
30 | { | 28 | { |
31 | return _lc_open(filename, buf, buf_size); | 29 | (void)buf; |
30 | (void)buf_size; | ||
31 | void *handle = dlopen(filename, RTLD_NOW); | ||
32 | if (handle == NULL) | ||
33 | { | ||
34 | DEBUGF("failed to load %s\n", filename); | ||
35 | DEBUGF("lc_open(%s): %s\n", filename, dlerror()); | ||
36 | } | ||
37 | return handle; | ||
32 | } | 38 | } |
33 | 39 | ||
34 | void *lc_get_header(void *handle) | 40 | void *lc_get_header(void *handle) |
35 | { | 41 | { |
36 | return _lc_get_header(handle); | 42 | char *ret = dlsym(handle, "__header"); |
43 | if (ret == NULL) | ||
44 | ret = dlsym(handle, "___header"); | ||
45 | |||
46 | return ret; | ||
37 | } | 47 | } |
38 | 48 | ||
39 | void lc_close(void *handle) | 49 | void lc_close(void *handle) |
40 | { | 50 | { |
41 | _lc_close(handle); | 51 | dlclose(handle); |
42 | } | 52 | } |
43 | 53 | ||
54 | void *lc_open_from_mem(void *addr, size_t blob_size) | ||
55 | { | ||
56 | (void)addr; | ||
57 | (void)blob_size; | ||
58 | /* we don't support loading code from memory on application builds, | ||
59 | * it doesn't make sense (since it means writing the blob to disk again and | ||
60 | * then falling back to load from disk) and requires the ability to write | ||
61 | * to an executable directory */ | ||
62 | return NULL; | ||
63 | } | ||