Changeset 15205


Ignore:
Timestamp:
Feb 12, 2012, 8:38:52 PM (8 years ago)
Author:
gb
Message:

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.)

Location:
trunk/source/lisp-kernel
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/androidarm/Makefile

    r15197 r15205  
    6464
    6565COBJ  = pmcl-kernel.o gc-common.o arm-gc.o bits.o  arm-exceptions.o \
    66         image.o thread_manager.o lisp-debug.o memory.o unix-calls.o
     66        image.o thread_manager.o lisp-debug.o memory.o unix-calls.o \
     67        android_native_app_glue.o
    6768
    6869DEBUGOBJ = lispdcmd.o plprint.o plsym.o albt.o arm_print.o
     
    8081
    8182KSPOBJ = $(SPOBJ)
    82 all:    ../../aarmcl.so ../../aarmcl
     83all:    ../../libaarmcl.so ../../aarmcl
    8384
    8485aarmcl.o: aarmcl.c
    8586        $(CC) -g -I$(NDKINC) -c $< -fpic -o $@
    8687
    87 # No:
    8888
    89 # KSPOBJ=
    90 # all:  ../../armcl ../../subprims.so
    91 
    92 OSLIBS = -ldl -lm -lc
     89OSLIBS = -ldl -lm -lc -landroid -llog
    9390APPLIBS = $(OSLIBS) $(NDKLIB)/crtbegin_dynamic.o $(NDKLIB)/crtend_android.o
    9491
    9592
    96 ../../aarmcl.so:        $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ) ./armandroid.x ./fixlib
    97         $(LD) --shared -Bdynamic -dynamic-linker /system/bin/linker -nostdlib -z nocopyreloc  -o ../../aarmcl.so  -L $(NDKLIB) pad.o arm-spentry.o  pmcl-kernel.o gc-common.o arm-gc.o bits.o arm-exceptions.o image.o thread_manager.o lisp-debug.o memory.o unix-calls.o arm-asmutils.o imports.o lispdcmd.o plprint.o plsym.o albt.o arm_print.o $(OSLIBS) -T ./armandroid.x
    98         ./fixlib $(LIBBASE) >> ../../aarmcl.so
     93../../libaarmcl.so:     $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ) ./armandroid.x ./fixlib
     94        $(LD) --shared -Bdynamic -dynamic-linker /system/bin/linker -nostdlib -z nocopyreloc  -o ../../libaarmcl.so  -L $(NDKLIB) pad.o arm-spentry.o  pmcl-kernel.o gc-common.o arm-gc.o bits.o arm-exceptions.o image.o thread_manager.o lisp-debug.o memory.o unix-calls.o arm-asmutils.o imports.o lispdcmd.o plprint.o plsym.o albt.o arm_print.o android_native_app_glue.o --no-as-needed $(OSLIBS) -T ./armandroid.x
     95        ./fixlib $(LIBBASE) >> ../../libaarmcl.so
    9996
    10097../../aarmcl:   aarmcl.o
     
    111108
    112109cclean:
    113         $(RM) -f $(KERNELOBJ) $(DEBUGOBJ) ../../aarmcl ../../aarmcl.so ./fixlib
     110        $(RM) -f $(KERNELOBJ) $(DEBUGOBJ) ../../aarmcl ../../libaarmcl.so ./fixlib
    114111
    115112clean:  cclean
  • trunk/source/lisp-kernel/androidarm/aarmcl.c

    r14569 r15205  
    1212main(int argc, char *argv[], char *envp, void *auxv)
    1313{
    14   char buf[PATH_MAX], *path;
    15   int n;
     14  char buf[PATH_MAX], *path, *lastslash;
     15  int n, prefixlen;
    1616  void *libhandle;
    1717
    1818  if ((n = readlink("/proc/self/exe", buf, PATH_MAX)) > 0) {
    19     path = malloc(n+4);
    20     memmove(path,buf,n);
    21     memmove(path+n,".so",3);
    22     path[n+3] = 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    }
    2334    libhandle = dlopen(path,RTLD_GLOBAL|RTLD_NOW);
    2435    if (libhandle != NULL) {
  • trunk/source/lisp-kernel/arm-spentry.s

    r15158 r15205  
    44364436        .long 0
    44374437        .long 0
    4438         .ltorg
    44394438        .data
    4440         .global C(sptab)
    4441         .global C(sptab_end)
     4439        .globl C(sptab)
     4440        .globl C(sptab_end)
    44424441        new_local_labels()
    44434442C(sptab):
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r15202 r15205  
    23862386     at an address other than 0x8000.  Todo: parse /proc/self/maps. */
    23872387  char *p;
    2388   Elf_Ehdr *elf_header;
    2389   Elf_Shdr *section_header;
     2388  Elf_Ehdr_thing *elf_header;
     2389  Elf_Shdr_thing *section_header;
    23902390  int i,fd;
    23912391  struct stat _stat;
    2392   Elf_Dyn *result = NULL;
     2392  Elf_Dyn_thing *result = NULL;
    23932393 
    23942394  fd = open("/proc/self/exe",O_RDONLY);
     
    23972397      p = (char *)mmap(NULL,_stat.st_size,PROT_READ,MAP_PRIVATE,fd,0);
    23982398      if (p != MAP_FAILED) {
    2399         elf_header = (Elf_Ehdr *)p;
    2400         for (section_header = (Elf_Shdr *)(p+elf_header->e_shoff),
     2399        elf_header = (Elf_Ehdr_thing *)p;
     2400        for (section_header = (Elf_Shdr_thing *)(p+elf_header->e_shoff),
    24012401               i = 0;
    24022402             i < elf_header->e_shnum;
    24032403             i++,section_header++) {
    24042404          if (section_header->sh_type == SHT_DYNAMIC) {
    2405             result = (Elf_Dyn *)section_header->sh_addr;
     2405            result = (Elf_Dyn_thing *)section_header->sh_addr;
    24062406            break;
    24072407          }
     
    25892589}
    25902590     
     2591#ifdef ANDROID
     2592#include <jni.h>
     2593#include "android_native_app_glue.h"
     2594
     2595jint
     2596JNI_OnLoad(JavaVM *vm, void *unused)
     2597{
     2598  return -1;
     2599}
     2600
     2601
     2602/*
     2603   This runs on a secondary thread that isn't bound to the JVM.
     2604   Splitting the event loop in two like this is supposed to
     2605   weaken timing constraints somehow.  It's not clear that it
     2606   actually does so, but Android NDK examples generally use
     2607   this mechanism.
     2608*/
     2609   
     2610void
     2611android_main(struct android_app* state)
     2612{
     2613}
     2614#endif
     2615
Note: See TracChangeset for help on using the changeset viewer.