我编译了以下程序:
#include <iostream>
using namespace std;
// function declaration
int max(int num1, int num2);
int main ()
{
// local variable declaration:
int a = 100;
int b = 200;
int ret;
// calling a function to get max value.
ret = max(a, b);
cout << "Max value is : " << ret << endl;
return 0;
}
// function returning the max between two numbers
int max(int num1, int num2)
{
// local variable declaration
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
我已经生成了下面的汇编语言:
.file "CallFunction.cpp"
.def __main; .scl 2; .type 32; .endef
.section .rdata,"dr"
.LC0:
.ascii "Max value is : \0"
.text
.globl main
.def main; .scl 2; .type 32; .endef
.seh_proc main
main:
.LFB969:
subq $40
leaq .LC0(%rip, %rsp
.seh_stackalloc 40
.seh_endprologue
call __main), %rdx
movq .refptr._ZSt4cout(%rip), %rcx
call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
movl $200, %edx
movq %rax, %rcx
call _ZNSolsEi
movq %rax, %rcx
call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
movl $0, %eax
addq $40, %rsp
ret
.seh_endproc
.globl _Z3maxii
.def _Z3maxii; .scl 2; .type 32; .endef
.seh_proc _Z3maxii
_Z3maxii:
.LFB970:
.seh_endprologue
cmpl %edx, %ecx
movl %edx, %eax
cmovge %ecx, %eax
ret
.seh_endproc
.def _GLOBAL__sub_I_main; .scl 3; .type 32; .endef
.seh_proc _GLOBAL__sub_I_main
_GLOBAL__sub_I_main:
.LFB980:
subq $40, %rsp
.seh_stackalloc 40
.seh_endprologue
leaq _ZStL8__ioinit(%rip), %rcx
call _ZNSt8ios_base4InitC1Ev
nop
addq $40, %rsp
ret
.seh_endproc
.section .ctors,"w"
.align 8
.quad _GLOBAL__sub_I_main
.text
.def _GLOBAL__sub_D_main; .scl 3; .type 32; .endef
.seh_proc _GLOBAL__sub_D_main
_GLOBAL__sub_D_main:
.LFB981:
subq $40, %rsp
.seh_stackalloc 40
.seh_endprologue
leaq _ZStL8__ioinit(%rip), %rcx
call _ZNSt8ios_base4InitD1Ev
nop
addq $40, %rsp
ret
.seh_endproc
.section .dtors,"w"
.align 8
.quad _GLOBAL__sub_D_main
.lcomm _ZStL8__ioinit,1,1
.ident "GCC: (GNU) 4.8.1"
.def _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc; .scl 2; .type 32; .endef
.def _ZNSolsEi; .scl 2; .type 32; .endef
.def _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_; .scl 2; .type 32; .endef
.def _ZNSt8ios_base4InitC1Ev; .scl 2; .type 32; .endef
.def _ZNSt8ios_base4InitD1Ev; .scl 2; .type 32; .endef
.section .rdata$.refptr._ZSt4cout, "dr"
.globl .refptr._ZSt4cout
.linkonce discard
.refptr._ZSt4cout:
.quad _ZSt4cout
我期待两个标签(每种方法一个),但似乎有六个。为什么有六个?此外,命名约定是如何工作的,即“.LFB969”是什么意思?