summaryrefslogtreecommitdiffstats
path: root/firmware/target/hosted/lc-unix.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-05-26 22:46:56 +0200
committerThomas Martitz <kugel@rockbox.org>2012-05-26 22:46:56 +0200
commit3f365fc06b67f8842b2e155349110f7c5659768d (patch)
tree3c83d9fc4802331cf542bfb23546a52b2190ba5c /firmware/target/hosted/lc-unix.c
parent3f72ba0e3f34ac47a83a426e6a19b96045b842de (diff)
downloadrockbox-3f365fc06b67f8842b2e155349110f7c5659768d.tar.gz
rockbox-3f365fc06b67f8842b2e155349110f7c5659768d.zip
load_code: Get rid of win32 specific code in favor SDL_LoadFunction & friends APIs.
Refactor native/hosted implementation seperation while at it (no wrappers starting with _ anymore). Change-Id: If68ae89700443bb3be483c1cace3d6739409560a
Diffstat (limited to 'firmware/target/hosted/lc-unix.c')
-rw-r--r--firmware/target/hosted/lc-unix.c34
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 @@
****************************************************************************/
#include <string.h> /* size_t */
+#include <dlfcn.h>
+#include "debug.h"
#include "load_code.h"
-/* unix specific because WIN32 wants UCS instead of UTF-8, so filenames
- * need to be converted */
-
-/* plain wrappers , nothing to do */
void *lc_open(const char *filename, unsigned char *buf, size_t buf_size)
{
- return _lc_open(filename, buf, buf_size);
+ (void)buf;
+ (void)buf_size;
+ void *handle = dlopen(filename, RTLD_NOW);
+ if (handle == NULL)
+ {
+ DEBUGF("failed to load %s\n", filename);
+ DEBUGF("lc_open(%s): %s\n", filename, dlerror());
+ }
+ return handle;
}
void *lc_get_header(void *handle)
{
- return _lc_get_header(handle);
+ char *ret = dlsym(handle, "__header");
+ if (ret == NULL)
+ ret = dlsym(handle, "___header");
+
+ return ret;
}
void lc_close(void *handle)
{
- _lc_close(handle);
+ dlclose(handle);
}
+void *lc_open_from_mem(void *addr, size_t blob_size)
+{
+ (void)addr;
+ (void)blob_size;
+ /* we don't support loading code from memory on application builds,
+ * it doesn't make sense (since it means writing the blob to disk again and
+ * then falling back to load from disk) and requires the ability to write
+ * to an executable directory */
+ return NULL;
+}