source: trunk/source/lisp-kernel/androidarm/aarmcl.c @ 15205

Last change on this file since 15205 was 15205, checked in by gb, 9 years ago

Include the (Apache-licensed) android_native_app_glue stuff and
hook it into the kernel; add some dependent Android libraries.

In arm-spentry.s, use ".globl" instead of ".global", since the
World's Most Advanced Assembler doesn't understand the latter.
(Not that we currently care.)

File size: 1.1 KB
Line 
1#include <dlfcn.h>
2#include <errno.h>
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6#include <unistd.h>
7
8int
9(*cclmain)();
10
11int
12main(int argc, char *argv[], char *envp, void *auxv)
13{
14  char buf[PATH_MAX], *path, *lastslash;
15  int n, prefixlen;
16  void *libhandle;
17
18  if ((n = readlink("/proc/self/exe", buf, PATH_MAX)) > 0) {
19    path = malloc(n+4+3);
20    lastslash = strrchr(buf,'/');
21    if (lastslash) {
22      lastslash++;
23      prefixlen = lastslash-buf;
24      strncpy(path,buf,prefixlen);
25      strcat(path,"lib");
26      strcat(path,lastslash);
27      strcat(path,".so");
28    } else {
29      memmove(path,"lib",3);
30      memmove(path+3,buf,n);
31      memmove(path+3+n,".so",3);
32      path[n+3+3] = 0;
33    }
34    libhandle = dlopen(path,RTLD_GLOBAL|RTLD_NOW);
35    if (libhandle != NULL) {
36      cclmain = dlsym(libhandle, "cclmain");
37      if (cclmain != NULL) {
38        return cclmain(argc,argv,envp, auxv);
39      } else {
40        fprintf(stderr, "Couldn't resolve library entrpoint.\n");
41      }
42    } else {
43      fprintf(stderr, "Couldn't open shared library %s : %s\n",
44              path, dlerror());
45    }
46    return 1;
47  }
48}
49
50
51
52
53 
Note: See TracBrowser for help on using the repository browser.