본문 바로가기
Research/Linux

object dump file 정렬

by sunnyan 2008. 12. 11.
728x90
objdump를 이용해서 심볼테이블 파일을 만들면 각 변수나 함수들이 차지하는 사이즈를 알 수 있다.
문제는 이 심볼 사이즈가 정렬이 안되어 있는데... 이 파일을 정렬해 보기로 하자...

우선 objdump -t foo > dump.txt 로 하자...
그러면 dump.txt에 아래와 같은 형식으로 심볼테이블이 출력된다...

libmythtv-0.21.so:     file format elf32-sh-linux

SYMBOL TABLE:
00000114 l    d  .gnu.hash  00000000              .gnu.hash
0000d9bc l    d  .dynsym    00000000              .dynsym
000311ec l    d  .dynstr    00000000              .dynstr
0007e0f2 l    d  .gnu.version   00000000              .gnu.version
000827f8 l    d  .gnu.version_r 00000000              .gnu.version_r
000828d8 l    d  .rela.dyn  00000000              .rela.dyn
000c20b8 l    d  .rela.plt  00000000              .rela.plt
000cc8c0 l    d  .init  00000000              .init
000cc924 l    d  .plt   00000000              .plt
000e5140 l    d  .text  00000000              .text
006c65a0 l    d  .fini  00000000              .fini
006c65d8 l    d  .rodata    00000000              .rodata
0071af04 l    d  .eh_frame_hdr  00000000              .eh_frame_hdr
00726e68 l    d  .eh_frame  00000000              .eh_frame
00773c80 l    d  .gcc_except_table  00000000              .gcc_except_table
007ffbd8 l    d  .ctors 00000000              .ctors
007ffdc8 l    d  .dtors 00000000              .dtors
007ffdd0 l    d  .jcr   00000000              .jcr
007ffdd4 l    d  .data.rel.ro   00000000              .data.rel.ro
00813ee0 l    d  .dynamic   00000000              .dynamic
00814000 l    d  .data  00000000              .data
008267b8 l    d  .got   00000000              .got
0082ad40 l    d  .bss   00000000              .bss
00000000 l    d  .comment   00000000              .comment

먼저
# cat dump.txt | sed 's/.................//' > dump1.txt 명령어로 (. 17개) 다음과 같이 출력된다.

:     file format elf32-sh-linux

SYMBOL TABLE:
.gnu.hash   00000000              .gnu.hash
.dynsym 00000000              .dynsym
.dynstr 00000000              .dynstr
.gnu.version    00000000              .gnu.version
.gnu.version_r  00000000              .gnu.version_r
.rela.dyn   00000000              .rela.dyn
.rela.plt   00000000              .rela.plt
.init   00000000              .init
.plt    00000000              .plt
.text   00000000              .text
.fini   00000000              .fini
.rodata 00000000              .rodata
.eh_frame_hdr   00000000              .eh_frame_hdr
.eh_frame   00000000              .eh_frame
.gcc_except_table   00000000              .gcc_except_table
.ctors  00000000              .ctors
.dtors  00000000              .dtors
.jcr    00000000              .jcr
.data.rel.ro    00000000              .data.rel.ro
.dynamic    00000000              .dynamic
.data   00000000              .data
.got    00000000              .got
.bss    00000000              .bss
.comment    00000000              .comment

다음에 탭문자를 공백문자로 바꾼다.
# cat dump1.txt | sed 's/t/ /' > dump2.txt

:     file format elf32-sh-linux

SYMBOL TABLE:
.gnu.hash 00000000              .gnu.hash
.dynsym 00000000              .dynsym
.dynstr 00000000              .dynstr
.gnu.version 00000000              .gnu.version
.gnu.version_r 00000000              .gnu.version_r
.rela.dyn 00000000              .rela.dyn
.rela.plt 00000000              .rela.plt
.init 00000000              .init
.plt 00000000              .plt
.text 00000000              .text
.fini 00000000              .fini
.rodata 00000000              .rodata
.eh_frame_hdr 00000000              .eh_frame_hdr
.eh_frame 00000000              .eh_frame
.gcc_except_table 00000000              .gcc_except_table
.ctors 00000000              .ctors
.dtors 00000000              .dtors
.jcr 00000000              .jcr
.data.rel.ro 00000000              .data.rel.ro
.dynamic 00000000              .dynamic
.data 00000000              .data
.got 00000000              .got
.bss 00000000              .bss
.comment 00000000              .comment

다음 아래와 같은 명령을 주면 심볼 사이즈가 정렬되서 dump3.txt에 출력된다.
# sort -n dump2.txt > dump3.txt


728x90

'Research > Linux' 카테고리의 다른 글

history 사용법  (0) 2008.12.16
pmap  (0) 2008.12.15
rpm 파일에서 파일 추출  (0) 2008.11.12
특정 패턴의 파일을 제외하고 tar로 묶기  (0) 2008.10.23
crontab ftp 업로드 자동  (0) 2008.10.21