2013年8月27日 星期二

Dynamic vs static library


最想解出的問題就是dynamic library是load在process何處
被老大assign的工作: 他發現他跑程式,不同的process,只要是有同一個dynamic library,point到library的pointer位置都是一樣,我也覺得很好奇

Dynamic library vs static library:
Static:
  Usually xxx.a.
  整個library compile進執行檔,所以檔案會很大
  執行時可獨立執行
  gcc -static hello.c -o static
Dynamic:
  Usually xxx.so.
  compile時,用pointer指向library位置,library的內容沒有compile到執行檔中,而是執行檔要使用到library時,程式才會去讀取library
  執行時需要知道library的明確路徑,沒辦法獨立執行
  gcc hello.c -o dynamic (gcc default is compiled in dynamic  library)

以下hello.c只是print出hello,可以看到靜態跟動態的執行檔大小差很大


Reference:
IBM的由參數使用不同動態函示庫
http://www.ibm.com/developerworks/cn/linux/l-dynamic-libraries/
以下待看
http://sp1.wikidot.com/linuxdynamiclinking
http://loda.hala01.com/2009/04/linux%E5%8B%95%E6%85%8B%E5%87%BD%E5%BC%8F%E5%BA%AB%E8%A7%A3%E6%9E%90/

Related Posts:

  • Booting ARM system from bootloader to linux kernel有空來讀一下 會以u-boot code當作bootloader base 開到start_kernel之前的組語部分可以參考 http://gicl.cs.drexel.edu/people/sevy/linux/ARM_Linux_boot_sequence.html… Read More
  • Describing Physical MemoryReference: http://www.chudov.com/tmp/LinuxVM/html/understand/node16.html NUMA(non-uniform memory access)架構下,memory被分成很多的bank(又稱為node),而每個bank被CPU access的cost不同 Linux用struct pg_data_t來代表bank(or node) 而PC是一UMA的架構,所以只有一個p… Read More
  • Allocating and Freeing Page TablesReference : http://www.chudov.com/tmp/LinuxVM/html/understand/node26.html 因為page table的allocation跟free有很大的cost,而且又是很常要執行的操作(process create&delete) 所以Linux kernel使用quicklists來cache住用來當page table的page quicklist包含pgd_quick… Read More
  • Kernel Space MemoryReference : http://www.chudov.com/tmp/LinuxVM/html/understand/node28.html Kernel的virtual memory適用linear mapping,physical address 0對應到kernel virtual memory的PAGE_OFFSET(通常是0xC000_0000) 也就是說kernel virtual address - PAGE_OFFSET就… Read More
  • Memory zoneReference : Understaning the Linux Kernel Chap.8 Ideal computer architecture上,任意page frame都是可以被access的 但實際上的電腦架構在硬體上會有些限制住page frame被使用 Linux kernel must deal with two hardware constraints of the 80 × 86 architecture: • The D… Read More

0 意見:

張貼留言