ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2010年10月25日 星期一

myhello - native shell runnable program in android-linux

會這樣寫是因為這是在 shell run 的程式,沒有用 Dalvik. 是要看看 android linux 的 bionic , share library 用偷懶的方法,拿 system/extra/sound 來參考 (copy)
  • 在 system/extra 下 create "myhello" folder
  • copy sound 的 Android.mk 過來
  • 修改 Android.mk
  • mm
build log: make: Entering directory `/home/checko/myandroid8.1' target thumb C: myhello <= system/extras/myhello/myhello.c target Executable: myhello (out/target/product/myBBG/obj/EXECUTABLES/myhello_intermediates/LINKED/myhello) target Non-prelinked: myhello (out/target/product/myBBG/symbols/system/bin/myhello) target Strip: myhello (out/target/product/myBBG/obj/EXECUTABLES/myhello_intermediates/myhello) Install: out/target/product/myBBG/system/bin/myhello Copy: out/target/product/myBBG/system/etc/apns-conf.xml make: Leaving directory `/home/checko/myandroid8.1' 在 croot (android project root),用 make showcommands myhello 的 log: build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/myBBG/obj/include/libpv/getactualaacconfig.h' build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/myBBG/obj/include/libpv/getactualaacconfig.h' /bin/bash: line 0: cd: sdk/layoutopt/app/src/resources: No such file or directory No private recovery resources for TARGET_DEVICE myBBG target thumb C: myhello <= system/extras/myhello/myhello.c prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gcc -I system/core/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I dalvik/libnativehelper/include -I frameworks/base/include -I frameworks/base/opengl/include -I external/skia/include -I out/target/product/myBBG/obj/include -I bionic/libc/arch-arm/include -I bionic/libc/include -I bionic/libstdc++/include -I bionic/libc/kernel/common -I bionic/libc/kernel/arch-arm -I bionic/libm/include -I bionic/libm/include/arch/arm -I bionic/libthread_db/include -I system/extras/myhello -I out/target/product/myBBG/obj/EXECUTABLES/myhello_intermediates -I out/target/product/myBBG/obj/STATIC_LIBRARIES/libwebcore_intermediates -c -fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -include system/core/include/arch/linux-arm/AndroidConfig.h -I system/core/include/arch/linux-arm/ -mthumb-interwork -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -DSK_RELEASE -DNDEBUG -g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -DNDEBUG -UDEBUG -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -MD -o out/target/product/myBBG/obj/EXECUTABLES/myhello_intermediates/myhello.o system/extras/myhello/myhello.c Install: out/host/linux-x86/bin/apriori out/host/linux-x86/bin/acp -fpt out/host/linux-x86/obj/EXECUTABLES/apriori_intermediates/apriori out/host/linux-x86/bin/apriori Install: out/host/linux-x86/bin/soslim out/host/linux-x86/bin/acp -fpt out/host/linux-x86/obj/EXECUTABLES/soslim_intermediates/soslim out/host/linux-x86/bin/soslim target Executable: myhello (out/target/product/myBBG/obj/EXECUTABLES/myhello_intermediates/LINKED/myhello) prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-g++ -nostdlib -Bdynamic -Wl,-T,build/core/armelf.x -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -o out/target/product/myBBG/obj/EXECUTABLES/myhello_intermediates/LINKED/myhello -Lout/target/product/myBBG/obj/lib -Wl,-rpath-link=out/target/product/myBBG/obj/lib -lc -lstdc++ -lm out/target/product/myBBG/obj/lib/crtbegin_dynamic.o out/target/product/myBBG/obj/EXECUTABLES/myhello_intermediates/myhello.o -Wl,--no-undefined /home/checko/myandroid8.1/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/interwork/libgcc.a out/target/product/myBBG/obj/lib/crtend_android.o target Non-prelinked: myhello (out/target/product/myBBG/symbols/system/bin/myhello) out/host/linux-x86/bin/acp -fpt out/target/product/myBBG/obj/EXECUTABLES/myhello_intermediates/LINKED/myhello out/target/product/myBBG/symbols/system/bin/myhello target Strip: myhello (out/target/product/myBBG/obj/EXECUTABLES/myhello_intermediates/myhello) out/host/linux-x86/bin/soslim --strip --shady --quiet out/target/product/myBBG/symbols/system/bin/myhello --outfile out/target/product/myBBG/obj/EXECUTABLES/myhello_intermediates/myhello Install: out/target/product/myBBG/system/lib/libdl.so out/host/linux-x86/bin/acp -fpt out/target/product/myBBG/obj/lib/libdl.so out/target/product/myBBG/system/lib/libdl.so Install: out/target/product/myBBG/system/lib/libc.so out/host/linux-x86/bin/acp -fpt out/target/product/myBBG/obj/lib/libc.so out/target/product/myBBG/system/lib/libc.so Install: out/target/product/myBBG/system/lib/libstdc++.so out/host/linux-x86/bin/acp -fpt out/target/product/myBBG/obj/lib/libstdc++.so out/target/product/myBBG/system/lib/libstdc++.so Install: out/target/product/myBBG/system/lib/libm.so out/host/linux-x86/bin/acp -fpt out/target/product/myBBG/obj/lib/libm.so out/target/product/myBBG/system/lib/libm.so Install: out/target/product/myBBG/system/bin/myhello out/host/linux-x86/bin/acp -fpt out/target/product/myBBG/obj/EXECUTABLES/myhello_intermediates/myhello out/target/product/myBBG/system/bin/myhello 這樣build 出來的 myhello 會被 install 在 system/bin 中,boot 後直接 invoke 就可以執行。 啟動 strace myhello 的內容: strace myhello execve("/system/bin/myhello", ["myhello"], [/* 19 vars */]) = 0 syscall_983045(0xb0017900, 0xbed6dbb4, 0, 0x847c, 0xb000f448, 0xbed6dbb0, 0x8, 0xf0005, 0, 0, 0, 0, 0, 0xbed6db58, 0xb000194b, 0xb000228c, 0x80000010, 0xb0017900, 0, 0, 0xc764, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) = 0 getpid() = 2109 sigaction(SIGILL, {0xb0001d45, [], SA_RESTART}, {SIG_DFL}, 0) = 0 sigaction(SIGABRT, {0xb0001d45, [], SA_RESTART}, {SIG_DFL}, 0) = 0 sigaction(SIGBUS, {0xb0001d45, [], SA_RESTART}, {SIG_DFL}, 0) = 0 sigaction(SIGFPE, {0xb0001d45, [], SA_RESTART}, {SIG_DFL}, 0) = 0 sigaction(SIGSEGV, {0xb0001d45, [], SA_RESTART}, {SIG_DFL}, 0) = 0 sigaction(SIGSTKFLT, {0xb0001d45, [], SA_RESTART}, {SIG_DFL}, 0) = 0 sigaction(SIGPIPE, {0xb0001d45, [], SA_RESTART}, {SIG_DFL}, 0) = 0 getuid32() = 0 geteuid32() = 0 getgid32() = 0 getegid32() = 0 stat64("/system/lib/libc.so", {st_mode=S_IFREG|0644, st_size=239972, ...}) = 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 \250\0\000"..., 4096) = 4096 lseek(3, -8, SEEK_END) = 239964 read(3, "\0\0\340\257PRE ", 8) = 8 mmap2(0xafe00000, 286720, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xafe00000 mmap2(0xafe00000, 228532, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xafe00000 mprotect(0xafe00000, 229376, PROT_READ|PROT_WRITE|PROT_EXEC) = 0 mmap2(0xafe38000, 8596, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x38) = 0xafe38000 mmap2(0xafe3b000, 42160, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xafe3b000 close(3) = 0 mprotect(0xafe00000, 229376, PROT_READ|PROT_EXEC) = 0 getuid32() = 0 geteuid32() = 0 getgid32() = 0 getegid32() = 0 gettid() = 2109 syscall_983045(0xafe42ad4, 0xafe42a98, 0, 0x40, 0xafe38e08, 0xbed6dbb0, 0xbed6da58, 0xf0005, 0, 0, 0, 0, 0, 0xbed6da48, 0xafe1f721, 0xafe0d89c, 0x60000010, 0xafe42ad4, 0, 0, 0xc764, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) = 0 mmap2(NULL, 32768, PROT_READ, MAP_SHARED, 9, 0) = 0x40000000 open("/dev/urandom", O_RDONLY|O_LARGEFILE) = 3 read(3, "\223\31\234=", 4) = 4 close(3) = 0 stat64("/system/lib/libstdc++.so", {st_mode=S_IFREG|0644, st_size=5268, ...}) = 0 open("/system/lib/libstdc++.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\0X\10\0\000"..., 4096) = 4096 lseek(3, -8, SEEK_END) = 5260 read(3, "\0\0\320\257PRE ", 8) = 8 mmap2(0xafd00000, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xafd00000 mmap2(0xafd00000, 2848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xafd00000 mprotect(0xafd00000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0 mmap2(0xafd01000, 232, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x1) = 0xafd01000 close(3) = 0 mprotect(0xafd00000, 4096, PROT_READ|PROT_EXEC) = 0 getuid32() = 0 geteuid32() = 0 getgid32() = 0 getegid32() = 0 stat64("/system/lib/libm.so", {st_mode=S_IFREG|0644, st_size=132116, ...}) = 0 open("/system/lib/libm.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\000"..., 4096) = 4096 lseek(3, -8, SEEK_END) = 132108 read(3, "\0\0\300\257PRE ", 8) = 8 mmap2(0xafc00000, 135168, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xafc00000 mmap2(0xafc00000, 129828, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xafc00000 mprotect(0xafc00000, 131072, PROT_READ|PROT_WRITE|PROT_EXEC) = 0 mmap2(0xafc20000, 280, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x20) = 0xafc20000 close(3) = 0 mprotect(0xafc00000, 131072, PROT_READ|PROT_EXEC) = 0 getuid32() = 0 geteuid32() = 0 getgid32() = 0 getegid32() = 0 mprotect(0x8000, 4096, PROT_READ|PROT_EXEC) = 0 getuid32() = 0 geteuid32() = 0 getgid32() = 0 getegid32() = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40008000 mprotect(0x40008000, 4096, PROT_READ) = 0 fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(207, 16), ...}) = 0 brk(0) = 0xa000 brk(0xa000) = 0xa000 brk(0xc000) = 0xc000 mprotect(0x40008000, 4096, PROT_READ|PROT_WRITE) = 0 mprotect(0x40008000, 4096, PROT_READ) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon echo ...}) = 0 write(1, "Hello Bionic\n", 13Hello Bionic ) = 13 mprotect(0x40008000, 4096, PROT_READ|PROT_WRITE) = 0 mprotect(0x40008000, 4096, PROT_READ) = 0 munmap(0x40008000, 4096) = 0 exit_group(0) = ? Process 2109 detached 所以確認 share library path 是 OK 的 :(

沒有留言:

標籤

網誌存檔