〔リスト1〕-fno-inlineオプションを使う例(test226.c)
|
//インライン・ファンクションの例
#include
static int a;
static inline int test1();
static inline int test1()
{
return a++;
}
int main()
{
int res;
a = 1;
res = test1();
printf("%d\n",res);
res = test1();
printf("%d\n",res);
return 0;
}
|
|
〔リスト2〕-fno-inlineオプションを付けて生成されたアセンブラ・ソース(test226a.s)
|
.file "test226.c"
.section .rodata
.LC0:
.string "%d\n"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
movl $0, %eax
subl %eax, %esp
movl $1, a
movl a, %eax
incl a
movl %eax, -8(%ebp)
movl -8(%ebp), %eax
movl %eax, -4(%ebp)
subl $8, %esp
pushl -4(%ebp)
pushl $.LC0
call printf
addl $16, %esp
movl a, %eax
incl a
movl %eax, -8(%ebp)
movl -8(%ebp), %eax
movl %eax, -4(%ebp)
subl $8, %esp
pushl -4(%ebp)
pushl $.LC0
call printf
addl $16, %esp
movl $0, %eax
leave
ret
.size main, .-main
.local a
.comm a,4,4
.section .note.GNU-stack,"",@progbits
.ident "GCC: (GNU) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)"
|
|
〔リスト3〕-finlineオプションを付けて生成されたアセンブラ・ソース(test226.s)
|
.file "test226.c"
.section .rodata
.LC0:
.string "%d\n"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
movl $0, %eax
subl %eax, %esp
movl $1, a
call test1
movl %eax, -4(%ebp)
subl $8, %esp
pushl -4(%ebp)
pushl $.LC0
call printf
addl $16, %esp
call test1
movl %eax, -4(%ebp)
subl $8, %esp
pushl -4(%ebp)
pushl $.LC0
call printf
addl $16, %esp
movl $0, %eax
leave
ret
.size main, .-main
.local a
.comm a,4,4
.type test1, @function
test1:
pushl %ebp
movl %esp, %ebp
movl a, %eax
incl a
leave
ret
.size test1, .-test1
.section .note.GNU-stack,"",@progbits
.ident "GCC: (GNU) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)"
|
|
〔リスト4〕-fno-inlineオプションを付けて生成されたシンボル・リスト(test226a.nm)
|
080494d0 D _DYNAMIC
0804959c D _GLOBAL_OFFSET_TABLE_
080484b0 R _IO_stdin_used
w _Jv_RegisterClasses
080494c0 d __CTOR_END__
080494bc d __CTOR_LIST__
080494c8 d __DTOR_END__
080494c4 d __DTOR_LIST__
080484b8 r __FRAME_END__
080494cc d __JCR_END__
080494cc d __JCR_LIST__
080495bc A __bss_start
080495b0 D __data_start
0804846c t __do_global_ctors_aux
08048308 t __do_global_dtors_aux
080495b4 D __dso_handle
080494bc A __fini_array_end
080494bc A __fini_array_start
w __gmon_start__
080494bc A __init_array_end
080494bc A __init_array_start
08048428 T __libc_csu_fini
080483e0 T __libc_csu_init
U __libc_start_main@@GLIBC_2.0
080494bc A __preinit_array_end
080494bc A __preinit_array_start
080495bc A _edata
080495c4 A _end
08048490 T _fini
080484ac R _fp_hw
08048278 T _init
080482c0 T _start
080495c0 b a
080482e4 t call_gmon_start
080495bc b completed.1
080495b0 W data_start
08048344 t frame_dummy
08048370 T main
080495b8 d p.0
U printf@@GLIBC_2.0
|
|
〔リスト5〕-finlineオプションを付けて生成されたシンボル・リスト(test226.nm)
|
080494c8 D _DYNAMIC
08049594 D _GLOBAL_OFFSET_TABLE_
080484a8 R _IO_stdin_used
w _Jv_RegisterClasses
080494b8 d __CTOR_END__
080494b4 d __CTOR_LIST__
080494c0 d __DTOR_END__
080494bc d __DTOR_LIST__
080484b0 r __FRAME_END__
080494c4 d __JCR_END__
080494c4 d __JCR_LIST__
080495b4 A __bss_start
080495a8 D __data_start
08048464 t __do_global_ctors_aux
08048308 t __do_global_dtors_aux
080495ac D __dso_handle
080494b4 A __fini_array_end
080494b4 A __fini_array_start
w __gmon_start__
080494b4 A __init_array_end
080494b4 A __init_array_start
08048420 T __libc_csu_fini
080483d8 T __libc_csu_init
U __libc_start_main@@GLIBC_2.0
080494b4 A __preinit_array_end
080494b4 A __preinit_array_start
080495b4 A _edata
080495bc A _end
08048488 T _fini
080484a4 R _fp_hw
08048278 T _init
080482c0 T _start
080495b8 b a
080482e4 t call_gmon_start
080495b4 b completed.1
080495a8 W data_start
08048344 t frame_dummy
08048370 T main
080495b0 d p.0
U printf@@GLIBC_2.0
080483c7 t test1
|
|
〔リスト6〕関数名が重複している例1(test227.c)
|
//インライン・ファンクションの例
int test1();
int test2();
int test1()
{
int a = 100;
return a++;
}
int test2()
{
int b = test1();
return b;
}
|
|
〔リスト7〕関数名が重複している例2(test228.c)
|
//インライン・ファンクションの例
#include
static int a;
int test1();
int test1()
{
return a++;
}
int main()
{
int res;
a = 1;
res = test1();
printf("%d\n",res);
res = test1();
printf("%d\n",res);
res = test2();
printf("%d\n",res);
return 0;
}
|
|
〔リスト8〕関数名が重複している例3(test229.c)
|
//インライン・ファンクションの例
static int test1();
int test2();
static int test1()
{
int a = 100;
return a++;
}
int test2()
{
int b = test1();
return b;
}
|
|
〔リスト9〕生成されたオブジェクト・ダンプ・リスト1(test227.txt)
|
test227: ファイル形式 elf32-i386
セクション .interp の逆アセンブル:
08048114 <.interp>:
----------略----------
セクション .note.ABI-tag の逆アセンブル:
08048128 <.note.ABI-tag>:
----------略----------
...
セクション .hash の逆アセンブル:
08048148 <.hash>:
----------略----------
...
セクション .dynsym の逆アセンブル:
08048174 <.dynsym>:
...
----------略----------
...
セクション .dynstr の逆アセンブル:
080481d4 <.dynstr>:
----------略----------
セクション .gnu.version の逆アセンブル:
08048234 <.gnu.version>:
8048234: 00 00 add %al,(%eax)
8048236: 02 00 add (%eax),%al
8048238: 02 00 add (%eax),%al
804823a: 01 00 add %eax,(%eax)
804823c: 00 00 add %al,(%eax)
...
セクション .gnu.version_r の逆アセンブル:
08048240 <.gnu.version_r>:
----------略----------
...
セクション .rel.dyn の逆アセンブル:
08048260 <.rel.dyn>:
8048260: d8 95 04 08 06 05 fcoms 0x5060804(%ebp)
...
セクション .rel.plt の逆アセンブル:
08048268 <.rel.plt>:
----------略----------
...
セクション .init の逆アセンブル:
08048278 <_init>:
----------略----------
セクション .plt の逆アセンブル:
08048290 <.plt>:
----------略----------
セクション .text の逆アセンブル:
080482c0 <_start>:
----------略----------
080482e4 :
----------略----------
08048308 <__do_global_dtors_aux>:
----------略----------
<__do_global_dtors_aux+0x38>
----------略----------
<__do_global_dtors_aux+0x31>
----------略----------
<__do_global_dtors_aux+0x1c>
----------略----------
08048344 :
----------略----------
08048370 :
8048370: 55 push %ebp
8048371: 89 e5 mov %esp,%ebp
8048373: a1 00 96 04 08 mov 0x8049600,%eax
8048378: ff 05 00 96 04 08 incl 0x8049600
804837e: c9 leave
804837f: c3 ret
08048380 :
8048380: 55 push %ebp
8048381: 89 e5 mov %esp,%ebp
8048383: 83 ec 08 sub $0x8,%esp
8048386: 83 e4 f0 and $0xfffffff0,%esp
8048389: b8 00 00 00 00 mov $0x0,%eax
804838e: 29 c4 sub %eax,%esp
8048390: c7 05 00 96 04 08 01 movl $0x1,0x8049600
8048397: 00 00 00
804839a: e8 d1 ff ff ff call 8048370
804839f: 89 45 fc mov %eax,0xfffffffc(%ebp)
80483a2: 83 ec 08 sub $0x8,%esp
80483a5: ff 75 fc pushl 0xfffffffc(%ebp)
80483a8: 68 f4 84 04 08 push $0x80484f4
80483ad: e8 fe fe ff ff call 80482b0 <_init+0x38>
80483b2: 83 c4 10 add $0x10,%esp
80483b5: e8 b6 ff ff ff call 8048370
80483ba: 89 45 fc mov %eax,0xfffffffc(%ebp)
80483bd: 83 ec 08 sub $0x8,%esp
80483c0: ff 75 fc pushl 0xfffffffc(%ebp)
80483c3: 68 f4 84 04 08 push $0x80484f4
80483c8: e8 e3 fe ff ff call 80482b0 <_init+0x38>
80483cd: 83 c4 10 add $0x10,%esp
80483d0: e8 36 00 00 00 call 804840b
80483d5: 89 45 fc mov %eax,0xfffffffc(%ebp)
80483d8: 83 ec 08 sub $0x8,%esp
80483db: ff 75 fc pushl 0xfffffffc(%ebp)
80483de: 68 f4 84 04 08 push $0x80484f4
80483e3: e8 c8 fe ff ff call 80482b0 <_init+0x38>
80483e8: 83 c4 10 add $0x10,%esp
80483eb: b8 00 00 00 00 mov $0x0,%eax
80483f0: c9 leave
80483f1: c3 ret
80483f2: 90 nop
80483f3: 90 nop
080483f4 :
80483f4: 55 push %ebp
80483f5: 89 e5 mov %esp,%ebp
80483f7: 83 ec 04 sub $0x4,%esp
80483fa: c7 45 fc 64 00 00 00 movl
$0x64,0xfffffffc(%ebp)
8048401: 8b 45 fc mov 0xfffffffc(%ebp),%eax
8048404: 8d 55 fc lea 0xfffffffc(%ebp),%edx
8048407: ff 02 incl (%edx)
8048409: c9 leave
804840a: c3 ret
0804840b :
804840b: 55 push %ebp
804840c: 89 e5 mov %esp,%ebp
804840e: 83 ec 08 sub $0x8,%esp
8048411: e8 de ff ff ff call 80483f4
8048416: 89 45 fc mov %eax,0xfffffffc(%ebp)
8048419: 8b 45 fc mov 0xfffffffc(%ebp),%eax
804841c: c9 leave
804841d: c3 ret
804841e: 90 nop
804841f: 90 nop
08048420 <__libc_csu_init>:
----------略----------
08048468 <__libc_csu_fini>:
----------略----------
080484ac <__do_global_ctors_aux>:
----------略----------
<__do_global_ctors_aux+0x20>
----------略----------
<__do_global_ctors_aux+0x14>
----------略----------
セクション .fini の逆アセンブル:
080484d0 <_fini>:
----------略----------
セクション .rodata の逆アセンブル:
080484ec <_fp_hw>:
80484ec: 03 00 add (%eax),%eax
...
080484f0 <_IO_stdin_used>:
----------略----------
セクション .eh_frame の逆アセンブル:
080484f8 <__FRAME_END__>:
80484f8: 00 00 add %al,(%eax)
...
セクション .ctors の逆アセンブル:
080494fc <__CTOR_LIST__>:
----------略----------
08049500 <__CTOR_END__>:
8049500: 00 00 add %al,(%eax)
...
セクション .dtors の逆アセンブル:
08049504 <__DTOR_LIST__>:
----------略----------
08049508 <__DTOR_END__>:
8049508: 00 00 add %al,(%eax)
...
セクション .jcr の逆アセンブル:
0804950c <__JCR_END__>:
804950c: 00 00 add %al,(%eax)
...
セクション .dynamic の逆アセンブル:
08049510 <_DYNAMIC>:
----------略----------
...
セクション .got の逆アセンブル:
080495d8 <.got>:
80495d8: 00 00 add %al,(%eax)
...
セクション .got.plt の逆アセンブル:
080495dc <_GLOBAL_OFFSET_TABLE_>:
----------略----------
セクション .data の逆アセンブル:
080495f0 <__data_start>:
80495f0: 00 00 add %al,(%eax)
...
080495f4 <__dso_handle>:
80495f4: 00 00 add %al,(%eax)
...
080495f8 :
80495f8: 08 .byte 0x8
80495f9: 95 xchg %eax,%ebp
80495fa: 04 08 add $0x8,%al
セクション .bss の逆アセンブル:
080495fc :
80495fc: 00 00 add %al,(%eax)
...
08049600 :
8049600: 00 00 add %al,(%eax)
...
セクション .comment の逆アセンブル:
00000000 <.comment>:
----------略----------
...
|
|
〔リスト10〕生成されたオブジェクト・ダンプ・リスト2(test227a.txt)
|
test227: ファイル形式 elf32-i386
セクション .interp の逆アセンブル:
08048114 <.interp>:
----------略----------
セクション .note.ABI-tag の逆アセンブル:
08048128 <.note.ABI-tag>:
----------略----------
...
セクション .hash の逆アセンブル:
08048148 <.hash>:
----------略----------
...
セクション .dynsym の逆アセンブル:
08048174 <.dynsym>:
...
----------略----------
...
セクション .dynstr の逆アセンブル:
080481d4 <.dynstr>:
----------略----------
セクション .gnu.version の逆アセンブル:
08048234 <.gnu.version>:
----------略----------
...
セクション .gnu.version_r の逆アセンブル:
08048240 <.gnu.version_r>:
----------略----------
...
セクション .rel.dyn の逆アセンブル:
08048260 <.rel.dyn>:
----------略----------
...
セクション .rel.plt の逆アセンブル:
08048268 <.rel.plt>:
----------略----------
...
セクション .init の逆アセンブル:
08048278 <_init>:
----------略----------
セクション .plt の逆アセンブル:
08048290 <.plt>:
----------略----------
セクション .text の逆アセンブル:
080482c0 <_start>:
----------略----------
080482e4 :
----------略----------
08048308 <__do_global_dtors_aux>:
----------略----------
<__do_global_dtors_aux+0x38>
----------略----------
<__do_global_dtors_aux+0x31>
----------略----------
<__do_global_dtors_aux+0x1c>
----------略----------
08048344 :
----------略----------
08048370 :
8048370: 55 push %ebp
8048371: 89 e5 mov %esp,%ebp
8048373: 83 ec 08 sub $0x8,%esp
8048376: 83 e4 f0 and $0xfffffff0,%esp
8048379: 83 ec 08 sub $0x8,%esp
804837c: 6a 01 push $0x1
804837e: 68 b8 84 04 08 push $0x80484b8
8048383: c7 05 c4 95 04 08 02 movl $0x2,0x80495c4
804838a: 00 00 00
804838d: e8 1e ff ff ff call 80482b0 <_init+0x38>
8048392: 58 pop %eax
8048393: 8b 0d c4 95 04 08 mov 0x80495c4,%ecx
8048399: 5a pop %edx
804839a: 51 push %ecx
804839b: 8d 41 01 lea 0x1(%ecx),%eax
804839e: 68 b8 84 04 08 push $0x80484b8
80483a3: a3 c4 95 04 08 mov %eax,0x80495c4
80483a8: e8 03 ff ff ff call 80482b0 <_init+0x38>
80483ad: e8 26 00 00 00 call 80483d8
80483b2: 5a pop %edx
80483b3: 59 pop %ecx
80483b4: 50 push %eax
80483b5: 68 b8 84 04 08 push $0x80484b8
80483ba: e8 f1 fe ff ff call 80482b0 <_init+0x38>
80483bf: 31 c0 xor %eax,%eax
80483c1: c9 leave
80483c2: c3 ret
80483c3: 90 nop
080483c4 :
80483c4: a1 c4 95 04 08 mov 0x80495c4,%eax
80483c9: 55 push %ebp
80483ca: 89 e5 mov %esp,%ebp
80483cc: 8d 48 01 lea 0x1(%eax),%ecx
80483cf: 89 0d c4 95 04 08 mov %ecx,0x80495c4
80483d5: c9 leave
80483d6: c3 ret
80483d7: 90 nop
080483d8 :
80483d8: 55 push %ebp
80483d9: 89 e5 mov %esp,%ebp
80483db: b8 64 00 00 00 mov $0x64,%eax
80483e0: c9 leave
80483e1: c3 ret
80483e2: 90 nop
80483e3: 90 nop
080483e4 <__libc_csu_init>:
----------略----------
0804842c <__libc_csu_fini>:
----------略----------
08048470 <__do_global_ctors_aux>:
----------略----------
<__do_global_ctors_aux+0x20>
----------略----------
<__do_global_ctors_aux+0x14>
----------略----------
セクション .fini の逆アセンブル:
08048494 <_fini>:
----------略----------
セクション .rodata の逆アセンブル:
080484b0 <_fp_hw>:
80484b0: 03 00 add (%eax),%eax
...
080484b4 <_IO_stdin_used>:
----------略----------
セクション .eh_frame の逆アセンブル:
080484bc <__FRAME_END__>:
80484bc: 00 00 add %al,(%eax)
...
セクション .ctors の逆アセンブル:
080494c0 <__CTOR_LIST__>:
----------略----------
080494c4 <__CTOR_END__>:
80494c4: 00 00 add %al,(%eax)
...
セクション .dtors の逆アセンブル:
080494c8 <__DTOR_LIST__>:
----------略----------
080494cc <__DTOR_END__>:
80494cc: 00 00 add %al,(%eax)
...
セクション .jcr の逆アセンブル:
080494d0 <__JCR_END__>:
80494d0: 00 00 add %al,(%eax)
...
セクション .dynamic の逆アセンブル:
080494d4 <_DYNAMIC>:
----------略----------
...
セクション .got の逆アセンブル:
0804959c <.got>:
804959c: 00 00 add %al,(%eax)
...
セクション .got.plt の逆アセンブル:
080495a0 <_GLOBAL_OFFSET_TABLE_>:
----------略----------
セクション .data の逆アセンブル:
080495b4 <__data_start>:
80495b4: 00 00 add %al,(%eax)
...
080495b8 <__dso_handle>:
80495b8: 00 00 add %al,(%eax)
...
080495bc :
----------略----------
セクション .bss の逆アセンブル:
080495c0 :
80495c0: 00 00 add %al,(%eax)
...
080495c4 :
80495c4: 00 00 add %al,(%eax)
...
セクション .comment の逆アセンブル:
00000000 <.comment>:
----------略----------
|
|
 記事内インデックス 連載インデックスはこちら Interfaceのトップ |
|
|
Copyright 2004 岸 哲夫
Copyright 1997-2004 CQ Publishing Co.,Ltd.
|