1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 by Thomas Martitz
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include <string.h> /* size_t */
25 #include "load_code.h"
27 void *lc_open(const char *filename
, unsigned char *buf
, size_t buf_size
)
31 void *handle
= dlopen(filename
, RTLD_NOW
);
34 DEBUGF("failed to load %s\n", filename
);
35 DEBUGF("lc_open(%s): %s\n", filename
, dlerror());
40 void *lc_get_header(void *handle
)
42 char *ret
= dlsym(handle
, "__header");
44 ret
= dlsym(handle
, "___header");
49 void lc_close(void *handle
)
54 void *lc_open_from_mem(void *addr
, size_t 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 */