??????????????C++??????????
???????????? ???????[ 2014/7/2 11:24:38 ] ????????Net ???????
????3. ??????????????????????
????g++???????????????????????????????????????????????????????????????з???????????????point???????沼???
????g++??????????£?
????[lyt@t468 ~]$ g++ -g -o object object.cpp
????[lyt@t468 ~]$ g++ -g -S -o object.s object.cpp
????object.s???????????????????????????????δ???λ?????????Щ??????????Щ????????????????????????????????????????????????????????????ЩC++???????????????????????????????????
????object???????????gdb?????????????gdb??????????????????λ?????????????з????
????4. ??????point?????????
????C++??????????????????linux?3??ELF???????????????????????????????????????и????????????????????????????????????????????readelf??????????object??????????point?????????з??????????c++filt?????????Щ????????C++?????????????壬???£?
[lyt@t468 ~]$ readelf -s object | grep point
41: 08048530 10 FUNC WEAK DEFAULT 13 _ZN5point13get_instancesE
49: 0804853a 40 FUNC WEAK DEFAULT 13 _ZN5point4moveEii
56: 080484fa 35 FUNC WEAK DEFAULT 13 _ZN5pointC1Eii
58: 0804851e 18 FUNC WEAK DEFAULT 13 _ZN5pointD1Ev
59: 0804a01c 4 OBJECT GLOBAL DEFAULT 25 _ZN5point7ins_cntE
[lyt@t468 ~]$ c++filt _ZN5point13get_instancesE
point::get_instances
[lyt@t468 ~]$ c++filt _ZN5point4moveEii
point::move(int?? int)
[lyt@t468 ~]$ c++filt _ZN5pointC1Eii
point::point(int?? int)
[lyt@t468 ~]$ c++filt _ZN5pointD1Ev
point::~point()
[lyt@t468 ~]$ c++filt _ZN5point7ins_cntE
point::ins_cnt
|
????????????????????????point????????????????????move?????????get_instances???????????????????????????????????е?????????point?????????ins_cnt??????????????????????????0804a01c?????????0804a01c ???д????????????ζ???????C++??????д??????????point???????????
????5. point???????沼????????
?????????????????????????????й??????????????????????????????????棬????????????????????????????ν??г????????????????????????????????????沼???
??????????????C++??????????????gdb??point????????????????н??з??????????£?
(gdb) disassemble /m _ZN5pointC1Eii
Dump of assembler code for function point:
5 point(int x?? int y)
0x080484fa <point+0>: push ebp
0x080484fb <point+1>: mov ebp??esp
6 {
7 this->x = x;
0x080484fd <point+3>: mov eax??DWORD PTR [ebp+0x8]
0x08048500 <point+6>: mov edx??DWORD PTR [ebp+0xc]
0x08048503 <point+9>: mov DWORD PTR [eax]??edx
8 this->y = y;
0x08048505 <point+11>: mov eax??DWORD PTR [ebp+0x8]
0x08048508 <point+14>: mov edx??DWORD PTR [ebp+0x10]
0x0804850b <point+17>: mov DWORD PTR [eax+0x4]??edx
9 ins_cnt++;
0x0804850e <point+20>: mov eax??ds:0x804a01c
0x08048513 <point+25>: add eax??0x1
0x08048516 <point+28>: mov ds:0x804a01c??eax
10 }
0x0804851b <point+33>: pop ebp
0x0804851c <point+34>: ret
End of assembler dump.
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11