Subversion Repositories Kolibri OS

Rev

Rev 7851 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7851 Rev 7950
Line 12... Line 12...
12
typedef struct {
12
typedef struct {
13
    void **importNames;
13
    void **importNames;
14
    char * libraryName;
14
    char * libraryName;
15
} KosImp;
15
} KosImp;
Line 16... Line 16...
16
 
16
 
Line 17... Line 17...
17
static const char *__error;
17
static int stdcall dll_Load(KosImp *importTableEntry);
Line 18... Line 18...
18
 
18
 
19
static int stdcall dll_Load(KosImp *importTable);
19
static const char *__error;
20
 
20
 
21
static int stdcall dll_Load(KosImp *importTableEntry) {
21
static int stdcall dll_Load(KosImp *importTableEntry) {
Line 36... Line 36...
36
// https://pubs.opengroup.org/onlinepubs/007908799/xsh/dlopen.html
36
// https://pubs.opengroup.org/onlinepubs/007908799/xsh/dlopen.html
37
// Current implementation fully ignores "mode" parameter
37
// Current implementation fully ignores "mode" parameter
38
void *dlopen(const char *name, int mode) {
38
void *dlopen(const char *name, int mode) {
39
    KosExp *exports = NULL;
39
    KosExp *exports = NULL;
Line 40... Line 40...
40
 
40
 
41
    // загрузить либу сискаллом
41
    // load library using syscall
42
    asm volatile ("int $0x40":"=a"(exports):"a"(68), "b"(19), "c"(name));
42
    asm volatile ("int $0x40":"=a"(exports):"a"(68), "b"(19), "c"(name));
43
    if (!exports) {
43
    if (!exports) {
Line 44... Line 44...
44
        char libPath[256] = "/sys/lib/";
44
        char libPath[256] = "/sys/lib/";
Line 48... Line 48...
48
        if (!exports) {
48
        if (!exports) {
49
            __error = "Library not found in \"/sys/lib/\" nor current folder";
49
            __error = "Library not found in \"/sys/lib/\" nor current folder";
50
            return NULL;
50
            return NULL;
51
        }
51
        }
52
    }
52
    }
53
    // Вызвать что-нибудь что начинается с "lib_"
53
    // call anything starting with "lib_"
54
    for (KosExp *export = exports; export->name; export++) {
54
    for (KosExp *export = exports; export->name; export++) {
55
        if (!memcmp(export->name, "lib_", 4)) {
55
        if (!memcmp(export->name, "lib_", 4)) {
56
            asm volatile (
56
            asm volatile (
57
                "call *%4" ::
57
                "call *%4" ::
58
                "a"(sysmalloc),
58
                "a"(sysmalloc),