mprotect

d:\linux\linuxkernel\WORKING_DIRECTORY\android-omap-20111108-gingerbread\dalvik\vm\oo\Class.c
bool dvmClassStartup(void)
    gDvm.pBootLoaderAlloc = dvmLinearAllocCreate(NULL);


d:\linux\linuxkernel\WORKING_DIRECTORY\android-omap-20111108-gingerbread\dalvik\vm\LinearAlloc.c
LinearAllocHdr* dvmLinearAllocCreate(Object* classLoader)
    pHdr->mapAddr = mmap(NULL, pHdr->mapLength, PROT_READ | PROT_WRITE,
        MAP_PRIVATE, fd, 0);// 0xa850000
static inline LinearAllocHdr* getHeader(Object* classLoader)
{
    return gDvm.pBootLoaderAlloc;
}
void* dvmLinearAlloc(Object* classLoader, size_t size)
{
    LinearAllocHdr* pHdr = getHeader(classLoader);


        *(u4*)(pHdr->mapAddr + startOffset) = size;
This is writing the memory of mappingfile, and there's some kind of vialation. In LinearAlloc.c:
//    pHdr->mapAddr = mmap(NULL, pHdr->mapLength, PROT_READ | PROT_WRITE,
//        MAP_PRIVATE, fd, 0);
    pHdr->mapAddr = mmap(NULL, pHdr->mapLength, PROT_READ | PROT_WRITE,
        MAP_SHARED, fd, 0);
d:\linux\linuxkernel\WORKING_DIRECTORY\android-omap-20111108-gingerbread\dalvik\vm\LinearAlloc.
* commented by ango
     */
//    if (mprotect(pHdr->mapAddr, pHdr->mapLength, PROT_NONE) != 0) {
mprotect make the pHdr->mapAddr cannot be accessed at all
0  0x005556cb  dvmLinearAlloc  d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/LinearAlloc.c  382
1  0x004d1e8a  loadClassFromDex0  d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/oo/Class.c  1750
2  0x004d24f1  loadClassFromDex  d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/oo/Class.c  1921
3  0x004d16dd  findClassNoInit  d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/oo/Class.c  1461
4  0x004d1586  dvmFindSystemClassNoInit  d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/oo/Class.c  1382
5  0x004d14e2  dvmFindSystemClass  d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/oo/Class.c  1360
6  0x0052ecab  loadAllClasses  d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/analysis/DexPrepare.c  871
7  0x0052eb56  rewriteDex  d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/analysis/DexPrepare.c  800
8  0x0052e577  dvmContinueOptimization  d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/analysis/DexPrepare.c  577
9  0x0040205f  fromDex  d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/dexopt/OptMain.c  538
10  0x00402188  dexoptmain  d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/dexopt/OptMain.c  597
11  0x00401330  main  d:/linux/linuxkernel/WORKING_DIRECTORY/ango/dexopt/main.c  8

你可能感兴趣的:(android,AnGo)