- 浏览: 208999 次
- 性别:
- 来自: 北京
最新评论
-
fuliang:
more cleanner than before
Big Integer Arithmetic -
yaojingguo:
Hi, Liang LiangThanks for the i ...
Redirect and restore stdout in C -
fuliang:
使用gcc编译.cpp,可以使用-lstdc++选项,这样gc ...
Redirect and restore stdout in C
C code:
#include <stdio.h> // change no's type from int to long long long long func(long long no) { return no + 1; } int main(int argc, const char *argv[]) { int i; i = 100; func(i); return 0; }
Run 'gcc -g' to compile it. Then run 'objdump -S a.out' produce:
a.out: file format elf32-i386 Disassembly of section .init: 08048298 <_init>: 8048298: 55 push %ebp 8048299: 89 e5 mov %esp,%ebp 804829b: 53 push %ebx 804829c: 83 ec 04 sub $0x4,%esp 804829f: e8 00 00 00 00 call 80482a4 <_init+0xc> 80482a4: 5b pop %ebx 80482a5: 81 c3 50 1d 00 00 add $0x1d50,%ebx 80482ab: 8b 93 fc ff ff ff mov -0x4(%ebx),%edx 80482b1: 85 d2 test %edx,%edx 80482b3: 74 05 je 80482ba <_init+0x22> 80482b5: e8 1e 00 00 00 call 80482d8 <__gmon_start__@plt> 80482ba: e8 d1 00 00 00 call 8048390 <frame_dummy> 80482bf: e8 bc 01 00 00 call 8048480 <__do_global_ctors_aux> 80482c4: 58 pop %eax 80482c5: 5b pop %ebx 80482c6: c9 leave 80482c7: c3 ret Disassembly of section .plt: 080482c8 <__gmon_start__@plt-0x10>: 80482c8: ff 35 f8 9f 04 08 pushl 0x8049ff8 80482ce: ff 25 fc 9f 04 08 jmp *0x8049ffc 80482d4: 00 00 add %al,(%eax) ... 080482d8 <__gmon_start__@plt>: 80482d8: ff 25 00 a0 04 08 jmp *0x804a000 80482de: 68 00 00 00 00 push $0x0 80482e3: e9 e0 ff ff ff jmp 80482c8 <_init+0x30> 080482e8 <__libc_start_main@plt>: 80482e8: ff 25 04 a0 04 08 jmp *0x804a004 80482ee: 68 08 00 00 00 push $0x8 80482f3: e9 d0 ff ff ff jmp 80482c8 <_init+0x30> Disassembly of section .text: 08048300 <_start>: 8048300: 31 ed xor %ebp,%ebp 8048302: 5e pop %esi 8048303: 89 e1 mov %esp,%ecx 8048305: 83 e4 f0 and $0xfffffff0,%esp 8048308: 50 push %eax 8048309: 54 push %esp 804830a: 52 push %edx 804830b: 68 10 84 04 08 push $0x8048410 8048310: 68 20 84 04 08 push $0x8048420 8048315: 51 push %ecx 8048316: 56 push %esi 8048317: 68 d4 83 04 08 push $0x80483d4 804831c: e8 c7 ff ff ff call 80482e8 <__libc_start_main@plt> 8048321: f4 hlt 8048322: 90 nop 8048323: 90 nop 8048324: 90 nop 8048325: 90 nop 8048326: 90 nop 8048327: 90 nop 8048328: 90 nop 8048329: 90 nop 804832a: 90 nop 804832b: 90 nop 804832c: 90 nop 804832d: 90 nop 804832e: 90 nop 804832f: 90 nop 08048330 <__do_global_dtors_aux>: 8048330: 55 push %ebp 8048331: 89 e5 mov %esp,%ebp 8048333: 53 push %ebx 8048334: 83 ec 04 sub $0x4,%esp 8048337: 80 3d 10 a0 04 08 00 cmpb $0x0,0x804a010 804833e: 75 3f jne 804837f <__do_global_dtors_aux+0x4f> 8048340: a1 14 a0 04 08 mov 0x804a014,%eax 8048345: bb 18 9f 04 08 mov $0x8049f18,%ebx 804834a: 81 eb 14 9f 04 08 sub $0x8049f14,%ebx 8048350: c1 fb 02 sar $0x2,%ebx 8048353: 83 eb 01 sub $0x1,%ebx 8048356: 39 d8 cmp %ebx,%eax 8048358: 73 1e jae 8048378 <__do_global_dtors_aux+0x48> 804835a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8048360: 83 c0 01 add $0x1,%eax 8048363: a3 14 a0 04 08 mov %eax,0x804a014 8048368: ff 14 85 14 9f 04 08 call *0x8049f14(,%eax,4) 804836f: a1 14 a0 04 08 mov 0x804a014,%eax 8048374: 39 d8 cmp %ebx,%eax 8048376: 72 e8 jb 8048360 <__do_global_dtors_aux+0x30> 8048378: c6 05 10 a0 04 08 01 movb $0x1,0x804a010 804837f: 83 c4 04 add $0x4,%esp 8048382: 5b pop %ebx 8048383: 5d pop %ebp 8048384: c3 ret 8048385: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 8048389: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 08048390 <frame_dummy>: 8048390: 55 push %ebp 8048391: 89 e5 mov %esp,%ebp 8048393: 83 ec 18 sub $0x18,%esp 8048396: a1 1c 9f 04 08 mov 0x8049f1c,%eax 804839b: 85 c0 test %eax,%eax 804839d: 74 12 je 80483b1 <frame_dummy+0x21> 804839f: b8 00 00 00 00 mov $0x0,%eax 80483a4: 85 c0 test %eax,%eax 80483a6: 74 09 je 80483b1 <frame_dummy+0x21> 80483a8: c7 04 24 1c 9f 04 08 movl $0x8049f1c,(%esp) 80483af: ff d0 call *%eax 80483b1: c9 leave 80483b2: c3 ret 80483b3: 90 nop 080483b4 <func>: #include <stdio.h> long long func(long long no) { 80483b4: 55 push %ebp 80483b5: 89 e5 mov %esp,%ebp 80483b7: 83 ec 08 sub $0x8,%esp 80483ba: 8b 45 08 mov 0x8(%ebp),%eax 80483bd: 89 45 f8 mov %eax,-0x8(%ebp) 80483c0: 8b 45 0c mov 0xc(%ebp),%eax 80483c3: 89 45 fc mov %eax,-0x4(%ebp) return no + 1; 80483c6: 8b 45 f8 mov -0x8(%ebp),%eax 80483c9: 8b 55 fc mov -0x4(%ebp),%edx 80483cc: 83 c0 01 add $0x1,%eax 80483cf: 83 d2 00 adc $0x0,%edx } 80483d2: c9 leave 80483d3: c3 ret 080483d4 <main>: int main(int argc, const char *argv[]) { 80483d4: 55 push %ebp 80483d5: 89 e5 mov %esp,%ebp 80483d7: 83 e4 f8 and $0xfffffff8,%esp 80483da: 83 ec 18 sub $0x18,%esp int i; i = 100; 80483dd: c7 44 24 14 64 00 00 movl $0x64,0x14(%esp) 80483e4: 00 func(i); 80483e5: 8b 44 24 14 mov 0x14(%esp),%eax 80483e9: 89 c2 mov %eax,%edx 80483eb: c1 fa 1f sar $0x1f,%edx 80483ee: 89 04 24 mov %eax,(%esp) 80483f1: 89 54 24 04 mov %edx,0x4(%esp) 80483f5: e8 ba ff ff ff call 80483b4 <func> return 0; 80483fa: b8 00 00 00 00 mov $0x0,%eax } 80483ff: c9 leave 8048400: c3 ret 8048401: 90 nop 8048402: 90 nop 8048403: 90 nop 8048404: 90 nop 8048405: 90 nop 8048406: 90 nop 8048407: 90 nop 8048408: 90 nop 8048409: 90 nop 804840a: 90 nop 804840b: 90 nop 804840c: 90 nop 804840d: 90 nop 804840e: 90 nop 804840f: 90 nop 08048410 <__libc_csu_fini>: 8048410: 55 push %ebp 8048411: 89 e5 mov %esp,%ebp 8048413: 5d pop %ebp 8048414: c3 ret 8048415: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 8048419: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 08048420 <__libc_csu_init>: 8048420: 55 push %ebp 8048421: 89 e5 mov %esp,%ebp 8048423: 57 push %edi 8048424: 56 push %esi 8048425: 53 push %ebx 8048426: e8 4f 00 00 00 call 804847a <__i686.get_pc_thunk.bx> 804842b: 81 c3 c9 1b 00 00 add $0x1bc9,%ebx 8048431: 83 ec 1c sub $0x1c,%esp 8048434: e8 5f fe ff ff call 8048298 <_init> 8048439: 8d bb 18 ff ff ff lea -0xe8(%ebx),%edi 804843f: 8d 83 18 ff ff ff lea -0xe8(%ebx),%eax 8048445: 29 c7 sub %eax,%edi 8048447: c1 ff 02 sar $0x2,%edi 804844a: 85 ff test %edi,%edi 804844c: 74 24 je 8048472 <__libc_csu_init+0x52> 804844e: 31 f6 xor %esi,%esi 8048450: 8b 45 10 mov 0x10(%ebp),%eax 8048453: 89 44 24 08 mov %eax,0x8(%esp) 8048457: 8b 45 0c mov 0xc(%ebp),%eax 804845a: 89 44 24 04 mov %eax,0x4(%esp) 804845e: 8b 45 08 mov 0x8(%ebp),%eax 8048461: 89 04 24 mov %eax,(%esp) 8048464: ff 94 b3 18 ff ff ff call *-0xe8(%ebx,%esi,4) 804846b: 83 c6 01 add $0x1,%esi 804846e: 39 fe cmp %edi,%esi 8048470: 72 de jb 8048450 <__libc_csu_init+0x30> 8048472: 83 c4 1c add $0x1c,%esp 8048475: 5b pop %ebx 8048476: 5e pop %esi 8048477: 5f pop %edi 8048478: 5d pop %ebp 8048479: c3 ret 0804847a <__i686.get_pc_thunk.bx>: 804847a: 8b 1c 24 mov (%esp),%ebx 804847d: c3 ret 804847e: 90 nop 804847f: 90 nop 08048480 <__do_global_ctors_aux>: 8048480: 55 push %ebp 8048481: 89 e5 mov %esp,%ebp 8048483: 53 push %ebx 8048484: 83 ec 04 sub $0x4,%esp 8048487: a1 0c 9f 04 08 mov 0x8049f0c,%eax 804848c: 83 f8 ff cmp $0xffffffff,%eax 804848f: 74 13 je 80484a4 <__do_global_ctors_aux+0x24> 8048491: bb 0c 9f 04 08 mov $0x8049f0c,%ebx 8048496: 66 90 xchg %ax,%ax 8048498: 83 eb 04 sub $0x4,%ebx 804849b: ff d0 call *%eax 804849d: 8b 03 mov (%ebx),%eax 804849f: 83 f8 ff cmp $0xffffffff,%eax 80484a2: 75 f4 jne 8048498 <__do_global_ctors_aux+0x18> 80484a4: 83 c4 04 add $0x4,%esp 80484a7: 5b pop %ebx 80484a8: 5d pop %ebp 80484a9: c3 ret 80484aa: 90 nop 80484ab: 90 nop Disassembly of section .fini: 080484ac <_fini>: 80484ac: 55 push %ebp 80484ad: 89 e5 mov %esp,%ebp 80484af: 53 push %ebx 80484b0: 83 ec 04 sub $0x4,%esp 80484b3: e8 00 00 00 00 call 80484b8 <_fini+0xc> 80484b8: 5b pop %ebx 80484b9: 81 c3 3c 1b 00 00 add $0x1b3c,%ebx 80484bf: e8 6c fe ff ff call 8048330 <__do_global_dtors_aux> 80484c4: 59 pop %ecx 80484c5: 5b pop %ebx 80484c6: c9 leave 80484c7: c3 ret
You can see that a implict cast in source code causes a substantial object code change.
发表评论
-
Division and modulo in C/C++, Java and Python
2013-12-19 12:58 688引用 a is an integer, n is a posi ... -
Hacking Assembly Code Generated by G++
2013-06-09 15:31 1205For the following C++ code: ... -
An Application of Bubble Sort
2013-04-11 21:03 775This problem is inspired by t ... -
C++ inline
2012-07-10 13:41 734http://www.parashift.com/c++-fa ... -
Check the final definition of a typedef
2012-07-04 10:43 661Refer to http://stackoverflow.c ... -
C symbol table
2012-05-06 10:38 1204C source code: #include ... -
GCC options: -ffunction-sections and -fdata-sections
2012-05-05 11:21 2070C code: struct person { ... -
gcov tutorial
2012-05-03 21:01 822tmp.c #include <stdio.h& ... -
x86 64 assembly tutorial (MEMO)
2012-04-24 15:50 685Refer to http://os-blog.com/x86 ... -
The New C: X Macros (memo)
2012-04-20 10:42 792The code: #include <stdi ... -
Assembly code for stack array initialization
2012-04-14 10:28 845I develop the code with x86 gcc ... -
C array initialization
2012-04-14 10:18 732For fewer initializers, refer t ... -
Example of snprintf
2012-04-09 18:18 789#include <stdio.h> ... -
Array and its first element
2012-04-09 17:46 862#include <stdio.h> ... -
Struct array member
2012-04-08 10:59 843C code: #include <stdio. ... -
Relationship between union and its members
2012-04-08 09:42 664Code: #include <stdio.h& ... -
#if and #ifdef in C
2012-04-06 22:19 739#include <stdio.h> ... -
Optional comma in C initialization
2012-04-06 14:09 721#include <stdio.h> ... -
Access elements in array of struct
2012-04-05 10:32 766#include <stdio.h> ... -
Compute the difference between a value and 2's power
2012-03-31 10:14 544#include <stdio.h> ...
相关推荐
Source Code is made available at time of download, from the official UUI page: http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/ IMPORTANT! No Warranty is being offered with this ...
You may modify, copy, and distribute the source and object code form of the sample source code included in the subfolders of the project files. * Third Party Distribution. You may permit distributors...
Create new folder where source code and binary files will be kept (For example, C:\RAD_Studio_XE2\Components\EhLib). Hereinafter this folder will be call as "EhLib folder". Create new subfolder Lib ...
• C# source code with XML comments on all public members. • Tooltip explanations for all visible variables. Compatible With Complete Terrain Shader and IK Driver Vehicle Controller European Truck...
The default priority for each msg created will be prNormal, so you don‘t need to change your code any bit.1.8.6- Ulf Sturegren has added D4 compatibility, not many changes to the source (one letter)...
EhLib 6.3 Build 6.3.176 Russian version....Create new folder where source code and binary files will be kept (For example, C:\RAD_Studio_XE2\Components\EhLib). Hereinafter this folder will be call as...
It will allow you to graphically design your message box, specify how you want it to look and will create the source code for you and put it into the clipboard where you <END><br>47,vb2word.zip ...
Its a VB program with all source code and sample for creating a bspline / beziere curve / wireframe generator. Very good and fast code.<END><br>43,reaction.zip A computer engineering student from ...
+ to load old Hiedit templates as RTF code use the formatstring -HiEditFields. This will create merge fields for ALL fields. - NL sign was not shown right after CTRL+ENTER was pressed (requires ShowNL...
// and it doesn't release the handle of the source bitmap which // // is used to assign to the GIF object as in gif.assign(bm); // // These changes were made as a result of a news post made by Renate ...
Much faster processing due to linking to Zlib object files for compression and decompression routines. Blocked Zip Files (spanned zip archives split onto hard drive) - Now completely compatible ...
A general familiarity with object-oriented programming concepts and the Java programming language is necessary. The Java language essentials tutorial can help. copyright 1996-2000 Magelang ...
Twitter Digg Facebook Del.icio.us Reddit Stumbleupon Newsvine Technorati Mr....Database » Database » Other databasesLicence...In v2.3 a single simple change of converting internal classes ...
- Support more host OS to run on: - Include win64 native binary in the release. - Fixed failures on big endian hosts. - BIOS: Support for up to 2M ROM BIOS images. - GUI: select mouse capture toggle...
However, the req_mode column of master.dbo.syslockinfo has lock mode code that is one less than the code values shown here. For example, value of req_mode = 3 represents the Shared lock mode rather ...
or on the external source (updating parameters [Params] and requiring data from DataDriver). Allows once-only (without the dynamic support) sort data, including Calculated and Lookup field. ...
or on the external source (updating parameters [Params] and requiring data from DataDriver). Allows once-only (without the dynamic support) sort data, including Calculated and Lookup field. ...
30)..Fixed: Leak of EurekaLog exception information object 31)..Fixed: Wrong chaining exceptions inside GetMem/FreeMem 32)..Fixed: Memory leak after low-level unhook of function 33)..Fixed: Re-...
The only source of any storage location information is the sysindexes table, which keeps track of the address of the root page for every index, and the first IAM page for the index or table....
集合了 所有的 Unix命令大全 ...telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss ... 各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ ... 命令和参数之间必需用空格隔...