議論/DLL/初めての.so


Top / 議論 / DLL / 初めての.so

Linuxで共有ライブラリを作る

  1. gcc -fPIC -c -Wall test.c # -fPIC位置独立コード
  2. gcc -shared -Wl,-soname,libtest.so.1 - o libtest.so.1.0 test.o

中身解析

動的セクション:
   NEEDED      libgcc_s.so.1
   NEEDED      libc.so.6

objdump -x libtest.so.1.0

libtest.so.1.0:     ファイル形式 elf32-i386
libtest.so.1.0
アーキテクチャ: i386, フラグ 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
開始アドレス 0x00000670
 
プログラムヘッダ:
    LOAD off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12
         filesz 0x0000084c memsz 0x0000084c flags r-x
    LOAD off    0x0000084c vaddr 0x0000184c paddr 0x0000184c align 2**12
         filesz 0x00000124 memsz 0x00000140 flags rw-
 DYNAMIC off    0x000008a0 vaddr 0x000018a0 paddr 0x000018a0 align 2**2
         filesz 0x000000d0 memsz 0x000000d0 flags rw-
 
動的セクション:
  NEEDED      libgcc_s.so.1
  NEEDED      libc.so.6
  SONAME      libtest.so.1
  INIT        0x5f8
  FINI        0x830
  HASH        0x94
  STRTAB      0x414
  SYMTAB      0x1c4
  STRSZ       0xe6
  SYMENT      0x10
  PLTGOT      0x186c
  PLTRELSZ    0x20
  PLTREL      0x11
  JMPREL      0x5d8
  REL         0x598
  RELSZ       0x40
  RELENT      0x8
  VERNEED     0x558
  VERNEEDNUM  0x2
  VERSYM      0x50e
  RELCOUNT    0x1
 
バージョン参照:
  libc.so.6 からの要求:
    0x09691f73 0x00 03 GLIBC_2.1.3
  libgcc_s.so.1 からの要求:
    0x0b792650 0x00 02 GCC_3.0
 
セクション:
索引名          サイズ      VMA       LMA       File off  Algn
  0 .hash         00000130  00000094  00000094  00000094  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .dynsym       00000250  000001c4  000001c4  000001c4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .dynstr       000000fa  00000414  00000414  00000414  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .gnu.version  0000004a  0000050e  0000050e  0000050e  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .gnu.version_r 00000040  00000558  00000558  00000558  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .rel.dyn      00000040  00000598  00000598  00000598  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .rel.plt      00000020  000005d8  000005d8  000005d8  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .init         00000025  000005f8  000005f8  000005f8  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  8 .plt          00000050  00000620  00000620  00000620  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  9 .text         000001c0  00000670  00000670  00000670  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 10 .fini         0000001c  00000830  00000830  00000830  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 11 .data         00000008  0000184c  0000184c  0000084c  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 12 .jcr          00000004  00001854  00001854  00000854  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 13 .eh_frame     00000004  00001858  00001858  00000858  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 14 .ctors        00000008  0000185c  0000185c  0000085c  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 15 .dtors        00000008  00001864  00001864  00000864  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 16 .got          00000034  0000186c  0000186c  0000086c  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 17 .dynamic      000000d0  000018a0  000018a0  000008a0  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 18 .sbss         00000000  00001970  00001970  00000970  2**0
                  CONTENTS
 19 .bss          0000001c  00001970  00001970  00000970  2**2
                  ALLOC
 20 .comment      00000082  00000000  00000000  00000970  2**0
                  CONTENTS, READONLY
 21 .note         00000028  00000000  00000000  000009f2  2**0
                  CONTENTS, READONLY
