`
yaojingguo
  • 浏览: 208945 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Hacking Assembly Code Generated by G++

阅读更多

For the following C++ code:

 

class person {
  public:
    person() {}
    person(const person& rhs) {}
};
void func(person p) {
}
int main(int argc, const char *argv[]) 
{
  person yao; 
  func(yao);
  return 0;
}

 

Run "g++ -S" produces (some .cfi directives removed):

 

	.file	"clean.cpp"
	.section	.text._ZN6personC2Ev,"axG",@progbits,_ZN6personC5Ev,comdat
	.align 2
	.weak	_ZN6personC2Ev
	.type	_ZN6personC2Ev, @function
_ZN6personC2Ev:
.LFB1:
	pushl	%ebp
	movl	%esp, %ebp
	popl	%ebp
	ret
.LFE1:
	.size	_ZN6personC2Ev, .-_ZN6personC2Ev
	.section	.text._ZN6personC2ERKS_,"axG",@progbits,_ZN6personC5ERKS_,comdat
	.align 2
	.weak	_ZN6personC2ERKS_
	.type	_ZN6personC2ERKS_, @function
_ZN6personC2ERKS_:
.LFB4:
	pushl	%ebp
	movl	%esp, %ebp
	popl	%ebp
	ret
.LFE4:
	.size	_ZN6personC2ERKS_, .-_ZN6personC2ERKS_
	.text
	.globl	_Z4func6person
	.type	_Z4func6person, @function
_Z4func6person:
.LFB6:
	pushl	%ebp
	movl	%esp, %ebp
	popl	%ebp
	ret
.LFE6:
	.size	_Z4func6person, .-_Z4func6person
	.globl	main
	.type	main, @function
main:
.LFB7:
	pushl	%ebp
	movl	%esp, %ebp
	andl	$-16, %esp
	subl	$32, %esp
	leal	30(%esp), %eax
	movl	%eax, (%esp)
	call	_ZN6personC1Ev
	leal	30(%esp), %eax
	movl	%eax, 4(%esp)
	leal	31(%esp), %eax
	movl	%eax, (%esp)
	call	_ZN6personC1ERKS_
	leal	31(%esp), %eax
	movl	%eax, (%esp)
	call	_Z4func6person
	movl	$0, %eax
	leave
	ret
.LFE7:
	.size	main, .-main
	.weak	_ZN6personC1Ev
	.set	_ZN6personC1Ev,_ZN6personC2Ev
	.weak	_ZN6personC1ERKS_
	.set	_ZN6personC1ERKS_,_ZN6personC2ERKS_
	.ident	"GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3"
	.section	.note.GNU-stack,"",@progbits

 

 To see the meaningful names for the mangle function names, user c++filt. For how gcc does name mangling on Linux, see http://refspecs.linux-foundation.org/cxxabi-1.83.html#mangling.

 

For the source code, we can have the following conclusion. A person object is created using its constructor. Before calling func, a new person object is created using its copy constructor.

分享到:
评论

相关推荐

    Hacking the Code ASP.NET Web Application Security.pdf

    《Hacking the Code ASP.NET Web Application Security》这本书深入探讨了ASP.NET Web应用程序的安全性问题,旨在帮助开发者构建更安全的Web应用,防止黑客攻击。书中的内容覆盖了用户管理、身份验证与授权等多个...

    Hacking - The Art of Exploitation, 2nd Ed

    more accessible by providing the complete picture—from programming to machine code to exploitation. In addition, this edition features a bootable LiveCD based on Ubuntu Linux that can be used in any ...

    英文原版-Game Hacking 1st Edition

    Learn the basics, like reverse engineering, assembly code analysis, programmatic memory manipulation, and code injection, and hone your new skills with hands-on example code and practice binaries....

    Web Hacking 101: How to Make Money Hacking Ethically

    With a Foreword written by HackerOne Co-Founders Michiel Prins and Jobert Abma, Web Hacking 101 is about the ethical exploration of software for security issues but learning to hack isn’t always easy...

    swing hacking code

    《Swing Hacking Code》是关于Java Swing组件库深度探索和优化的一篇文章,结合了源码分析和实用工具的讨论。在Java GUI编程领域,Swing是一个强大的框架,用于构建桌面应用程序。这篇博客作者通过分享自己的理解和...

    Hacking_ A 101 Hacking Guide

    Hacking_ A 101 Hacking Guide,hack参考书,值的一看。

    WiFi Hacking for Beginners 2017

    WiFi Hacking for Beginners - Learn Hacking by Hacking WiFi networks (2017) (Azw3)

    WiFi Hacking for Beginners

    WiFi Hacking for Beginners - Learn Hacking by Hacking WiFi networks (2017) (Epub)

    Hacking_Tool_Developer_Sources_Primer_v10_by_Gunther

    由于压缩包内只有一个文件,即同名的"Hacking Tool Developer Sources Primer_v10_by_Gunther",我们可以推断这可能是一个综合性的文件,比如PDF或EPUB格式的电子书,包含了完整的指南内容。内容可能包括以下几个...

    Hacking the Hacker Learn From the Experts Who Take Down Hackers

    Hacking the Hacker takes you inside the world of ... final chapters include a guide for parents of young hackers, as well as the Code of Ethical Hacking to help you start your own journey to the top.

    Hacking - The Art of Exploitation

    Hacking is the art of creating problem solving, whether used to find an unconventional solution to a difficult problem or to exploit holes in sloppy programming. Many people call themselves hackers, ...

    hacking hacking hacking

    - **书名**:《Hacking: The Art of Exploitation》第二版 - **作者**:Jon Erickson - **出版社**:No Starch Press - **出版日期**:2008年1月15日 - **ISBN-13**:978-1-59-327144-2 - **页数**:480页 ### 二、...

    Game Hacking

    Learn the basics, like reverse engineering, assembly code analysis, programmatic memory manipulation, and code injection, and hone your new skills with hands-on example code and practice binaries....

    Hacking Tutorials

    Hacking Tutorials

    Hacking the next generation

    比较新的Hacking攻防的概念和技术,具有很好的指导价值。

    Google Hacking

    ### Google Hacking详解 在数字化时代,信息安全已成为企业和个人必须重视的重要议题。随着网络技术的发展,利用搜索引擎进行安全渗透的技术也日益成熟。“Google Hacking”就是一种通过利用搜索引擎(特别是Google...

Global site tag (gtag.js) - Google Analytics