ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2015年7月23日 星期四

android : run glibc linked elf file

使用 buildroot build 出自己的的 arm-linux-gcc 和 glibc

以 hello.c 來來測試:
buildroot$ ./output/host/usr/bin/arm-linux-readelf --program-headers hello

Elf file type is EXEC (Executable file)
Entry point 0x82c8
There are 8 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  EXIDX          0x000494 0x00008494 0x00008494 0x00008 0x00008 R   0x4
  PHDR           0x000034 0x00008034 0x00008034 0x00100 0x00100 R E 0x4
  INTERP         0x000134 0x00008134 0x00008134 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.3]
  LOAD           0x000000 0x00008000 0x00008000 0x004a0 0x004a0 R E 0x8000
  LOAD           0x0004a0 0x000104a0 0x000104a0 0x0011c 0x00120 RW  0x8000
  DYNAMIC        0x0004ac 0x000104ac 0x000104ac 0x000e8 0x000e8 RW  0x4
  NOTE           0x000148 0x00008148 0x00008148 0x00020 0x00020 R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x4

 Section to Segment mapping:
  Segment Sections...
   00     .ARM.exidx 
   01     
   02     .interp 
   03     .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.exidx .eh_frame 
   04     .init_array .fini_array .jcr .dynamic .got .data .bss 
   05     .dynamic 
   06     .note.ABI-tag 
   07     
要要 /lib/ld-linux.so.3
所以在 android 上鍵一個 /lib,再再把把 ld-linux.so.3 copy 過去...

然後出現:
error while loading shared libraries: libc.so.6: cannot open shared object file: No such file ro directory
所以 copy libc.so.6 到 /system/lib/
再執行就ok了,。


  • http://www.eoeandroid.com/thread-22046-1-1.html
  • http://thedevilking.blog.51cto.com/8144260/1364547
  • http://stackoverflow.com/questions/8610103/how-do-you-cross-compile-elf-executables-for-android
  • https://groups.google.com/forum/#!topic/android-internals/fHKKNkdPvAU

同時將 glibc 和 bionic 放到 android:

可以在 build toolchain 時,把 glibc 的 default path 改到 /lib
這樣 ld-linus.so 和 glibc 的 so 都會在 /lib

原本 android bionic 的 libc 會在 /systme/lib
就可以做出區別。

這樣的系統,用 toolchain build 出來的 elf, 可以在 android 系統上直接 run


附:

buildroot

build 出 buildroot 的 cross-tool 和 libc.
menuconfig:
Target options: 
-- Target Architecture : ARM(little endian)
-- Target Architecture Variant : (cortex-A9)
-- Floating point strategy : VFPv2
Toolchain:
-- kernel headers : Linux 3.0.x kernel header)
-- C library : glibc
-- Additional gcc options
[*] enable C++ support

先用 default: lastest stable & uclibc
build 完後,修改 hello program 的 envsetup.sh
把 toolchain 指向 buildroot/out/usr/bin/arm-linux-

uclibc 沒有實做 execinfo.h 的 backtrace.
還有 progma 問題。

改用 tag: 2013.11 結果也一樣。

所以改用 glibc
OK

build 完完會在 out

2015年7月8日 星期三

分析一下用的toolchain...

拿 mdnsreponder 來測試:
prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gcc
prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-g++
prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-strip
用 gcc compile, 用 g++ link, 用 strip ...

deatails: Compile:
prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gcc 
-I external/mdnsresponder/mDNSPosix 
-I external/mdnsresponder/mDNSCore 
-I external/mdnsresponder/mDNSShared 
-I external/mdnsresponder 
-I out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates 
-I libnativehelper/include/nativehelper  
-isystem system/core/include 
-isystem hardware/libhardware/include 
-isystem hardware/libhardware_legacy/include 
-isystem hardware/ril/include 
-isystem libnativehelper/include 
-isystem frameworks/native/include 
-isystem frameworks/native/opengl/include 
-isystem frameworks/av/include 
-isystem frameworks/base/include 
-isystem frameworks/base/opengl/include 
-isystem external/skia/include 
-isystem out/target/product/sugar-bpi/obj/include 
-isystem bionic/libc/arch-arm/include 
-isystem bionic/libc/include 
-isystem bionic/libstdc++/include 
-isystem bionic/libc/kernel/common 
-isystem bionic/libc/kernel/arch-arm 
-isystem bionic/libm/include 
-isystem bionic/libm/include/arm 
-isystem bionic/libthread_db/include 
-c  -fno-exceptions -Wno-multichar -msoft-float -fpic 
-fPIE -ffunction-sections -fdata-sections -funwind-tables -fstack-protector 
-Wa,--noexecstack -Werror=format-security -D_FORTIFY_SOURCE=1 -fno-short-enums 
-march=armv7-a -mfloat-abi=softfp -mfpu=neon 
-include build/core/combo/include/arch/linux-arm/AndroidConfig.h 
-I build/core/combo/include/arch/linux-arm/ 
-Wno-unused-but-set-variable -fno-builtin-sin -fno-strict-volatile-bitfields -Wno-psabi 
-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 
-DNDEBUG -g -Wstrict-aliasing=2 -fgcse-after-reload -frerun-cse-after-loop -frename-registers 
-DNDEBUG -UDEBUG -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing  -O2 -g -W -Wall 
-D__ANDROID__ -D_GNU_SOURCE -DHAVE_IPV6 -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DTARGET_OS_LINUX 
-fno-strict-aliasing -DHAVE_LINUX -DMDNS_DEBUGMSGS=0 
-DMDNS_UDS_SERVERPATH=\"/dev/socket/mdnsd\" 
-DMDNS_USERNAME=\"mdnsr\" -DPLATFORM_NO_RLIMIT     -MD 
-MF out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSPosix/PosixDaemon.d 
-o out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSPosix/PosixDaemon.o external/mdnsresponder/mDNSPosix/PosixDaemon.c

