1

全部。我正在尝试让 dalvikVM 在嵌入式 linux 上运行。我将 xilinx-linux 用于在 qemu 上运行的 zynq-zc702。我遵循了本教程:

http://www.bolatdinc.com/?p=336&cpage=1

我将 ashmem 和 logger 移植到我的 linux 内核,并为 armv7-a 架构编译了 dalvik。但是当我运行 /system/bin/dalvikvm 时,我得到了以下 strace 的段错误:

execve("/system/bin/dalvikvm", ["dalvikvm"], [/* 10 vars */]) = 0
set_tls(0xb0012c70, 0xb00144bc, 0xffffffd0, 0, 0) = 0
getpid()                                = 1210
getuid32()                              = 0
geteuid32()                             = 0
getgid32()                              = 0
getegid32()                             = 0
sigaction(SIGILL, {0xb0005b29, [], SA_RESTART|SA_SIGINFO}, NULL, 0) = 0
sigaction(SIGABRT, {0xb0005b29, [], SA_RESTART|SA_SIGINFO}, NULL, 0) = 0
sigaction(SIGBUS, {0xb0005b29, [], SA_RESTART|SA_SIGINFO}, NULL, 0) = 0
sigaction(SIGFPE, {0xb0005b29, [], SA_RESTART|SA_SIGINFO}, NULL, 0) = 0
sigaction(SIGSEGV, {0xb0005b29, [], SA_RESTART|SA_SIGINFO}, NULL, 0) = 0
sigaction(SIGSTKFLT, {0xb0005b29, [], SA_RESTART|SA_SIGINFO}, NULL, 0) = 0
sigaction(SIGPIPE, {0xb0005b29, [], SA_RESTART|SA_SIGINFO}, NULL, 0) = 0
stat64("/vendor/lib/libdvm.so", 0xbec3da20) = -1 ENOENT (No such file or directory)
stat64("/system/lib/libdvm.so", {st_mode=S_IFREG|0775, st_size=753884, ...}) = 0
open("/system/lib/libdvm.so", O_RDONLY|O_LARGEFILE) = 3
lseek(3, 0, SEEK_SET)                   = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\0\0\0004\0\0\0"..., 4096) = 4096
lseek(3, -8, SEEK_END)                  = 753876
read(3, "\1\0\0\0\0\0\0\0", 8)          = 8
mmap2(NULL, 765952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6e95000
mmap2(0xb6e95000, 719912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xb6e95000
mprotect(0xb6e95000, 720896, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mmap2(0xb6f45000, 31748, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xb0) = 0xb6f45000
mmap2(0xb6f4d000, 8812, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f4d000
close(3)                                = 0
stat64("/vendor/lib/liblog.so", 0xbec3d778) = -1 ENOENT (No such file or directory)
stat64("/system/lib/liblog.so", {st_mode=S_IFREG|0775, st_size=13888, ...}) = 0
open("/system/lib/liblog.so", O_RDONLY|O_LARGEFILE) = 3
lseek(3, 0, SEEK_SET)                   = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\0\0\0004\0\0\0"..., 4096) = 4096
lseek(3, -8, SEEK_END)                  = 13880
read(3, "\1\0\0\0\0\0\0\0", 8)          = 8
mmap2(NULL, 16384, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6e91000
mmap2(0xb6e91000, 10864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xb6e91000
mprotect(0xb6e91000, 12288, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mmap2(0xb6e94000, 412, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x3) = 0xb6e94000
close(3)                                = 0
stat64("/vendor/lib/libc.so", 0xbec3d4d0) = -1 ENOENT (No such file or directory)
stat64("/system/lib/libc.so", {st_mode=S_IFREG|0775, st_size=282212, ...}) = 0
open("/system/lib/libc.so", O_RDONLY|O_LARGEFILE) = 3
lseek(3, 0, SEEK_SET)                   = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\0\0\0004\0\0\0"..., 4096) = 4096
lseek(3, -8, SEEK_END)                  = 282204
read(3, "\1\0\0\0\0\0\0\0", 8)          = 8
mmap2(NULL, 327680, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6e41000
mmap2(0xb6e41000, 270012, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xb6e41000
mprotect(0xb6e41000, 270336, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mmap2(0xb6e83000, 10100, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x42) = 0xb6e83000
mmap2(0xb6e86000, 43772, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6e86000
close(3)                                = 0
mprotect(0xb6e41000, 270336, PROT_READ|PROT_EXEC) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xc} ---
open("/dev/log/main", O_WRONLY|O_LARGEFILE) = 3
writev(3, [{"\7", 1}, {"libc\0", 5}, {"Fatal signal 11 (SIGSEGV) at 0x0"..., 49}], 3) = 55
gettid()                                = 1210
socket(PF_FILE, SOCK_STREAM, 0)         = 4
connect(4, {sa_family=AF_FILE, sun_path=@"android:debuggerd"}, 20) = -1 ECONNREFUSED (Connection refused)
close(4)                                = 0
sigaction(SIGSEGV, {SIG_DFL, [], SA_RESTART}, {0xb0005b29, [], SA_RESTART|SA_SIGINFO}, 0) = 0
rt_sigreturn()                          = -61456
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xc} ---
+++ killed by SIGSEGV +++
Segmentation fault

奇怪的是,即使我评论了 dalvik/dalvikvm/Main.cpp main(...) 函数中的所有行,除了 return 0; 我仍然得到这个段错误。

writev(3, [{"\7", 1}, {"libc\0", 5}, {"Fatal signal 11 (SIGSEGV) at 0x0"..., 49}], 3) = 55

似乎是某种 libc/bionic 问题,但我仍然不知道如何解决它。

如果我为它创建非常基本的 helloworld 应用程序和 Android.mk,将 helloworld 构建为 android 树的一部分,我会得到相同的段错误。如果我使用 arm-xilinx-linux-gnueabi- 工具链构建 helloworld,它可以正常工作。我相信那是因为它与 glibc 相关,而不是仿生。

我不太擅长拆解东西,所以我附加了 objdump -d 输出来工作 helloworld 和 segfaulting 一个。

在职的:

../testapp/main_stdlib:     file format elf32-littlearm


Disassembly of section .init:

0000836c <_init>:
    836c:   e92d4008    push    {r3, lr}
    8370:   eb00001d    bl  83ec <call_weak_fn>
    8374:   e8bd8008    pop {r3, pc}

Disassembly of section .plt:

00008378 <.plt>:
    8378:   e52de004    push    {lr}        ; (str lr, [sp, #-4]!)
    837c:   e59fe004    ldr lr, [pc, #4]    ; 8388 <_init+0x1c>
    8380:   e08fe00e    add lr, pc, lr
    8384:   e5bef008    ldr pc, [lr, #8]!
    8388:   00008388    .word   0x00008388
    838c:   e28fc600    add ip, pc, #0, 12
    8390:   e28cca08    add ip, ip, #8, 20  ; 0x8000
    8394:   e5bcf388    ldr pc, [ip, #904]! ; 0x388
    8398:   e28fc600    add ip, pc, #0, 12
    839c:   e28cca08    add ip, ip, #8, 20  ; 0x8000
    83a0:   e5bcf380    ldr pc, [ip, #896]! ; 0x380
    83a4:   e28fc600    add ip, pc, #0, 12
    83a8:   e28cca08    add ip, ip, #8, 20  ; 0x8000
    83ac:   e5bcf378    ldr pc, [ip, #888]! ; 0x378

Disassembly of section .text:

000083b0 <_start>:
    83b0:   e3a0b000    mov fp, #0
    83b4:   e3a0e000    mov lr, #0
    83b8:   e49d1004    pop {r1}        ; (ldr r1, [sp], #4)
    83bc:   e1a0200d    mov r2, sp
    83c0:   e52d2004    push    {r2}        ; (str r2, [sp, #-4]!)
    83c4:   e52d0004    push    {r0}        ; (str r0, [sp, #-4]!)
    83c8:   e59fc010    ldr ip, [pc, #16]   ; 83e0 <_start+0x30>
    83cc:   e52dc004    push    {ip}        ; (str ip, [sp, #-4]!)
    83d0:   e59f000c    ldr r0, [pc, #12]   ; 83e4 <_start+0x34>
    83d4:   e59f300c    ldr r3, [pc, #12]   ; 83e8 <_start+0x38>
    83d8:   ebffffeb    bl  838c <_init+0x20>
    83dc:   ebfffff0    bl  83a4 <_init+0x38>
    83e0:   0000857c    .word   0x0000857c
    83e4:   000084e4    .word   0x000084e4
    83e8:   00008518    .word   0x00008518

000083ec <call_weak_fn>:
    83ec:   e59f3014    ldr r3, [pc, #20]   ; 8408 <call_weak_fn+0x1c>
    83f0:   e59f2014    ldr r2, [pc, #20]   ; 840c <call_weak_fn+0x20>
    83f4:   e08f3003    add r3, pc, r3
    83f8:   e7932002    ldr r2, [r3, r2]
    83fc:   e3520000    cmp r2, #0
    8400:   012fff1e    bxeq    lr
    8404:   eaffffe3    b   8398 <_init+0x2c>
    8408:   00008314    .word   0x00008314
    840c:   00000018    .word   0x00000018

00008410 <deregister_tm_clones>:
    8410:   e92d4008    push    {r3, lr}
    8414:   e3000734    movw    r0, #1844   ; 0x734
    8418:   e59f3024    ldr r3, [pc, #36]   ; 8444 <deregister_tm_clones+0x34>
    841c:   e3400001    movt    r0, #1
    8420:   e0603003    rsb r3, r0, r3
    8424:   e3530006    cmp r3, #6
    8428:   98bd8008    popls   {r3, pc}
    842c:   e3003000    movw    r3, #0
    8430:   e3403000    movt    r3, #0
    8434:   e3530000    cmp r3, #0
    8438:   08bd8008    popeq   {r3, pc}
    843c:   e12fff33    blx r3
    8440:   e8bd8008    pop {r3, pc}
    8444:   00010737    .word   0x00010737

00008448 <register_tm_clones>:
    8448:   e92d4008    push    {r3, lr}
    844c:   e3000734    movw    r0, #1844   ; 0x734
    8450:   e3003734    movw    r3, #1844   ; 0x734
    8454:   e3400001    movt    r0, #1
    8458:   e3403001    movt    r3, #1
    845c:   e0603003    rsb r3, r0, r3
    8460:   e1a03143    asr r3, r3, #2
    8464:   e0833fa3    add r3, r3, r3, lsr #31
    8468:   e1b010c3    asrs    r1, r3, #1
    846c:   08bd8008    popeq   {r3, pc}
    8470:   e3002000    movw    r2, #0
    8474:   e3402000    movt    r2, #0
    8478:   e3520000    cmp r2, #0
    847c:   08bd8008    popeq   {r3, pc}
    8480:   e12fff32    blx r2
    8484:   e8bd8008    pop {r3, pc}

00008488 <__do_global_dtors_aux>:
    8488:   e92d4010    push    {r4, lr}
    848c:   e3004734    movw    r4, #1844   ; 0x734
    8490:   e3404001    movt    r4, #1
    8494:   e5d43000    ldrb    r3, [r4]
    8498:   e3530000    cmp r3, #0
    849c:   18bd8010    popne   {r4, pc}
    84a0:   ebffffda    bl  8410 <deregister_tm_clones>
    84a4:   e3a03001    mov r3, #1
    84a8:   e5c43000    strb    r3, [r4]
    84ac:   e8bd8010    pop {r4, pc}

000084b0 <frame_dummy>:
    84b0:   e300061c    movw    r0, #1564   ; 0x61c
    84b4:   e3400001    movt    r0, #1
    84b8:   e92d4008    push    {r3, lr}
    84bc:   e5903000    ldr r3, [r0]
    84c0:   e3530000    cmp r3, #0
    84c4:   0a000004    beq 84dc <frame_dummy+0x2c>
    84c8:   e3003000    movw    r3, #0
    84cc:   e3403000    movt    r3, #0
    84d0:   e3530000    cmp r3, #0
    84d4:   0a000000    beq 84dc <frame_dummy+0x2c>
    84d8:   e12fff33    blx r3
    84dc:   e8bd4008    pop {r3, lr}
    84e0:   eaffffd8    b   8448 <register_tm_clones>

000084e4 <main>:
    84e4:   e52db004    push    {fp}        ; (str fp, [sp, #-4]!)
    84e8:   e28db000    add fp, sp, #0
    84ec:   e24dd014    sub sp, sp, #20
    84f0:   e50b0010    str r0, [fp, #-16]
    84f4:   e50b1014    str r1, [fp, #-20]  ; 0xffffffec
    84f8:   e308358c    movw    r3, #34188  ; 0x858c
    84fc:   e3403000    movt    r3, #0
    8500:   e50b3008    str r3, [fp, #-8]
    8504:   e3a03000    mov r3, #0
    8508:   e1a00003    mov r0, r3
    850c:   e28bd000    add sp, fp, #0
    8510:   e8bd0800    ldmfd   sp!, {fp}
    8514:   e12fff1e    bx  lr

00008518 <__libc_csu_init>:
    8518:   e92d45f8    push    {r3, r4, r5, r6, r7, r8, sl, lr}
    851c:   e1a07000    mov r7, r0
    8520:   e59f504c    ldr r5, [pc, #76]   ; 8574 <__libc_csu_init+0x5c>
    8524:   e1a08001    mov r8, r1
    8528:   e59f6048    ldr r6, [pc, #72]   ; 8578 <__libc_csu_init+0x60>
    852c:   e1a0a002    mov sl, r2
    8530:   e08f5005    add r5, pc, r5
    8534:   ebffff8c    bl  836c <_init>
    8538:   e08f6006    add r6, pc, r6
    853c:   e0656006    rsb r6, r5, r6
    8540:   e1b06146    asrs    r6, r6, #2
    8544:   08bd85f8    popeq   {r3, r4, r5, r6, r7, r8, sl, pc}
    8548:   e2455004    sub r5, r5, #4
    854c:   e3a04000    mov r4, #0
    8550:   e5b53004    ldr r3, [r5, #4]!
    8554:   e1a00007    mov r0, r7
    8558:   e1a01008    mov r1, r8
    855c:   e1a0200a    mov r2, sl
    8560:   e2844001    add r4, r4, #1
    8564:   e12fff33    blx r3
    8568:   e1540006    cmp r4, r6
    856c:   1afffff7    bne 8550 <__libc_csu_init+0x38>
    8570:   e8bd85f8    pop {r3, r4, r5, r6, r7, r8, sl, pc}
    8574:   000080dc    .word   0x000080dc
    8578:   000080d8    .word   0x000080d8

0000857c <__libc_csu_fini>:
    857c:   e12fff1e    bx  lr

Disassembly of section .fini:

00008580 <_fini>:
    8580:   e92d4008    push    {r3, lr}
    8584:   e8bd8008    pop {r3, pc}

带段错误:

~/android/out/debug/target/product/generic/system/bin/dalvikvm:     file format elf32-littlearm


Disassembly of section .plt:

00008410 <.plt>:
    8410:   e52de004    .word   0xe52de004
    8414:   e59fe004    .word   0xe59fe004
    8418:   e08fe00e    .word   0xe08fe00e
    841c:   e5bef008    .word   0xe5bef008
    8420:   00000cc0    .word   0x00000cc0
    8424:   e28fc600    .word   0xe28fc600
    8428:   e28cca00    .word   0xe28cca00
    842c:   e5bcfcc0    .word   0xe5bcfcc0

Disassembly of section .text:

00008430 <__aeabi_llsr-0x30>:
    8430:   e1a0000d    .word   0xe1a0000d
    8434:   e3a01000    .word   0xe3a01000
    8438:   e28f2004    .word   0xe28f2004
    843c:   e28f3004    .word   0xe28f3004
    8440:   eafffff7    .word   0xeafffff7
    8444:   ea000014    .word   0xea000014
    8448:   00009000    .word   0x00009000
    844c:   00009008    .word   0x00009008
    8450:   00009010    .word   0x00009010
    8454:   00009018    .word   0x00009018
    8458:   e1a00000    .word   0xe1a00000
    845c:   e1a00000    .word   0xe1a00000

00008460 <__aeabi_llsr>:
    8460:   e2523020    subs    r3, r2, #32
    8464:   e262c020    rsb ip, r2, #32
    8468:   41a00230    lsrmi   r0, r0, r2
    846c:   51a00331    lsrpl   r0, r1, r3
    8470:   41800c11    orrmi   r0, r0, r1, lsl ip
    8474:   e1a01231    lsr r1, r1, r2
    8478:   e12fff1e    bx  lr

0000847c <__aeabi_llsl>:
    847c:   e2523020    subs    r3, r2, #32
    8480:   e262c020    rsb ip, r2, #32
    8484:   41a01211    lslmi   r1, r1, r2
    8488:   51a01310    lslpl   r1, r0, r3
    848c:   41811c30    orrmi   r1, r1, r0, lsr ip
    8490:   e1a00210    lsl r0, r0, r2
    8494:   e12fff1e    bx  lr
    8498:   47702000    ldrbmi  r2, [r0, -r0]!
    849c:   e51ff004    ldr pc, [pc, #-4]   ; 84a0 <__aeabi_llsl+0x24>
    84a0:   00008499    muleq   r0, r9, r4

任何帮助或想法表示赞赏。谢谢

4

2 回答 2

0

从您的跟踪中很难判断它实际失败的位置。您是在使用 Android 还是尝试在非 Android 配置中使用 dalvik?使用 Android 的嵌入式配置可能比尝试将 Dalvik 移植到基于非仿生的 Linux 发行版更容易。

像 Dalvik 这样的 Android 系统组件使用了相当多的额外内核组件,因此您可能仍然缺少其中的一些。

我在内核配置中启用了以下功能,并且能够运行 dalvik:

#
# Android
#
CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=y
CONFIG_ASHMEM=y
CONFIG_ANDROID_LOGGER=y
CONFIG_ANDROID_TIMED_OUTPUT=y
# CONFIG_ANDROID_TIMED_GPIO is not set
CONFIG_ANDROID_LOW_MEMORY_KILLER=y
CONFIG_ANDROID_INTF_ALARM_DEV=y
于 2014-05-23T13:53:30.817 回答
0

最终,我能够通过从 Android 构建树中获取 dalvik 源和依赖项并创建我自己的一组 makefile 而不是 Android.mk 来解决这个问题。在我的 Makefiles 中,我使用了 arm-xilinx-linux-gnueabi- 工具链中的 libc 链接,而不是仿生。在这种情况下,一切都运行完美

于 2014-05-30T11:39:02.393 回答