SYMBOL TABLE:
00000094 l    d  .hash	00000000              
000001c4 l    d  .dynsym	00000000              
00000414 l    d  .dynstr	00000000              
0000050e l    d  .gnu.version	00000000              
00000558 l    d  .gnu.version_r	00000000              
00000598 l    d  .rel.dyn	00000000              
000005d8 l    d  .rel.plt	00000000              
000005f8 l    d  .init	00000000              
00000620 l    d  .plt	00000000              
00000670 l    d  .text	00000000              
00000830 l    d  .fini	00000000              
0000184c l    d  .data	00000000              
00001854 l    d  .jcr	00000000              
00001858 l    d  .eh_frame	00000000              
0000185c l    d  .ctors	00000000              
00001864 l    d  .dtors	00000000              
0000186c l    d  .got	00000000              
000018a0 l    d  .dynamic	00000000              
00001970 l    d  .sbss	00000000              
00001970 l    d  .bss	00000000              
00000000 l    d  .comment	00000000              
00000000 l    d  .note	00000000              
00000000 l    d  *ABS*	00000000              
00000000 l    d  *ABS*	00000000              
00000000 l    d  *ABS*	00000000              
00000000 l    df *ABS*	00000000              initfini.c
00000670 l       .text	00000000              gcc2_compiled.
00000670 l     F .text	00000000              call_gmon_start
00000000 l    df *ABS*	00000000              crtstuff.c
0000185c l     O .ctors	00000000              __CTOR_LIST__
00001864 l     O .dtors	00000000              __DTOR_LIST__
00001858 l     O .eh_frame	00000000              __EH_FRAME_BEGIN__
00001854 l     O .jcr	00000000              __JCR_LIST__
00001850 l     O .data	00000000              p.0
00001970 l     O .bss	00000001              completed.1
000006a0 l     F .text	00000000              __do_global_dtors_aux
00001974 l     O .bss	00000018              object.2
00000730 l     F .text	00000000              frame_dummy
00000000 l    df *ABS*	00000000              crtstuff.c
00001860 l     O .ctors	00000000              __CTOR_END__
00001868 l     O .dtors	00000000              __DTOR_END__
00001858 l     O .eh_frame	00000000              __FRAME_END__
00001854 l     O .jcr	00000000              __JCR_END__
000007e0 l     F .text	00000000              __do_global_ctors_aux
00000000 l    df *ABS*	00000000              initfini.c
00000830 l       .text	00000000              gcc2_compiled.
00000000 l    df *ABS*	00000000              test.c
000018a0 g     O *ABS*	00000000              _DYNAMIC
0000184c g     O .data	00000000              __dso_handle
00000000  w    F *UND*	000000ff              __deregister_frame_info_bases@@GCC_3.0
000005f8 g     F .init	00000000              _init
000007b0 g     F .text	00000021              max
00001970 g     O *ABS*	00000000              __bss_start
00000000  w    F *UND*	0000009a              __register_frame_info_bases@@GCC_3.0
00000830 g     F .fini	00000000              _fini
00000000  w    F *UND*	0000007b              __cxa_finalize@@GLIBC_2.1.3
00001970 g     O *ABS*	00000000              _edata
0000186c g     O *ABS*	00000000              _GLOBAL_OFFSET_TABLE_
0000198c g     O *ABS*	00000000              _end
00000000  w      *UND*	00000000              _Jv_RegisterClasses
00000000  w      *UND*	00000000              __gmon_start__

MENU

now: 1

リンク


最新の20件
2018-05-03 2017-09-29 2017-04-25 2017-01-10 2016-12-11 2016-10-04 2016-08-14 2016-06-05 2016-05-29 2016-04-15 2015-12-28 2013-02-25 2013-02-21 2013-02-20 2013-02-12 2013-02-11 2013-02-10
最新の20件
2010-02-01 2010-01-31 2010-01-30 2010-01-29 2010-01-16

Counter: 3495, today: 1, yesterday: 0

リロード   新規 編集 凍結 差分 添付 複製 改名   トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS

Last-modified: 2008-03-28 (金) 15:48:02 (3761d);  Modified by mona
PukiWiki 1.4.6 Copyright © 2001-2005 PukiWiki Developers Team. License is GPL.
Based on "PukiWiki" 1.3 by yu-ji
Powered by PHP 5.2.17
HTML convert time to 0.016 sec.