Link:
prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-g++ 
-nostdlib 
-Bdynamic 
-fPIE 
-pie 
-Wl,-dynamic-linker,/system/bin/linker 
-Wl,--gc-sections 
-Wl,-z,nocopyreloc 
-o out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/LINKED/mdnsd 
-Lout/target/product/sugar-bpi/obj/lib 
-Wl,-rpath-link=out/target/product/sugar-bpi/obj/lib 
-lc 
-lcutils  
out/target/product/sugar-bpi/obj/lib/crtbegin_dynamic.o         
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSPosix/PosixDaemon.o 
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSPosix/mDNSPosix.o 
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSPosix/mDNSUNP.o 
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSCore/mDNS.o 
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSCore/DNSDigest.o 
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSCore/uDNS.o 
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSCore/DNSCommon.o 
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSShared/uds_daemon.o 
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSShared/mDNSDebug.o 
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSShared/dnssd_ipc.o 
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSShared/GenLinkedList.o 
out/target/product/sugar-bpi/obj/EXECUTABLES/mdnsd_intermediates/mDNSShared/PlatformCommon.o       
-Wl,--whole-archive   
-Wl,--no-whole-archive   
out/target/product/sugar-bpi/obj/STATIC_LIBRARIES/libcompiler-rt-extras_intermediates/libcompiler-rt-extras.a   
-Wl,-z,noexecstack 
-Wl,-z,relro 
-Wl,-z,now 
-Wl,--warn-shared-textrel 
-Wl,--icf=safe 
-Wl,--fix-cortex-a8   
-Wl,--no-undefined  
/home/charles-chang/hd/BPiA4.2.2/android/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/armv7-a/libgcc.a 
out/target/product/sugar-bpi/obj/lib/crtend_android.o

另一個說明在 系統上放多個 share library 的方法。

2015年7月6日 星期一

XIGMATEK secure III, usb 3.0

[  249.332710] usb 4-3: new SuperSpeed USB device number 5 using xhci_hcd
[  249.349266] usb 4-3: New USB device found, idVendor=174c, idProduct=55aa
[  249.349273] usb 4-3: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[  249.349276] usb 4-3: Product: ASMT1051
[  249.349279] usb 4-3: Manufacturer: asmedia
[  249.349281] usb 4-3: SerialNumber: 12345678A02E
[  249.349705] usb-storage 4-3:1.0: USB Mass Storage device detected
[  249.349875] usb-storage 4-3:1.0: Quirks match for vid 174c pid 55aa: 400000
[  249.349948] scsi9 : usb-storage 4-3:1.0
[  250.349417] scsi 9:0:0:0: Direct-Access     ASMT     2105             0    PQ: 0 ANSI: 6
[  250.350216] sd 9:0:0:0: Attached scsi generic sg5 type 0
[  250.351426] sd 9:0:0:0: [sde] 976773168 512-byte logical blocks: (500 GB/465 GiB)
[  250.351668] sd 9:0:0:0: [sde] Write Protect is off
[  250.351673] sd 9:0:0:0: [sde] Mode Sense: 43 00 00 00
[  250.351897] sd 9:0:0:0: [sde] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[  250.398727]  sde: sde1 sde2 < sde5 >
[  250.400395] sd 9:0:0:0: [sde] Attached SCSI disk

TEST

USB 2.0:
charles-chang@jessie431:~$ time -p bash -c "cp sd/test11 sd/test; sudo umount sd"
real 52.59
user 0.04
sys 3.22
charles-chang@jessie431:~$ sudo mount /dev/sde1 sd 
charles-chang@jessie431:~$ rm sd/test
charles-chang@jessie431:~$ time -p bash -c "cp sd/test11 sd/test; sudo umount sd"
real 53.93
user 0.02
sys 3.22
charles-chang@jessie431:~$ sudo mount /dev/sde1 sd 
charles-chang@jessie431:~$ rm sd/test
charles-chang@jessie431:~$ time -p bash -c "cp sd/test11 sd/test; sudo umount sd"
real 52.77
user 0.04
sys 3.19

USB 3.0:
charles-chang@jessie431:~$ time -p bash -c "cp sd/test11 sd/test; sudo umount sd"
real 17.81
user 0.02
sys 2.18
charles-chang@jessie431:~$ sudo mount /dev/sde1 sd 
charles-chang@jessie431:~$ rm sd/test
charles-chang@jessie431:~$ time -p bash -c "cp sd/test11 sd/test; sudo umount sd"
real 17.53
user 0.02
sys 2.14
charles-chang@jessie431:~$ sudo mount /dev/sde1 sd 
charles-chang@jessie431:~$ rm sd/test
charles-chang@jessie431:~$ time -p bash -c "cp sd/test11 sd/test; sudo umount sd"
real 17.64
user 0.00
sys 2.15

2015年7月3日 星期五

git Error : gnutls_handshake() failed: A TLS fatal alert has been received.

ubuntu 版本太舊了...
所以出現這個error.
本來以為是 git 版本太舊 (1.7.2),
所以去抓 source, 分別 build 了 1.9 和 2.0, 結果樣。
後來才看到是 library 的問題。

ref: http://askubuntu.com/questions/186847/error-gnutls-handshake-failed-when-connecting-to-https-servers

解決就是..
把 libcurl4-gnutls-dev換成 libcurl4-openssl-dev

然後重 build git 就可以。

標籤

網誌存檔