編輯:初級開發
linker 主要用於實現共享庫的加載與鏈接。它支持應用程序對庫函數的隱式和顯式調用。對於隱式調用,應用程序的編譯與靜態庫大致相同,只是在靜態鏈接的時候通過--dynamic-linker /system/bin/linker 指定動態鏈接器,(該信息將被存放在ELF文件的.interp節中,內核執行目標映像文件前將通過該信息加載並運行相應的解釋器程序linker.)並鏈接相應的共享庫。與ld.so不同的是,Linker目前沒有提供Lazy Binding機制,所有外部過程引用都在映像執行之前解析。對於顯式調用,可以同過linker中提供的接口dlopen,dlsym,dlerror和dlclose來動態加載和鏈接共享庫。
prelinking:
System librarIEs in android are internally prelinked, which means that any internal relocations within them are stripped from the corresponding shared object, in order to reduce size and speed up loading.
Such libraries can only be loaded at the very specific virtual memory address they have been prelinked to (during the build process). The list of prelinked system librarIEs and their corresponding virtual memory address is found in the file:
build/core/prelink-Linux-<arch>.map
It should be updated each time a new system library is added to the system.
The prelink step happens at build time, and uses the 'soslim' and 'apriori' tools:
- 'apriori' is the real prelink tool which removes relocations from the shared object, however, it must be given a list of symbols to remove from the file.
- 'soslim' is used to find symbols in an executable ELF file and generate a list that can be passed to 'apriori'.
prelink-Linux-arm.map:
# 0xC0000000 - 0xFFFFFFFF Kernel 3G-4G
# 0xB0100000 - 0xBFFFFFFF Thread 0 Stack
# 0xB0000000 - 0xB00FFFFF Linker
# 0xA0000000 - 0xBFFFFFFF Prelinked System LibrarIEs
# 0x90000000 - 0x9FFFFFFF Prelinked App LibrarIEs
# 0x80000000 - 0x8FFFFFFF Non-prelinked LibrarIEs
# 0x40000000 - 0x7FFFFFFF mmap'd stuff
# 0x10000000 - 0x3FFFFFFF Thread Stacks
# 0x00000000 - 0x0FFFFFFF .text / .data / heap
# Note: The general rule is that libraries should be aligned on 1MB boundarIEs. For ease of updating this file, you will find a comment
# on each line, indicating the observed size of the library, which is one of:
# [<64K] observed to be less than 64K
# [~1M] rounded up, one megabyte (similarly for other sizes)
# [???] no size observed, assumed to be one megabyte
# core system librarIEs
libdl.so 0xAFF00000 # [<64K]
libc.so 0xAFD00000 # [~2M]
libstdc++.so 0xAFC00000 # [<64K]
libm.so 0xAFB00000 # [~1M]
liblog.so 0xAFA00000 # [<64K]
libcutils.so 0xAF900000 # [~1M]
libthread_db.so 0xAF800000 # [<64K]
libz.so 0xAF700000 # [~1M]
libevent.so 0xAF600000 # [???]
libssl.so 0xAF400000 # [~2M]
libcrypto.so 0xAF000000 # [~4M]
libsysutils.so 0xAEF00000 # [~1M]
即庫的加載位置已經固定。
1.2.4 範例程式(3):採單純委託方法1.2.4.1 撰寫步驟:Step-1: 建立android專案:Px03。Step-2: 撰寫Activity的子類別:ac
最近逛其它論壇的時候看到有這樣一個問題,需要界面加載完成後自動彈出軟鍵盤。開始我認為沒有那麼麻煩,最後自己做了一個小例子,還真不好搞定,直到昨天再想這個的問題的時候,想
講義摘錄之8:如何從DDMS發出簡(短)訊給應用程式?1. 如何切換到DDMS?途徑-1:從Eclipse/android應用程式編輯畫面:按下右上角的:就出現:再選取
在android開發中ListView是比較常用的組件,它以列表的形式展示具體內容,並且能夠根據數據的長度自適應顯示。抽空把對ListVIEw的使用做了整理,並寫了個小