<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>codercat (codercat)</title>
    <link>https://ruby-china.org/codercat</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>深入理解函数调用原理</title>
      <description>&lt;p&gt;这是一篇讲述函数调用原理的文章，通过大量的示意图从比较基础的概念开始阐述函数调用时堆栈的完整变化过程，同时还会通过具体例子来分析在 X-64 平台上函数调用在汇编级的表示，从而深刻理解函数调用原理。最后会提供几个例子来发现 C 语言函数栈帧的一些有意思的行为。&lt;/p&gt;

&lt;p&gt;全文将带领你领略函数与栈的魅力，文章提供了&lt;a href="https://gitbook.coder.cat/function-call-principle/" rel="nofollow" target="_blank" title=""&gt;gitbook&lt;/a&gt;的阅读方式。
如果你觉得对你有帮助，可以来到文章的&lt;a href="https://github.com/acodercat/function-call-principle" rel="nofollow" target="_blank" title=""&gt;github 仓库&lt;/a&gt;点个 star 啊！&lt;/p&gt;
&lt;h2 id="目录"&gt;目录&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://gitbook.coder.cat/function-call-principle/content/pre-knowledge.html" rel="nofollow" target="_blank" title=""&gt;前置知识&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gitbook.coder.cat/function-call-principle/content/stack-in-memory.html" rel="nofollow" target="_blank" title=""&gt;内存中的栈&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gitbook.coder.cat/function-call-principle/content/control-transfer.html" rel="nofollow" target="_blank" title=""&gt;控制转移&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gitbook.coder.cat/function-call-principle/content/data-transfer.html" rel="nofollow" target="_blank" title=""&gt;数据传递&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gitbook.coder.cat/function-call-principle/content/save-and-restore-of-registers.html" rel="nofollow" target="_blank" title=""&gt;寄存器的保存与恢复&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gitbook.coder.cat/function-call-principle/content/storage-of-local-variables.html" rel="nofollow" target="_blank" title=""&gt;局部变量的存储&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gitbook.coder.cat/function-call-principle/content/function-stack-frame.html" rel="nofollow" target="_blank" title=""&gt;函数栈帧&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gitbook.coder.cat/function-call-principle/content/c-stack-frame-example.html" rel="nofollow" target="_blank" title=""&gt;C 语言函数栈帧实例&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gitbook.coder.cat/function-call-principle/content/interesting-example.html" rel="nofollow" target="_blank" title=""&gt;一个有趣的例子&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gitbook.coder.cat/function-call-principle/content/modify-stack-frame-data.html" rel="nofollow" target="_blank" title=""&gt;手动修改栈帧数据&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gitbook.coder.cat/function-call-principle/content/summary.html" rel="nofollow" target="_blank" title=""&gt;总结&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="本文可以收获什么？"&gt;本文可以收获什么？&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;函数间如何转移控制&lt;/li&gt;
&lt;li&gt;函数间如何传递数据&lt;/li&gt;
&lt;li&gt;栈帧的初始化与销毁&lt;/li&gt;
&lt;li&gt;C/C++ 数组越界的危害&lt;/li&gt;
&lt;li&gt;为什么内联（inline）函数效率高&lt;/li&gt;
&lt;li&gt;为什么尽量用循环来代替递归调用&lt;/li&gt;
&lt;li&gt;为什么静态变量在函数返回后不会被释放&lt;/li&gt;
&lt;li&gt;什么是栈溢出攻击&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="其他"&gt;其他&lt;/h2&gt;
&lt;p&gt;文中有一个重要的概念&lt;code&gt;内存对齐&lt;/code&gt;没有提及，它不属于函数调用范畴之内。我在构造示例时避免了编译器为了&lt;code&gt;内存对齐&lt;/code&gt;而生成一些额外的指令，所以文中见不到它的影子。如果你有兴趣可以通过网络去了解与它相关的内容。&lt;/p&gt;
&lt;h2 id="相关资源"&gt;相关资源&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;书籍：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;《深入理解计算机系统》（第三版）&lt;/li&gt;
&lt;li&gt;《汇编语言》（王爽第三版）&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;公开课：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;《编程范式》（斯坦福公开课）&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="绘图工具"&gt;绘图工具&lt;/h2&gt;
&lt;p&gt;文中所有图片都使用了&lt;a href="https://excalidraw.com/" rel="nofollow" target="_blank" title=""&gt;excalidraw&lt;/a&gt;作为绘图工具，这是一款非常棒的在线绘图工具，它提供了不同风格的绘制模式。&lt;/p&gt;</description>
      <author>codercat</author>
      <pubDate>Thu, 07 Jan 2021 14:10:03 +0800</pubDate>
      <link>https://ruby-china.org/topics/40787</link>
      <guid>https://ruby-china.org/topics/40787</guid>
    </item>
  </channel>
</rss>
