{"id":42693,"date":"2025-06-10T08:54:55","date_gmt":"2025-06-10T00:54:55","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/42693.html"},"modified":"2025-06-10T08:54:55","modified_gmt":"2025-06-10T00:54:55","slug":"%e3%80%90hitcsapp-%e5%93%88%e5%b7%a5%e5%a4%a7%e8%ae%a1%e7%ae%97%e6%9c%ba%e7%b3%bb%e7%bb%9f%e6%9c%9f%e6%9c%ab%e5%a4%a7%e4%bd%9c%e4%b8%9a%e3%80%91-%e7%a8%8b%e5%ba%8f%e4%ba%ba%e7%94%9f-hellos-p2","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/42693.html","title":{"rendered":"\u3010HITCSAPP \u54c8\u5de5\u5927\u8ba1\u7b97\u673a\u7cfb\u7edf\u671f\u672b\u5927\u4f5c\u4e1a\u3011 \u7a0b\u5e8f\u4eba\u751f-Hello\u2019s P2P"},"content":{"rendered":"<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"44\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825d3802b.jpg\" width=\"241\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u8ba1\u7b97\u673a\u7cfb\u7edf<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u5927\u4f5c\u4e1a<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0px;margin-right:0px;text-align:center\">\u9898 \u00a0\u00a0\u00a0\u00a0\u76ee \u00a0\u7a0b\u5e8f\u4eba\u751f-Hello\u2019s P2P\u00a0  <\/p>\n<p style=\"margin-left:0px;margin-right:0px;text-align:center\">\u4e13\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u4e1a \u00a0\u00a0\u8ba1\u7b97\u673a\u4e0e\u7535\u5b50\u901a\u4fe1\u7c7b\u00a0 \u00a0\u00a0<\/p>\n<p style=\"margin-left:0px;margin-right:0px;text-align:center\">\u5b66\u3000\u3000\u00a0\u00a0 \u53f7 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02023112915\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/p>\n<p style=\"margin-left:0px;margin-right:0px;text-align:center\">\u73ed\u3000\u3000\u00a0\u00a0 \u7ea7 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a023L0505\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p style=\"margin-left:0px;margin-right:0px;text-align:center\">\u5b66\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u751f \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6768\u6615\u5f66\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p style=\"margin-left:0px;margin-right:0px;text-align:center\">\u6307 \u5bfc \u6559 \u5e08 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5218\u5b8f\u4f1f \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u8ba1\u7b97\u673a\u79d1\u5b66\u4e0e\u6280\u672f\u5b66\u9662<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">2024\u5e745\u6708<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u6458\u00a0 \u8981<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u672c\u6587\u8be6\u7ec6\u63cf\u8ff0\u4e86\u201cHello\u201d\u7a0b\u5e8f\u4ece\u6e90\u4ee3\u7801\u5230\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5168\u751f\u547d\u5468\u671f&#xff0c;\u6db5\u76d6\u4e86\u9884\u5904\u7406\u3001\u7f16\u8bd1\u3001\u6c47\u7f16\u3001\u94fe\u63a5\u3001\u8fd0\u884c\u53ca\u56de\u6536\u7684\u5404\u4e2a\u9636\u6bb5\u3002\u901a\u8fc7\u5206\u6790\u6bcf\u4e2a\u9636\u6bb5\u7684\u5177\u4f53\u64cd\u4f5c\u548c\u5de5\u5177&#xff0c;\u6df1\u5165\u63a2\u8ba8\u4e86\u8ba1\u7b97\u673a\u7cfb\u7edf\u7684\u5de5\u4f5c\u539f\u7406\u3002\u6587\u7ae0\u9996\u5148\u4ecb\u7ecd\u4e86\u9884\u5904\u7406\u9636\u6bb5\u5982\u4f55\u5c55\u5f00\u5b8f\u548c\u5934\u6587\u4ef6&#xff0c;\u751f\u6210\u4e2d\u95f4\u6587\u4ef6hello.i&#xff1b;\u63a5\u7740\u9610\u8ff0\u4e86\u7f16\u8bd1\u9636\u6bb5\u5c06hello.i\u8f6c\u6362\u4e3a\u6c47\u7f16\u4ee3\u7801hello.s\u7684\u8fc7\u7a0b&#xff1b;\u968f\u540e\u8ba8\u8bba\u4e86\u6c47\u7f16\u9636\u6bb5\u5c06hello.s\u6c47\u7f16\u6210\u76ee\u6807\u6587\u4ef6hello.o\u7684\u6b65\u9aa4&#xff1b;\u6700\u540e\u8bb2\u89e3\u4e86\u94fe\u63a5\u9636\u6bb5\u5982\u4f55\u5c06hello.o\u4e0e\u5e93\u6587\u4ef6\u5408\u5e76\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6hello\u3002\u5728\u8fd0\u884c\u9636\u6bb5&#xff0c;\u6587\u7ae0\u8be6\u7ec6\u63cf\u8ff0\u4e86Shell\u5982\u4f55\u901a\u8fc7fork\u548cexecve\u521b\u5efa\u5e76\u6267\u884chello\u8fdb\u7a0b&#xff0c;\u5e76\u63a2\u8ba8\u4e86\u865a\u62df\u5730\u5740\u5230\u7269\u7406\u5730\u5740\u7684\u8f6c\u6362\u673a\u5236\u3002\u6b64\u5916&#xff0c;\u6587\u7ae0\u8fd8\u5206\u6790\u4e86printf\u548cgetchar\u7b49\u51fd\u6570\u7684\u5b9e\u73b0\u539f\u7406&#xff0c;\u63ed\u793a\u4e86Linux I\/O\u8bbe\u5907\u7ba1\u7406\u7684\u6838\u5fc3\u601d\u60f3\u3002\u901a\u8fc7\u8fd9\u4e00\u7cfb\u5217\u6b65\u9aa4&#xff0c;\u6587\u7ae0\u5c55\u793a\u4e86\u8ba1\u7b97\u673a\u7cfb\u7edf\u4ece\u6e90\u4ee3\u7801\u5230\u786c\u4ef6\u6267\u884c\u7684\u590d\u6742\u6d41\u7a0b&#xff0c;\u5f3a\u8c03\u4e86\u7406\u8bba\u4e0e\u5b9e\u8df5\u7ed3\u5408\u7684\u91cd\u8981\u6027&#xff0c;\u5e76\u603b\u7ed3\u4e86\u5b66\u4e60\u8ba1\u7b97\u673a\u7cfb\u7edf\u7684\u6df1\u523b\u4f53\u4f1a\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5173\u952e\u8bcd&#xff1a;Hello&#xff1b;CSAPP&#xff1b;P2P&#xff1b;Linux&#xff1b; VM&#xff1b;I\/O&#xff1b;Shell&#xff1b;Cache&#xff1b;Ubuntu&#xff1b;\u8fdb\u7a0b&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u76ee\u00a0 \u5f55<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E7%AC%AC1%E7%AB%A0%20%E6%A6%82%E8%BF%B0-toc\" style=\"margin-left:0px\">\u7b2c1\u7ae0 \u6982\u8ff0<\/p>\n<p id=\"1.1%20Hello%E7%AE%80%E4%BB%8B-toc\" style=\"margin-left:40px\">1.1 Hello\u7b80\u4ecb<\/p>\n<p id=\"1.1.1%20P2P-toc\" style=\"margin-left:80px\">1.1.1 P2P<\/p>\n<p id=\"1.1.2%20020-toc\" style=\"margin-left:80px\">1.1.2 020<\/p>\n<p id=\"1.2%20%E7%8E%AF%E5%A2%83%E4%B8%8E%E5%B7%A5%E5%85%B7-toc\" style=\"margin-left:40px\">1.2 \u73af\u5883\u4e0e\u5de5\u5177<\/p>\n<p id=\"1.2.1%20%E7%A1%AC%E4%BB%B6%E7%8E%AF%E5%A2%83-toc\" style=\"margin-left:80px\">1.2.1 \u786c\u4ef6\u73af\u5883<\/p>\n<p id=\"1.2.2%20%E8%BD%AF%E4%BB%B6%E7%8E%AF%E5%A2%83-toc\" style=\"margin-left:80px\">1.2.2 \u8f6f\u4ef6\u73af\u5883<\/p>\n<p id=\"1.2.3%20%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-toc\" style=\"margin-left:80px\">1.2.3 \u5f00\u53d1\u5de5\u5177<\/p>\n<p id=\"1.3%20%E4%B8%AD%E9%97%B4%E7%BB%93%E6%9E%9C-toc\" style=\"margin-left:40px\">1.3 \u4e2d\u95f4\u7ed3\u679c<\/p>\n<p id=\"1.4%20%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93-toc\" style=\"margin-left:40px\">1.4 \u672c\u7ae0\u5c0f\u7ed3<\/p>\n<p id=\"%E7%AC%AC2%E7%AB%A0%20%E9%A2%84%E5%A4%84%E7%90%86-toc\" style=\"margin-left:0px\">\u7b2c2\u7ae0 \u9884\u5904\u7406<\/p>\n<p id=\"2.1%20%E9%A2%84%E5%A4%84%E7%90%86%E7%9A%84%E6%A6%82%E5%BF%B5%E4%B8%8E%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:40px\">2.1 \u9884\u5904\u7406\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528<\/p>\n<p id=\"2.1.1%20%E9%A2%84%E5%A4%84%E7%90%86%E7%9A%84%E6%A6%82%E5%BF%B5-toc\" style=\"margin-left:80px\">2.1.1 \u9884\u5904\u7406\u7684\u6982\u5ff5<\/p>\n<p id=\"2.1.2%20%E9%A2%84%E5%A4%84%E7%90%86%E7%9A%84%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:80px\">2.1.2 \u9884\u5904\u7406\u7684\u4f5c\u7528<\/p>\n<p id=\"2.2%E5%9C%A8Ubuntu%E4%B8%8B%E9%A2%84%E5%A4%84%E7%90%86%E7%9A%84%E5%91%BD%E4%BB%A4-toc\" style=\"margin-left:40px\">2.2\u5728Ubuntu\u4e0b\u9884\u5904\u7406\u7684\u547d\u4ee4<\/p>\n<p id=\"2.3%20Hello%E7%9A%84%E9%A2%84%E5%A4%84%E7%90%86%E7%BB%93%E6%9E%9C%E8%A7%A3%E6%9E%90-toc\" style=\"margin-left:40px\">2.3 Hello\u7684\u9884\u5904\u7406\u7ed3\u679c\u89e3\u6790<\/p>\n<p id=\"2.4%20%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93-toc\" style=\"margin-left:40px\">2.4 \u672c\u7ae0\u5c0f\u7ed3<\/p>\n<p id=\"%E7%AC%AC3%E7%AB%A0%20%E7%BC%96%E8%AF%91-toc\" style=\"margin-left:0px\">\u7b2c3\u7ae0 \u7f16\u8bd1<\/p>\n<p id=\"3.1%20%E7%BC%96%E8%AF%91%E7%9A%84%E6%A6%82%E5%BF%B5%E4%B8%8E%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:40px\">3.1 \u7f16\u8bd1\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528<\/p>\n<p id=\"3.1.1%20%E7%BC%96%E8%AF%91%E7%9A%84%E6%A6%82%E5%BF%B5-toc\" style=\"margin-left:80px\">3.1.1 \u7f16\u8bd1\u7684\u6982\u5ff5<\/p>\n<p id=\"3.1.2%20%E7%BC%96%E8%AF%91%E7%9A%84%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:80px\">3.1.2 \u7f16\u8bd1\u7684\u4f5c\u7528<\/p>\n<p id=\"3.2%20%E5%9C%A8Ubuntu%E4%B8%8B%E7%BC%96%E8%AF%91%E7%9A%84%E5%91%BD%E4%BB%A4-toc\" style=\"margin-left:40px\">3.2 \u5728Ubuntu\u4e0b\u7f16\u8bd1\u7684\u547d\u4ee4<\/p>\n<p id=\"3.3%20Hello%E7%9A%84%E7%BC%96%E8%AF%91%E7%BB%93%E6%9E%9C%E8%A7%A3%E6%9E%90-toc\" style=\"margin-left:40px\">3.3 Hello\u7684\u7f16\u8bd1\u7ed3\u679c\u89e3\u6790<\/p>\n<p id=\"3.3.1%20%E6%95%B0%E6%8D%AE-toc\" style=\"margin-left:80px\">3.3.1 \u6570\u636e<\/p>\n<p id=\"3.3.1.1%20%E5%B8%B8%E9%87%8F-toc\" style=\"margin-left:80px\">3.3.1.1 \u5e38\u91cf<\/p>\n<p id=\"3.3.1.2%20%E5%8F%98%E9%87%8F(%E5%85%A8%E5%B1%80%2F%E5%B1%80%E9%83%A8%2F%E9%9D%99%E6%80%81)-toc\" style=\"margin-left:80px\">3.3.1.2 \u53d8\u91cf(\u5168\u5c40\/\u5c40\u90e8\/\u9759\u6001)<\/p>\n<p id=\"3.3.1.2%20%E8%A1%A8%E8%BE%BE%E5%BC%8F-toc\" style=\"margin-left:80px\">3.3.1.2 \u8868\u8fbe\u5f0f<\/p>\n<p id=\"3.3.1.4%20%E7%B1%BB%E5%9E%8B-toc\" style=\"margin-left:80px\">3.3.1.4 \u7c7b\u578b<\/p>\n<p id=\"3.3.1.5%20%E5%AE%8F-toc\" style=\"margin-left:80px\">3.3.1.5 \u5b8f<\/p>\n<p id=\"3.3.2%20%E8%B5%8B%E5%80%BC-toc\" style=\"margin-left:80px\">3.3.2 \u8d4b\u503c<\/p>\n<p id=\"3.3.3%20%E7%AE%97%E6%9C%AF%E6%93%8D%E4%BD%9C-toc\" style=\"margin-left:80px\">3.3.3 \u7b97\u672f\u64cd\u4f5c<\/p>\n<p id=\"3.3.4%20%E5%85%B3%E7%B3%BB%E6%93%8D%E4%BD%9C-toc\" style=\"margin-left:80px\">3.3.4 \u5173\u7cfb\u64cd\u4f5c<\/p>\n<p id=\"3.3.5%20%E6%95%B0%E7%BB%84%2F%E6%8C%87%E9%92%88%2F%E7%BB%93%E6%9E%84%E6%93%8D%E4%BD%9C-toc\" style=\"margin-left:80px\">3.3.5 \u6570\u7ec4\/\u6307\u9488\/\u7ed3\u6784\u64cd\u4f5c<\/p>\n<p id=\"3.3.6%20%E6%8E%A7%E5%88%B6%E8%BD%AC%E7%A7%BB-toc\" style=\"margin-left:80px\">3.3.6 \u63a7\u5236\u8f6c\u79fb<\/p>\n<p id=\"3.3.7%E5%87%BD%E6%95%B0%E6%93%8D%E4%BD%9C-toc\" style=\"margin-left:80px\">3.3.7\u51fd\u6570\u64cd\u4f5c<\/p>\n<p id=\"3.3.7.1%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92(%E5%9C%B0%E5%9D%80%2F%E5%80%BC)-toc\" style=\"margin-left:80px\">3.3.7.1\u53c2\u6570\u4f20\u9012(\u5730\u5740\/\u503c)<\/p>\n<p id=\"3.3.7.2%E5%87%BD%E6%95%B0%E8%B0%83%E7%94%A8-toc\" style=\"margin-left:80px\">3.3.7.2\u51fd\u6570\u8c03\u7528<\/p>\n<p id=\"3.3.7.3%E5%87%BD%E6%95%B0%E8%BF%94%E5%9B%9E-toc\" style=\"margin-left:80px\">3.3.7.3\u51fd\u6570\u8fd4\u56de<\/p>\n<p id=\"3.4%20%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93-toc\" style=\"margin-left:40px\">3.4 \u672c\u7ae0\u5c0f\u7ed3<\/p>\n<p id=\"%E7%AC%AC4%E7%AB%A0%20%E6%B1%87%E7%BC%96-toc\" style=\"margin-left:0px\">\u7b2c4\u7ae0 \u6c47\u7f16<\/p>\n<p id=\"4.1%20%E6%B1%87%E7%BC%96%E7%9A%84%E6%A6%82%E5%BF%B5%E4%B8%8E%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:40px\">4.1 \u6c47\u7f16\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528<\/p>\n<p id=\"4.1.1%20%E6%B1%87%E7%BC%96%E7%9A%84%E6%A6%82%E5%BF%B5-toc\" style=\"margin-left:80px\">4.1.1 \u6c47\u7f16\u7684\u6982\u5ff5<\/p>\n<p id=\"4.1.2%20%E6%B1%87%E7%BC%96%E7%9A%84%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:80px\">4.1.2 \u6c47\u7f16\u7684\u4f5c\u7528<\/p>\n<p id=\"4.2%20%E5%9C%A8Ubuntu%E4%B8%8B%E6%B1%87%E7%BC%96%E7%9A%84%E5%91%BD%E4%BB%A4-toc\" style=\"margin-left:40px\">4.2 \u5728Ubuntu\u4e0b\u6c47\u7f16\u7684\u547d\u4ee4<\/p>\n<p id=\"-toc\" style=\"margin-left:40px\">\n<p id=\"4.3%20%E5%8F%AF%E9%87%8D%E5%AE%9A%E4%BD%8D%E7%9B%AE%E6%A0%87elf%E6%A0%BC%E5%BC%8F-toc\" style=\"margin-left:40px\">4.3 \u53ef\u91cd\u5b9a\u4f4d\u76ee\u6807elf\u683c\u5f0f<\/p>\n<p id=\"%C2%A0%C2%A0%C2%A0%204.3.1%E6%96%87%E4%BB%B6%E5%A4%B4-toc\" style=\"margin-left:80px\">\u00a0\u00a0\u00a0 4.3.1\u6587\u4ef6\u5934<\/p>\n<p id=\"%C2%A0%C2%A0%C2%A0%204.3.2%E7%A8%8B%E5%BA%8F%E5%A4%B4%E8%A1%A8-toc\" style=\"margin-left:80px\">\u00a0\u00a0\u00a0 4.3.2\u7a0b\u5e8f\u5934\u8868<\/p>\n<p id=\"%C2%A0%C2%A0%C2%A0%204.3.2%E8%8A%82%E8%A1%A8-toc\" style=\"margin-left:80px\">\u00a0\u00a0\u00a0 4.3.2\u8282\u8868<\/p>\n<p id=\"4.4%20Hello.o%E7%9A%84%E7%BB%93%E6%9E%9C%E8%A7%A3%E6%9E%90-toc\" style=\"margin-left:40px\">4.4 Hello.o\u7684\u7ed3\u679c\u89e3\u6790<\/p>\n<p id=\"4.4.1%20hello.o%E5%8F%8D%E6%B1%87%E7%BC%96%E4%B8%8Ehello.s%E7%9A%84%E6%AF%94%E8%BE%83-toc\" style=\"margin-left:80px\">4.4.1 hello.o\u53cd\u6c47\u7f16\u4e0ehello.s\u7684\u6bd4\u8f83<\/p>\n<p id=\"4.4.2%20%E6%9C%BA%E5%99%A8%E8%AF%AD%E8%A8%80%E7%9A%84%E6%9E%84%E6%88%90-toc\" style=\"margin-left:80px\">4.4.2 \u673a\u5668\u8bed\u8a00\u7684\u6784\u6210<\/p>\n<p id=\"4.4.3%20%E4%B8%8E%E6%B1%87%E7%BC%96%E8%AF%AD%E8%A8%80%E7%9A%84%E6%98%A0%E5%B0%84%E5%85%B3%E7%B3%BB-toc\" style=\"margin-left:80px\">4.4.3 \u4e0e\u6c47\u7f16\u8bed\u8a00\u7684\u6620\u5c04\u5173\u7cfb<\/p>\n<p id=\"-toc\" style=\"margin-left:40px\">\n<p id=\"4.5%20%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93-toc\" style=\"margin-left:40px\">4.5 \u672c\u7ae0\u5c0f\u7ed3<\/p>\n<p id=\"%E7%AC%AC5%E7%AB%A0%20%E9%93%BE%E6%8E%A5-toc\" style=\"margin-left:0px\">\u7b2c5\u7ae0 \u94fe\u63a5<\/p>\n<p id=\"5.1%20%E9%93%BE%E6%8E%A5%E7%9A%84%E6%A6%82%E5%BF%B5%E4%B8%8E%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:40px\">5.1 \u94fe\u63a5\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528<\/p>\n<p id=\"-toc\" style=\"margin-left:80px\">\n<p id=\"5.1.1%20%E9%93%BE%E6%8E%A5%E7%9A%84%E6%A6%82%E5%BF%B5-toc\" style=\"margin-left:80px\">5.1.1 \u94fe\u63a5\u7684\u6982\u5ff5<\/p>\n<p id=\"5.1.2%20%E9%93%BE%E6%8E%A5%E7%9A%84%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:80px\">5.1.2 \u94fe\u63a5\u7684\u4f5c\u7528<\/p>\n<p id=\"5.2%20%E5%9C%A8Ubuntu%E4%B8%8B%E9%93%BE%E6%8E%A5%E7%9A%84%E5%91%BD%E4%BB%A4-toc\" style=\"margin-left:40px\">5.2 \u5728Ubuntu\u4e0b\u94fe\u63a5\u7684\u547d\u4ee4<\/p>\n<p id=\"5.3%20%E5%8F%AF%E6%89%A7%E8%A1%8C%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6hello%E7%9A%84%E6%A0%BC%E5%BC%8F-toc\" style=\"margin-left:40px\">5.3 \u53ef\u6267\u884c\u76ee\u6807\u6587\u4ef6hello\u7684\u683c\u5f0f<\/p>\n<p id=\"%C2%A0%C2%A0%20%C2%A05.3.1%20ELF%E5%A4%B4%E4%BF%A1%E6%81%AF-toc\" style=\"margin-left:80px\">\u00a0\u00a0 \u00a05.3.1 ELF\u5934\u4fe1\u606f<\/p>\n<p id=\"%C2%A0%C2%A0%C2%A0%205.3.2%E8%8A%82%E5%A4%B4-toc\" style=\"margin-left:80px\">\u00a0\u00a0\u00a0 5.3.2\u8282\u5934<\/p>\n<p id=\"%C2%A0%C2%A0%C2%A0%205.3.3%E7%A8%8B%E5%BA%8F%E5%A4%B4-toc\" style=\"margin-left:80px\">\u00a0\u00a0\u00a0 5.3.3\u7a0b\u5e8f\u5934<\/p>\n<p id=\"%C2%A0%C2%A0%C2%A0%205.3.4%E7%AC%A6%E5%8F%B7%E8%A1%A8-toc\" style=\"margin-left:80px\">\u00a0\u00a0\u00a0 5.3.4\u7b26\u53f7\u8868<\/p>\n<p id=\"%C2%A0%C2%A0%C2%A0%205.3.5%E9%87%8D%E5%AE%9A%E4%BD%8D%E8%8A%82-toc\" style=\"margin-left:80px\">\u00a0\u00a0\u00a0 5.3.5\u91cd\u5b9a\u4f4d\u8282<\/p>\n<p id=\"5.4%20hello%E7%9A%84%E8%99%9A%E6%8B%9F%E5%9C%B0%E5%9D%80%E7%A9%BA%E9%97%B4-toc\" style=\"margin-left:40px\">5.4 hello\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4<\/p>\n<p id=\"5.5%20%E9%93%BE%E6%8E%A5%E7%9A%84%E9%87%8D%E5%AE%9A%E4%BD%8D%E8%BF%87%E7%A8%8B%E5%88%86%E6%9E%90-toc\" style=\"margin-left:40px\">5.5 \u94fe\u63a5\u7684\u91cd\u5b9a\u4f4d\u8fc7\u7a0b\u5206\u6790<\/p>\n<p id=\"5.6%20hello%E7%9A%84%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B-toc\" style=\"margin-left:40px\">5.6 hello\u7684\u6267\u884c\u6d41\u7a0b<\/p>\n<p id=\"5.7%20Hello%E7%9A%84%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%88%86%E6%9E%90-toc\" style=\"margin-left:40px\">5.7 Hello\u7684\u52a8\u6001\u94fe\u63a5\u5206\u6790<\/p>\n<p id=\"5.8%20%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93-toc\" style=\"margin-left:40px\">5.8 \u672c\u7ae0\u5c0f\u7ed3<\/p>\n<p id=\"%E7%AC%AC6%E7%AB%A0%20hello%E8%BF%9B%E7%A8%8B%E7%AE%A1%E7%90%86-toc\" style=\"margin-left:0px\">\u7b2c6\u7ae0 hello\u8fdb\u7a0b\u7ba1\u7406<\/p>\n<p id=\"6.1%20%E8%BF%9B%E7%A8%8B%E7%9A%84%E6%A6%82%E5%BF%B5%E4%B8%8E%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:40px\">6.1 \u8fdb\u7a0b\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528<\/p>\n<p id=\"6.1.1%20%E8%BF%9B%E7%A8%8B%E7%9A%84%E6%A6%82%E5%BF%B5-toc\" style=\"margin-left:80px\">6.1.1 \u8fdb\u7a0b\u7684\u6982\u5ff5<\/p>\n<p id=\"6.1.2%20%E8%BF%9B%E7%A8%8B%E7%9A%84%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:80px\">6.1.2 \u8fdb\u7a0b\u7684\u4f5c\u7528<\/p>\n<p id=\"6.2%20%E7%AE%80%E8%BF%B0%E5%A3%B3Shell-bash%E7%9A%84%E4%BD%9C%E7%94%A8%E4%B8%8E%E5%A4%84%E7%90%86%E6%B5%81%E7%A8%8B-toc\" style=\"margin-left:40px\">6.2 \u7b80\u8ff0\u58f3Shell-bash\u7684\u4f5c\u7528\u4e0e\u5904\u7406\u6d41\u7a0b<\/p>\n<p id=\"6.3%20Hello%E7%9A%84fork%E8%BF%9B%E7%A8%8B%E5%88%9B%E5%BB%BA%E8%BF%87%E7%A8%8B-toc\" style=\"margin-left:40px\">6.3 Hello\u7684fork\u8fdb\u7a0b\u521b\u5efa\u8fc7\u7a0b<\/p>\n<p id=\"6.4%20Hello%E7%9A%84execve%E8%BF%87%E7%A8%8B-toc\" style=\"margin-left:40px\">6.4 Hello\u7684execve\u8fc7\u7a0b<\/p>\n<p id=\"6.5%20Hello%E7%9A%84%E8%BF%9B%E7%A8%8B%E6%89%A7%E8%A1%8C-toc\" style=\"margin-left:40px\">6.5 Hello\u7684\u8fdb\u7a0b\u6267\u884c<\/p>\n<p id=\"6.6%20hello%E7%9A%84%E5%BC%82%E5%B8%B8%E4%B8%8E%E4%BF%A1%E5%8F%B7%E5%A4%84%E7%90%86-toc\" style=\"margin-left:40px\">6.6 hello\u7684\u5f02\u5e38\u4e0e\u4fe1\u53f7\u5904\u7406<\/p>\n<p id=\"6.6.1%20%E5%BC%82%E5%B8%B8%E7%9A%84%E7%B1%BB%E5%9E%8B-toc\" style=\"margin-left:80px\">6.6.1 \u5f02\u5e38\u7684\u7c7b\u578b<\/p>\n<p id=\"6.6.2%20%E5%BC%82%E5%B8%B8%E7%9A%84%E5%A4%84%E7%90%86%E6%96%B9%E5%BC%8F-toc\" style=\"margin-left:80px\">6.6.2 \u5f02\u5e38\u7684\u5904\u7406\u65b9\u5f0f<\/p>\n<p id=\"-toc\" style=\"margin-left:40px\">\n<p id=\"6.7%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93-toc\" style=\"margin-left:40px\">6.7\u672c\u7ae0\u5c0f\u7ed3<\/p>\n<p id=\"%E7%AC%AC7%E7%AB%A0%20hello%E7%9A%84%E5%AD%98%E5%82%A8%E7%AE%A1%E7%90%86-toc\" style=\"margin-left:40px\">\u7b2c7\u7ae0 hello\u7684\u5b58\u50a8\u7ba1\u7406<\/p>\n<p id=\"7.1%20hello%E7%9A%84%E5%AD%98%E5%82%A8%E5%99%A8%E5%9C%B0%E5%9D%80%E7%A9%BA%E9%97%B4-toc\" style=\"margin-left:40px\">7.1 hello\u7684\u5b58\u50a8\u5668\u5730\u5740\u7a7a\u95f4<\/p>\n<p id=\"7.2%20Intel%E9%80%BB%E8%BE%91%E5%9C%B0%E5%9D%80%E5%88%B0%E7%BA%BF%E6%80%A7%E5%9C%B0%E5%9D%80%E7%9A%84%E5%8F%98%E6%8D%A2-%E6%AE%B5%E5%BC%8F%E7%AE%A1%E7%90%86-toc\" style=\"margin-left:40px\">7.2 Intel\u903b\u8f91\u5730\u5740\u5230\u7ebf\u6027\u5730\u5740\u7684\u53d8\u6362-\u6bb5\u5f0f\u7ba1\u7406<\/p>\n<p id=\"%C2%A0%C2%A0%C2%A0%207.2.1%E6%AE%B5%E6%8F%8F%E8%BF%B0%E4%B8%8E%E6%AE%B5%E9%80%89%E6%8B%A9%E7%AC%A6-toc\" style=\"margin-left:80px\">\u00a0\u00a0\u00a0 7.2.1\u6bb5\u63cf\u8ff0\u4e0e\u6bb5\u9009\u62e9\u7b26<\/p>\n<p id=\"%C2%A0%C2%A0%207.2.2%E9%80%BB%E8%BE%91%E5%9C%B0%E5%9D%80%E5%88%B0%E7%BA%BF%E6%80%A7%E5%9C%B0%E5%9D%80%E7%9A%84%E8%BD%AC%E6%8D%A2%E8%BF%87%E7%A8%8B-toc\" style=\"margin-left:80px\">\u00a0\u00a0 7.2.2\u903b\u8f91\u5730\u5740\u5230\u7ebf\u6027\u5730\u5740\u7684\u8f6c\u6362\u8fc7\u7a0b<\/p>\n<p id=\"7.2.3%E6%AE%B5%E5%AF%84%E5%AD%98%E5%99%A8%E4%B8%8E%E6%8F%8F%E8%BF%B0%E7%AC%A6%E7%BC%93%E5%AD%98-toc\" style=\"margin-left:80px\">7.2.3\u6bb5\u5bc4\u5b58\u5668\u4e0e\u63cf\u8ff0\u7b26\u7f13\u5b58<\/p>\n<p id=\"7.3%20Hello%E7%9A%84%E7%BA%BF%E6%80%A7%E5%9C%B0%E5%9D%80%E5%88%B0%E7%89%A9%E7%90%86%E5%9C%B0%E5%9D%80%E7%9A%84%E5%8F%98%E6%8D%A2-%E9%A1%B5%E5%BC%8F%E7%AE%A1%E7%90%86-toc\" style=\"margin-left:40px\">7.3 Hello\u7684\u7ebf\u6027\u5730\u5740\u5230\u7269\u7406\u5730\u5740\u7684\u53d8\u6362-\u9875\u5f0f\u7ba1\u7406<\/p>\n<p id=\"7.3.1%E8%99%9A%E6%8B%9F%E5%86%85%E5%AD%98%E7%9A%84%E7%BB%84%E7%BB%87%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:80px\">7.3.1\u865a\u62df\u5185\u5b58\u7684\u7ec4\u7ec7\u7ed3\u6784<\/p>\n<p id=\"7.3.2%E9%A1%B5%E8%A1%A8%E4%B8%8E%E5%9C%B0%E5%9D%80%E6%98%A0%E5%B0%84-toc\" style=\"margin-left:80px\">7.3.2\u9875\u8868\u4e0e\u5730\u5740\u6620\u5c04<\/p>\n<p id=\"7.3.2%E7%BC%BA%E9%A1%B5%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86-toc\" style=\"margin-left:80px\">7.3.2\u7f3a\u9875\u5f02\u5e38\u5904\u7406<\/p>\n<p id=\"-toc\" style=\"margin-left:40px\">\n<p id=\"7.4%20TLB%E4%B8%8E%E5%9B%9B%E7%BA%A7%E9%A1%B5%E8%A1%A8%E6%94%AF%E6%8C%81%E4%B8%8B%E7%9A%84VA%E5%88%B0PA%E7%9A%84%E5%8F%98%E6%8D%A2-toc\" style=\"margin-left:40px\">7.4 TLB\u4e0e\u56db\u7ea7\u9875\u8868\u652f\u6301\u4e0b\u7684VA\u5230PA\u7684\u53d8\u6362<\/p>\n<p id=\"7.5%20%E4%B8%89%E7%BA%A7Cache%E6%94%AF%E6%8C%81%E4%B8%8B%E7%9A%84%E7%89%A9%E7%90%86%E5%86%85%E5%AD%98%E8%AE%BF%E9%97%AE-toc\" style=\"margin-left:40px\">7.5 \u4e09\u7ea7Cache\u652f\u6301\u4e0b\u7684\u7269\u7406\u5185\u5b58\u8bbf\u95ee<\/p>\n<p id=\"7.6%20hello%E8%BF%9B%E7%A8%8Bfork%E6%97%B6%E7%9A%84%E5%86%85%E5%AD%98%E6%98%A0%E5%B0%84-toc\" style=\"margin-left:40px\">7.6 hello\u8fdb\u7a0bfork\u65f6\u7684\u5185\u5b58\u6620\u5c04<\/p>\n<p id=\"7.6.1%20fork()%E6%97%B6%E7%9A%84%E5%86%85%E5%AD%98%E6%98%A0%E5%B0%84-toc\" style=\"margin-left:80px\">7.6.1 fork()\u65f6\u7684\u5185\u5b58\u6620\u5c04<\/p>\n<p id=\"7.6.2%20%E5%86%99%E6%97%B6%E5%A4%8D%E5%88%B6%EF%BC%88COW%EF%BC%89%E5%85%B7%E4%BD%93%E8%BF%87%E7%A8%8B-toc\" style=\"margin-left:80px\">7.6.2 \u5199\u65f6\u590d\u5236&#xff08;COW&#xff09;\u5177\u4f53\u8fc7\u7a0b<\/p>\n<p id=\"7.7%20hello%E8%BF%9B%E7%A8%8Bexecve%E6%97%B6%E7%9A%84%E5%86%85%E5%AD%98%E6%98%A0%E5%B0%84-toc\" style=\"margin-left:40px\">7.7 hello\u8fdb\u7a0bexecve\u65f6\u7684\u5185\u5b58\u6620\u5c04<\/p>\n<p id=\"7.8%20%E7%BC%BA%E9%A1%B5%E6%95%85%E9%9A%9C%E4%B8%8E%E7%BC%BA%E9%A1%B5%E4%B8%AD%E6%96%AD%E5%A4%84%E7%90%86-toc\" style=\"margin-left:40px\">7.8 \u7f3a\u9875\u6545\u969c\u4e0e\u7f3a\u9875\u4e2d\u65ad\u5904\u7406<\/p>\n<p id=\"7.9%E5%8A%A8%E6%80%81%E5%AD%98%E5%82%A8%E5%88%86%E9%85%8D%E7%AE%A1%E7%90%86-toc\" style=\"margin-left:40px\">7.9\u52a8\u6001\u5b58\u50a8\u5206\u914d\u7ba1\u7406<\/p>\n<p id=\"7.10%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93-toc\" style=\"margin-left:40px\">7.10\u672c\u7ae0\u5c0f\u7ed3<\/p>\n<p id=\"%E7%AC%AC8%E7%AB%A0%20hello%E7%9A%84IO%E7%AE%A1%E7%90%86-toc\" style=\"margin-left:0px\">\u7b2c8\u7ae0 hello\u7684IO\u7ba1\u7406<\/p>\n<p id=\"8.1%20Linux%E7%9A%84IO%E8%AE%BE%E5%A4%87%E7%AE%A1%E7%90%86%E6%96%B9%E6%B3%95-toc\" style=\"margin-left:40px\">8.1 Linux\u7684IO\u8bbe\u5907\u7ba1\u7406\u65b9\u6cd5<\/p>\n<p id=\"8.2%20%E7%AE%80%E8%BF%B0Unix%20IO%E6%8E%A5%E5%8F%A3%E5%8F%8A%E5%85%B6%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:40px\">8.2 \u7b80\u8ff0Unix IO\u63a5\u53e3\u53ca\u5176\u51fd\u6570<\/p>\n<p id=\"8.3%20printf%E7%9A%84%E5%AE%9E%E7%8E%B0%E5%88%86%E6%9E%90-toc\" style=\"margin-left:40px\">8.3 printf\u7684\u5b9e\u73b0\u5206\u6790<\/p>\n<p id=\"-toc\" style=\"margin-left:40px\">\n<p id=\"8.4%20getchar%E7%9A%84%E5%AE%9E%E7%8E%B0%E5%88%86%E6%9E%90-toc\" style=\"margin-left:40px\">8.4 getchar\u7684\u5b9e\u73b0\u5206\u6790<\/p>\n<p id=\"8.5%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93-toc\" style=\"margin-left:40px\">8.5\u672c\u7ae0\u5c0f\u7ed3<\/p>\n<p id=\"%E7%BB%93%E8%AE%BA-toc\" style=\"margin-left:0px\">\u7ed3\u8bba<\/p>\n<p id=\"%E9%99%84%E4%BB%B6-toc\" style=\"margin-left:0px\">\u9644\u4ef6<\/p>\n<p id=\"%E5%8F%82%E8%80%83%E6%96%87%E7%8C%AE-toc\" style=\"margin-left:0px\">\u53c2\u8003\u6587\u732e<\/p>\n<hr id=\"hr-toc\" \/>\n<\/p>\n<h2 id=\"%E7%AC%AC1%E7%AB%A0%20%E6%A6%82%E8%BF%B0\" style=\"margin-left:0;margin-right:0;text-align:center\">\u7b2c1\u7ae0 \u6982\u8ff0<\/h2>\n<h3 id=\"1.1%20Hello%E7%AE%80%E4%BB%8B\" style=\"margin-left:0;margin-right:0;text-align:justify\">1.1 Hello\u7b80\u4ecb<\/h3>\n<h4 id=\"1.1.1%20P2P\" style=\"margin-left:0;margin-right:0;text-align:justify\">1.1.1 P2P<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">P2P&#xff0c;\u5373\u201c\u4ece\u7a0b\u5e8f\u5230\u8fdb\u7a0b\u201d&#xff08;From Program to Process&#xff09;&#xff0c;\u6307\u7684\u5c31\u662f\u5c06\u4eba\u53ef\u8bfb\u7684\u6e90\u7a0b\u5e8f\u8f6c\u53d8\u4e3a\u64cd\u4f5c\u7cfb\u7edf\u53ef\u8c03\u5ea6\u6267\u884c\u7684\u8fdb\u7a0b\u7684\u5168\u8fc7\u7a0b\u3002\u4ee5hello\u4e3a\u4f8b&#xff0c;\u5176\u751f\u547d\u5468\u671f\u59cb\u4e8e\u4e00\u4efd\u7528 C \u8bed\u8a00\u7f16\u5199\u3001\u6613\u4e8e\u7406\u89e3\u7684\u6e90\u4ee3\u7801\u6587\u4ef6 hello.c&#xff0c;\u968f\u540e\u7531 GCC \u7f16\u8bd1\u9a71\u52a8\u7a0b\u5e8f\u63a5\u7ba1&#xff0c;\u5c06\u5176\u7ffb\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6 hello\u3002\u6574\u4e2a\u7ffb\u8bd1\u8fc7\u7a0b\u5206\u4e3a\u56db\u4e2a\u9636\u6bb5&#xff1a;\u9996\u5148&#xff0c;\u9884\u5904\u7406\u5668 cpp \u5bf9 hello.c \u8fdb\u884c\u9884\u5904\u7406&#xff0c;\u751f\u6210\u542b\u6709\u5c55\u5f00\u5b8f\u548c\u5934\u6587\u4ef6\u5185\u5bb9\u7684\u4e2d\u95f4\u6587\u4ef6 hello.i&#xff1b;\u63a5\u7740&#xff0c;\u7f16\u8bd1\u5668\u524d\u7aef cc1 \u5c06 hello.i \u8f6c\u6362\u4e3a\u6c47\u7f16\u4ee3\u7801 hello.s&#xff1b;\u7136\u540e&#xff0c;\u6c47\u7f16\u5668 as \u5c06 hello.s \u6c47\u7f16\u6210\u76ee\u6807\u6587\u4ef6 hello.o&#xff1b;\u6700\u540e&#xff0c;\u94fe\u63a5\u5668 ld \u5c06 hello.o \u4e0e\u6240\u5f15\u7528\u7684\u6807\u51c6\u5e93\u6216\u5176\u4ed6\u5e93\u6587\u4ef6\u8fdb\u884c\u94fe\u63a5&#xff0c;\u8f93\u51fa\u6700\u7ec8\u7684\u53ef\u6267\u884c\u6587\u4ef6 hello\u3002\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\u540e&#xff0c;\u5f53\u5728 Shell \u4e2d\u8fd0\u884c\u65f6&#xff0c;\u7cfb\u7edf\u9996\u5148\u901a\u8fc7 fork() \u521b\u5efa\u4e00\u4e2a\u5b50\u8fdb\u7a0b&#xff0c;\u518d\u901a\u8fc7 execve() \u5c06 hello \u7684\u4ee3\u7801\u548c\u6570\u636e\u52a0\u8f7d\u5230\u8be5\u5b50\u8fdb\u7a0b\u7684\u5185\u5b58\u7a7a\u95f4\u4e2d&#xff0c;\u81f3\u6b64&#xff0c;\u4e00\u4e2a\u65b0\u7684\u8fdb\u7a0b\u4fbf\u8bde\u751f\u4e86\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"149\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825d50345.png\" width=\"461\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe1 \u7f16\u8bd1\u7cfb\u7edf<\/p>\n<h4 id=\"1.1.2%20020\" style=\"margin-left:0;margin-right:0;text-align:justify\">1.1.2 020<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">020&#xff0c;\u5373From Zero-0 to Zero-0&#xff0c;\u63cf\u8ff0\u4e86\u7a0b\u5e8f\u4ece\u52a0\u8f7d\u5230\u7ed3\u675f\u7684\u5b8c\u6574\u751f\u547d\u5468\u671f\u3002\u5f53\u7528\u6237\u5728\u7ec8\u7aef\u8f93\u5165 .\/hello \u65f6&#xff0c;Shell \u5148\u8c03\u7528 fork() \u521b\u5efa\u5b50\u8fdb\u7a0b&#xff0c;\u5b50\u8fdb\u7a0b\u518d\u901a\u8fc7 execve() \u5c06\u53ef\u6267\u884c\u6587\u4ef6\u6620\u5165\u8fdb\u7a0b\u865a\u62df\u5730\u5740\u7a7a\u95f4&#xff0c;\u5e76\u501f\u52a9 mmap \u5c06\u5fc5\u8981\u7684\u4ee3\u7801\u548c\u6570\u636e\u4ece\u5b58\u50a8\u4ecb\u8d28\u8f7d\u5165\u7269\u7406\u5185\u5b58&#xff0c;\u968f\u540e\u4ea4\u7531 CPU \u8c03\u5ea6\u6267\u884c\u3002CPU \u4e3a\u8be5\u8fdb\u7a0b\u5206\u914d\u65f6\u95f4\u7247&#xff0c;\u4f9d\u6b21\u8fdb\u884c\u53d6\u6307\u3001\u8bd1\u7801\u3001\u6267\u884c\u7b49\u6d41\u6c34\u7ebf\u64cd\u4f5c&#xff1b;\u5728\u6b64\u8fc7\u7a0b\u4e2d&#xff0c;\u5185\u5b58\u7ba1\u7406\u5355\u5143\u901a\u8fc7\u591a\u7ea7\u9875\u8868\u548c TLB \u8fdb\u884c\u5730\u5740\u8f6c\u6362&#xff0c;\u5e76\u5229\u7528 L1\u3001L2\u3001L3 \u7f13\u5b58\u52a0\u901f\u6570\u636e\u8bbf\u95ee&#xff1b;I\/O \u5b50\u7cfb\u7edf\u5219\u6839\u636e\u7a0b\u5e8f\u6307\u4ee4\u5b8c\u6210\u5916\u90e8\u8bbe\u5907\u7684\u8bfb\u5199\u8f93\u51fa\u3002\u5f85\u7a0b\u5e8f\u6267\u884c\u7ed3\u675f\u540e&#xff0c;\u5b50\u8fdb\u7a0b\u5c06\u8fdb\u5165\u50f5\u5c38\u72b6\u6001&#xff0c;\u7531\u7236\u8fdb\u7a0b\u8c03\u7528 wait() \u6216\u7c7b\u4f3c\u673a\u5236\u56de\u6536&#xff0c;\u5185\u6838\u968f\u5373\u91ca\u653e\u5176\u865a\u62df\u5185\u5b58\u7a7a\u95f4\u5e76\u6e05\u9664\u76f8\u5173\u8fdb\u7a0b\u8868\u9879&#xff0c;\u4ece\u800c\u5b8c\u6210\u7a0b\u5e8f\u4ecezero\u5230zero\u7684\u8fc7\u7a0b\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h3 id=\"1.2%20%E7%8E%AF%E5%A2%83%E4%B8%8E%E5%B7%A5%E5%85%B7\" style=\"margin-left:0;margin-right:0;text-align:justify\">1.2 \u73af\u5883\u4e0e\u5de5\u5177<\/h3>\n<h4 id=\"1.2.1%20%E7%A1%AC%E4%BB%B6%E7%8E%AF%E5%A2%83\" style=\"margin-left:0;margin-right:0;text-align:justify\">1.2.1 \u786c\u4ef6\u73af\u5883<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">X64 CPU&#xff1b;2GHz&#xff1b;2G RAM&#xff1b;256GHD Disk \u4ee5\u4e0a<\/p>\n<h4 id=\"1.2.2%20%E8%BD%AF%E4%BB%B6%E7%8E%AF%E5%A2%83\" style=\"margin-left:0;margin-right:0;text-align:justify\">1.2.2 \u8f6f\u4ef6\u73af\u5883<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">Windows7\/10 64\u4f4d\u4ee5\u4e0a&#xff1b;VirtualBox\/Vmware 11\u4ee5\u4e0a&#xff1b;Ubuntu 16.04 LTS 64\u4f4d\/\u4f18\u9e92\u9e9f 64\u4f4d \u4ee5\u4e0a<\/p>\n<h4 id=\"1.2.3%20%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7\" style=\"margin-left:0;margin-right:0;text-align:justify\">1.2.3 \u5f00\u53d1\u5de5\u5177<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">Visual Studio 2010 64\u4f4d\u4ee5\u4e0a&#xff1b;CodeBlocks 64\u4f4d&#xff1b;vi\/vim\/gedit&#043;gcc&#xff1b;edb<\/p>\n<h3 id=\"1.3%20%E4%B8%AD%E9%97%B4%E7%BB%93%E6%9E%9C\" style=\"margin-left:0;margin-right:0;text-align:justify\">1.3 \u4e2d\u95f4\u7ed3\u679c<\/h3>\n<table border=\"1\" cellspacing=\"0\" style=\"width:438.25pt\">\n<tbody>\n<tr>\n<td style=\"border-color:black;height:18.05pt;vertical-align:top;width:219.1pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u6587\u4ef6\u7684\u540d\u5b57<\/p>\n<\/td>\n<td style=\"border-color:black;height:18.05pt;vertical-align:top;width:219.15pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u6587\u4ef6\u7684\u4f5c\u7528<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border-color:black;height:17.35pt;width:219.1pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">hello.c<\/p>\n<\/td>\n<td style=\"height:17.35pt;width:219.15pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u6e90\u7a0b\u5e8f\u6587\u4ef6<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border-color:black;height:36.15pt;width:219.1pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">hello.i<\/p>\n<\/td>\n<td style=\"height:36.15pt;width:219.15pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">hello.c\u901a\u8fc7\u9884\u5904\u7406\u5668cpp\u9884\u5904\u7406\u540e\u7684\u6587\u672c\u6587\u4ef6<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border-color:black;height:17.35pt;width:219.1pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">hello.s<\/p>\n<\/td>\n<td style=\"height:17.35pt;width:219.15pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">hello.i\u901a\u8fc7\u7f16\u8bd1\u5668ccl\u7f16\u8bd1\u540e\u7684\u6c47\u7f16\u7a0b\u5e8f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border-color:black;height:18.05pt;width:219.1pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">hello.o<\/p>\n<\/td>\n<td style=\"height:18.05pt;width:219.15pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">hello.s\u901a\u8fc7\u6c47\u7f16\u5668as\u6c47\u7f16\u540e\u7684\u6587\u4ef6<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border-color:black;height:36.15pt;width:219.1pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">hello<\/p>\n<\/td>\n<td style=\"height:36.15pt;width:219.15pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">hello.o\u901a\u8fc7\u94fe\u63a5\u5668ld\u94fe\u63a5\u540e\u7684\u53ef\u6267\u884c\u6587\u4ef6<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h3 id=\"1.4%20%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93\" style=\"margin-left:0;margin-right:0;text-align:justify\">1.4 \u672c\u7ae0\u5c0f\u7ed3<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u672c\u7ae0\u9996\u5148\u4ee5 \u201cHello\u201d \u7a0b\u5e8f\u4e3a\u4f8b&#xff0c;\u9610\u8ff0\u4e86\u4ece\u53ef\u8bfb\u7684 C \u8bed\u8a00\u6e90\u4ee3\u7801\u5230\u64cd\u4f5c\u7cfb\u7edf\u53ef\u8c03\u5ea6\u8fdb\u7a0b\u7684\u5168\u6d41\u7a0b&#xff1a;\u6e90\u6587\u4ef6\u901a\u8fc7 cpp\u3001cc1\u3001as \u548c ld \u56db\u4e2a\u9636\u6bb5\u4f9d\u6b21\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6&#xff0c;\u518d\u7531 Shell \u8c03\u7528 fork() \u4e0e execve() \u5728\u5185\u5b58\u4e2d\u521b\u5efa\u5e76\u8fd0\u884c\u8fdb\u7a0b&#xff1b;\u968f\u540e\u901a\u8fc7 mmap\u3001\u591a\u7ea7\u9875\u8868\u3001TLB \u53ca L1\/L2\/L3 \u7f13\u5b58\u8fdb\u884c\u5185\u5b58\u7ba1\u7406&#xff0c;\u5e76\u7531 CPU \u6309\u65f6\u95f4\u7247\u6267\u884c\u53d6\u6307\u2014\u8bd1\u7801\u2014\u6267\u884c\u6d41\u6c34\u7ebf&#xff0c;I\/O \u5b50\u7cfb\u7edf\u8d1f\u8d23\u5916\u8bbe\u8bfb\u5199&#xff1b;\u8fdb\u7a0b\u7ed3\u675f\u540e\u7531\u7236\u8fdb\u7a0b wait() \u56de\u6536&#xff0c;\u5185\u6838\u91ca\u653e\u8d44\u6e90&#xff0c;\u5b8c\u6210\u4ece\u201c\u96f6\u201d\u5230\u201c\u96f6\u201d\u7684\u95ed\u73af\u3002\u6b64\u5916&#xff0c;\u672c\u7ae0\u8fd8\u4ecb\u7ecd\u4e86\u786c\u4ef6&#xff08;X64\u30012 GHz\u30012 GB RAM\u3001256 GB \u786c\u76d8\u53ca\u4ee5\u4e0a&#xff09;\u3001\u8f6f\u4ef6&#xff08;Windows 7\/10 64 \u4f4d\u6216 Ubuntu 16.04 LTS\/\u4f18\u9e92\u9e9f&#xff09;\u3001\u865a\u62df\u5316&#xff08;VirtualBox\/VMware 11&#043;&#xff09;\u4e0e\u5f00\u53d1\u5de5\u5177&#xff08;Visual Studio\u3001Code::Blocks\u3001GCC\u3001edb \u7b49&#xff09;\u73af\u5883&#xff0c;\u5e76\u5217\u51fa\u4e86 hello.c\u2192hello.i\u2192hello.s\u2192hello.o\u2192hello \u53ca\u76f8\u5173 ELF \u548c\u53cd\u6c47\u7f16\u6587\u4ef6\u7684\u4e2d\u95f4\u4ea7\u7269\u53ca\u5176\u4f5c\u7528\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<\/p>\n<h2 id=\"%E7%AC%AC2%E7%AB%A0%20%E9%A2%84%E5%A4%84%E7%90%86\" style=\"margin-left:0;margin-right:0;text-align:center\">\u7b2c2\u7ae0 \u9884\u5904\u7406<\/h2>\n<h3 id=\"2.1%20%E9%A2%84%E5%A4%84%E7%90%86%E7%9A%84%E6%A6%82%E5%BF%B5%E4%B8%8E%E4%BD%9C%E7%94%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">2.1 \u9884\u5904\u7406\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528<\/h3>\n<h4 id=\"2.1.1%20%E9%A2%84%E5%A4%84%E7%90%86%E7%9A%84%E6%A6%82%E5%BF%B5\" style=\"margin-left:0;margin-right:0;text-align:justify\">2.1.1 \u9884\u5904\u7406\u7684\u6982\u5ff5<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u9884\u5904\u7406\u662f\u7531\u9884\u5904\u7406\u5668&#xff08;cpp&#xff09;\u8d1f\u8d23\u5b8c\u6210\u7684\u6e90\u4ee3\u7801\u51c6\u5907\u9636\u6bb5&#xff0c;\u5b83\u4f1a\u8bc6\u522b\u4ee5 # \u5f00\u5934\u7684\u6307\u4ee4\u5e76\u5bf9 .c \u6587\u4ef6\u8fdb\u884c\u6539\u5199\u4e0e\u6269\u5c55\u3002\u4e3b\u8981\u64cd\u4f5c\u5305\u62ec&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5b8f\u5b9a\u4e49\u66ff\u6362&#xff08;define&#xff09;&#xff1a;\u5c06\u4ee3\u7801\u4e2d\u51fa\u73b0\u7684\u5b8f\u6807\u8bc6\u7b26\u66ff\u6362\u4e3a\u5bf9\u5e94\u7684\u6587\u672c\u6216\u8868\u8fbe\u5f0f&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6587\u4ef6\u5305\u542b&#xff08;include&#xff09;&#xff1a;\u5c06\u88ab\u5305\u542b\u6587\u4ef6\u7684\u5185\u5bb9\u5d4c\u5165\u5230\u5f53\u524d\u6e90\u6587\u4ef6\u4e2d&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6761\u4ef6\u7f16\u8bd1&#xff08;ifdef\u3001if \u7b49&#xff09;&#xff1a;\u6839\u636e\u6761\u4ef6\u51b3\u5b9a\u662f\u5426\u4fdd\u7559\u6216\u4e22\u5f03\u7279\u5b9a\u4ee3\u7801\u6bb5\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5b8c\u6210\u9884\u5904\u7406\u540e&#xff0c;\u751f\u6210\u7684\u4e2d\u95f4\u7ed3\u679c\u4ecd\u662f\u4e00\u4efd\u5408\u6cd5\u7684 C \u8bed\u8a00\u6e90\u4ee3\u7801&#xff0c;\u901a\u5e38\u4ee5 .i \u4e3a\u6269\u5c55\u540d&#xff0c;\u4f9b\u540e\u7eed\u7f16\u8bd1\u9636\u6bb5\u4f7f\u7528\u3002<\/p>\n<h4 id=\"2.1.2%20%E9%A2%84%E5%A4%84%E7%90%86%E7%9A%84%E4%BD%9C%E7%94%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">2.1.2 \u9884\u5904\u7406\u7684\u4f5c\u7528<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u9884\u5904\u7406\u9636\u6bb5\u901a\u8fc7\u89e3\u6790\u4ee5 # \u5f00\u5934\u7684\u6307\u4ee4&#xff0c;\u5bf9\u6e90\u4ee3\u7801\u8fdb\u884c\u521d\u6b65\u8f6c\u6362\u548c\u7ec4\u7ec7&#xff0c;\u4e3a\u540e\u7eed\u7684\u7f16\u8bd1\u3001\u6c47\u7f16\u548c\u94fe\u63a5\u6253\u4e0b\u57fa\u7840\u3002\u5176\u4e3b\u8981\u529f\u80fd\u5305\u62ec\u4ee5\u4e0b\u4e09\u65b9\u9762&#xff1a;<\/p>\n<li style=\"text-align:justify\">\u5b8f\u5b9a\u4e49\u66ff\u6362 \u5141\u8bb8\u7a0b\u5e8f\u5458\u4f7f\u7528 define \u5b9a\u4e49\u7b26\u53f7\u5e38\u91cf\u6216\u4ee3\u7801\u7247\u65ad&#xff0c;\u5728\u9884\u5904\u7406\u65f6\u5c06\u8fd9\u4e9b\u5b8f\u6807\u8bc6\u7b26\u66ff\u6362\u4e3a\u5bf9\u5e94\u7684\u6587\u672c\u6216\u8868\u8fbe\u5f0f&#xff0c;\u4ece\u800c\u51cf\u5c11\u91cd\u590d\u4ee3\u7801\u3001\u63d0\u5347\u53ef\u7ef4\u62a4\u6027\u548c\u53ef\u8bfb\u6027\u3002<\/li>\n<li style=\"text-align:justify\">\u6587\u4ef6\u5305\u542b \u901a\u8fc7 include \u6307\u4ee4\u5c06\u5934\u6587\u4ef6\u6216\u5176\u4ed6\u6e90\u6587\u4ef6\u7684\u5185\u5bb9\u63d2\u5165\u5230\u5f53\u524d\u6587\u4ef6\u4e2d&#xff0c;\u8fd9\u4e0d\u4ec5\u80fd\u96c6\u4e2d\u7ba1\u7406\u51fd\u6570\u58f0\u660e\u3001\u6570\u636e\u7ed3\u6784\u548c\u5b8f\u5b9a\u4e49&#xff0c;\u8fd8\u80fd\u5b9e\u73b0\u6a21\u5757\u5316\u7f16\u7a0b\u3002 <\/li>\n<li style=\"text-align:justify\">\u6761\u4ef6\u7f16\u8bd1 \u4f7f\u7528 if\u3001ifdef\u3001ifndef \u7b49\u6307\u4ee4&#xff0c;\u6839\u636e\u7f16\u8bd1\u73af\u5883\u6216\u81ea\u5b9a\u4e49\u5b8f\u7684\u5b9a\u4e49\u60c5\u51b5\u9009\u62e9\u6027\u5730\u4fdd\u7559\u6216\u5254\u9664\u4ee3\u7801\u7247\u6bb5&#xff0c;\u4ee5\u4fbf\u540c\u4e00\u4efd\u6e90\u4ee3\u7801\u5728\u4e0d\u540c\u5e73\u53f0\u3001\u4e0d\u540c\u914d\u7f6e\u4e0b\u80fd\u591f\u7075\u6d3b\u7f16\u8bd1\u3002<\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u603b\u4f53\u800c\u8a00&#xff0c;\u9884\u5904\u7406\u4f7f\u5f97\u7a0b\u5e8f\u5728\u903b\u8f91\u4e0a\u66f4\u7b80\u6d01\u3001\u6709\u6761\u7406&#xff0c;\u5e76\u589e\u5f3a\u4e86\u53ef\u79fb\u690d\u6027\u4e0e\u8c03\u8bd5\u6548\u7387&#xff0c;\u662f\u73b0\u4ee3 C\/C&#043;&#043; \u5f00\u53d1\u6d41\u7a0b\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u7b2c\u4e00\u6b65\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h3 id=\"2.2%E5%9C%A8Ubuntu%E4%B8%8B%E9%A2%84%E5%A4%84%E7%90%86%E7%9A%84%E5%91%BD%E4%BB%A4\" style=\"margin-left:0;margin-right:0;text-align:justify\">2.2\u5728Ubuntu\u4e0b\u9884\u5904\u7406\u7684\u547d\u4ee4<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"113\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825d5cb55.png\" width=\"520\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe2 cpp hello.c &gt;hello.i<\/p>\n<h3 id=\"2.3%20Hello%E7%9A%84%E9%A2%84%E5%A4%84%E7%90%86%E7%BB%93%E6%9E%9C%E8%A7%A3%E6%9E%90\" style=\"margin-left:0;margin-right:0;text-align:justify\">2.3 Hello\u7684\u9884\u5904\u7406\u7ed3\u679c\u89e3\u6790<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u9884\u5904\u7406\u9636\u6bb5\u751f\u6210\u4e2d\u95f4\u6587\u4ef6 hello.i&#xff0c;\u6b64\u65f6\u9884\u5904\u7406\u5668\u5df2\u6839\u636e\u6e90\u4ee3\u7801\u4e2d #include \u6307\u4ee4\u5728\u8fdb\u5165 main \u51fd\u6570\u4e4b\u524d&#xff0c;\u6309\u987a\u5e8f\u8bfb\u53d6\u5e76\u5c55\u5f00\u4e86\u7cfb\u7edf\u5934\u6587\u4ef6 stdio.h\u3001unistd.h \u548c stdlib.h \u7684\u5168\u90e8\u5185\u5bb9&#xff1b;\u82e5\u8fd9\u4e9b\u5934\u6587\u4ef6\u5185\u90e8\u4ecd\u5305\u542b\u4ee5 # \u5f00\u5934\u7684\u6307\u4ee4&#xff0c;\u9884\u5904\u7406\u5668\u540c\u6837\u4f1a\u7ee7\u7eed\u5904\u7406\u76f4\u81f3\u5c55\u5f00\u5b8c\u6bd5\u3002\u6240\u6709\u6ce8\u91ca\u88ab\u5254\u9664&#xff0c;\u5b8f\u5b9a\u4e49\u5728\u9884\u5904\u7406\u5b8c\u6210\u540e\u4e0d\u518d\u4fdd\u7559&#xff0c;\u6700\u7ec8\u5f97\u5230\u4e00\u4efd\u6807\u51c6\u4e14\u5b8c\u6574\u7684 C \u6e90\u4ee3\u7801&#xff0c;\u53ef\u76f4\u63a5\u4f9b\u540e\u7eed\u7684\u7f16\u8bd1\u9636\u6bb5\u4f7f\u7528\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"290\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825d69ae5.png\" width=\"545\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe3 \u9884\u5904\u7406\u7ed3\u679c<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h3 id=\"2.4%20%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93\" style=\"margin-left:0;margin-right:0;text-align:justify\">2.4 \u672c\u7ae0\u5c0f\u7ed3<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u672c\u8282\u9996\u5148\u9610\u8ff0\u4e86\u9884\u5904\u7406\u5728 C \u8bed\u8a00\u7f16\u8bd1\u6d41\u7a0b\u4e2d\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528&#xff0c;\u7136\u540e\u5728 Ubuntu \u73af\u5883\u4e0b\u4f7f\u7528gcc -E \u547d\u4ee4\u5bf9 hello.c \u8fdb\u884c\u4e86\u9884\u5904\u7406&#xff0c;\u751f\u6210\u4e86\u4e2d\u95f4\u6587\u4ef6 hello.i\u3002\u901a\u8fc7\u67e5\u770b hello.i&#xff0c;\u53ef\u4ee5\u76f4\u89c2\u5730\u770b\u5230&#xff1a;\u6240\u6709\u4ee5 include \u5f15\u5165\u7684\u7cfb\u7edf\u5934\u6587\u4ef6&#xff08;\u5982 stdio.h\u3001unistd.h\u3001stdlib.h&#xff09;\u5df2\u6309\u987a\u5e8f\u5c55\u5f00\u63d2\u5165&#xff1b;\u6ce8\u91ca\u88ab\u6e05\u9664&#xff1b;\u5b8f\u5b9a\u4e49\u4ea6\u5df2\u5c55\u5f00\u4e14\u5728\u7ed3\u679c\u6587\u4ef6\u4e2d\u4e0d\u518d\u4fdd\u7559&#xff0c;\u4ece\u800c\u5f62\u6210\u4e00\u4efd\u53ef\u76f4\u63a5\u9001\u5165\u7f16\u8bd1\u5668\u7684\u6807\u51c6 C \u6e90\u4ee3\u7801&#xff0c;\u6709\u52a9\u4e8e\u66f4\u6df1\u5165\u5730\u7406\u89e3\u9884\u5904\u7406\u9636\u6bb5\u7684\u6838\u5fc3\u529f\u80fd\u4e0e\u5de5\u4f5c\u539f\u7406\u3002<\/p>\n<\/p>\n<h2 id=\"%E7%AC%AC3%E7%AB%A0%20%E7%BC%96%E8%AF%91\" style=\"margin-left:0;margin-right:0;text-align:center\">\u7b2c3\u7ae0 \u7f16\u8bd1<\/h2>\n<h3 id=\"3.1%20%E7%BC%96%E8%AF%91%E7%9A%84%E6%A6%82%E5%BF%B5%E4%B8%8E%E4%BD%9C%E7%94%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.1 \u7f16\u8bd1\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528<\/h3>\n<h4 id=\"3.1.1%20%E7%BC%96%E8%AF%91%E7%9A%84%E6%A6%82%E5%BF%B5\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.1.1 \u7f16\u8bd1\u7684\u6982\u5ff5<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7f16\u8bd1\u9636\u6bb5\u7531\u7f16\u8bd1\u5668&#xff08;cc1&#xff09;\u8d1f\u8d23&#xff0c;\u5c06\u9884\u5904\u7406\u540e\u751f\u6210\u7684 hello.i \u6587\u4ef6\u4f5c\u4e3a\u8f93\u5165&#xff0c;\u7ffb\u8bd1\u6210\u76ee\u6807\u5e73\u53f0\u5bf9\u5e94\u7684\u6c47\u7f16\u4ee3\u7801&#xff0c;\u5e76\u8f93\u51fa\u4e3a hello.s\u3002\u8be5\u8fc7\u7a0b\u9996\u5148\u8fdb\u884c\u8bcd\u6cd5\u548c\u8bed\u6cd5\u5206\u6790&#xff0c;\u9a8c\u8bc1\u4ee3\u7801\u7684\u6b63\u786e\u6027&#xff1b;\u63a5\u7740\u5728\u8bed\u4e49\u5206\u6790\u4e2d\u68c0\u67e5\u7c7b\u578b\u4e0e\u4f5c\u7528\u57df&#xff1b;\u968f\u540e\u751f\u6210\u4e2d\u95f4\u8868\u793a&#xff08;IR&#xff09;&#xff0c;\u5e76\u5bf9\u5176\u8fdb\u884c\u5fc5\u8981\u7684\u4f18\u5316&#xff1b;\u6700\u540e\u5c06\u7ecf\u8fc7\u4f18\u5316\u7684 IR \u8f6c\u6362\u4e3a\u5177\u4f53\u7684\u6c47\u7f16\u6307\u4ee4&#xff0c;\u5f62\u6210\u5305\u542b main \u51fd\u6570\u5b9a\u4e49\u53ca\u6240\u6709\u51fd\u6570\u5b9e\u73b0\u7684\u6c47\u7f16\u7a0b\u5e8f\u3002\u6574\u4e2a\u6d41\u7a0b\u4e0d\u4ec5\u5b8c\u6210\u4e86\u4ece\u9ad8\u7ea7\u8bed\u8a00\u5230\u6c47\u7f16\u8bed\u8a00\u7684\u8f6c\u6362&#xff0c;\u8fd8\u4e3a\u540e\u7eed\u7684\u6c47\u7f16\u548c\u94fe\u63a5\u9636\u6bb5\u63d0\u4f9b\u4e86\u53ef\u8bfb\u4e14\u9ad8\u6548\u7684\u6c47\u7f16\u6e90\u7801\u3002<\/p>\n<h4 id=\"3.1.2%20%E7%BC%96%E8%AF%91%E7%9A%84%E4%BD%9C%E7%94%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.1.2 \u7f16\u8bd1\u7684\u4f5c\u7528<\/h4>\n<p style=\"margin-left:21pt;margin-right:0;text-align:justify\">\u7f16\u8bd1\u9636\u6bb5\u7531\u7f16\u8bd1\u5668&#xff08;cc1&#xff09;\u63a5\u7ba1&#xff0c;\u5c06\u9884\u5904\u7406\u751f\u6210\u7684 .i \u6587\u4ef6\u7ffb\u8bd1\u6210\u76ee\u6807\u5e73\u53f0\u5bf9\u5e94\u7684\u6c47\u7f16\u4ee3\u7801&#xff08;.s \u6587\u4ef6&#xff09;&#xff0c;\u5176\u4e3b\u8981\u529f\u80fd\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762&#xff1a;<\/p>\n<li style=\"text-align:justify\">\u8bed\u6cd5\u4e0e\u8bed\u4e49\u68c0\u67e5 \u7f16\u8bd1\u5668\u9996\u5148\u5bf9\u6e90\u4ee3\u7801\u8fdb\u884c\u8bcd\u6cd5\u5206\u6790\u548c\u8bed\u6cd5\u5206\u6790&#xff0c;\u786e\u4fdd\u7a0b\u5e8f\u7b26\u5408\u8bed\u8a00\u89c4\u8303&#xff1b;\u968f\u540e\u8fdb\u884c\u8bed\u4e49\u5206\u6790&#xff0c;\u68c0\u67e5\u7c7b\u578b\u4e00\u81f4\u6027\u4e0e\u4f5c\u7528\u57df\u6b63\u786e\u6027&#xff0c;\u4e3a\u751f\u6210\u6b63\u786e\u7684\u4f4e\u7ea7\u4ee3\u7801\u5960\u5b9a\u57fa\u7840\u3002<\/li>\n<li style=\"text-align:justify\">\u4e2d\u95f4\u8868\u793a\u4e0e\u4f18\u5316 \u5728\u5206\u6790\u901a\u8fc7\u540e&#xff0c;\u4ee3\u7801\u4f1a\u88ab\u8f6c\u6362\u4e3a\u4e2d\u95f4\u8868\u793a&#xff08;IR&#xff09;&#xff0c;\u7f16\u8bd1\u5668\u53ef\u5728\u6b64\u9636\u6bb5\u5bf9\u5176\u8fdb\u884c\u591a\u79cd\u4f18\u5316&#xff0c;\u5982\u5e38\u91cf\u6298\u53e0\u3001\u5faa\u73af\u5c55\u5f00\u7b49&#xff0c;\u4ee5\u63d0\u5347\u6700\u7ec8\u751f\u6210\u4ee3\u7801\u7684\u6267\u884c\u6548\u7387\u3002<\/li>\n<li style=\"text-align:justify\">\u6c47\u7f16\u751f\u6210 \u4f18\u5316\u540e\u7684 IR \u4f1a\u88ab\u6620\u5c04\u4e3a\u5177\u4f53\u7684\u6c47\u7f16\u6307\u4ee4&#xff0c;\u5f62\u6210\u5305\u542b main \u51fd\u6570\u5b9a\u4e49\u53ca\u6240\u6709\u7a0b\u5e8f\u903b\u8f91\u7684\u6c47\u7f16\u7a0b\u5e8f&#xff0c;\u4fbf\u4e8e\u540e\u7eed\u7684\u6c47\u7f16\u548c\u94fe\u63a5\u73af\u8282\u5904\u7406\u3002<\/li>\n<p style=\"margin-left:21pt;margin-right:0;text-align:justify\">\u603b\u4f53\u800c\u8a00&#xff0c;\u7f16\u8bd1\u4e0d\u4ec5\u5b8c\u6210\u4e86\u5c06\u4eba\u7c7b\u53ef\u8bfb\u7684\u9ad8\u7ea7\u8bed\u8a00\u8f6c\u6362\u4e3a\u673a\u5668\u53ef\u6267\u884c\u7684\u4f4e\u7ea7\u6307\u4ee4&#xff0c;\u8fd8\u901a\u8fc7\u4e00\u7cfb\u5217\u68c0\u67e5\u548c\u4f18\u5316\u624b\u6bb5&#xff0c;\u4fdd\u8bc1\u4e86\u751f\u6210\u4ee3\u7801\u7684\u6b63\u786e\u6027\u4e0e\u9ad8\u6548\u6027&#xff0c;\u540c\u65f6\u4e3a\u540e\u7eed\u6c47\u7f16\u548c\u94fe\u63a5\u9636\u6bb5\u63d0\u4f9b\u4e86\u7ed3\u6784\u6e05\u6670\u3001\u6027\u80fd\u4f18\u826f\u7684\u6c47\u7f16\u6e90\u6587\u4ef6\u3002 \u00a0<\/p>\n<h3 id=\"3.2%20%E5%9C%A8Ubuntu%E4%B8%8B%E7%BC%96%E8%AF%91%E7%9A%84%E5%91%BD%E4%BB%A4\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.2 \u5728Ubuntu\u4e0b\u7f16\u8bd1\u7684\u547d\u4ee4<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728Ubuntu\u4e2d&#xff0c;hello.i\u6587\u4ef6\u8fdb\u884c\u7f16\u8bd1\u7684\u64cd\u4f5c\u547d\u4ee4\u4e3a&#xff1a;gcc -S hello.i -o hello.s<\/p>\n<p style=\"margin-left:21pt;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"128\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825d796f7.png\" width=\"508\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe4 \u7f16\u8bd1\u547d\u4ee4<\/p>\n<h3 id=\"3.3%20Hello%E7%9A%84%E7%BC%96%E8%AF%91%E7%BB%93%E6%9E%9C%E8%A7%A3%E6%9E%90\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3 Hello\u7684\u7f16\u8bd1\u7ed3\u679c\u89e3\u6790<\/h3>\n<h4 id=\"3.3.1%20%E6%95%B0%E6%8D%AE\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.1 \u6570\u636e<\/h4>\n<h4 id=\"3.3.1.1%20%E5%B8%B8%E9%87%8F\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.1.1 \u5e38\u91cf<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5b57\u7b26\u4e32\u5e38\u91cf&#xff0c;\u4f4d\u4e8e\u53ea\u8bfb\u6570\u636e\u6bb5&#xff08;.rodata)<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"114\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825d855e9.png\" width=\"528\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe5 \u5b57\u7b26\u4e32\u5e38\u91cf<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h4 id=\"3.3.1.2%20%E5%8F%98%E9%87%8F(%E5%85%A8%E5%B1%80%2F%E5%B1%80%E9%83%A8%2F%E9%9D%99%E6%80%81)\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.1.2 \u53d8\u91cf(\u5168\u5c40\/\u5c40\u90e8\/\u9759\u6001)<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">1&#xff09;\u65e0\u5168\u5c40\u4e0e\u9759\u6001\u53d8\u91cf\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5168\u5c40\u53d8\u91cf\u5728\u6c47\u7f16\u8bed\u8a00\u4e2d\u901a\u5e38\u5b58\u50a8\u5728\u6570\u636e\u6bb5&#xff08;Data Segment&#xff09;\u4e2d\u3002\u6570\u636e\u6bb5\u662f\u7a0b\u5e8f\u7684\u4e00\u90e8\u5206&#xff0c;\u7528\u4e8e\u5b58\u50a8\u5168\u5c40\u53d8\u91cf\u548c\u9759\u6001\u53d8\u91cf\u3002\u5168\u5c40\u53d8\u91cf\u5728\u7a0b\u5e8f\u7684\u6574\u4e2a\u751f\u547d\u5468\u671f\u5185\u90fd\u5b58\u5728&#xff0c;\u800c\u4e0d\u4ec5\u4ec5\u5728\u7279\u5b9a\u7684\u51fd\u6570\u8c03\u7528\u671f\u95f4\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;\u5168\u5c40\u53d8\u91cf\u7684\u4fee\u6539\u548c\u8bbf\u95ee\u662f\u5728\u6574\u4e2a\u7a0b\u5e8f\u6267\u884c\u671f\u95f4\u6709\u6548\u7684&#xff0c;\u56e0\u6b64\u5b83\u53ef\u4ee5\u88ab\u7a0b\u5e8f\u4e2d\u7684\u4efb\u4f55\u51fd\u6570\u8bbf\u95ee\u548c\u4fee\u6539\u3002\u8fd9\u4f7f\u5f97\u5168\u5c40\u53d8\u91cf\u5728\u9700\u8981\u5728\u4e0d\u540c\u90e8\u5206\u4e4b\u95f4\u5171\u4eab\u6570\u636e\u65f6\u975e\u5e38\u6709\u7528\u3002\u7531\u4e8ehello.c\u4e2d\u4e0d\u542b\u5168\u5c40\u53d8\u91cf&#xff0c;\u8fd9\u91cc\u5c31\u4e0d\u8be6\u7ec6\u63cf\u8ff0\u4e86\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">2&#xff09;\u5c40\u90e8\u53d8\u91cf<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5c40\u90e8\u53d8\u91cf\u901a\u5e38\u4f7f\u7528\u6808\u6307\u9488&#xff08;%rsp&#xff09;\u548c\u57fa\u5740\u6307\u9488&#xff08;%rbp&#xff09;\u8fdb\u884c\u8bbf\u95ee\u3002\u5728\u6b64\u6bb5\u6c47\u7f16\u4ee3\u7801\u4e2d&#xff0c;\u53ef\u4ee5\u770b\u5230\u901a\u8fc7\u57fa\u5740\u6307\u9488&#xff08;%rbp&#xff09;\u6765\u8bbf\u95ee\u5c40\u90e8\u53d8\u91cf\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">-20(%rbp)&#xff1a;\u8be5\u504f\u79fb\u91cf\u7528\u4e8e\u5728\u6808\u5e27\u4e2d\u5b58\u653e\u6765\u81ea main \u51fd\u6570\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570 argc \u7684\u503c&#xff0c;\u5bf9\u5e94\u6c47\u7f16\u6307\u4ee4 movl %edi, -20(%rbp)\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">-32(%rbp)&#xff1a;\u8be5\u504f\u79fb\u91cf\u7528\u4e8e\u5728\u6808\u5e27\u4e2d\u5b58\u653e\u6765\u81ea main \u51fd\u6570\u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570 argv \u7684\u5730\u5740&#xff0c;\u5bf9\u5e94\u6c47\u7f16\u6307\u4ee4 movq %rsi, -32(%rbp)\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">-4(%rbp)&#xff1a;\u5b58\u50a8\u5c40\u90e8\u53d8\u91cfi&#xff0c;\u7528\u4e8e\u5728\u5faa\u73af\u4e2d\u8ba1\u6570\u3002\u6c47\u7f16\u4ee3\u7801\u4e2d\u901a\u8fc7movl $0, -4(%rbp)\u521d\u59cb\u5316\u8be5\u53d8\u91cf\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u901a\u8fc7addl $1, -4(%rbp)\u9012\u589e\u8be5\u53d8\u91cf\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"244\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825d8ffad.png\" width=\"240\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825d9aab6.png\" width=\"250\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe6 \u5c40\u90e8\u53d8\u91cf<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u51fd\u6570\u8c03\u7528\u7ed3\u675f\u540e\u7684\u6e05\u7406&#xff1a; \u5728\u51fd\u6570\u8fd4\u56de\u524d&#xff0c;\u6808\u5e27\u4f1a\u88ab\u6e05\u7406\u3002\u8fd9\u5305\u62ec\u5c06\u6808\u6307\u9488\u6062\u590d\u5230\u539f\u59cb\u7684\u4f4d\u7f6e&#xff0c;\u4ee5\u53ca\u5f39\u51fa\u4fdd\u5b58\u7684\u5e27\u6307\u9488\u503c\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u786e\u4fdd\u4e86\u6808\u7684\u4e00\u81f4\u6027\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"156\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825da25e6.png\" width=\"299\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe7\u51fd\u6570\u8c03\u7528\u7ed3\u675f\u540e\u7684\u6e05\u7406<\/p>\n<h4 id=\"3.3.1.2%20%E8%A1%A8%E8%BE%BE%E5%BC%8F\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.1.2 \u8868\u8fbe\u5f0f<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">.c\u4e2d\u7684\u8868\u8fbe\u5f0fargc!&#061;5,\u5728.s\u6587\u4ef6\u4e2d\u8868\u793a\u4e3a&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"170\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825dac5cd.jpg\" width=\"329\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe8 .c\u4e2d\u7684\u8868\u8fbe\u5f0fargc!&#061;5\u5728.s\u6587\u4ef6<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">i&lt;10\u8868\u793a\u4e3a&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"163\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825dba14e.jpg\" width=\"269\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe9 .c\u4e2d\u7684\u8868\u8fbe\u5f0fi&#xff1c;10\u5728.s\u6587\u4ef6<\/p>\n<h4 id=\"3.3.1.4%20%E7%B1%BB%E5%9E%8B\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.1.4 \u7c7b\u578b<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7c7b\u578b\u7684\u89e3\u6790\u901a\u8fc7\u6c47\u7f16\u6307\u4ee4\u7684\u9009\u62e9\u548c\u64cd\u4f5c\u6570\u7684\u5927\u5c0f\u6765\u4f53\u73b0\u3002\u6839\u636e\u53d8\u91cf\u7c7b\u578b\u4f7f\u7528\u4e0d\u540c\u7684mov\u6307\u4ee4\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"62\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825dc4236.png\" width=\"205\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe10 \u4e0d\u540c\u7684mov\u6307\u4ee4<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h4 id=\"3.3.1.5%20%E5%AE%8F\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.1.5 \u5b8f<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5982\u679c\u6e90\u4ee3\u7801\u4e2d\u6ca1\u6709\u5b9a\u4e49\u4efb\u4f55\u5b8f&#xff0c;\u90a3\u4e48\u5728\u9884\u5904\u7406\u9636\u6bb5\u5c31\u4e0d\u4f1a\u8fdb\u884c\u5b8f\u66ff\u6362\u64cd\u4f5c\u3002\u5373\u4f7f\u5b58\u5728\u5b8f\u5b9a\u4e49&#xff0c;\u6240\u6709\u7684\u5b8f\u66ff\u6362\u4e5f\u90fd\u5728\u9884\u5904\u7406\u9636\u6bb5\u5b8c\u6210&#xff0c;\u7f16\u8bd1\u5668\u4e0d\u4f1a\u518d\u8fdb\u884c\u5b8f\u76f8\u5173\u7684\u5904\u7406\u3002\u8fd9\u610f\u5473\u7740\u5b8f\u7684\u4f5c\u7528\u4ec5\u9650\u4e8e\u9884\u5904\u7406\u9636\u6bb5&#xff0c;\u7f16\u8bd1\u5668\u5904\u7406\u7684\u662f\u5df2\u7ecf\u5c55\u5f00\u4e86\u5b8f\u7684\u4ee3\u7801\u3002<\/p>\n<h4 id=\"3.3.2%20%E8%B5%8B%E5%80%BC\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.2 \u8d4b\u503c<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5c06\u53c2\u6570\u7684\u503c\u4ece\u5bc4\u5b58\u5668&#xff08;%edi \u548c %rsi&#xff09;\u79fb\u52a8\u5230\u4e86\u76f8\u5bf9\u4e8e\u57fa\u5740\u6307\u9488 %rbp \u7684\u6808\u4e0a\u7684\u4f4d\u7f6e&#xff08;\u504f\u79fb -20 \u548c -32 \u5904&#xff09;\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"62\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825dca89a.png\" width=\"205\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe11 \u8d4b\u503c\u4e0d\u540c\u7684\u53c2\u6570<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8d4b\u503c0\u7ed9i<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825dd0ee9.png\" width=\"250\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe12 \u8d4b\u503c0\u7ed9i<\/p>\n<h4 id=\"3.3.3%20%E7%AE%97%E6%9C%AF%E6%93%8D%E4%BD%9C\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.3 \u7b97\u672f\u64cd\u4f5c<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">i&#043;&#043;\u7531addl $1,-4(%rbp)\u5b8c\u6210.<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"113\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825dd9252.png\" width=\"319\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe13 i&#043;&#043;\u7684\u5b8c\u6210\u65b9\u5f0f<\/p>\n<h4 id=\"3.3.4%20%E5%85%B3%E7%B3%BB%E6%93%8D%E4%BD%9C\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.4 \u5173\u7cfb\u64cd\u4f5c<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u7f16\u8bd1\u5668\u9996\u5148\u8bc6\u522b\u5173\u7cfb\u8868\u8fbe\u5f0f\u4e2d\u7684\u5173\u7cfb\u8fd0\u7b97\u7b26\u548c\u64cd\u4f5c\u6570&#xff0c;\u5e76\u6784\u5efa\u8bed\u6cd5\u5206\u6790\u6811\u6216\u62bd\u8c61\u8bed\u6cd5\u6811&#xff08;AST&#xff09;\u6765\u8868\u793a\u8868\u8fbe\u5f0f\u7684\u7ed3\u6784\u3002\u68c0\u67e5\u64cd\u4f5c\u6570\u7684\u7c7b\u578b&#xff0c;\u786e\u4fdd\u5b83\u4eec\u4e0e\u5173\u7cfb\u8fd0\u7b97\u7b26\u517c\u5bb9\u3002\u6839\u636eC\u8bed\u8a00\u7684\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u548c\u7ed3\u5408\u6027\u89c4\u5219&#xff0c;\u7f16\u8bd1\u5668\u786e\u5b9a\u5173\u7cfb\u8868\u8fbe\u5f0f\u7684\u6c42\u503c\u987a\u5e8f\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">i&lt;10: \u5e76\u6ca1\u6709\u752810&#xff0c;\u800c\u662f\u75289\u5728\u6bd4\u8f83&#xff0c;\u82e5\u7b49\u4e8e9\u540e\u5219\u8df3\u8f6c\u5230\u4e0b\u90e8\u5206\u4ee3\u7801\u4e0d\u518d\u5faa\u73af\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"106\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825de5df6.png\" width=\"321\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe14 i&lt;10\u7684\u5b8c\u6210\u65b9\u5f0f<\/p>\n<h4 id=\"3.3.5%20%E6%95%B0%E7%BB%84%2F%E6%8C%87%E9%92%88%2F%E7%BB%93%E6%9E%84%E6%93%8D%E4%BD%9C\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.5 \u6570\u7ec4\/\u6307\u9488\/\u7ed3\u6784\u64cd\u4f5c<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 main\u63a5\u6536\u7684argv[]\u6570\u7ec4\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"259\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825df1115.png\" width=\"254\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe14 main\u63a5\u6536\u7684argv[]\u6570\u7ec4<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h4 id=\"3.3.6%20%E6%8E%A7%E5%88%B6%E8%BD%AC%E7%A7%BB\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.6 \u63a7\u5236\u8f6c\u79fb<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7f16\u8bd1\u5668\u9996\u5148\u8bc6\u522b\u63a7\u5236\u8f6c\u79fb\u8bed\u53e5\u7684\u8bed\u6cd5\u7ed3\u6784&#xff0c;\u5982if\u3001else\u3001switch\u3001for\u3001while\u7b49&#xff0c;\u68c0\u67e5\u63a7\u5236\u8f6c\u79fb\u8bed\u53e5\u7684\u8bed\u4e49&#xff0c;\u786e\u4fdd\u6761\u4ef6\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u662f\u53ef\u6bd4\u8f83\u7684&#xff0c;\u5e76\u9a8c\u8bc1\u5faa\u73af\u53d8\u91cf\u7684\u521d\u59cb\u5316\u548c\u66f4\u65b0\u8868\u8fbe\u5f0f\u7b49\u3002\u5206\u6790\u63a7\u5236\u8f6c\u79fb\u8bed\u53e5\u7684\u63a7\u5236\u6d41\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7531\u4e8ehello\u7a0b\u5e8f\u53ea\u6d89\u53ca\u5230\u4e86if\u548cfor&#xff0c;\u4e0b\u9762\u6211\u4eec\u7740\u91cd\u5bf9\u8fd9\u4e24\u4e2a\u8bed\u6cd5\u7ed3\u6784\u8fdb\u884c\u5206\u6790&#xff1a;<\/p>\n<li style=\"text-align:justify\">if\u6761\u4ef6\u8bed\u53e5<\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">if(argc!&#061;4)&#xff0c;\u88ab\u7f16\u8bd1\u5668\u8f6c\u6362\u4e3a\u4e24\u884c\u6c47\u7f16\u8bed\u8a00&#xff0c;\u7528\u6307\u4ee4cmpl\u548cje\u6765\u5b8c\u6210\u5224\u5b9a\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"45\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005454-6847825e07ce2.png\" width=\"303\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe15 if(argc!&#061;4)<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<li style=\"text-align:justify\">for\u5faa\u73af\u8bed\u53e5<\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">for(i&#061;0;i&lt;8;i&#043;&#043;)&#xff0c;\u88ab\u7f16\u8bd1\u5668\u8f6c\u6362\u4e3a\u4e24\u90e8\u5206&#xff0c;\u5206\u522b\u662f\u5faa\u73af\u4f53L4\u548c\u5faa\u73af\u7ec8\u6b62\u6761\u4ef6L3.<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"363\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005454-6847825e110e1.png\" width=\"276\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"147\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005454-6847825e25510.png\" width=\"245\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe16 for(i&#061;0;i&lt;8;i&#043;&#043;)<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h4 id=\"3.3.7%E5%87%BD%E6%95%B0%E6%93%8D%E4%BD%9C\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.7\u51fd\u6570\u64cd\u4f5c<\/h4>\n<h4 id=\"3.3.7.1%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92(%E5%9C%B0%E5%9D%80%2F%E5%80%BC)\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.7.1\u53c2\u6570\u4f20\u9012(\u5730\u5740\/\u503c)<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728 C \u8bed\u8a00\u4e2d&#xff0c;\u51fd\u6570\u53c2\u6570\u7684\u4f20\u9012\u65b9\u5f0f\u4e3b\u8981\u6709\u4e24\u79cd&#xff1a;\u503c\u4f20\u9012\u548c\u5730\u5740\u4f20\u9012\u3002\u5728\u503c\u4f20\u9012\u4e2d&#xff0c;\u5b9e\u53c2\u7684\u503c\u88ab\u590d\u5236\u5230\u5f62\u53c2\u4e2d&#xff0c;\u51fd\u6570\u5185\u90e8\u5bf9\u5f62\u53c2\u7684\u4fee\u6539\u4e0d\u4f1a\u5f71\u54cd\u5b9e\u53c2\u3002\u800c\u5728\u5730\u5740\u4f20\u9012\u4e2d&#xff0c;\u5b9e\u53c2\u7684\u5730\u5740\u88ab\u4f20\u9012\u7ed9\u5f62\u53c2&#xff0c;\u51fd\u6570\u5185\u90e8\u901a\u8fc7\u8be5\u5730\u5740\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539\u5b9e\u53c2\u7684\u503c\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u8c03\u7528 main \u51fd\u6570\u65f6&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u5c06\u547d\u4ee4\u884c\u53c2\u6570\u7684\u4e2a\u6570&#xff08;argc&#xff09;\u548c\u53c2\u6570\u6570\u7ec4\u7684\u5730\u5740&#xff08;argv&#xff09;\u4f20\u9012\u7ed9\u7a0b\u5e8f\u3002\u5728 x86-64 \u67b6\u6784\u4e0b&#xff0c;\u6309\u7167\u8c03\u7528\u7ea6\u5b9a&#xff0c;\u524d\u51e0\u4e2a\u51fd\u6570\u53c2\u6570\u901a\u8fc7\u5bc4\u5b58\u5668\u4f20\u9012\u3002\u5177\u4f53\u6765\u8bf4&#xff0c;argc \u4f1a\u88ab\u4f20\u9012\u5230 %edi \u5bc4\u5b58\u5668&#xff0c;argv \u7684\u5730\u5740\u4f1a\u88ab\u4f20\u9012\u5230 %rsi \u5bc4\u5b58\u5668\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728 main \u51fd\u6570\u7684\u6c47\u7f16\u4ee3\u7801\u4e2d&#xff0c;\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u6307\u4ee4&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"113\" src=\"2025-06-101eivvvtjgvg.png\" width=\"290\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe17 \u53c2\u6570\u4f20\u9012<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fd9\u4e24\u6761\u6307\u4ee4\u5c06\u5bc4\u5b58\u5668\u4e2d\u7684\u503c\u4fdd\u5b58\u5230\u6808\u5e27\u4e2d&#xff0c;\u4ee5\u4fbf\u5728\u51fd\u6570\u5185\u90e8\u4f7f\u7528\u3002\u5176\u4e2d&#xff0c;-20(%rbp) \u7528\u4e8e\u5b58\u50a8 argc \u7684\u503c&#xff0c;-32(%rbp) \u7528\u4e8e\u5b58\u50a8 argv \u7684\u5730\u5740\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u56e0\u6b64&#xff0c;\u53c2\u6570\u7684\u4f20\u9012\u8fc7\u7a0b\u5982\u4e0b&#xff1a;\u64cd\u4f5c\u7cfb\u7edf\u5c06\u53c2\u6570\u4f20\u9012\u5230\u6307\u5b9a\u7684\u5bc4\u5b58\u5668\u4e2d&#xff0c;\u51fd\u6570\u5f00\u59cb\u6267\u884c\u65f6\u5c06\u8fd9\u4e9b\u5bc4\u5b58\u5668\u7684\u503c\u4fdd\u5b58\u5230\u6808\u5e27\u4e2d&#xff0c;\u4f9b\u51fd\u6570\u5185\u90e8\u4f7f\u7528\u3002\u8fd9\u79cd\u673a\u5236\u786e\u4fdd\u4e86\u51fd\u6570\u80fd\u591f\u6b63\u786e\u5730\u63a5\u6536\u5230\u5e76\u5904\u7406\u4f20\u9012\u7ed9\u5b83\u7684\u53c2\u6570\u3002<\/p>\n<h4 id=\"3.3.7.2%E5%87%BD%E6%95%B0%E8%B0%83%E7%94%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.7.2\u51fd\u6570\u8c03\u7528<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5bf9\u4e8e\u51fd\u6570\u8c03\u7528&#xff0c;\u7f16\u8bd1\u5668\u9700\u8981\u751f\u6210\u4ee3\u7801\u6765\u4f20\u9012\u53c2\u6570\u3001\u4fdd\u5b58\u8fd4\u56de\u5730\u5740\u4ee5\u53ca\u8df3\u8f6c\u5230\u51fd\u6570\u5165\u53e3\u70b9\u3002\u5b83\u8fd8\u9700\u8981\u5904\u7406\u51fd\u6570\u7684\u8fd4\u56de&#xff0c;\u5305\u62ec\u6062\u590d\u8c03\u7528\u70b9\u7684\u4e0a\u4e0b\u6587\u548c\u83b7\u53d6\u8fd4\u56de\u503c&#xff08;\u5982\u679c\u6709\u7684\u8bdd&#xff09;\u3002\u7f16\u8bd1\u5668\u5c06\u51fd\u6570\u5b9a\u4e49\u548c\u8c03\u7528\u8f6c\u6362\u4e3a\u673a\u5668\u4ee3\u7801\u3002\u901a\u8fc7call\u6307\u4ee4\u8c03\u7528&#xff0c;\u5982\u56fe&#xff0c;\u5206\u522b\u8c03\u7528\u4e86\u5934\u6587\u4ef6\u63d0\u4f9b\u7684printf, sleep, getchar\u51fd\u6570\u3002hello\u7a0b\u5e8f\u6d89\u53ca\u5230\u7684\u51fd\u6570\u5305\u62ecmain printf exit sleep getchar atoi\u7b49&#xff0c;\u5176\u4e2d\u7684\u53c2\u6570\u5305\u542b\u5982\u4e0b&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">main\u51fd\u6570\u5305\u62ecargc\u548cargv\u4e24\u4e2a\u53c2\u6570&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">printf\u51fd\u6570\u5305\u62ec\u5b57\u7b26\u4e32\u53c2\u6570&#034;\u7528\u6cd5: Hello \u5b66\u53f7 \u59d3\u540d \u79d2\u6570&#xff01;\\\\n&#034;&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">exit\u53c2\u6570\u4e3a0x1&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">sleep\u53c2\u6570\u4e3aatoi(argv[3])&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">atoi\u53c2\u6570\u4e3aargv[3]&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">getchar\u6ca1\u6709\u53c2\u6570&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"46\" src=\"2025-06-10v0fsvqg4km0.png\" width=\"224\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"67\" src=\"2025-06-10brrfcf5kfkk.png\" width=\"205\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"85\" src=\"2025-06-10bnsiobeh2rz.png\" width=\"236\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe18 \u51fd\u6570\u8c03\u7528<\/p>\n<h4 id=\"3.3.7.3%E5%87%BD%E6%95%B0%E8%BF%94%E5%9B%9E\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.3.7.3\u51fd\u6570\u8fd4\u56de<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">ret \u6307\u4ee4\u7528\u4e8e\u5c06\u7a0b\u5e8f\u7684\u63a7\u5236\u6743\u8fd4\u56de\u5230\u8c03\u7528\u8be5\u51fd\u6570\u7684\u4f4d\u7f6e&#xff0c;\u5e76\u4e14\u901a\u5e38\u5728\u51fd\u6570\u7684\u7ed3\u5c3e\u5904\u4f7f\u7528\u3002\u6307\u4ee4 .cfi_endproc \u8868\u793a\u8fd9\u662f\u4e00\u4e2a\u51fd\u6570\u7ed3\u675f\u7684\u6807\u8bb0&#xff0c;\u5b83\u7528\u4e8e\u901a\u77e5\u8c03\u8bd5\u5668\u548c\u5176\u4ed6\u5de5\u5177\u51fd\u6570\u7684\u7ed3\u675f\u4f4d\u7f6e\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"65\" src=\"2025-06-10dx1jnwefg4g.png\" width=\"261\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe19 \u51fd\u6570\u8fd4\u56de<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h3 id=\"3.4%20%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93\" style=\"margin-left:0;margin-right:0;text-align:justify\">3.4 \u672c\u7ae0\u5c0f\u7ed3<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u672c\u7ae0\u6df1\u5165\u63a2\u8ba8\u4e86 C \u8bed\u8a00\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\u7684\u7b2c\u4e8c\u9636\u6bb5\u2014\u2014\u7f16\u8bd1&#xff08;Compilation&#xff09;&#xff0c;\u5373\u5c06\u9884\u5904\u7406\u540e\u7684 C \u8bed\u8a00\u6e90\u6587\u4ef6&#xff08;\u5982 hello.i&#xff09;\u8f6c\u6362\u4e3a\u6c47\u7f16\u8bed\u8a00\u4ee3\u7801&#xff08;\u5982 hello.s&#xff09;\u7684\u8fc7\u7a0b\u3002\u901a\u8fc7\u5728 Ubuntu \u73af\u5883\u4e0b\u4f7f\u7528 gcc -S hello.i -o hello.s \u547d\u4ee4&#xff0c;\u751f\u6210\u4e86\u6c47\u7f16\u6587\u4ef6 hello.s&#xff0c;\u5e76\u5bf9\u5176\u5185\u5bb9\u8fdb\u884c\u4e86\u8be6\u7ec6\u5206\u6790\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u751f\u6210\u7684\u6c47\u7f16\u4ee3\u7801\u4e2d&#xff0c;\u5c55\u793a\u4e86\u53d8\u91cf\u7684\u58f0\u660e\u4e0e\u521d\u59cb\u5316\u3001\u8868\u8fbe\u5f0f\u7684\u8ba1\u7b97\u3001\u6761\u4ef6\u5224\u65ad\u3001\u51fd\u6570\u8c03\u7528\u4ee5\u53ca\u5faa\u73af\u63a7\u5236\u7b49\u5173\u952e\u7f16\u8bd1\u7ed3\u679c\u3002\u4f8b\u5982&#xff0c;movl $0, -4(%rbp) \u8868\u793a\u5c06\u6574\u6570 0 \u8d4b\u503c\u7ed9\u5c40\u90e8\u53d8\u91cf i&#xff0c;cmpl $9, -4(%rbp) \u7528\u4e8e\u6bd4\u8f83\u53d8\u91cf i \u4e0e\u5e38\u6570 9 \u7684\u5927\u5c0f&#xff0c;call printf&#064;PLT \u8868\u793a\u8c03\u7528\u6807\u51c6\u5e93\u51fd\u6570 printf\u3002\u8fd9\u4e9b\u6c47\u7f16\u6307\u4ee4\u4f53\u73b0\u4e86\u9ad8\u7ea7\u8bed\u8a00\u7ed3\u6784\u5728\u4f4e\u7ea7\u8bed\u8a00\u4e2d\u7684\u5177\u4f53\u5b9e\u73b0\u65b9\u5f0f\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u901a\u8fc7\u5bf9 hello.s \u6587\u4ef6\u7684\u5206\u6790&#xff0c;\u8fdb\u4e00\u6b65\u7406\u89e3\u4e86\u7f16\u8bd1\u5668\u5982\u4f55\u5c06\u9ad8\u7ea7\u8bed\u8a00\u7684\u8bed\u6cd5\u7ed3\u6784\u8f6c\u6362\u4e3a\u6c47\u7f16\u8bed\u8a00\u6307\u4ee4&#xff0c;\u4e3a\u540e\u7eed\u7684\u6c47\u7f16\u548c\u94fe\u63a5\u9636\u6bb5\u5960\u5b9a\u4e86\u57fa\u7840\u3002\u8fd9\u4e0d\u4ec5\u52a0\u6df1\u4e86\u5bf9\u7f16\u8bd1\u8fc7\u7a0b\u7684\u7406\u89e3&#xff0c;\u4e5f\u4e3a\u5b66\u4e60\u7a0b\u5e8f\u7684\u5e95\u5c42\u6267\u884c\u673a\u5236\u63d0\u4f9b\u4e86\u5b9e\u7528\u7684\u89c6\u89d2\u3002<\/p>\n<\/p>\n<h2 id=\"%E7%AC%AC4%E7%AB%A0%20%E6%B1%87%E7%BC%96\" style=\"margin-left:0;margin-right:0;text-align:center\">\u7b2c4\u7ae0 \u6c47\u7f16<\/h2>\n<h3 id=\"4.1%20%E6%B1%87%E7%BC%96%E7%9A%84%E6%A6%82%E5%BF%B5%E4%B8%8E%E4%BD%9C%E7%94%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">4.1 \u6c47\u7f16\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528<\/h3>\n<h4 id=\"4.1.1%20%E6%B1%87%E7%BC%96%E7%9A%84%E6%A6%82%E5%BF%B5\" style=\"margin-left:0;margin-right:0;text-align:justify\">4.1.1 \u6c47\u7f16\u7684\u6982\u5ff5<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6c47\u7f16\u662f\u5c06\u4eba\u53ef\u8bfb\u7684\u6c47\u7f16\u8bed\u8a00\u6587\u672c&#xff08;\u5982\u202fhello.s&#xff09;\u4ea4\u7531\u6c47\u7f16\u5668&#xff08;as&#xff09;\u5904\u7406&#xff0c;\u7ffb\u8bd1\u6210\u5bf9\u5e94\u7684\u673a\u5668\u6307\u4ee4&#xff0c;\u5e76\u5c06\u751f\u6210\u7684\u4e8c\u8fdb\u5236\u4ee3\u7801\u6309\u53ef\u91cd\u5b9a\u4f4d\u76ee\u6807\u6587\u4ef6\u683c\u5f0f\u6253\u5305&#xff0c;\u6700\u7ec8\u8f93\u51fa\u4e00\u4e2a\u4e0d\u53ef\u76f4\u63a5\u6253\u5f00\u7684\u76ee\u6807\u6587\u4ef6&#xff08;\u5982\u202fhello.o&#xff09;\u3002\u8fd9\u4e00\u8fc7\u7a0b\u5b8c\u6210\u4e86\u4ece\u6c47\u7f16\u8bed\u8a00\u5230\u673a\u5668\u8bed\u8a00\u7684\u8f6c\u6362&#xff0c;\u4f7f\u5f97\u4e0a\u5c42\u7f16\u5199\u7684\u6c47\u7f16\u7a0b\u5e8f\u80fd\u591f\u88ab\u94fe\u63a5\u5668\u8fdb\u4e00\u6b65\u5904\u7406&#xff0c;\u6700\u7ec8\u7ec4\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<h4 id=\"4.1.2%20%E6%B1%87%E7%BC%96%E7%9A%84%E4%BD%9C%E7%94%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">4.1.2 \u6c47\u7f16\u7684\u4f5c\u7528<\/h4>\n<li style=\"text-align:justify\">\u673a\u5668\u6307\u4ee4\u7ffb\u8bd1 \u5c06\u4e0a\u5c42\u7f16\u5199\u7684\u6c47\u7f16\u4ee3\u7801\u8f6c\u8bd1\u6210\u673a\u5668\u6307\u4ee4&#xff0c;\u4f7f\u5176\u5728\u94fe\u63a5\u5b8c\u6210\u540e\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u80fd\u591f\u88ab\u8ba1\u7b97\u673a\u786c\u4ef6\u76f4\u63a5\u8bc6\u522b\u5e76\u8fd0\u884c\u3002<\/li>\n<li style=\"text-align:justify\">\u5e95\u5c42\u63a7\u5236 \u6c47\u7f16\u8bed\u8a00\u53ef\u76f4\u63a5\u64cd\u4f5c\u8ba1\u7b97\u673a\u7684\u6838\u5fc3\u786c\u4ef6\u8d44\u6e90\u2014\u2014\u5305\u62ec CPU \u5bc4\u5b58\u5668\u3001\u5185\u5b58\u5730\u5740\u3001\u4ee5\u53ca\u5404\u7c7b\u8f93\u5165\/\u8f93\u51fa\u8bbe\u5907\u7b49\u2014\u2014\u56e0\u6b64\u6781\u5927\u5730\u589e\u5f3a\u4e86\u5bf9\u7cfb\u7edf\u5e95\u5c42\u884c\u4e3a\u7684\u638c\u63a7\u80fd\u529b&#xff0c;\u9002\u7528\u4e8e\u9a71\u52a8\u7a0b\u5e8f\u3001\u5b9e\u65f6\u7cfb\u7edf\u548c\u5d4c\u5165\u5f0f\u5f00\u53d1\u7b49\u573a\u666f\u3002<\/li>\n<li style=\"text-align:justify\">\u6027\u80fd\u4f18\u5316 \u7531\u4e8e\u65e0\u9700\u7ecf\u8fc7\u9ad8\u7ea7\u8bed\u8a00\u7684\u62bd\u8c61\u5c42&#xff0c;\u6c47\u7f16\u7a0b\u5e8f\u5458\u80fd\u591f\u7cbe\u7ec6\u5730\u8c03\u5ea6\u6307\u4ee4\u6267\u884c\u987a\u5e8f\u3001\u5229\u7528\u7279\u5b9a\u67b6\u6784\u6307\u4ee4\u96c6\u3001\u4ee5\u53ca\u5408\u7406\u5206\u914d\u5bc4\u5b58\u5668\u4f7f\u7528&#xff0c;\u4ece\u800c\u6700\u5927\u9650\u5ea6\u5730\u63d0\u5347\u4ee3\u7801\u6267\u884c\u6548\u7387&#xff0c;\u5b9e\u73b0\u5bf9\u5173\u952e\u8def\u5f84\u6216\u6027\u80fd\u74f6\u9888\u7684\u6df1\u5ea6\u4f18\u5316\u3002<\/li>\n<li style=\"text-align:justify\">\u6700\u9ad8\u6548\u7387\u7684\u786c\u4ef6\u6267\u884c \u673a\u5668\u8bed\u8a00\u662f\u8ba1\u7b97\u673a\u80fd\u591f\u76f4\u63a5\u6267\u884c\u7684\u6700\u4f4e\u7ea7\u8bed\u8a00&#xff0c;\u5176\u6307\u4ee4\u65e0\u9700\u89e3\u91ca\u6216\u7f16\u8bd1\u5f00\u9500&#xff0c;\u5b8c\u5168\u7531\u786c\u4ef6\u7535\u8def\u9a71\u52a8&#xff0c;\u56e0\u800c\u5728\u901f\u5ea6\u548c\u8d44\u6e90\u5229\u7528\u7387\u4e0a\u90fd\u8fbe\u5230\u6700\u4f18\u3002<\/li>\n<h3 id=\"4.2%20%E5%9C%A8Ubuntu%E4%B8%8B%E6%B1%87%E7%BC%96%E7%9A%84%E5%91%BD%E4%BB%A4\" style=\"margin-left:0;margin-right:0;text-align:justify\">4.2 \u5728Ubuntu\u4e0b\u6c47\u7f16\u7684\u547d\u4ee4<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728Ubuntu\u4e2d&#xff0c;hello.s\u6587\u4ef6\u8fdb\u884c\u7f16\u8bd1\u7684\u64cd\u4f5c\u547d\u4ee4\u4e3a&#xff1a;gcc hello.s -c -o hello.o\u6216\u8005as -o hello.o hello.s<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"140\" src=\"2025-06-10tjjlau5jig5.png\" width=\"582\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe20 gcc hello.s -c -o hello.o\u6307\u4ee4\u6267\u884c<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h3 id=\"\" style=\"margin-left:0;margin-right:0;text-align:justify\"><\/h3>\n<h3 id=\"4.3%20%E5%8F%AF%E9%87%8D%E5%AE%9A%E4%BD%8D%E7%9B%AE%E6%A0%87elf%E6%A0%BC%E5%BC%8F\" style=\"margin-left:0;margin-right:0;text-align:justify\">4.3 \u53ef\u91cd\u5b9a\u4f4d\u76ee\u6807elf\u683c\u5f0f<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">ELF \u662f Unix \u53ca\u7c7b Unix \u7cfb\u7edf\u4e2d\u6700\u5e38\u89c1\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4e0e\u53ef\u91cd\u5b9a\u4f4d\u76ee\u6807\u6587\u4ef6\u683c\u5f0f\u3002\u4e00\u4e2a\u6807\u51c6\u7684 ELF \u6587\u4ef6\u7531\u4e0b\u56fe\u5c55\u793a&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"365\" src=\"2025-06-10m5tw1wch4un.png\" width=\"516\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe21 \u53ef\u91cd\u5b9a\u4f4d\u76ee\u6807\u6587\u4ef6\u683c\u5f0f<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fd9\u79cd\u7ed3\u6784\u65e2\u652f\u6301\u6700\u7ec8\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6&#xff0c;\u4e5f\u4fbf\u4e8e\u94fe\u63a5\u5668\u5c06\u591a\u4e2a\u76ee\u6807\u6587\u4ef6\u548c\u5e93\u6587\u4ef6\u7ec4\u5408\u6210\u5b8c\u6574\u7a0b\u5e8f\u3002<\/p>\n<h4 id=\"%C2%A0%C2%A0%C2%A0%204.3.1%E6%96%87%E4%BB%B6%E5%A4%B4\" style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0 4.3.1\u6587\u4ef6\u5934<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u9996\u5148\u67e5\u770b\u6587\u4ef6\u5934(ELF Header)\u3002\u5176\u5305\u542b\u4e86\u63cf\u8ff0ELF\u6587\u4ef6\u6574\u4f53\u7ed3\u6784\u548c\u5c5e\u6027\u7684\u4fe1\u606f&#xff0c;\u5305\u62ecELF\u6807\u8bc6\u3001\u76ee\u6807\u4f53\u7cfb\u7ed3\u6784\u3001\u8282\u8868\u504f\u79fb\u3001\u7a0b\u5e8f\u5934\u8868\u504f\u79fb\u7b49\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u547d\u4ee4&#xff1a;readelf -h hello.o<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5f97\u5230hello.o\u7684ELF\u5934<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"473\" src=\"2025-06-10qelgbly4xvg.png\" width=\"505\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe22 hello.o\u7684ELF\u5934<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\n<h4 id=\"%C2%A0%C2%A0%C2%A0%204.3.2%E7%A8%8B%E5%BA%8F%E5%A4%B4%E8%A1%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0 4.3.2\u7a0b\u5e8f\u5934\u8868<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5bf9\u4e8e\u76ee\u6807\u6587\u4ef6&#xff0c;\u7a0b\u5e8f\u5934\u8868(Program Header Table)\u53ef\u80fd\u4e3a\u7a7a\u3002\u67e5\u8be2\u540e\u786e\u5b9e\u5982\u6b64\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u547d\u4ee4&#xff1a;readelf -l hello.o<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"69\" src=\"2025-06-10e4pigcheglg.png\" width=\"425\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe23 \u7a0b\u5e8f\u5934\u8868\u7684\u67e5\u8be2<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h4 id=\"%C2%A0%C2%A0%C2%A0%204.3.2%E8%8A%82%E8%A1%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0 4.3.2\u8282\u8868<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8282\u8868\u8bb0\u5f55\u4e86 ELF \u6587\u4ef6\u4e2d\u5404\u4e2a\u8282&#xff08;Section&#xff09;\u7684\u5173\u952e\u4fe1\u606f&#xff0c;\u5305\u62ec\u8282\u540d\u79f0\u3001\u8282\u7c7b\u578b\u3001\u5728\u6587\u4ef6\u4e2d\u7684\u504f\u79fb\u5730\u5740\u3001\u8282\u5927\u5c0f\u4ee5\u53ca\u5176\u4ed6\u5c5e\u6027\u7b49\u3002ELF \u6587\u4ef6\u4e2d\u7684\u4ee3\u7801\u548c\u6570\u636e\u90fd\u88ab\u7ec4\u7ec7\u5b58\u653e\u5728\u4e0d\u540c\u7684\u8282\u4e2d&#xff1a;\u4f8b\u5982&#xff0c;.text \u8282\u7528\u4e8e\u5b58\u653e\u53ef\u6267\u884c\u4ee3\u7801&#xff0c;.data \u8282\u7528\u4e8e\u5b58\u653e\u5df2\u521d\u59cb\u5316\u7684\u5168\u5c40\u548c\u9759\u6001\u6570\u636e\u3002\u901a\u5e38&#xff0c;.text \u4e0e .data \u662f\u5728\u6c47\u7f16\u6e90\u6587\u4ef6\u4e2d\u663e\u5f0f\u58f0\u660e\u7684\u8282&#xff0c;\u800c\u8bf8\u5982\u7b26\u53f7\u8868\u8282\u3001\u5b57\u7b26\u4e32\u8868\u8282\u3001\u91cd\u5b9a\u4f4d\u8282\u7b49\u5176\u4ed6\u8282&#xff0c;\u5219\u7531\u6c47\u7f16\u5668\u81ea\u52a8\u751f\u6210\u5e76\u63d2\u5165\u5230\u76ee\u6807\u6587\u4ef6\u4e2d&#xff0c;\u4ee5\u4fbf\u94fe\u63a5\u5668\u548c\u8c03\u8bd5\u5668\u540e\u7eed\u4f7f\u7528\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u547d\u4ee4&#xff1a;readelf -S hello.o<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"558\" src=\"2025-06-10bypmq5gpedy.png\" width=\"393\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe24 readelf -S hello.o\u67e5\u8be2<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u4e4b\u540e\u7528readelf -a hello.o\u63a2\u67e5 ELF \u5934\u90e8\u3001\u7a0b\u5e8f\u5934&#xff08;\u82e5\u6709&#xff09;\u3001\u8282\u533a\u8868\u3001\u91cd\u5b9a\u4f4d\u8868\u3001\u7b26\u53f7\u8868\u3001\u6ce8\u91ca\u8282\u7b49\u5168\u90e8\u5185\u5bb9\u3002\u4ee5\u4e0b\u4e3a\u5173\u952e\u90e8\u5206\u7684\u6458\u5f55\u4e0e\u89e3\u6790&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"185\" src=\"2025-06-10cr42ekr5poo.png\" width=\"463\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe25 .rela.text\u7684\u66f4\u8be6\u7ec6\u4fe1\u606f<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u91cd\u5b9a\u4f4d\u8282 .rela.eh_frame \u8bb0\u5f55\u4e86\u9700\u8981\u8fdb\u884c\u5730\u5740\u91cd\u5b9a\u4f4d\u7684\u5f02\u5e38\u5904\u7406\u6846\u67b6&#xff08;exception handling frame&#xff09;\u4fe1\u606f\u3002\u5176\u4f5c\u7528\u662f\u8c03\u6574\u5f02\u5e38\u5904\u7406\u6846\u67b6&#xff08;EH frame&#xff09;\u4e2d\u5bf9\u4ee3\u7801\u5730\u5740\u7684\u5f15\u7528&#xff0c;\u4fdd\u8bc1\u8fd0\u884c\u65f6\u629b\u51fa\u6216\u6355\u83b7\u5f02\u5e38\u65f6\u80fd\u6b63\u786e\u5b9a\u4f4d\u3002\u4ee5\u4e0b\u662f\u67e5\u770b .rela.eh_frame \u7684\u8f93\u51fa&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"478\" src=\"2025-06-103iqthsp4isj.png\" width=\"423\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe26 .rela.eh_frame<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u7b26\u53f7\u8868 .symtab \u662f\u76ee\u6807\u6587\u4ef6\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u4e00\u90e8\u5206&#xff0c;\u5b83\u5217\u51fa\u76ee\u6807\u6587\u4ef6\u4e2d\u6240\u6709\u7b26\u53f7&#xff08;\u51fd\u6570\u540d\u3001\u5168\u5c40\u53d8\u91cf\u3001\u8282\u5f15\u7528\u7b49&#xff09;&#xff0c;\u5bf9\u94fe\u63a5\u5668\u5206\u914d\u6700\u7ec8\u5730\u5740\u53ca\u8c03\u8bd5\u5668\u7b26\u53f7\u89e3\u6790\u81f3\u5173\u91cd\u8981\u3002\u4ee5\u4e0b\u662f\u7b26\u53f7\u8868 .symtab \u7684\u5177\u4f53\u5185\u5bb9\u548c\u89e3\u91ca&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"204\" src=\"2025-06-10uazrptnnrb5.png\" width=\"423\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe27 .symtab\u7684\u5177\u4f53\u5185\u5bb9\u548c\u89e3\u91ca<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">.note.gnu.property\u8282\u5305\u542b\u5e73\u53f0\u6216\u7f16\u8bd1\u5668\u7279\u5b9a\u5c5e\u6027\u6ce8\u91ca&#xff0c;\u5982 x86 \u67b6\u6784\u7684 IBT&#xff08;Indirect Branch Tracking&#xff09;\u4e0e SHSTK&#xff08;Shadow Stack&#xff09;\u652f\u6301\u6807\u8bb0&#xff0c;\u4fbf\u4e8e\u52a0\u8f7d\u5668\u6216\u5b89\u5168\u673a\u5236\u8fdb\u884c\u76f8\u5e94\u914d\u7f6e\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"133\" src=\"2025-06-10nqyaf2lnxin.png\" width=\"474\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe28 .note.gnu.property\u7684\u5177\u4f53\u5185\u5bb9\u548c\u89e3\u91ca<\/p>\n<h3 id=\"4.4%20Hello.o%E7%9A%84%E7%BB%93%E6%9E%9C%E8%A7%A3%E6%9E%90\" style=\"margin-left:0;margin-right:0;text-align:justify\">4.4 Hello.o\u7684\u7ed3\u679c\u89e3\u6790<\/h3>\n<h4 id=\"4.4.1%20hello.o%E5%8F%8D%E6%B1%87%E7%BC%96%E4%B8%8Ehello.s%E7%9A%84%E6%AF%94%E8%BE%83\" style=\"margin-left:0;margin-right:0;text-align:justify\">4.4.1 hello.o\u53cd\u6c47\u7f16\u4e0ehello.s\u7684\u6bd4\u8f83<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">objdump -d -r hello.o<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"288\" src=\"2025-06-10ubqvhjrih0z.png\" width=\"259\" \/>\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"289\" src=\"2025-06-10vbzevzvrxrj.png\" width=\"264\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe29 hello.o\u7684\u53cd\u6c47\u7f16\u67e5\u770b<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5bf9\u7167\u5206\u6790&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u53cd\u6c47\u7f16\u8f93\u51fa\u4e2d&#xff0c;\u6bcf\u884c\u672b\u5c3e\u7684\u6307\u4ee4\u4e0e\u539f hello.s \u4e2d\u7684\u6c47\u7f16\u4ee3\u7801\u4fdd\u6301\u4e00\u81f4&#xff0c;\u4f46\u5728\u6bcf\u6761\u6307\u4ee4\u524d&#xff0c;\u8fd8\u4f1a\u591a\u51fa\u4e00\u4e32\u5bf9\u5e94\u7684\u5341\u516d\u8fdb\u5236\u673a\u5668\u7801\u3002\u4e0e\u7eaf\u7cb9\u7684\u6c47\u7f16\u8bed\u8a00\u4e0d\u540c&#xff0c;\u6c47\u7f16\u4ee3\u7801\u662f\u4e00\u79cd\u9762\u5411\u4eba\u7c7b\u3001\u5e26\u6709\u52a9\u8bb0\u7b26\u7684\u62bd\u8c61\u8868\u793a&#xff1b;\u800c\u4ece\u76ee\u6807\u6587\u4ef6\u53cd\u6c47\u7f16\u5f97\u5230\u7684\u5185\u5bb9&#xff0c;\u5219\u5b8c\u6574\u5730\u5c55\u793a\u4e86\u673a\u5668\u8bed\u8a00\u2014\u2014\u5373\u8ba1\u7b97\u673a\u80fd\u591f\u76f4\u63a5\u8bc6\u522b\u548c\u6267\u884c\u7684\u4e8c\u8fdb\u5236\u7f16\u7801\u3002\u673a\u5668\u8bed\u8a00\u6ca1\u6709\u4efb\u4f55\u62bd\u8c61\u5c42&#xff0c;\u5b8c\u5168\u7531 0 \u548c 1 \u7ec4\u6210&#xff0c;\u56e0\u800c\u624d\u80fd\u88ab\u5904\u7406\u5668\u786c\u4ef6\u6240\u9a71\u52a8\u3002\u5206\u652f\u8f6c\u79fb\u65f6&#xff0c;.s\u6587\u4ef6\u4e2d\u4f1a\u8df3\u8f6c\u5230\u8bf8\u5982.L3\u7684\u4ee3\u7801\u6bb5&#xff0c;\u50cf\u8fd9\u6837&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"143\" src=\"2025-06-10wzke1c2wdoy.png\" width=\"227\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe30 hello.s\u7684L3\u6307\u4ee4<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u800c\u53cd\u6c47\u7f16\u6587\u4ef6\u4e2d&#xff0c;\u6bcf\u6761\u6307\u4ee4\u524d\u7684\u5341\u516d\u8fdb\u5236\u6570\u8868\u793a\u8be5\u6307\u4ee4\u5728\u5730\u5740\u7a7a\u95f4&#xff08;\u6216\u6587\u4ef6&#xff09;\u4e2d\u7684\u4f4d\u7f6e&#xff1b;\u800c\u5f53\u6307\u4ee4\u672c\u8eab\u662f\u8df3\u8f6c&#xff08;jmp\u3001call \u7b49&#xff09;\u65f6&#xff0c;\u5176\u64cd\u4f5c\u6570\u4e2d\u5305\u542b\u7684\u504f\u79fb\u91cf\u4f1a\u88ab\u52a0\u5230\u5f53\u524d\u6307\u4ee4\u7684\u5730\u5740\u4e0a&#xff0c;\u8ba1\u7b97\u51fa\u8df3\u8f6c\u76ee\u6807\u7684\u7edd\u5bf9\u5730\u5740&#xff0c;\u5e76\u5728\u53cd\u6c47\u7f16\u8f93\u51fa\u4e2d\u4e00\u5e76\u663e\u793a&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"107\" src=\"2025-06-10zddwzyvwmt5.png\" width=\"462\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe31 hello.o\u7684\u53cd\u6c47\u7f16\u4ee3\u7801<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u51fd\u6570\u8c03\u7528\u65f6&#xff0c;\u6c47\u7f16\u6587\u4ef6\u4e2d&#xff0c;call\u6307\u4ee4\u76f4\u63a5\u8c03\u7528\u51fd\u6570&#xff0c;call\u540e\u7d27\u8ddf\u51fd\u6570\u7684\u540d\u5b57&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"46\" src=\"2025-06-10r5yvv4azyfi.png\" width=\"224\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"67\" src=\"2025-06-10exmvwpforot.png\" width=\"205\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"85\" src=\"2025-06-10iyojku2jjv4.png\" width=\"236\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe32 \u6c47\u7f16\u6587\u4ef6\u4e2d\u7684\u51fd\u6570\u8c03\u7528<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u53cd\u6c47\u7f16\u6587\u4ef6\u4e2d&#xff0c;86: \u8868\u793a\u53d7\u91cd\u5b9a\u4f4d\u6761\u76ee\u5f71\u54cd\u7684\u5730\u5740\u504f\u79fb\u91cf&#xff0c;\u662f call \u6307\u4ee4\u4e2d\u5730\u5740\u5b57\u6bb5\u5728\u6307\u4ee4\u6d41\u4e2d\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002 \u91cd\u5b9a\u4f4d\u8868\u4e2d\u7684\u6bcf\u4e2a\u6761\u76ee&#xff08;Elf64_Rela \u7ed3\u6784&#xff09;\u8bb0\u5f55\u4e86\u7b26\u53f7\u7d22\u5f15\u3001\u7c7b\u578b\u548c\u52a0\u6570\u7b49\u4fe1\u606f&#xff0c;\u4ee5\u4fbf\u94fe\u63a5\u5668\u6839\u636e\u8fd9\u4e9b\u6570\u636e\u4fee\u6b63\u76ee\u6807\u6587\u4ef6\u4e2d\u5bf9\u5e94\u7684\u5730\u5740\u57df\u3002 R_X86_64_PLT32 \u662f\u91cd\u5b9a\u4f4d\u7c7b\u578b&#xff0c;\u8868\u660e\u5bf9\u8fc7\u7a0b\u94fe\u63a5\u8868&#xff08;Procedure Linkage Table&#xff09;\u7684 32 \u4f4d PC \u76f8\u5bf9\u91cd\u5b9a\u4f4d&#xff0c;\u8fd9\u79cd\u91cd\u5b9a\u4f4d\u7528\u4e8e\u652f\u6301\u8fd0\u884c\u65f6\u7684\u5ef6\u8fdf\u7ed1\u5b9a\u8c03\u7528\u3002 \u5728\u7b2c\u4e00\u6b21\u8c03\u7528\u65f6&#xff0c;PLT \u6761\u76ee\u4f1a\u5f15\u5bfc\u7a0b\u5e8f\u8df3\u8f6c\u5230\u52a8\u6001\u94fe\u63a5\u5668&#xff0c;\u7531\u5176\u89e3\u6790\u7b26\u53f7\u5730\u5740\u5e76\u5199\u5165\u5168\u5c40\u504f\u79fb\u8868&#xff08;GOT&#xff09;&#xff0c;\u4e4b\u540e\u5bf9\u540c\u4e00\u51fd\u6570\u7684\u8c03\u7528\u5c06\u76f4\u63a5\u900f\u8fc7 GOT \u5b8c\u6210&#xff0c;\u4ece\u800c\u52a0\u901f\u540e\u7eed\u8c03\u7528\u6027\u80fd\u3002 \u5728 readelf -r \u6216 objdump -r \u7684\u91cd\u5b9a\u4f4d\u8f93\u51fa\u4e2d&#xff0c;\u53ef\u4ee5\u770b\u5230\u8fd9\u4e9b\u6761\u76ee\u8be6\u7ec6\u5217\u51fa\u504f\u79fb\u91cf&#xff08;Offset&#xff09;\u3001Info \u5b57\u6bb5\u3001\u91cd\u5b9a\u4f4d\u7c7b\u578b\u3001\u7b26\u53f7\u540d\u79f0\u548c\u52a0\u6570&#xff08;Addend&#xff09;\u7b49\u4fe1\u606f Mindfruit\u3002 \u201catoi-0x4\u201d \u8868\u793a\u91cd\u5b9a\u4f4d\u76ee\u6807\u7b26\u53f7\u4e3a\u202fatoi&#xff0c;\u52a0\u6570\u4e3a\u202f-4&#xff0c;\u8fd9\u6b63\u662f\u56e0\u4e3a x86\u201164 \u7684 call \u6307\u4ee4\u91c7\u7528 PC \u76f8\u5bf9\u5bfb\u5740\u65b9\u5f0f&#xff0c;\u5176\u4f4d\u79fb\u662f\u76f8\u5bf9\u4e8e\u4e0b\u4e00\u6761\u6307\u4ee4&#xff08;P&#xff09;\u7684\u504f\u79fb\u6570&#xff0c;\u56e0\u6b64\u9700\u51cf\u53bb 4\u202f\u5b57\u8282\u6765\u6821\u6b63\u3002 \u5c3d\u7ba1\u540d\u79f0\u4e3a\u202fR_X86_64_PLT32&#xff0c;\u94fe\u63a5\u5668\u4ecd\u6cbf\u7528 R_X86_64_PC32 \u7684\u8ba1\u7b97\u65b9\u6cd5\u202fS &#043; A \u2212 P\u202f\u6765\u751f\u6210\u6700\u7ec8\u7684\u91cd\u5b9a\u4f4d\u503c&#xff0c;\u4ece\u800c\u7b80\u5316\u5bf9 PC \u76f8\u5bf9\u5206\u652f\u7684\u5904\u7406\u3002 \u94fe\u63a5\u5668\u5728\u5904\u7406 R_X86_64_PLT32 \u91cd\u5b9a\u4f4d\u65f6&#xff0c;\u4f1a\u6839\u636e\u516c\u5f0f\u202fS &#043; A \u2212 P\u202f&#xff08;S \u4e3a\u7b26\u53f7\u503c\u3001A \u4e3a\u91cd\u5b9a\u4f4d\u52a0\u6570\u3001P \u4e3a\u8c03\u7528\u6307\u4ee4\u4e0b\u4e00\u5730\u5740&#xff09;\u8ba1\u7b97\u5e76\u586b\u5145\u81f3 call \u6307\u4ee4\u7684\u7acb\u5373\u6570\u57df\u4e2d&#xff0c;\u4fdd\u8bc1\u5728\u8fd0\u884c\u65f6\u80fd\u8df3\u8f6c\u5230\u6b63\u786e\u7684\u51fd\u6570\u5165\u53e3\u3002 call \u6307\u4ee4\u6267\u884c\u65f6&#xff0c;CPU \u4f1a\u5c06\u8fd4\u56de\u5730\u5740\u538b\u5165\u6808&#xff0c;\u5e76\u6839\u636e\u5df2\u586b\u5145\u7684\u4f4d\u79fb\u8ba1\u7b97\u51fa\u76ee\u6807\u5730\u5740\u540e\u8df3\u8f6c&#xff0c;\u5b8c\u6210\u5bf9\u76ee\u6807\u51fd\u6570&#xff08;\u5982 atoi&#xff09;\u7684\u8c03\u7528\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"151\" src=\"2025-06-10lgl30sdqaug.png\" width=\"431\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe33 \u53cd\u6c47\u7f16\u6587\u4ef6\u4e2d\u7684\u51fd\u6570\u8c03\u7528<\/p>\n<h4 id=\"4.4.2%20%E6%9C%BA%E5%99%A8%E8%AF%AD%E8%A8%80%E7%9A%84%E6%9E%84%E6%88%90\" style=\"margin-left:0;margin-right:0;text-align:justify\">4.4.2 \u673a\u5668\u8bed\u8a00\u7684\u6784\u6210<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">x86\u201164 \u6307\u4ee4\u91c7\u7528\u53ef\u53d8\u957f\u5ea6\u7f16\u7801&#xff0c;\u4efb\u4f55\u4e00\u6761\u6307\u4ee4\u7684\u957f\u5ea6\u4ecb\u4e8e\u202f1\u202f\u5230\u202f15\u202f\u5b57\u8282\u4e4b\u95f4&#xff1b;\u4f8b\u5982\u64cd\u4f5c\u6570\u5f88\u5c11\u7684 pop\u202f%rbx \u4ec5\u9700\u5355\u5b57\u8282\u64cd\u4f5c\u7801\u202f0x5B&#xff0c;\u800c\u66f4\u590d\u6742\u6216\u5e26\u66f4\u591a\u64cd\u4f5c\u6570\u7684\u6307\u4ee4\u5219\u66f4\u957f\u3002\u6307\u4ee4\u683c\u5f0f\u7531\u524d\u7f00&#xff08;Legacy\/REX&#xff09;\u3001\u64cd\u4f5c\u7801\u3001ModR\/M\u3001SIB\u3001\u53ef\u9009\u4f4d\u79fb\u548c\u7acb\u5373\u6570\u7b49\u5b57\u6bb5\u6309\u56fa\u5b9a\u987a\u5e8f\u7ec4\u6210&#xff0c;CPU \u4ece\u6307\u4ee4\u6d41\u8d77\u70b9\u9010\u5b57\u8282\u5730\u89e3\u6790\u5373\u53ef\u552f\u4e00\u8bc6\u522b\u51fa\u5b8c\u6574\u6307\u4ee4&#xff0c;\u65e0\u9700\u56de\u6eaf\u3002\u82e5\u6307\u4ee4\u643a\u5e26\u591a\u5b57\u8282\u5e38\u6570\u6216\u5185\u5b58\u5730\u5740&#xff0c;\u8fd9\u4e9b\u5b57\u6bb5\u5fc5\u987b\u6309\u7167\u5c0f\u7aef\u5e8f\u7684\u65b9\u5f0f\u4f9d\u6b21\u7f16\u7801&#xff0c;\u4ee5\u4fdd\u8bc1\u52a0\u8f7d\u65f6\u5404\u5bbd\u5ea6\u8bbf\u95ee\u5747\u80fd\u6b63\u786e\u8bfb\u53d6\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\n<h4 id=\"4.4.3%20%E4%B8%8E%E6%B1%87%E7%BC%96%E8%AF%AD%E8%A8%80%E7%9A%84%E6%98%A0%E5%B0%84%E5%85%B3%E7%B3%BB\" style=\"margin-left:0;margin-right:0;text-align:justify\">4.4.3 \u4e0e\u6c47\u7f16\u8bed\u8a00\u7684\u6620\u5c04\u5173\u7cfb<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u53cd\u6c47\u7f16\u5668\u53ea\u662f\u57fa\u4e8e\u673a\u5668\u4ee3\u7801\u6587\u4ef6\u4e2d\u7684\u5b57\u8282\u5e8f\u5217\u6765\u786e\u5b9a\u6c47\u7f16\u4ee3\u7801\u3002\u5b83\u4e0d\u9700\u8981\u8bbf\u95ee\u8be5\u7a0b\u5e8f\u7684\u6e90\u4ee3\u7801\u6216\u6c47\u7f16\u4ee3\u7801&#xff1b;\u53cd\u6c47\u7f16\u5668\u4f7f\u7528\u7684\u6307\u4ee4\u547d\u540d\u89c4\u5219\u4e0eGCC\u751f\u6210\u7684\u6c47\u7f16\u4ee3\u7801\u4f7f\u7528\u7684\u6709\u4e9b\u7ec6\u5fae\u7684\u5dee\u522b\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5728\u51fd\u6570\u8c03\u7528\u548c\u5206\u652f\u8df3\u8f6c\u65f6&#xff0c;\u4e8c\u8005\u4e5f\u662f\u6709\u5dee\u522b\u7684\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">1&#xff09;\u51fd\u6570\u8c03\u7528&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u51fd\u6570\u8c03\u7528\u5728\u6c47\u7f16\u8bed\u8a00\u4e2d\u901a\u5e38\u6d89\u53ca\u5230\u5c06\u53c2\u6570\u538b\u5165\u6808\u4e2d&#xff0c;\u7136\u540e\u8df3\u8f6c\u5230\u51fd\u6570\u5165\u53e3\u70b9\u3002\u51fd\u6570\u8fd4\u56de\u65f6&#xff0c;\u901a\u5e38\u4f1a\u4ece\u6808\u4e2d\u5f39\u51fa\u8fd4\u56de\u503c&#xff0c;\u5e76\u8df3\u8f6c\u5230\u8c03\u7528\u70b9\u4e4b\u540e\u7684\u6307\u4ee4\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">2&#xff09;\u5206\u652f\u8df3\u8f6c&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u673a\u5668\u8bed\u8a00\u4e2d&#xff0c;\u5206\u652f\u8f6c\u79fb\u548c\u51fd\u6570\u8c03\u7528\u901a\u5e38\u6d89\u53ca\u5230\u7279\u5b9a\u7684\u6307\u4ee4\u548c\u64cd\u4f5c\u6570\u6765\u8868\u793a\u8df3\u8f6c\u7684\u76ee\u6807\u5730\u5740\u3002\u8fd9\u4e9b\u5730\u5740\u53ef\u80fd\u662f\u7edd\u5bf9\u7684&#xff0c;\u4e5f\u53ef\u80fd\u662f\u76f8\u5bf9\u4e8e\u5f53\u524d\u6307\u4ee4\u6216\u67d0\u4e2a\u57fa\u51c6\u70b9\u7684\u504f\u79fb\u91cf\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u6c47\u7f16\u8bed\u8a00\u4e2d&#xff0c;\u8fd9\u4e9b\u8df3\u8f6c\u76ee\u6807\u901a\u5e38\u4f7f\u7528\u6807\u7b7e\u6765\u8868\u793a&#xff0c;\u5982JMP label\u8868\u793a\u8df3\u8f6c\u5230\u6807\u7b7elabel\u5904\u3002\u5728\u7f16\u8bd1\u6216\u6c47\u7f16\u8fc7\u7a0b\u4e2d&#xff0c;\u8fd9\u4e9b\u6807\u7b7e\u4f1a\u88ab\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u5185\u5b58\u5730\u5740\u6216\u504f\u79fb\u91cf\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h3 id=\"\" style=\"margin-left:0;margin-right:0;text-align:justify\"><\/h3>\n<h3 id=\"4.5%20%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93\" style=\"margin-left:0;margin-right:0;text-align:justify\">4.5 \u672c\u7ae0\u5c0f\u7ed3<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u672c\u7ae0\u9996\u5148\u4ecb\u7ecd\u4e86\u6c47\u7f16\u9636\u6bb5\u7684\u57fa\u672c\u6d41\u7a0b&#xff1a;\u4f7f\u7528\u6c47\u7f16\u5668\u5c06\u6c47\u7f16\u6e90\u6587\u4ef6&#xff08;.s&#xff09;\u8f6c\u6362\u4e3a\u53ef\u91cd\u5b9a\u4f4d\u7684\u76ee\u6807\u6587\u4ef6&#xff08;.o&#xff09;&#xff0c;\u8fd9\u4e00\u8fc7\u7a0b\u4ec5\u5b8c\u6210\u4ece\u52a9\u8bb0\u7b26\u5230\u673a\u5668\u6307\u4ee4\u7684\u7ffb\u8bd1&#xff0c;\u800c\u7b26\u53f7\u5f15\u7528\u7559\u5f85\u94fe\u63a5\u9636\u6bb5\u5904\u3002 \u63a5\u7740&#xff0c;\u901a\u8fc7 readelf -S hello.o \u89c2\u5bdf\u8282\u533a\u8868&#xff0c;\u638c\u63e1\u4e86\u5404\u8282\u7684\u540d\u79f0\u3001\u7c7b\u578b\u3001\u5728\u6587\u4ef6\u4e2d\u7684\u504f\u79fb\u4e0e\u5927\u5c0f&#xff0c;\u4ee5\u53ca\u6807\u5fd7\u5c5e\u6027\u7b49\u5173\u952e\u4fe1\u606f\u3002 \u968f\u540e&#xff0c;\u4f7f\u7528 readelf -a hello.o \u5168\u9762\u67e5\u770b\u4e86 ELF \u5934\u90e8\u3001\u91cd\u5b9a\u4f4d\u8868&#xff08;.rela.text\u3001.rela.eh_frame&#xff09;\u3001\u7b26\u53f7\u8868&#xff08;.symtab&#xff09;\u53ca\u6ce8\u91ca\u8282&#xff08;.note.gnu.property&#xff09;\u7b49&#xff0c;\u6df1\u5165\u4e86\u89e3\u4e86\u94fe\u63a5\u5668\u548c\u52a8\u6001\u52a0\u8f7d\u6240\u9700\u7684\u5143\u6570\u636e\u3002 \u5728\u53cd\u6c47\u7f16\u9636\u6bb5&#xff0c;\u5c06\u76ee\u6807\u6587\u4ef6\u4e2d\u7684\u4e8c\u8fdb\u5236\u5185\u5bb9\u8fd8\u539f\u4e3a\u6c47\u7f16\u6307\u4ee4&#xff0c;\u5e76\u4e0e\u539f\u59cb\u6c47\u7f16\u6e90\u5bf9\u6bd4&#xff0c;\u6e05\u6670\u5730\u770b\u5230\u673a\u5668\u7801&#xff08;\u5341\u516d\u8fdb\u5236\u7f16\u7801&#xff09;\u662f\u5982\u4f55\u5bf9\u5e94\u5230\u6c47\u7f16\u52a9\u8bb0\u7b26\u7684&#xff0c;\u8fdb\u4e00\u6b65\u7406\u89e3\u4e86\u6307\u4ee4\u6267\u884c\u903b\u8f91\u4e0e\u91cd\u5b9a\u4f4d\u673a\u5236\u3002 \u901a\u8fc7\u672c\u7ae0\u5b66\u4e60&#xff0c;\u4e0d\u4ec5\u638c\u63e1\u4e86\u4ece\u6c47\u7f16\u7a0b\u5e8f\u5230\u76ee\u6807\u6587\u4ef6\u7684\u5b8c\u6574\u6d41\u7a0b&#xff0c;\u8fd8\u80fd\u591f\u501f\u52a9 readelf \u548c\u53cd\u6c47\u7f16\u5de5\u5177\u5206\u6790\u4e8c\u8fdb\u5236\u6587\u4ef6\u7ed3\u6784\u4e0e\u673a\u5668\u4ee3\u7801\u6267\u884c\u903b\u8f91&#xff0c;\u4e3a\u540e\u7eed\u7684\u94fe\u63a5\u3001\u8c03\u8bd5\u548c\u9006\u5411\u5de5\u7a0b\u5960\u5b9a\u4e86\u575a\u5b9e\u57fa\u7840\u3002<\/p>\n<\/p>\n<h2 id=\"%E7%AC%AC5%E7%AB%A0%20%E9%93%BE%E6%8E%A5\" style=\"margin-left:0;margin-right:0;text-align:left\">\u7b2c5\u7ae0 \u94fe\u63a5<\/h2>\n<h3 id=\"5.1%20%E9%93%BE%E6%8E%A5%E7%9A%84%E6%A6%82%E5%BF%B5%E4%B8%8E%E4%BD%9C%E7%94%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">5.1 \u94fe\u63a5\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528<\/h3>\n<h4 id=\"\" style=\"margin-left:0;margin-right:0;text-align:justify\"><\/h4>\n<h4 id=\"5.1.1%20%E9%93%BE%E6%8E%A5%E7%9A%84%E6%A6%82%E5%BF%B5\" style=\"margin-left:0;margin-right:0;text-align:justify\">5.1.1 \u94fe\u63a5\u7684\u6982\u5ff5<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u94fe\u63a5\u662f\u7531\u94fe\u63a5\u5668&#xff08;ld&#xff09;\u5b8c\u6210\u7684\u4e00\u9879\u5173\u952e\u6b65\u9aa4&#xff0c;\u5176\u4e3b\u8981\u529f\u80fd\u662f\u5c06\u7f16\u8bd1\u6216\u6c47\u7f16\u9636\u6bb5\u4ea7\u751f\u7684\u591a\u4e2a\u53ef\u91cd\u5b9a\u4f4d\u76ee\u6807\u6587\u4ef6&#xff08;.o&#xff09;\u4ee5\u53ca\u6240\u9700\u7684\u5e93\u6587\u4ef6&#xff08;\u9759\u6001\u5e93 .a \u6216\u52a8\u6001\u5e93 .so&#xff09;\u6536\u96c6\u3001\u7b26\u53f7\u89e3\u6790\u5e76\u5408\u5e76&#xff0c;\u751f\u6210\u53ef\u4ee5\u88ab\u64cd\u4f5c\u7cfb\u7edf\u52a0\u8f7d\u5668\u88c5\u5165\u5185\u5b58\u7684\u6700\u7ec8\u53ef\u6267\u884c\u6587\u4ef6\u6216\u5171\u4eab\u5e93\u3002\u9759\u6001\u94fe\u63a5\u901a\u5e38\u5728\u7f16\u8bd1\u65f6\u5b8c\u6210&#xff0c;\u5c06\u6240\u6709\u7b26\u53f7\u548c\u4ee3\u7801\u6253\u5305\u8fdb\u5355\u4e00\u53ef\u6267\u884c\u6587\u4ef6&#xff1b;\u52a8\u6001\u94fe\u63a5\u5219\u53ef\u4ee5\u5728\u52a0\u8f7d\u65f6\u6216\u8fd0\u884c\u65f6\u5ef6\u8fdf\u89e3\u6790\u7b26\u53f7&#xff0c;\u5e38\u89c1\u4e8e\u4f7f\u7528 dlopen\/dlsym \u7684\u573a\u666f\u3002 \u53ef\u901a\u8fc7\u94fe\u63a5\u5b9e\u73b0\u5c06\u82e5\u5e72\u72ec\u7acb\u6a21\u5757\u7f16\u8bd1\u8f93\u51fa\u7684.o\u6587\u4ef6\u5408\u5e76\u4e3a\u4e00\u4e2a\u5b8c\u6574\u7a0b\u5e8f&#xff0c;\u4e5f\u53ef\u5c06\u672a\u5b9a\u4e49\u7b26\u53f7\u7559\u7ed9\u8fd0\u884c\u65f6\u94fe\u63a5\u5668\u518d\u89e3\u6790&#xff0c;\u56e0\u800c\u94fe\u63a5\u673a\u5236\u65e2\u652f\u6301\u9759\u6001\u53ef\u6267\u884c&#xff0c;\u4e5f\u652f\u6301\u5171\u4eab\u5e93\u4e0e\u52a8\u6001\u52a0\u8f7d\u3002<\/p>\n<h4 id=\"5.1.2%20%E9%93%BE%E6%8E%A5%E7%9A%84%E4%BD%9C%E7%94%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">5.1.2 \u94fe\u63a5\u7684\u4f5c\u7528<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u94fe\u63a5\u5c06\u591a\u4e2a\u9884\u7f16\u8bd1\u597d\u7684\u76ee\u6807\u6587\u4ef6\u6574\u5408\u4e3a\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6&#xff0c;\u4ece\u800c\u652f\u6301\u6a21\u5757\u5316\u7684\u5206\u79bb\u7f16\u8bd1&#xff0c;\u4f7f\u5f97\u5927\u578b\u5e94\u7528\u4e0d\u5fc5\u5199\u6210\u5355\u4e00\u5e9e\u5927\u6e90\u7a0b\u5e8f&#xff0c;\u800c\u662f\u53ef\u4ee5\u62c6\u5206\u4e3a\u53ef\u72ec\u7acb\u4fee\u6539\u3001\u7f16\u8bd1\u7684\u529f\u80fd\u6a21\u5757\u3002\u8fd9\u6837\u4e0d\u4ec5\u5927\u5e45\u7f29\u77ed\u4e86\u6bcf\u6b21\u4fee\u6539\u540e\u91cd\u5efa\u7684\u65f6\u95f4&#xff0c;\u63d0\u5347\u4e86\u5f00\u53d1\u6548\u7387&#xff0c;\u8fd8\u7b80\u5316\u4e86\u4ee3\u7801\u7ec4\u7ec7\u4e0e\u7ef4\u62a4&#xff0c;\u589e\u5f3a\u4e86\u7a0b\u5e8f\u751f\u6210\u7684\u7075\u6d3b\u6027\u548c\u8de8\u5e73\u53f0\u53ef\u79fb\u690d\u6027\u3002\u94fe\u63a5\u5668\u901a\u8fc7\u89e3\u6790\u5404\u76ee\u6807\u6587\u4ef6\u95f4\u7684\u7b26\u53f7\u5f15\u7528&#xff0c;\u81ea\u52a8\u5408\u5e76\u5e76\u89e3\u51b3\u6a21\u5757\u95f4\u4f9d\u8d56&#xff0c;\u6700\u7ec8\u8f93\u51fa\u7b26\u5408\u5e73\u53f0 ABI \u89c4\u8303\u7684\u53ef\u6267\u884c\u6620\u50cf)\u3002<\/p>\n<h3 id=\"5.2%20%E5%9C%A8Ubuntu%E4%B8%8B%E9%93%BE%E6%8E%A5%E7%9A%84%E5%91%BD%E4%BB%A4\" style=\"margin-left:0;margin-right:0;text-align:justify\">5.2 \u5728Ubuntu\u4e0b\u94fe\u63a5\u7684\u547d\u4ee4<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5728Ubuntu\u4e2d&#xff0c;hello.s\u6587\u4ef6\u8fdb\u884c\u7f16\u8bd1\u7684\u64cd\u4f5c\u547d\u4ee4\u4e3a&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">ld -o hello -dynamic-linker \/lib64\/ld-linux-x86-64.so.2 \/usr\/lib\/x86_64-linux-gnu\/crt1.o \/usr\/lib\/x86_64-linux-gnu\/crti.o hello.o \/usr\/lib\/x86_64-linux-gnu\/libc.so \/usr\/lib\/x86_64-linux-gnu\/crtn.o<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"121\" src=\"2025-06-104baeiqv0fhb.png\" width=\"596\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe34 ld\u7684\u64cd\u4f5c\u8fc7\u7a0b<\/p>\n<h3 id=\"5.3%20%E5%8F%AF%E6%89%A7%E8%A1%8C%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6hello%E7%9A%84%E6%A0%BC%E5%BC%8F\" style=\"margin-left:0;margin-right:0;text-align:justify\">5.3 \u53ef\u6267\u884c\u76ee\u6807\u6587\u4ef6hello\u7684\u683c\u5f0f<\/h3>\n<h4 id=\"%C2%A0%C2%A0%20%C2%A05.3.1%20ELF%E5%A4%B4%E4%BF%A1%E6%81%AF\" style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0 \u00a05.3.1 ELF\u5934\u4fe1\u606f<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u547d\u4ee4&#xff1a;readelf -h hello<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f97\u5230hello\u7684ELF\u5934\u4fe1\u606f<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"457\" src=\"2025-06-10l54nyuzu1gl.png\" width=\"507\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe35 hello\u7684ELF\u5934\u4fe1\u606f<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h4 id=\"%C2%A0%C2%A0%C2%A0%205.3.2%E8%8A%82%E5%A4%B4\" style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0 5.3.2\u8282\u5934<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u63cf\u8ff0\u4e86\u5404\u4e2a\u8282\u7684\u5927\u5c0f\u3001\u8d77\u59cb\u4f4d\u7f6e\u548c\u5176\u4ed6\u5c5e\u6027\u3002\u94fe\u63a5\u5668\u94fe\u63a5\u65f6&#xff0c;\u4f1a\u5c06\u5404\u4e2a\u6587\u4ef6\u7684\u76f8\u540c\u6bb5\u5408\u5e76\u6210\u4e00\u4e2a\u5927\u6bb5&#xff0c;\u5e76\u4e14\u6839\u636e\u8fd9\u4e2a\u5927\u6bb5\u7684\u5927\u5c0f\u4ee5\u53ca\u504f\u79fb\u91cf\u91cd\u65b0\u8bbe\u7f6e\u5404\u4e2a\u7b26\u53f7\u7684\u5730\u5740\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u547d\u4ee4&#xff1a;readelf -S hello<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f97\u5230hello\u7684\u8282\u5934\u90e8\u8868<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"385\" src=\"2025-06-10ragfp3plihf.png\" width=\"281\" \/>\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"383\" src=\"2025-06-10cliwrnbfzkd.png\" width=\"284\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe36 hello\u7684\u8282\u5934\u90e8\u8868<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h4 id=\"%C2%A0%C2%A0%C2%A0%205.3.3%E7%A8%8B%E5%BA%8F%E5%A4%B4\" style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0 5.3.3\u7a0b\u5e8f\u5934<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u547d\u4ee4&#xff1a;readelf -l hello<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"241\" src=\"2025-06-10fhgsuxovv3j.png\" width=\"213\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe37 hello\u7684\u7a0b\u5e8f\u5934\u8868<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h4 id=\"%C2%A0%C2%A0%C2%A0%205.3.4%E7%AC%A6%E5%8F%B7%E8%A1%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0 5.3.4\u7b26\u53f7\u8868<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u547d\u4ee4&#xff1a;readelf -s hello<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5f97\u5230ELF\u7b26\u53f7\u8868&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"235\" src=\"2025-06-1021hi2oggkmo.png\" width=\"274\" \/>\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"183\" src=\"2025-06-10luxbqnfnhwg.png\" width=\"288\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe38 hello\u7684\u7b26\u53f7\u8868<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h4 id=\"%C2%A0%C2%A0%C2%A0%205.3.5%E9%87%8D%E5%AE%9A%E4%BD%8D%E8%8A%82\" style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0 5.3.5\u91cd\u5b9a\u4f4d\u8282<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u547d\u4ee4&#xff1a;readelf -r hello<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f97\u5230hello\u7684\u91cd\u5b9a\u4f4d\u8282<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"274\" src=\"2025-06-101z5m5xfuqay.png\" width=\"605\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe39 hello\u7684\u91cd\u5b9a\u4f4d\u8282<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h3 id=\"5.4%20hello%E7%9A%84%E8%99%9A%E6%8B%9F%E5%9C%B0%E5%9D%80%E7%A9%BA%E9%97%B4\" style=\"margin-left:0;margin-right:0;text-align:justify\">5.4 hello\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u547d\u4ee4&#xff1a;edb &#8211;run hello<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4f7f\u7528edb\u52a0\u8f7dhello<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"314\" src=\"2025-06-10epmbrlxtcji.png\" width=\"616\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u00a0\u00a0 \u56fe40 edb\u67e5\u770b<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u53ef\u4ee5\u770b\u51fa&#xff0c;\u865a\u62df\u5730\u5740\u5747\u4ece0x401000\u5f00\u59cb&#xff0c;\u4ece\u5f00\u59cb\u5230\u7ed3\u675f\u8fd9\u4e4b\u95f4\u7684\u6bcf\u4e00\u4e2a\u8282\u5bf9\u5e945.3\u4e2d\u7684\u6bcf\u4e00\u4e2a\u8282\u5934\u8868\u7684\u58f0\u660e\u3002\u4f8b\u5982&#xff0c;\u5728\u8d77\u59cb\u5730\u57400x401000\u53ef\u4e0e\u5728ELF\u4e2d\u770b\u5230\u5bf9\u5e94&#xff1a;init\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"55\" src=\"2025-06-10dfiypp32rso.png\" width=\"520\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u00a0 \u56fe41 hello\u7684\u8282\u5934\u4e2d\u7684.init<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"317\" src=\"2025-06-102twkmrqk1ey.png\" width=\"373\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u00a0 \u56fe42 edb\u67e5\u770b<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"119\" src=\"2025-06-10whcw3iifix4.png\" width=\"448\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe43 0x401000<\/p>\n<h3 id=\"5.5%20%E9%93%BE%E6%8E%A5%E7%9A%84%E9%87%8D%E5%AE%9A%E4%BD%8D%E8%BF%87%E7%A8%8B%E5%88%86%E6%9E%90\" style=\"margin-left:0;margin-right:0;text-align:justify\">5.5 \u94fe\u63a5\u7684\u91cd\u5b9a\u4f4d\u8fc7\u7a0b\u5206\u6790<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">hello\u53cd\u6c47\u7f16\u6587\u4ef6\u4e2d&#xff0c;\u6bcf\u884c\u6307\u4ee4\u90fd\u6709\u552f\u4e00\u7684\u865a\u62df\u5730\u5740&#xff0c;\u800chello.o\u7684\u53cd\u6c47\u7f16\u6ca1\u6709&#xff0c;\u53ea\u662f\u76f8\u5bf9\u4e8e\u4ee3\u7801\u6bb5&#xff08;\u901a\u5e38\u662f .text \u6bb5&#xff09;\u7684\u504f\u79fb\u5730\u5740\u3002\u8fd9\u662f\u56e0\u4e3a\u76ee\u6807\u6587\u4ef6\u53ea\u662f\u4e00\u4e2a\u4e2d\u95f4\u4ea7\u7269&#xff0c;\u8fd8\u6ca1\u6709\u88ab\u94fe\u63a5\u5230\u6700\u7ec8\u7684\u5185\u5b58\u5730\u5740\u7a7a\u95f4\u3002\u8fd9\u662f\u56e0\u4e3ahello\u7ecf\u8fc7\u94fe\u63a5&#xff0c;\u5df2\u7ecf\u5b8c\u6210\u91cd\u5b9a\u4f4d&#xff0c;\u6bcf\u6761\u6307\u4ee4\u5206\u914d\u4e86\u552f\u4e00\u7684\u865a\u62df\u5730\u5740&#xff0c;\u6bcf\u6761\u6307\u4ee4\u7684\u5730\u5740\u5173\u7cfb\u5df2\u7ecf\u786e\u5b9a&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u547d\u4ee4&#xff1a;objdump -d -r hello<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"236\" src=\"2025-06-10vzctboqw1xb.png\" width=\"516\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe44 \u5f97\u5230hello\u7684\u53cd\u6c47\u7f16<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">hello&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"210\" src=\"2025-06-105bni22obpqv.png\" width=\"460\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe45 hello\u7684\u53cd\u6c47\u7f16<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">hello.o:<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"306\" src=\"2025-06-10opfnla0vg1m.png\" width=\"450\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe46 hello.o\u7684\u53cd\u6c47\u7f16<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">hello&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"383\" src=\"2025-06-10xrhzyer2xyf.png\" width=\"435\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe47 hello\u7684\u53cd\u6c47\u7f16<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">hello\u5df2\u7ecf\u5b8c\u6210\u94fe\u63a5&#xff0c;\u6545\u5176\u53cd\u6c47\u7f16\u7684\u5730\u5740\u5173\u7cfb\u5df2\u7ecf\u786e\u5b9a&#xff0c;\u76f4\u63a5\u7ed9\u51fa\u5373\u53ef\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">hello.o:<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"375\" src=\"2025-06-10t415sosyyb0.png\" width=\"384\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe48 hello.o\u7684\u53cd\u6c47\u7f16<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">hello.o\u5e76\u6ca1\u6709\u94fe\u63a5&#xff0c;\u6240\u4ee5\u9700\u8981\u544a\u8bc9\u94fe\u63a5\u5668\u5728\u94fe\u63a5\u65f6\u9700\u8981\u6267\u884c\u7684\u52a8\u4f5c\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u4f8b\u5982&#xff0c;6f: R_X86_64_PLT32 printf-0x4\u544a\u8bc9\u94fe\u63a5\u5668\u5728\u94fe\u63a5\u65f6\u9700\u8981\u6267\u884c\u7684\u52a8\u4f5c\u30026f \u662f\u4e00\u4e2a\u5b57\u8282\u504f\u79fb\u91cf&#xff0c;\u6307\u793a\u4e86\u5728\u67d0\u4e2a\u7279\u5b9a\u4f4d\u7f6e\u53d1\u751f\u4e86\u91cd\u5b9a\u4f4d\u52a8\u4f5c\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\">R_X86_64_PLT32 \u662f\u4e00\u4e2a\u91cd\u5b9a\u4f4d\u7c7b\u578b&#xff0c;\u8868\u793a\u8fd9\u662f\u4e00\u4e2a32\u4f4d\u7684\u91cd\u5b9a\u4f4d\u9879\u3002printf-0x4 \u8868\u793a\u9700\u8981\u4fee\u6539\u7684\u76ee\u6807\u7b26\u53f7\u662f printf&#xff0c;\u5e76\u4e14\u8981\u5728\u94fe\u63a5\u65f6\u5c06\u5176\u5730\u5740\u51cf\u53bb 0x4\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u94fe\u63a5\u540e\u51fd\u6570\u6570\u91cf\u589e\u52a0\u3002\u94fe\u63a5\u540e\u7684\u53cd\u6c47\u7f16\u6587\u4ef6\u4e2d&#xff0c;\u591a\u51fa\u4e86.plt&#xff0c;puts&#064;plt&#xff0c;printf&#064;plt&#xff0c;getchar&#064;plt&#xff0c;exit&#064;plt&#xff0c;sleep&#064;plt\u7b49\u51fd\u6570\u7684\u4ee3\u7801\u3002\u8fd9\u662f\u56e0\u4e3a\u52a8\u6001\u94fe\u63a5\u5668\u5c06\u5171\u4eab\u5e93\u4e2dhello.c\u7528\u5230\u7684\u51fd\u6570\u52a0\u5165\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"259\" src=\"2025-06-10cpeua4hytzy.png\" width=\"304\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe49 hello\u7684\u53cd\u6c47\u7f16<\/p>\n<h3 id=\"5.6%20hello%E7%9A%84%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B\" style=\"margin-left:0;margin-right:0;text-align:justify\">5.6 hello\u7684\u6267\u884c\u6d41\u7a0b<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4f7f\u7528gdb\/edb\u6267\u884chello&#xff0c;\u8bf4\u660e\u4ece\u52a0\u8f7dhello\u5230_start&#xff0c;\u5230call main,\u4ee5\u53ca\u7a0b\u5e8f\u7ec8\u6b62\u7684\u6240\u6709\u8fc7\u7a0b&#xff08;\u4e3b\u8981\u51fd\u6570&#xff09;\u3002\u8bf7\u5217\u51fa\u5176\u8c03\u7528\u4e0e\u8df3\u8f6c\u7684\u5404\u4e2a\u5b50\u7a0b\u5e8f\u540d\u6216\u7a0b\u5e8f\u5730\u5740\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">Edb\u67e5\u770b\u5982\u4e0b&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"371\" src=\"2025-06-10prtqvtit2h2.png\" width=\"340\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe50 edb\u7684symbols\u67e5\u770b<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h3 id=\"5.7%20Hello%E7%9A%84%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%88%86%E6%9E%90\" style=\"margin-left:0;margin-right:0;text-align:justify\">5.7 Hello\u7684\u52a8\u6001\u94fe\u63a5\u5206\u6790<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5206\u6790hello\u7a0b\u5e8f\u7684\u52a8\u6001\u94fe\u63a5\u9879\u76ee&#xff0c;\u901a\u8fc7edb\/gdb\u8c03\u8bd5&#xff0c;\u5206\u6790\u5728\u52a8\u6001\u94fe\u63a5\u524d\u540e&#xff0c;\u8fd9\u4e9b\u9879\u76ee\u7684\u5185\u5bb9\u53d8\u5316\u3002\u8981\u622a\u56fe\u6807\u8bc6\u8bf4\u660e\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u7a0b\u5e8f\u8c03\u7528\u7531\u5171\u4eab\u5e93\u5b9a\u4e49\u7684\u51fd\u6570\u65f6&#xff0c;\u7f16\u8bd1\u5668\u65e0\u6cd5\u5728\u7f16\u8bd1\u9636\u6bb5\u786e\u5b9a\u8be5\u51fd\u6570\u5728\u5185\u5b58\u4e2d\u7684\u51c6\u786e\u5730\u5740\u3002\u8fd9\u662f\u56e0\u4e3a\u5171\u4eab\u5e93\u5728\u8fd0\u884c\u65f6\u53ef\u80fd\u88ab\u52a0\u8f7d\u5230\u5185\u5b58\u7684\u4efb\u610f\u4f4d\u7f6e\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898&#xff0c;\u73b0\u4ee3\u7f16\u8bd1\u7cfb\u7edf\u91c7\u7528\u4e86\u4e00\u79cd\u79f0\u4e3a\u5ef6\u8fdf\u7ed1\u5b9a\u7684\u673a\u5236&#xff0c;\u5c06\u51fd\u6570\u5730\u5740\u7684\u89e3\u6790\u63a8\u8fdf\u5230\u7a0b\u5e8f\u7b2c\u4e00\u6b21\u8c03\u7528\u8be5\u51fd\u6570\u7684\u65f6\u523b\u8fdb\u884c\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5ef6\u8fdf\u7ed1\u5b9a\u7684\u6570\u636e\u7ed3\u6784&#xff1a;PLT \u4e0e GOT<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5ef6\u8fdf\u7ed1\u5b9a\u4f9d\u8d56\u4e8e\u4e24\u4e2a\u5173\u952e\u7684\u6570\u636e\u7ed3\u6784&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">PLT PLT \u662f\u4e00\u4e2a\u8df3\u8f6c\u8868&#xff0c;\u7528\u4e8e\u652f\u6301\u5171\u4eab\u5e93\u51fd\u6570\u7684\u5ef6\u8fdf\u8c03\u7528\u3002\u6bcf\u4e2a\u5916\u90e8\u51fd\u6570\u5728 PLT \u4e2d\u90fd\u6709\u4e00\u4e2a\u5bf9\u5e94\u7684\u5165\u53e3&#xff0c;\u8be5\u5165\u53e3\u5305\u542b\u4e00\u6bb5\u8df3\u8f6c\u6307\u4ee4\u3002PLT[0] \u662f\u4e00\u4e2a\u7279\u6b8a\u6761\u76ee&#xff0c;\u7528\u4e8e\u8df3\u8f6c\u81f3\u52a8\u6001\u94fe\u63a5\u5668\u3002\u5176\u4f59\u7684 PLT \u6761\u76ee\u5219\u8d1f\u8d23\u5404\u81ea\u5bf9\u5e94\u7684\u51fd\u6570\u8c03\u7528\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">GOT GOT \u662f\u4e00\u4e2a\u5b58\u50a8\u51fd\u6570\u5b9e\u9645\u5730\u5740\u7684\u6570\u7ec4&#xff0c;\u6bcf\u4e2a\u6761\u76ee\u5360\u7528 8 \u5b57\u8282\u3002GOT \u4e0e PLT \u534f\u540c\u5de5\u4f5c\u3002GOT[0] \u548c GOT[1] \u5b58\u50a8\u52a8\u6001\u94fe\u63a5\u5668\u5728\u8fd0\u884c\u65f6\u4f7f\u7528\u7684\u7279\u5b9a\u4fe1\u606f&#xff0c;GOT[2] \u4fdd\u5b58\u52a8\u6001\u94fe\u63a5\u5668\u7684\u5165\u53e3\u5730\u5740&#xff0c;\u5176\u4f59\u6761\u76ee\u7528\u4e8e\u5b58\u50a8\u5404\u4e2a\u5916\u90e8\u51fd\u6570\u7684\u5730\u5740&#xff0c;\u5e76\u5728\u7b2c\u4e00\u6b21\u8c03\u7528\u8be5\u51fd\u6570\u65f6\u7531\u94fe\u63a5\u5668\u8fdb\u884c\u586b\u5145\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8c03\u7528\u6d41\u7a0b\u89e3\u6790<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f53\u7a0b\u5e8f\u8c03\u7528\u4e00\u4e2a\u5171\u4eab\u5e93\u51fd\u6570\u65f6&#xff0c;\u6574\u4e2a\u5ef6\u8fdf\u7ed1\u5b9a\u8fc7\u7a0b\u5982\u4e0b&#xff1a;<\/p>\n<li style=\"text-align:justify\">\u7b2c\u4e00\u6b21\u8c03\u7528 \u7a0b\u5e8f\u4e0d\u4f1a\u76f4\u63a5\u8c03\u7528\u51fd\u6570\u5730\u5740&#xff0c;\u800c\u662f\u8df3\u8f6c\u5230\u8be5\u51fd\u6570\u5728 PLT \u8868\u4e2d\u7684\u6761\u76ee\u3002\u4f8b\u5982&#xff0c;\u8c03\u7528 printf \u5b9e\u9645\u4e0a\u662f\u8df3\u8f6c\u5230 printf&#064;PLT\u3002\u8be5\u6761\u76ee\u7b2c\u4e00\u6761\u6307\u4ee4\u901a\u8fc7 GOT \u8868\u8fdb\u884c\u95f4\u63a5\u8df3\u8f6c&#xff0c;\u6b64\u65f6 GOT \u6761\u76ee\u4ecd\u672a\u586b\u5165\u771f\u5b9e\u5730\u5740&#xff0c;\u56e0\u6b64\u4f1a\u8df3\u8f6c\u56de\u8be5 PLT \u6761\u76ee\u7684\u7b2c\u4e8c\u6761\u6307\u4ee4\u3002<\/li>\n<li style=\"text-align:justify\">\u8df3\u8f6c\u56de\u81ea\u8eab\u5e76\u8c03\u7528\u52a8\u6001\u94fe\u63a5\u5668 PLT \u7684\u7b2c\u4e8c\u6761\u6307\u4ee4\u4f1a\u5c06\u51fd\u6570\u6807\u8bc6\u7b26\u538b\u5165\u6808&#xff0c;\u7136\u540e\u8df3\u8f6c\u5230 PLT[0]\u3002PLT[0] \u901a\u8fc7 GOT[1] \u53d6\u51fa\u4e00\u4e2a\u5730\u5740&#xff0c;\u538b\u6808\u540e&#xff0c;\u518d\u901a\u8fc7 GOT[2] \u8df3\u8f6c\u81f3\u52a8\u6001\u94fe\u63a5\u5668\u4e2d\u7684\u89e3\u6790\u51fd\u6570&#xff08;\u4f4d\u4e8e ld-linux.so \u4e2d&#xff09;\u3002<\/li>\n<li style=\"text-align:justify\">\u5730\u5740\u89e3\u6790\u4e0e\u8df3\u8f6c \u52a8\u6001\u94fe\u63a5\u5668\u6839\u636e\u538b\u5165\u6808\u7684\u53c2\u6570\u67e5\u627e\u51fd\u6570\u7684\u771f\u5b9e\u5730\u5740&#xff0c;\u5e76\u5c06\u5176\u5199\u56de\u5bf9\u5e94\u7684 GOT \u6761\u76ee\u3002\u4e4b\u540e\u5c06\u63a7\u5236\u6743\u8f6c\u4ea4\u7ed9\u771f\u6b63\u7684\u51fd\u6570\u5165\u53e3\u3002<\/li>\n<li style=\"text-align:justify\">\u540e\u7eed\u8c03\u7528\u4f18\u5316 \u4e00\u65e6 GOT \u6761\u76ee\u88ab\u586b\u5145&#xff0c;\u540e\u7eed\u5bf9\u8be5\u51fd\u6570\u7684\u8c03\u7528\u5c06\u76f4\u63a5\u901a\u8fc7 GOT \u4e2d\u4fdd\u5b58\u7684\u771f\u5b9e\u5730\u5740\u8df3\u8f6c&#xff0c;\u65e0\u9700\u518d\u6b21\u8fdb\u5165\u52a8\u6001\u94fe\u63a5\u5668\u3002\u8fd9\u5b9e\u73b0\u4e86\u51fd\u6570\u8c03\u7528\u7684\u5ef6\u8fdf\u7ed1\u5b9a\u4e0e\u9ad8\u6548\u6027\u3002<\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u52a8\u6001\u94fe\u63a5\u4e0e\u91cd\u5b9a\u4f4d\u884c\u4e3a\u5dee\u5f02<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7a0b\u5e8f\u542f\u52a8\u521d\u671f&#xff0c;\u5c1a\u672a\u52a0\u8f7d\u52a8\u6001\u94fe\u63a5\u5668\u524d&#xff0c;GOT \u8868\u4e2d\u7684\u5404\u4e2a\u51fd\u6570\u5730\u5740\u5c1a\u672a\u5b8c\u6210\u91cd\u5b9a\u4f4d&#xff0c;\u6240\u6709\u8c03\u7528\u90fd\u9700\u7ecf\u8fc7 PLT \u8def\u5f84\u8fdb\u5165\u94fe\u63a5\u5668\u3002\u53ea\u6709\u5728\u9996\u6b21\u8c03\u7528\u5e76\u5b8c\u6210\u91cd\u5b9a\u4f4d\u540e&#xff0c;GOT \u8868\u624d\u4f1a\u66f4\u65b0\u4e3a\u5b9e\u9645\u7684\u51fd\u6570\u5730\u5740&#xff0c;\u4ece\u800c\u907f\u514d\u91cd\u590d\u89e3\u6790\u3002\u8fd9\u4e5f\u4f53\u73b0\u4e86 hello \u7a0b\u5e8f\u5728\u52a8\u6001\u94fe\u63a5\u5668\u52a0\u8f7d\u524d\u540e\u5176\u5730\u5740\u89e3\u6790\u884c\u4e3a\u7684\u53d8\u5316\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"322\" src=\"2025-06-10i0xa4zpnupt.png\" width=\"567\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe51 edb<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u4ece\u5730\u5740 0x401020 \u5f00\u59cb&#xff0c;\u4e0b\u9762\u662f\u5404\u6761\u76ee\u7684\u7ed3\u6784\u7279\u5f81\u4e0e\u4f5c\u7528\u8bf4\u660e&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">1. 0x401020 \u5f00\u59cb\u7684\u6307\u4ee4\u5757&#xff1a;PLT[0] \u6761\u76ee&#xff08;\u901a\u7528\u5165\u53e3&#xff09;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">401020: ff 35 e2 2f 00 00\u00a0\u00a0\u00a0\u00a0 jmp *0x2fe2(%rip)\u00a0 ; \u5b9e\u9645\u8df3\u8f6c\u5230 GOT[2]<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">401026: 68 00 00 00 00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 pushq $0x0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ; \u63a8\u5165\u51fd\u6570ID&#xff08;index&#xff09;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">40102b: e9 d1 ff ff ff\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 jmp 0x401001\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ; \u8df3\u8f6c\u56de .plt \u8d77\u59cb<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u8fd9\u662f .plt[0] \u7684\u5185\u5bb9&#xff0c;\u4f5c\u7528\u662f\u8df3\u8f6c\u5230\u52a8\u6001\u94fe\u63a5\u5668&#xff0c;\u5b8c\u6210\u51fd\u6570\u7684\u5730\u5740\u89e3\u6790\u3002\u8fd9\u662f\u7b2c\u4e00\u6b21\u8c03\u7528\u5171\u4eab\u51fd\u6570\u65f6\u6267\u884c\u7684\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">2. \u540e\u7eed\u6761\u76ee&#xff08;\u4ece 0x401030 \u5f00\u59cb&#xff0c;\u6bcf 16 \u5b57\u8282\u4e00\u7ec4&#xff09;&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">401030: ff 25 e2 2f 00 00\u00a0\u00a0\u00a0\u00a0 jmp *0x2fe2(%rip)\u00a0\u00a0 ; \u95f4\u63a5\u8df3\u8f6c&#xff08;\u901a\u8fc7 GOT&#xff09;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">401036: 68 00 00 00 00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 push $0x0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ; \u51fd\u6570\u7d22\u5f15<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">40103b: e9 d1 ff ff ff\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 jmp 0x401010\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ; \u8df3\u56de plt[0]<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u8fd9\u7c7b\u6761\u76ee\u6784\u6210\u4e86\u5177\u4f53\u51fd\u6570\u7684 PLT \u8c03\u7528\u5165\u53e3&#xff0c;\u5982&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">printf&#064;plt<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">getchar&#064;plt<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">exit&#064;plt<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">sleep&#064;plt<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u8fd9\u4e9b\u8df3\u8f6c\u9996\u5148\u4f1a\u901a\u8fc7 GOT \u9879\u83b7\u53d6\u51fd\u6570\u5730\u5740&#xff0c;\u5982\u679c\u662f\u9996\u6b21\u8c03\u7528\u4f1a\u56de\u5230 .plt[0]&#xff0c;\u8fdb\u5165\u94fe\u63a5\u5668\u89e3\u6790\u5730\u5740\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\n<h3 id=\"5.8%20%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93\" style=\"margin-left:0;margin-right:0;text-align:justify\">5.8 \u672c\u7ae0\u5c0f\u7ed3<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u672c\u7ae0\u901a\u8fc7\u5b9e\u9a8c\u4e2d\u7684 hello \u53ef\u6267\u884c\u7a0b\u5e8f&#xff0c;\u7cfb\u7edf\u6027\u5730\u4ecb\u7ecd\u4e86\u7a0b\u5e8f\u94fe\u63a5\u7684\u57fa\u672c\u6982\u5ff5\u548c\u4e3b\u8981\u4f5c\u7528\u3002\u9996\u5148&#xff0c;\u901a\u8fc7\u5206\u6790 hello \u7a0b\u5e8f\u7684 ELF \u6587\u4ef6\u683c\u5f0f&#xff0c;\u638c\u63e1\u4e86\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u7684\u5404\u4e2a\u6bb5&#xff08;\u5982 .text\u3001.data\u3001.bss \u7b49&#xff09;\u53ca\u5176\u5e03\u5c40\u7279\u5f81&#xff0c;\u5e76\u5bf9\u6bd4\u4e86\u76ee\u6807\u6587\u4ef6 hello.o \u4e0e\u6700\u7ec8\u53ef\u6267\u884c\u6587\u4ef6 hello \u5728\u7ed3\u6784\u4e0a\u7684\u5dee\u5f02&#xff0c;\u52a0\u6df1\u4e86\u5bf9\u94fe\u63a5\u540e\u7a0b\u5e8f\u7ec4\u7ec7\u65b9\u5f0f\u7684\u7406\u89e3\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u63a5\u7740&#xff0c;\u63a2\u8ba8\u4e86 hello \u7a0b\u5e8f\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4\u5206\u5e03&#xff0c;\u660e\u786e\u4e86\u5404\u6bb5\u5728\u5185\u5b58\u4e2d\u7684\u6620\u5c04\u60c5\u51b5&#xff0c;\u4e3a\u7406\u89e3\u7a0b\u5e8f\u52a0\u8f7d\u6267\u884c\u63d0\u4f9b\u4e86\u57fa\u7840\u652f\u6491\u3002\u901a\u8fc7\u5bf9 hello \u548c hello.o \u8fdb\u884c\u53cd\u6c47\u7f16\u5206\u6790&#xff0c;\u8be6\u7ec6\u6bd4\u5bf9\u4e86\u5404\u7b26\u53f7\u7684\u5730\u5740\u4e0e\u8c03\u7528\u8fc7\u7a0b&#xff0c;\u4ece\u800c\u6df1\u5165\u7406\u89e3\u4e86\u94fe\u63a5\u5668\u5728\u91cd\u5b9a\u4f4d\u8fc7\u7a0b\u4e2d\u7684\u5173\u952e\u4f5c\u7528\u548c\u5b9e\u73b0\u673a\u5236\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6b64\u5916&#xff0c;\u5b9e\u9a8c\u4e2d\u8fd8\u5b8c\u6574\u8ddf\u8e2a\u4e86 hello \u7a0b\u5e8f\u7684\u6267\u884c\u6d41\u7a0b&#xff0c;\u6574\u7406\u5e76\u5206\u6790\u4e86\u6267\u884c\u8fc7\u7a0b\u4e2d\u6d89\u53ca\u7684\u5404\u4e2a\u5b50\u51fd\u6570\u8c03\u7528\u53ca\u5176\u5173\u7cfb&#xff0c;\u8fdb\u4e00\u6b65\u52a0\u6df1\u4e86\u5bf9\u7a0b\u5e8f\u6267\u884c\u903b\u8f91\u7684\u638c\u63e1\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6700\u540e&#xff0c;\u901a\u8fc7\u4f7f\u7528 gdb \u548c edb \u7b49\u8c03\u8bd5\u5de5\u5177&#xff0c;\u5bf9 hello \u7a0b\u5e8f\u7684\u52a8\u6001\u94fe\u63a5\u8fc7\u7a0b\u8fdb\u884c\u4e86\u5b9e\u9645\u5206\u6790&#xff0c;\u5bf9\u6bd4\u4e86\u7a0b\u5e8f\u5728\u94fe\u63a5\u524d\u540e .plt \u548c .got \u8868\u7684\u5185\u5bb9\u53d8\u5316&#xff0c;\u5168\u9762\u8ba4\u8bc6\u4e86\u52a8\u6001\u94fe\u63a5\u7684\u5de5\u4f5c\u539f\u7406\u53ca\u5176\u5bf9\u7a0b\u5e8f\u8fd0\u884c\u7684\u5f71\u54cd\u3002\u901a\u8fc7\u672c\u7ae0\u7684\u5b66\u4e60\u4e0e\u5b9e\u9a8c\u64cd\u4f5c&#xff0c;\u5bf9\u7a0b\u5e8f\u94fe\u63a5\u673a\u5236\u6709\u4e86\u66f4\u6df1\u5165\u548c\u7cfb\u7edf\u7684\u7406\u89e3\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<\/p>\n<h2 id=\"%E7%AC%AC6%E7%AB%A0%20hello%E8%BF%9B%E7%A8%8B%E7%AE%A1%E7%90%86\" style=\"margin-left:0;margin-right:0;text-align:center\">\u7b2c6\u7ae0 hello\u8fdb\u7a0b\u7ba1\u7406<\/h2>\n<h3 id=\"6.1%20%E8%BF%9B%E7%A8%8B%E7%9A%84%E6%A6%82%E5%BF%B5%E4%B8%8E%E4%BD%9C%E7%94%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">6.1 \u8fdb\u7a0b\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528<\/h3>\n<h4 id=\"6.1.1%20%E8%BF%9B%E7%A8%8B%E7%9A%84%E6%A6%82%E5%BF%B5\" style=\"margin-left:0;margin-right:0;text-align:justify\">6.1.1 \u8fdb\u7a0b\u7684\u6982\u5ff5<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fdb\u7a0b\u662f\u8ba1\u7b97\u673a\u4e2d\u5df2\u8fd0\u884c\u7a0b\u5e8f\u7684\u4e00\u4e2a\u52a8\u6001\u5b9e\u4f8b&#xff0c;\u662f\u7cfb\u7edf\u8fdb\u884c\u8d44\u6e90\u5206\u914d\u548c\u8c03\u5ea6\u7684\u57fa\u672c\u5355\u4f4d&#xff0c;\u4e5f\u662f\u64cd\u4f5c\u7cfb\u7edf\u7ed3\u6784\u7684\u6838\u5fc3\u7ec4\u6210\u90e8\u5206\u3002\u4f5c\u4e3a\u7a0b\u5e8f\u7684\u57fa\u672c\u6267\u884c\u5b9e\u4f53&#xff0c;\u8fdb\u7a0b\u5728\u5f53\u4ee3\u4ee5\u7ebf\u7a0b\u4e3a\u4e2d\u5fc3\u7684\u8ba1\u7b97\u673a\u4f53\u7cfb\u7ed3\u6784\u4e2d&#xff0c;\u626e\u6f14\u7740\u7ebf\u7a0b\u8fd0\u884c\u73af\u5883\u7684\u5bb9\u5668\u89d2\u8272\u3002\u7b80\u800c\u8a00\u4e4b&#xff0c;\u8fdb\u7a0b\u662f\u7a0b\u5e8f\u5b9e\u9645\u8fd0\u884c\u65f6\u7684\u57fa\u672c\u8f7d\u4f53\u548c\u6267\u884c\u5355\u4f4d\u3002<\/p>\n<h4 id=\"6.1.2%20%E8%BF%9B%E7%A8%8B%E7%9A%84%E4%BD%9C%E7%94%A8\" style=\"margin-left:0;margin-right:0;text-align:justify\">6.1.2 \u8fdb\u7a0b\u7684\u4f5c\u7528<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u73b0\u4ee3\u8ba1\u7b97\u673a\u7cfb\u7edf\u4e2d&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u4e3a\u6bcf\u4e2a\u8fdb\u7a0b\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684\u8fdb\u7a0b\u6807\u8bc6\u7b26&#xff08;PID&#xff09;&#xff0c;\u8fd9\u4f7f\u5f97\u7a0b\u5e8f\u5458\u80fd\u591f\u66f4\u9ad8\u6548\u5730\u8c03\u5ea6\u548c\u7ba1\u7406\u6b63\u5728\u8fd0\u884c\u7684\u7a0b\u5e8f\u53ca\u5176\u6240\u5360\u7528\u7684\u8d44\u6e90\u548c\u6570\u636e\u3002\u540c\u65f6&#xff0c;\u6bcf\u4e2a\u7a0b\u5e8f\u72ec\u5360\u4e00\u4e2a\u8fdb\u7a0b&#xff0c;\u6709\u52a9\u4e8e\u5b9e\u73b0\u8d44\u6e90\u9694\u79bb&#xff0c;\u4ece\u800c\u589e\u5f3a\u5bf9\u7a0b\u5e8f\u5185\u90e8\u6570\u636e\u548c\u72b6\u6001\u7684\u4fdd\u62a4\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7531\u4e8e\u4e00\u4e2aCPU\u6838\u5fc3\u5728\u4efb\u610f\u65f6\u523b\u53ea\u80fd\u6267\u884c\u4e00\u4e2a\u8fdb\u7a0b\u7684\u6307\u4ee4&#xff0c;\u8fd9\u79cd\u6267\u884c\u673a\u5236\u4fc3\u4f7f\u786c\u4ef6\u8d44\u6e90\u5f97\u4ee5\u5408\u7406\u8c03\u5ea6\u548c\u5145\u5206\u5229\u7528\u3002\u8fdb\u7a0b\u4e3a\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u4e24\u4e2a\u5173\u952e\u7684\u62bd\u8c61&#xff1a;\u903b\u8f91\u63a7\u5236\u6d41\u548c\u79c1\u6709\u5730\u5740\u7a7a\u95f4\u3002\u903b\u8f91\u63a7\u5236\u6d41\u4f7f\u5f97\u6bcf\u4e2a\u8fdb\u7a0b\u770b\u8d77\u6765\u50cf\u662f\u72ec\u5360\u5904\u7406\u5668\u5728\u8fd0\u884c&#xff0c;\u800c\u79c1\u6709\u5730\u5740\u7a7a\u95f4\u5219\u786e\u4fdd\u6bcf\u4e2a\u8fdb\u7a0b\u62e5\u6709\u72ec\u7acb\u7684\u5185\u5b58\u533a\u57df&#xff0c;\u4ece\u800c\u907f\u514d\u4e86\u4e0d\u540c\u7a0b\u5e8f\u4e4b\u95f4\u7684\u76f4\u63a5\u5e72\u6270<\/p>\n<h3 id=\"6.2%20%E7%AE%80%E8%BF%B0%E5%A3%B3Shell-bash%E7%9A%84%E4%BD%9C%E7%94%A8%E4%B8%8E%E5%A4%84%E7%90%86%E6%B5%81%E7%A8%8B\" style=\"margin-left:0;margin-right:0;text-align:justify\">6.2 \u7b80\u8ff0\u58f3Shell-bash\u7684\u4f5c\u7528\u4e0e\u5904\u7406\u6d41\u7a0b<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">Shell\u662f\u64cd\u4f5c\u7cfb\u7edf\u6838\u5fc3\u7684\u4ea4\u4e92\u63a5\u53e3&#xff0c;\u627f\u62c5\u547d\u4ee4\u89e3\u91ca\u4e0e\u7cfb\u7edf\u63a7\u5236\u7684\u53cc\u91cd\u804c\u80fd\u3002\u5176\u6838\u5fc3\u4f5c\u7528\u4f53\u73b0\u4e3a&#xff1a;\u4f5c\u4e3a\u7528\u6237\u4e0e\u5185\u6838\u7684\u7ffb\u8bd1\u5c42&#xff0c;\u5c06\u6587\u672c\u6307\u4ee4\u8f6c\u5316\u4e3a\u7cfb\u7edf\u8c03\u7528&#xff1b;\u4f5c\u4e3a\u8fdb\u7a0b\u63a7\u5236\u5668&#xff0c;\u901a\u8fc7\u521b\u5efa\u5b50\u8fdb\u7a0b\u6267\u884c\u5916\u90e8\u7a0b\u5e8f&#xff1b;\u540c\u65f6\u7ba1\u7406\u73af\u5883\u53d8\u91cf\u3001\u5b9e\u73b0\u811a\u672c\u81ea\u52a8\u5316\u3002\u5178\u578b\u5904\u7406\u6d41\u7a0b\u4e3a&#xff1a;\u8bfb\u53d6\u8f93\u5165\u2192\u89e3\u6790\u547d\u4ee4&#xff08;\u8bcd\u6cd5\u5206\u6790\/\u8bed\u6cd5\u6269\u5c55&#xff09;\u2192\u6267\u884c\u6307\u4ee4&#xff08;\u5185\u7f6e\u547d\u4ee4\u76f4\u63a5\u54cd\u5e94&#xff0c;\u5916\u90e8\u547d\u4ee4\u901a\u8fc7fork-exec\u673a\u5236\u542f\u52a8\u5b50\u8fdb\u7a0b&#xff09;\u2192\u53cd\u9988\u7ed3\u679c\u5e76\u5faa\u73af\u7b49\u5f85\u3002\u8fd9\u79cd\u673a\u5236\u65e2\u4fdd\u8bc1\u4e86\u7cfb\u7edf\u64cd\u4f5c\u7684\u9ad8\u6548\u6027&#xff0c;\u53c8\u901a\u8fc7\u8fdb\u7a0b\u9694\u79bb\u7ef4\u62a4\u4e86\u7cfb\u7edf\u7a33\u5b9a\u6027&#xff0c;\u6210\u4e3aUNIX\/Linux\u7cfb\u7edf\u8fd0\u7ef4\u7684\u6838\u5fc3\u5de5\u5177\u3002<\/p>\n<h3 id=\"6.3%20Hello%E7%9A%84fork%E8%BF%9B%E7%A8%8B%E5%88%9B%E5%BB%BA%E8%BF%87%E7%A8%8B\" style=\"margin-left:0;margin-right:0;text-align:justify\">6.3 Hello\u7684fork\u8fdb\u7a0b\u521b\u5efa\u8fc7\u7a0b<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8f93\u5165\u5408\u6cd5\u547d\u4ee4&#xff0c;\u5982.\/hello 2023112915 \u6768\u6615\u5f66 15682227797 2&#xff0c;\u89e3\u6790\u540e\u5224\u65ad\u4e3a\u6267\u884c\u7a0b\u5e8f&#xff0c;\u7236\u8fdb\u7a0b\u5c31\u901a\u8fc7fork\u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8fd0\u884c\u7684\u5b50\u8fdb\u7a0b&#xff1b;\u5b50\u8fdb\u7a0b\u5f97\u5230\u4e0e\u7236\u8fdb\u7a0b\u7528\u6237\u7ea7\u865a\u62df\u5730\u5740\u7a7a\u95f4\u76f8\u540c\u7684\u4e00\u4efd\u526f\u672c&#xff0c;\u5305\u62ec\u4ee3\u7801\u6bb5\u3001\u6570\u636e\u6bb5\u3001\u5806\u3001\u5171\u4eab\u5e93\u548c\u7528\u6237\u6808\u3002\u5b50\u8fdb\u7a0b\u4e2d&#xff0c;fork\u8fd4\u56de0&#xff0c;\u7236\u8fdb\u7a0b\u4e2d&#xff0c;\u8fd4\u56de\u5b50\u8fdb\u7a0b\u7684PID&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"69\" src=\"2025-06-10iqnsp34xzd5.png\" width=\"578\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe52 \u8fd0\u884c\u7ed3\u679c<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728UNIX\/Linux\u8fdb\u7a0b\u590d\u5236\u673a\u5236\u4e2d&#xff0c;fork()\u7cfb\u7edf\u8c03\u7528\u521b\u5efa\u7684\u5b50\u8fdb\u7a0b\u901a\u8fc7\u5199\u65f6\u590d\u5236&#xff08;Copy-on-Write&#xff09;\u6280\u672f\u751f\u6210\u8fd1\u4e4e\u5b8c\u6574\u7684\u7236\u8fdb\u7a0b\u526f\u672c\u3002\u5176\u6838\u5fc3\u7279\u5f81\u8868\u73b0\u4e3a&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5730\u5740\u7a7a\u95f4\u955c\u50cf&#xff1a;\u5b50\u8fdb\u7a0b\u7ee7\u627f\u7236\u8fdb\u7a0b\u865a\u62df\u5185\u5b58\u7a7a\u95f4\u7684\u7cbe\u786e\u62f7\u8d1d&#xff08;\u4ee3\u7801\u6bb5\/\u6570\u636e\u6bb5\/\u5806\u6808\u7b49&#xff09;&#xff0c;\u901a\u8fc7COW\u673a\u5236\u5b9e\u73b0\u7269\u7406\u5185\u5b58\u7684\u9ad8\u6548\u590d\u7528<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8d44\u6e90\u7ee7\u627f\u6027&#xff1a;\u5b8c\u6574\u590d\u5236\u7236\u8fdb\u7a0b\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u8868\u3001\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f\u53ca\u6267\u884c\u4e0a\u4e0b\u6587\u73af\u5883<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5dee\u5f02\u5316\u6807\u8bc6&#xff1a;\u72ec\u7acb\u5206\u914d\u7684\u8fdb\u7a0b\u6807\u8bc6\u7b26&#xff08;PID&#xff09;\u3001\u7236\u8fdb\u7a0b\u6807\u8bc6\u7b26&#xff08;PPID&#xff09;\u6307\u5411\u539f\u8fdb\u7a0b\u3001\u91cd\u7f6e\u8d44\u6e90\u4f7f\u7528\u7edf\u8ba1&#xff08;CPU\u65f6\u95f4\/\u6587\u4ef6\u9501\u7b49&#xff09;\u3001\u6e05\u9664\u672a\u51b3\u4fe1\u53f7\u4e0e\u5b9a\u65f6\u5668\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"353\" src=\"2025-06-10f54ecjx5onf.png\" width=\"293\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe53 \u5185\u5b58\u7a7a\u95f4\u793a\u610f\u56fe<\/p>\n<h3 id=\"6.4%20Hello%E7%9A%84execve%E8%BF%87%E7%A8%8B\" style=\"margin-left:0;margin-right:0;text-align:justify\">6.4 Hello\u7684execve\u8fc7\u7a0b<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728fork\u521b\u5efa\u5b50\u8fdb\u7a0b\u540e&#xff0c;execve\u7cfb\u7edf\u8c03\u7528\u89e6\u53d1\u8fdb\u7a0b\u6620\u50cf\u91cd\u6784&#xff1a;\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">1. \u5730\u5740\u7a7a\u95f4\u91cd\u7f6e<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0 \u6e05\u7a7a\u539f\u8fdb\u7a0b\u865a\u62df\u5185\u5b58\u7a7a\u95f4\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0 \u6839\u636ehello\u7684ELF\u6587\u4ef6\u7ed3\u6784&#xff0c;\u91cd\u6784\u4ee3\u7801\u6bb5\u3001\u6570\u636e\u6bb5\u3001\u5806\u6808\u53ca\u5185\u5b58\u6620\u5c04\u533a\u57df\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0 \u4fdd\u7559\u539f\u8fdb\u7a0b\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u8868\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">2. \u7a0b\u5e8f\u88c5\u8f7d\u9636\u6bb5*<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0 \u89e3\u6790hello\u53ef\u6267\u884c\u6587\u4ef6\u7684\u7a0b\u5e8f\u5934\u90e8\u8868\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0 \u5c06.text&#xff08;\u4ee3\u7801\u6bb5&#xff09;\u3001.data&#xff08;\u521d\u59cb\u5316\u6570\u636e\u6bb5&#xff09;\u8f7d\u5165\u5185\u5b58\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0 \u5efa\u7acb\u8fd0\u884c\u65f6\u5806&#xff08;heap&#xff09;\u548c\u7528\u6237\u6808&#xff08;stack&#xff09;\u7ed3\u6784\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">3. \u6267\u884c\u63a7\u5236\u8f6c\u79fb\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0 \u52a8\u6001\u94fe\u63a5\u5668&#xff08;ld.so&#xff09;\u5b8c\u6210\u5171\u4eab\u5e93\u52a0\u8f7d&#xff08;\u82e5\u9700&#xff09;\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0 \u91cd\u7f6e\u5bc4\u5b58\u5668\u72b6\u6001&#xff0c;\u5c06\u7a0b\u5e8f\u8ba1\u6570\u5668&#xff08;EIP\/RIP&#xff09;\u6307\u5411\u5165\u53e3\u70b9&#096;_start&#096;\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0 \u901a\u8fc7&#096;_start\u2192__libc_start_main\u2192main&#096;\u8c03\u7528\u94fe\u542f\u52a8\u7528\u6237\u7a0b\u5e8f\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8be5\u8fc7\u7a0b\u901a\u8fc7\u5185\u6838\u6001\u5230\u7528\u6237\u6001\u7684\u5207\u6362&#xff0c;\u5b9e\u73b0\u8fdb\u7a0b\u6267\u884c\u6d41\u7684\u65e0\u7f1d\u8f6c\u6362\u3002execve\u6210\u529f\u6267\u884c\u540e&#xff0c;\u539f\u8fdb\u7a0b\u4e0a\u4e0b\u6587\u88ab\u5b8c\u5168\u66ff\u6362&#xff0c;\u4ec5\u4fdd\u7559PID\u548c\u6587\u4ef6\u8d44\u6e90&#xff0c;\u5f62\u6210\u72ec\u7acb\u7684\u65b0\u6267\u884c\u73af\u5883\u3002\u6574\u4e2a\u52a0\u8f7d\u8fc7\u7a0b\u901a\u8fc7\u5185\u5b58\u6620\u5c04\u6280\u672f\u5b9e\u73b0\u7269\u7406\u5185\u5b58\u7684\u6309\u9700\u5206\u914d&#xff0c;\u4fdd\u8bc1\u6267\u884c\u6548\u7387\u3002<\/p>\n<h3 id=\"6.5%20Hello%E7%9A%84%E8%BF%9B%E7%A8%8B%E6%89%A7%E8%A1%8C\" style=\"margin-left:0;margin-right:0;text-align:justify\">6.5 Hello\u7684\u8fdb\u7a0b\u6267\u884c<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u7a0b\u5e8f\u6267\u884c\u671f\u95f4&#xff0c;Shell\u4e3a\u201chello\u201d\u8fdb\u7a0b\u521b\u5efa\u4e86\u4e00\u4e2a\u5b50\u8fdb\u7a0b&#xff0c;\u8be5\u5b50\u8fdb\u7a0b\u5177\u6709\u72ec\u7acb\u7684\u63a7\u5236\u6d41\u3002\u5728\u201chello\u201d\u8fdb\u7a0b\u7684\u8fd0\u884c\u8fc7\u7a0b\u4e2d&#xff0c;\u5982\u679c\u672a\u53d7\u5230\u5916\u90e8\u62a2\u5360&#xff0c;\u5219\u7ee7\u7eed\u6b63\u5e38\u6267\u884c&#xff1b;\u82e5\u88ab\u62a2\u5360&#xff0c;\u5219\u4f1a\u8fdb\u5165\u5185\u6838\u6a21\u5f0f&#xff0c;\u8fdb\u884c\u4e0a\u4e0b\u6587\u5207\u6362&#xff0c;\u5e76\u8fd4\u56de\u7528\u6237\u6a21\u5f0f&#xff0c;\u8c03\u5ea6\u5176\u4ed6\u8fdb\u7a0b\u3002\u5f53\u201chello\u201d\u8c03\u7528sleep\u7cfb\u7edf\u8c03\u7528\u65f6&#xff0c;\u4e3a\u4e86\u6700\u5927\u5316\u5904\u7406\u5668\u8d44\u6e90\u7684\u5229\u7528\u7387&#xff0c;\u7cfb\u7edf\u4f1a\u5c06\u201chello\u201d\u8fdb\u7a0b\u6302\u8d77&#xff0c;\u6267\u884c\u4e0a\u4e0b\u6587\u5207\u6362\u8fdb\u5165\u5185\u6838\u6a21\u5f0f&#xff0c;\u5c06\u5176\u72b6\u6001\u8f6c\u5165\u7b49\u5f85\u961f\u5217&#xff0c;\u540c\u65f6\u542f\u52a8\u5b9a\u65f6\u5668\u3002\u5f53\u5b9a\u65f6\u5668\u5230\u671f\u540e&#xff0c;sleep\u51fd\u6570\u8fd4\u56de&#xff0c;\u89e6\u53d1\u76f8\u5e94\u4e2d\u65ad&#xff0c;\u4fc3\u4f7f\u201chello\u201d\u8fdb\u7a0b\u88ab\u91cd\u65b0\u8c03\u5ea6&#xff0c;\u79fb\u51fa\u7b49\u5f85\u961f\u5217&#xff0c;\u5207\u6362\u56de\u7528\u6237\u6a21\u5f0f&#xff0c;\u4ece\u800c\u7ee7\u7eed\u6267\u884c\u5176\u5269\u4f59\u7684\u63a7\u5236\u6d41\u3002\u8fd9\u4e00\u673a\u5236\u6709\u6548\u5b9e\u73b0\u4e86\u8fdb\u7a0b\u7684\u6302\u8d77\u4e0e\u5524\u9192&#xff0c;\u786e\u4fdd\u4e86\u7cfb\u7edf\u7684\u8c03\u5ea6\u6548\u7387\u4e0e\u8d44\u6e90\u5229\u7528\u7684\u4f18\u5316<\/p>\n<h3 id=\"6.6%20hello%E7%9A%84%E5%BC%82%E5%B8%B8%E4%B8%8E%E4%BF%A1%E5%8F%B7%E5%A4%84%E7%90%86\" style=\"margin-left:0;margin-right:0;text-align:justify\">6.6 hello\u7684\u5f02\u5e38\u4e0e\u4fe1\u53f7\u5904\u7406<\/h3>\n<h4 id=\"6.6.1%20%E5%BC%82%E5%B8%B8%E7%9A%84%E7%B1%BB%E5%9E%8B\" style=\"margin-left:0;margin-right:0;text-align:justify\">6.6.1 \u5f02\u5e38\u7684\u7c7b\u578b<\/h4>\n<table align=\"center\" border=\"1\" cellspacing=\"0\" style=\"width:100.0%\">\n<tbody>\n<tr>\n<td style=\"border-color:black;vertical-align:top;width:10.12%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7c7b\u522b<\/p>\n<\/td>\n<td style=\"border-color:black;vertical-align:top;width:33.9%\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u539f\u56e0<\/p>\n<\/td>\n<td style=\"border-color:black;vertical-align:top;width:18.04%\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u5f02\u6b65\/\u540c\u6b65<\/p>\n<\/td>\n<td style=\"border-color:black;vertical-align:top;width:37.96%\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u8fd4\u56de\u884c\u4e3a<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border-color:black;vertical-align:top;width:10.12%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4e2d\u65ad<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:33.9%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6765\u81eaI\/O\u8bbe\u5907\u7684\u4fe1\u53f7<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:18.04%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f02\u6b65<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:37.96%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u603b\u662f\u8fd4\u56de\u5230\u4e0b\u4e00\u6761\u6307\u4ee4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border-color:black;vertical-align:top;width:10.12%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u9677\u9631<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:33.9%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6709\u610f\u7684\u5f02\u5e38<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:18.04%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u540c\u6b65<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:37.96%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u603b\u662f\u8fd4\u56de\u5230\u4e0b\u4e00\u6761\u6307\u4ee4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border-color:black;vertical-align:top;width:10.12%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6545\u969c<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:33.9%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6f5c\u5728\u53ef\u6062\u590d\u7684\u9519\u8bef<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:18.04%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u540c\u6b65<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:37.96%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u53ef\u80fd\u8fd4\u56de\u5230\u5f53\u524d\u6307\u4ee4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border-color:black;vertical-align:top;width:10.12%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7ec8\u6b62<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:33.9%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4e0d\u53ef\u6062\u590d\u7684\u9519\u8bef<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:18.04%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u540c\u6b65<\/p>\n<\/td>\n<td style=\"vertical-align:top;width:37.96%\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4e0d\u4f1a\u8fd4\u56de<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"6.6.2%20%E5%BC%82%E5%B8%B8%E7%9A%84%E5%A4%84%E7%90%86%E6%96%B9%E5%BC%8F\" style=\"margin-left:0;margin-right:0;text-align:justify\">6.6.2 \u5f02\u5e38\u7684\u5904\u7406\u65b9\u5f0f<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"113\" src=\"2025-06-10z1w1ol52idk.png\" width=\"347\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe54 \u4e2d\u65ad\u5904\u7406\u65b9\u5f0f<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"118\" src=\"2025-06-10dvy0ppovexf.png\" width=\"353\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe55 \u9677\u9631\u5904\u7406\u65b9\u5f0f<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"114\" src=\"2025-06-10ucehzvjqoax.png\" width=\"369\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe56 \u6545\u969c\u5904\u7406\u65b9\u5f0f<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"121\" src=\"2025-06-10psfmj2wdzjo.png\" width=\"345\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe57 \u7ec8\u6b62\u5904\u7406\u65b9\u5f0f<\/p>\n<li style=\"text-align:left\">Ctrl&#043;Z&#xff1a;\u6309\u4e0bCrtl&#043;Z&#xff0c;\u8fdb\u7a0b\u6536\u5230SIGSTP\u4fe1\u53f7&#xff0c;hello\u8fdb\u7a0b\u6302\u8d77\u5e76\u5411\u7236\u8fdb\u7a0b\u53d1\u9001SIGCHLD\u3002<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"101\" src=\"2025-06-10ir3cz0vtlk4.png\" width=\"539\" \/><\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe58 Ctrl&#043;Z<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u8fd0\u884cps\u547d\u4ee4\u67e5\u770b\u8fdb\u7a0b\u8fd0\u884c\u72b6\u6001\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"125\" src=\"2025-06-10hri0viovtye.png\" width=\"300\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe59ps\u67e5\u770b\u8fdb\u7a0b\u8fd0\u884c\u72b6\u6001<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fd0\u884cjobs\u547d\u4ee4&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u53ef\u4ee5\u770b\u5230\u505c\u6b62\u7684\u4f5c\u4e1a&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"70\" src=\"2025-06-10y4q2xfsq00w.png\" width=\"499\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe60 jobs\u770b\u505c\u6b62\u7684\u4f5c\u4e1a<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">pstree\u00a0\u662f\u4e00\u4e2a Linux\/Unix \u7cfb\u7edf\u5de5\u5177&#xff0c;\u7528\u4e8e\u4ee5\u6811\u72b6\u62d3\u6251\u56fe\u76f4\u89c2\u5c55\u793a\u7cfb\u7edf\u4e2d\u6240\u6709\u8fdb\u7a0b\u95f4\u7684\u7236\u5b50\u5173\u7cfb\u3002\u5176\u6838\u5fc3\u529f\u80fd\u4e0e\u7528\u6cd5\u5982\u4e0b&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fdb\u7a0b\u53ef\u89c6\u5316<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5c06\u8fdb\u7a0b\u6309\u5c42\u7ea7\u5173\u7cfb\u663e\u793a\u4e3a\u6811\u5f62\u7ed3\u6784&#xff0c;\u6839\u8282\u70b9\u4e3a\u7cfb\u7edf\u521d\u59cb\u8fdb\u7a0b&#xff08;\u5982\u00a0systemd\u00a0\u6216\u00a0init&#xff09;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5206\u652f\u8282\u70b9\u8868\u793a\u6d3e\u751f\u5173\u7cfb&#xff0c;\u4f8b\u5982&#xff1a;sshd \u2192 bash \u2192 vim<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5173\u952e\u4fe1\u606f\u6807\u6ce8<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u9ed8\u8ba4\u9690\u85cf\u7ebf\u7a0b&#xff08;\u53ef\u901a\u8fc7\u00a0-T\u00a0\u663e\u793a\u7ebf\u7a0b&#xff09;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fdb\u7a0b\u540d\u65c1\u6807\u6ce8\u8fdb\u7a0b\u53f7&#xff08;PID&#xff0c;\u9700\u00a0-p\u00a0\u53c2\u6570&#xff09;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u9ad8\u4eae\u5f53\u524d\u7ec8\u7aef\u5173\u8054\u7684\u8fdb\u7a0b\u6811&#xff08;-h&#xff09;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"353\" src=\"2025-06-10rqcfzqdahgd.png\" width=\"362\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe61 Pstree:\u663e\u793a\u6240\u6709\u8fd0\u884c\u4e2d\u7684\u8fdb\u7a0b\u7684\u6811\u72b6\u56fe<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<li style=\"text-align:justify\">Ctrl&#043;C&#xff1a;\u8fdb\u7a0b\u6536\u5230 SIGINT \u4fe1\u53f7&#xff0c;\u7ed3\u675f hello\u3002\u5728ps\u4e2d\u67e5\u8be2\u4e0d\u5230\u5176PID&#xff0c;\u5728job\u4e2d\u4e5f\u6ca1\u6709\u663e\u793a&#xff0c;\u53ef\u4ee5\u770b\u51fahello\u5df2\u7ecf\u88ab\u5f7b\u5e95\u7ed3\u675f\u3002<\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"80\" src=\"2025-06-10slrdlsnhuk2.png\" width=\"530\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe62 ctrl&#043;c<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"193\" src=\"2025-06-10h2hv1xh1wpt.png\" width=\"549\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe63 ps\u4e0ejobs\u7684\u8fd0\u884c\u7ed3\u679c<\/p>\n<li style=\"text-align:justify\">\u4e2d\u9014\u4e71\u6309&#xff1a;\u53ea\u662f\u5c06\u5c4f\u5e55\u7684\u8f93\u5165\u7f13\u5b58\u5230\u7f13\u51b2\u533a\u3002\u4e71\u7801\u88ab\u8ba4\u4e3a\u662f\u547d\u4ee4\u3002<\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"149\" src=\"2025-06-10m2si4u1zg1v.png\" width=\"601\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe64 \u4e2d\u9014\u4e71\u6309\u7684\u7ed3\u679c<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">4&#xff09;Kill\u547d\u4ee4&#xff1a;\u6302\u8d77\u7684\u8fdb\u7a0b\u88ab\u7ec8\u6b62&#xff0c;\u5728ps\u4e2d\u65e0\u6cd5\u67e5\u5230\u5230\u5176PID\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"176\" src=\"2025-06-105dlbp2iocfo.png\" width=\"513\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe65 kill\u6307\u4ee4\u7684\u4f5c\u7528<\/p>\n<h3 id=\"\" style=\"margin-left:0;margin-right:0;text-align:justify\"><\/h3>\n<h3 id=\"6.7%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93\" style=\"margin-left:0;margin-right:0;text-align:justify\">6.7\u672c\u7ae0\u5c0f\u7ed3<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u672c\u7ae0\u7cfb\u7edf\u9610\u8ff0\u4e86\u64cd\u4f5c\u7cfb\u7edf\u8fdb\u7a0b\u7684\u6838\u5fc3\u6982\u5ff5\u4e0e\u8fd0\u884c\u673a\u5236&#xff0c;\u91cd\u70b9\u5256\u6790\u4e86Shell\u4f5c\u4e3a\u7528\u6237-\u5185\u6838\u4ea4\u4e92\u4e2d\u4ecb\u7684\u5173\u952e\u4f5c\u7528\u3002\u901a\u8fc7hello\u53ef\u6267\u884c\u7a0b\u5e8f\u5b9e\u4f8b&#xff0c;\u6df1\u5ea6\u89e3\u6790\u4e86\u8fdb\u7a0b\u521b\u5efa\u53cc\u9636\u6bb5\u6a21\u578b&#xff1a;fork() \u91c7\u7528\u5199\u65f6\u590d\u5236\u6280\u672f\u514b\u9686\u7236\u8fdb\u7a0b\u4e0a\u4e0b\u6587&#xff0c;\u751f\u6210\u72ec\u7acbPID\u7684\u5b50\u8fdb\u7a0b&#xff1b; execve()\u901a\u8fc7\u6e05\u7a7a\u5730\u5740\u7a7a\u95f4\u3001\u52a0\u8f7dELF\u6587\u4ef6\u7ed3\u6784\u3001\u91cd\u6784\u4ee3\u7801\/\u6570\u636e\/\u5806\u6808\u6bb5&#xff0c;\u5b9e\u73b0\u8fdb\u7a0b\u6620\u50cf\u7684\u539f\u5b50\u7ea7\u66ff\u6362\u3002\u5b9e\u9a8c\u73af\u8282\u7ed3\u5408\u547d\u4ee4\u884c\u53c2\u6570\u4f20\u9012\u573a\u666f&#xff0c;\u9a8c\u8bc1\u4e86\u4fe1\u53f7\u5904\u7406\u673a\u5236\u5bf9SIGINT&#xff08;Ctrl&#043;C&#xff09;\u3001SIGSEGV\u7b49\u5f02\u5e38\u4e8b\u4ef6\u7684\u6355\u83b7\u4e0e\u54cd\u5e94\u7b56\u7565&#xff0c;\u63ed\u793a\u4e86\u8fdb\u7a0b\u6267\u884c\u6d41\u4e2d\u65ad\u540e\u7684\u8d44\u6e90\u56de\u6536\u4e0e\u72b6\u6001\u56de\u4f20\u539f\u7406\u3002\u8be5\u7814\u7a76\u5b8c\u6574\u5448\u73b0\u4e86\u4ece\u8fdb\u7a0b\u5b75\u5316\u3001\u7a0b\u5e8f\u52a0\u8f7d\u5230\u6267\u884c\u76d1\u63a7\u7684\u5168\u94fe\u8def\u6280\u672f\u7ec6\u8282&#xff0c;\u4e3a\u7406\u89e3UNIX\u7cfb\u7edf\u7ea7\u7f16\u7a0b\u5960\u5b9a\u4e86\u7406\u8bba\u4e0e\u5b9e\u8df5\u57fa\u7840\u3002<\/p>\n<h3 id=\"%E7%AC%AC7%E7%AB%A0%20hello%E7%9A%84%E5%AD%98%E5%82%A8%E7%AE%A1%E7%90%86\" style=\"margin-left:0;margin-right:0;text-align:justify\"> \u7b2c7\u7ae0 hello\u7684\u5b58\u50a8\u7ba1\u7406<\/h3>\n<h3 id=\"7.1%20hello%E7%9A%84%E5%AD%98%E5%82%A8%E5%99%A8%E5%9C%B0%E5%9D%80%E7%A9%BA%E9%97%B4\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.1 hello\u7684\u5b58\u50a8\u5668\u5730\u5740\u7a7a\u95f4<\/h3>\n<li style=\"text-align:justify\"> \u903b\u8f91\u5730\u5740 <\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5b9a\u4e49&#xff1a;\u7a0b\u5e8f\u7f16\u8bd1\u671f\u751f\u6210\u7684\u6bb5\u5185\u504f\u79fb\u91cf&#xff0c;\u5728x86\u67b6\u6784\u4e2d\u8868\u73b0\u4e3a\u6bb5\u9009\u62e9\u7b26:\u504f\u79fb\u91cf&#096;\u4e8c\u5143\u7ec4&#xff08;\u5982 CS:EIP&#xff09;\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5b9e\u4f8b\u7279\u5f81&#xff1a;\u5728&#096;hello.asm&#096;\u53cd\u6c47\u7f16\u4ee3\u7801\u4e2d\u4f53\u73b0\u4e3a\u4ee3\u7801\/\u6570\u636e\u7684\u76f8\u5bf9\u504f\u79fb&#xff08;\u5982 &#096;0x4004e0&#096;&#xff09;\u00a0<\/p>\n<li style=\"text-align:justify\">\u7ebf\u6027\u5730\u5740<\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8f6c\u6362\u673a\u5236&#xff1a;\u903b\u8f91\u5730\u5740\u7ecfCPU\u6bb5\u5f0f\u7ba1\u7406\u5355\u5143&#xff08;Segment Unit&#xff09;\u8f6c\u6362\u540e\u7684\u8fde\u7eed\u5730\u5740\u7a7a\u95f4\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5206\u9875\u9884\u5904\u7406&#xff1a;\u4f5c\u4e3a\u5206\u9875\u673a\u5236\u7684\u8f93\u5165\u5730\u5740&#xff0c;\u63cf\u8ff0\u7a0b\u5e8f\u89c6\u89d2\u7684\u8fde\u7eed\u865a\u62df\u5185\u5b58\u5e03\u5c40\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u793a\u4f8b\u6620\u5c04&#xff1a; hello\u7a0b\u5e8f\u7684\u4ee3\u7801\u6bb5\/\u6570\u636e\u6bb5\u5728\u865a\u62df\u5185\u5b58\u4e2d\u7684\u7ebf\u6027\u6392\u5e03\u00a0<\/p>\n<li style=\"text-align:justify\">\u865a\u62df\u5730\u5740<\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4f53\u7cfb\u7ed3\u6784\u7279\u6027&#xff1a;\u5728x86\u4fdd\u62a4\u6a21\u5f0f\u4e0b\u7b49\u540c\u4e8e\u7ebf\u6027\u5730\u5740&#xff08;\u6bb5\u5f0f\u7ba1\u7406\u88ab\u6241\u5e73\u5316&#xff09;\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fdb\u7a0b\u9694\u79bb\u6027&#xff1a;\u6bcf\u4e2a\u8fdb\u7a0b\u72ec\u5360\u72ec\u7acb\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4&#xff08;\u5982hello\u8fdb\u7a0b\u76840x400000\u8d77\u59cb\u4ee3\u7801\u533a&#xff09;\u00a0<\/p>\n<li style=\"text-align:justify\">\u7269\u7406\u5730\u5740<\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u786c\u4ef6\u5bfb\u5740&#xff1a;\u7ecfMMU\u5355\u5143\u901a\u8fc7\u9875\u8868&#xff08;Page Table&#xff09;&#043; TLB\u7f13\u5b58\u8f6c\u6362\u540e&#xff0c;\u8f93\u51fa\u81f3\u5730\u5740\u603b\u7ebf\u7684\u7535\u4fe1\u53f7\u7f16\u7801\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5b9e\u9645\u6620\u5c04&#xff1a;\u5bf9\u5e94DRAM\u82af\u7247\u4e0a\u7684\u7269\u7406\u5b58\u50a8\u5355\u5143&#xff0c;\u5982&#096;hello&#096;\u7a0b\u5e8f\u6307\u4ee4\u6700\u7ec8\u52a0\u8f7d\u7684\u5185\u5b58\u6761\u9897\u7c92\u4f4d\u7f6e\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u52a8\u6001\u6027&#xff1a;\u540c\u4e00\u865a\u62df\u5730\u5740\u5728\u4e0d\u540c\u65f6\u523b\u53ef\u80fd\u6620\u5c04\u5230\u4e0d\u540c\u7269\u7406\u5730\u5740&#xff08;\u5982\u8fdb\u7a0b\u4e0a\u4e0b\u6587\u5207\u6362\u65f6&#xff09;\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8be5\u591a\u7ea7\u6620\u5c04\u4f53\u7cfb\u901a\u8fc7\u6bb5\u9875\u5f0f\u7ba1\u7406&#xff08;Segmentation &#043; Paging&#xff09;\u5b9e\u73b0\u4e86\u5185\u5b58\u5b89\u5168\u9694\u79bb\u4e0e\u7269\u7406\u8d44\u6e90\u52a8\u6001\u5206\u914d&#xff0c;\u4fdd\u969c\u4e86hello\u7b49\u8fdb\u7a0b\u7684\u9ad8\u6548\u53ef\u9760\u8fd0\u884c\u3002\u5730\u5740\u8f6c\u6362\u8fc7\u7a0b\u6d89\u53caCPU\u786c\u4ef6&#xff08;MMU&#xff09;\u3001\u64cd\u4f5c\u7cfb\u7edf&#xff08;\u9875\u8868\u7ef4\u62a4&#xff09;\u53ca\u7f16\u8bd1\u5668&#xff08;\u6bb5\u63cf\u8ff0\u7b26\u751f\u6210&#xff09;\u7684\u534f\u540c\u5de5\u4f5c\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h3 id=\"7.2%20Intel%E9%80%BB%E8%BE%91%E5%9C%B0%E5%9D%80%E5%88%B0%E7%BA%BF%E6%80%A7%E5%9C%B0%E5%9D%80%E7%9A%84%E5%8F%98%E6%8D%A2-%E6%AE%B5%E5%BC%8F%E7%AE%A1%E7%90%86\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.2 Intel\u903b\u8f91\u5730\u5740\u5230\u7ebf\u6027\u5730\u5740\u7684\u53d8\u6362-\u6bb5\u5f0f\u7ba1\u7406<\/h3>\n<h4 id=\"%C2%A0%C2%A0%C2%A0%207.2.1%E6%AE%B5%E6%8F%8F%E8%BF%B0%E4%B8%8E%E6%AE%B5%E9%80%89%E6%8B%A9%E7%AC%A6\" style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0 7.2.1\u6bb5\u63cf\u8ff0\u4e0e\u6bb5\u9009\u62e9\u7b26<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u4fdd\u62a4\u6a21\u5f0f\u4e2d&#xff0c;\u6bb5\u7684\u76f8\u5173\u4fe1\u606f&#xff08;\u5982\u6bb5\u57fa\u5730\u5740\u3001\u6bb5\u754c\u9650\u3001\u8bbf\u95ee\u6743\u9650\u7b49&#xff09;\u88ab\u5c01\u88c5\u5728\u6bb5\u63cf\u8ff0\u7b26\u4e2d&#xff0c;\u6bcf\u4e2a\u6bb5\u63cf\u8ff0\u7b26\u5360\u7528 8 \u4e2a\u5b57\u8282\u3002\u7531\u4e8e\u6bb5\u5bc4\u5b58\u5668\u4ec5\u6709 16 \u4f4d&#xff0c;\u65e0\u6cd5\u76f4\u63a5\u5b58\u50a8\u5b8c\u6574\u7684\u6bb5\u63cf\u8ff0\u7b26\u4fe1\u606f&#xff0c;\u56e0\u6b64 Intel \u8bbe\u8ba1\u4e86\u5168\u5c40\u63cf\u8ff0\u7b26\u8868&#xff08;GDT&#xff09;\u548c\u5c40\u90e8\u63cf\u8ff0\u7b26\u8868&#xff08;LDT&#xff09;\u6765\u96c6\u4e2d\u5b58\u653e\u6bb5\u63cf\u8ff0\u7b26\u3002\u6bb5\u5bc4\u5b58\u5668\u4e2d\u5b58\u50a8\u7684\u662f\u6bb5\u9009\u62e9\u7b26&#xff08;Segment Selector&#xff09;&#xff0c;\u7528\u4e8e\u7d22\u5f15 GDT \u6216 LDT \u4e2d\u7684\u6bb5\u63cf\u8ff0\u7b26\u3002\u6bb5\u9009\u62e9\u7b26\u7684\u7ed3\u6784\u5982\u4e0b&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"65\" src=\"2025-06-10io3vgyvc1yt.png\" width=\"262\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe66 kill\u6bb5\u9009\u62e9\u7b26\u7684\u7ed3\u6784<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u9ad8 13 \u4f4d&#xff1a;\u63cf\u8ff0\u7b26\u7d22\u5f15&#xff08;Index&#xff09;&#xff0c;\u6307\u793a\u6bb5\u63cf\u8ff0\u7b26\u5728 GDT \u6216 LDT \u4e2d\u7684\u4f4d\u7f6e\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7b2c 2 \u4f4d&#xff08;TI&#xff09;&#xff1a;\u8868\u6307\u793a\u7b26&#xff08;Table Indicator&#xff09;&#xff0c;0 \u8868\u793a GDT&#xff0c;1 \u8868\u793a LDT\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4f4e 2 \u4f4d&#xff08;RPL&#xff09;&#xff1a;\u8bf7\u6c42\u7279\u6743\u7ea7&#xff08;Requested Privilege Level&#xff09;&#xff0c;\u7528\u4e8e\u6743\u9650\u68c0\u67e5\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f53\u4e00\u4e2a\u65b0\u7684\u6bb5\u9009\u62e9\u7b26\u88ab\u52a0\u8f7d\u5230\u6bb5\u5bc4\u5b58\u5668\u4e2d\u65f6&#xff0c;\u5904\u7406\u5668\u4f1a\u6839\u636e\u6bb5\u9009\u62e9\u7b26\u7684\u7d22\u5f15\u548c\u8868\u6307\u793a\u7b26&#xff0c;\u4ece GDT \u6216 LDT \u4e2d\u83b7\u53d6\u5bf9\u5e94\u7684\u6bb5\u63cf\u8ff0\u7b26&#xff0c;\u5e76\u5c06\u5176\u52a0\u8f7d\u5230\u6bb5\u5bc4\u5b58\u5668\u7684\u9690\u85cf\u90e8\u5206&#xff08;\u63cf\u8ff0\u7b26\u7f13\u5b58&#xff09;\u4e2d\u3002\u8fd9\u6837&#xff0c;\u5728\u540e\u7eed\u7684\u5185\u5b58\u8bbf\u95ee\u4e2d&#xff0c;\u5904\u7406\u5668\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u7f13\u5b58\u7684\u6bb5\u63cf\u8ff0\u7b26\u4fe1\u606f&#xff0c;\u65e0\u9700\u518d\u6b21\u8bbf\u95ee\u5185\u5b58\u4e2d\u7684\u63cf\u8ff0\u7b26\u8868&#xff0c;\u4ece\u800c\u63d0\u9ad8\u4e86\u8bbf\u95ee\u6548\u7387\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h4 id=\"%C2%A0%C2%A0%207.2.2%E9%80%BB%E8%BE%91%E5%9C%B0%E5%9D%80%E5%88%B0%E7%BA%BF%E6%80%A7%E5%9C%B0%E5%9D%80%E7%9A%84%E8%BD%AC%E6%8D%A2%E8%BF%87%E7%A8%8B\" style=\"margin-left:0;margin-right:0;text-align:justify\">\u00a0\u00a0 7.2.2\u903b\u8f91\u5730\u5740\u5230\u7ebf\u6027\u5730\u5740\u7684\u8f6c\u6362\u8fc7\u7a0b<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u4fdd\u62a4\u6a21\u5f0f\u4e0b&#xff0c;\u903b\u8f91\u5730\u5740\u7531\u6bb5\u9009\u62e9\u7b26\u548c\u6bb5\u5185\u504f\u79fb\u91cf\u7ec4\u6210\u3002\u5904\u7406\u5668\u5c06\u903b\u8f91\u5730\u5740\u8f6c\u6362\u4e3a\u7ebf\u6027\u5730\u5740\u7684\u8fc7\u7a0b\u5982\u4e0b&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u52a0\u8f7d\u6bb5\u63cf\u8ff0\u7b26&#xff1a;\u5f53\u4e00\u4e2a\u65b0\u7684\u6bb5\u9009\u62e9\u7b26\u88ab\u52a0\u8f7d\u5230\u6bb5\u5bc4\u5b58\u5668\u4e2d\u65f6&#xff0c;\u5904\u7406\u5668\u6839\u636e\u6bb5\u9009\u62e9\u7b26\u4e2d\u7684\u7d22\u5f15\u548c\u8868\u6307\u793a\u7b26&#xff0c;\u4ece GDT \u6216 LDT \u4e2d\u83b7\u53d6\u5bf9\u5e94\u7684\u6bb5\u63cf\u8ff0\u7b26&#xff0c;\u5e76\u5c06\u5176\u52a0\u8f7d\u5230\u6bb5\u5bc4\u5b58\u5668\u7684\u9690\u85cf\u90e8\u5206\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6743\u9650\u548c\u6709\u6548\u6027\u68c0\u67e5&#xff1a;\u5904\u7406\u5668\u6839\u636e\u6bb5\u63cf\u8ff0\u7b26\u4e2d\u7684\u6743\u9650\u4fe1\u606f\u548c\u5f53\u524d\u7684\u7279\u6743\u7ea7&#xff0c;\u68c0\u67e5\u662f\u5426\u5141\u8bb8\u8bbf\u95ee\u8be5\u6bb5\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8ba1\u7b97\u7ebf\u6027\u5730\u5740&#xff1a;\u5904\u7406\u5668\u5c06\u6bb5\u63cf\u8ff0\u7b26\u4e2d\u7684\u6bb5\u57fa\u5730\u5740\u4e0e\u6bb5\u5185\u504f\u79fb\u91cf\u76f8\u52a0&#xff0c;\u5f97\u5230\u7ebf\u6027\u5730\u5740\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fd9\u4e2a\u8fc7\u7a0b\u786e\u4fdd\u4e86\u5185\u5b58\u8bbf\u95ee\u7684\u5b89\u5168\u6027\u548c\u7075\u6d3b\u6027\u3002\u5982\u679c\u542f\u7528\u4e86\u5206\u9875\u673a\u5236&#xff0c;\u7ebf\u6027\u5730\u5740\u5c06\u8fdb\u4e00\u6b65\u88ab\u8f6c\u6362\u4e3a\u7269\u7406\u5730\u5740\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h4 id=\"7.2.3%E6%AE%B5%E5%AF%84%E5%AD%98%E5%99%A8%E4%B8%8E%E6%8F%8F%E8%BF%B0%E7%AC%A6%E7%BC%93%E5%AD%98\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.2.3\u6bb5\u5bc4\u5b58\u5668\u4e0e\u63cf\u8ff0\u7b26\u7f13\u5b58<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">x86 \u67b6\u6784\u63d0\u4f9b\u4e86\u516d\u4e2a\u6bb5\u5bc4\u5b58\u5668&#xff1a;CS&#xff08;\u4ee3\u7801\u6bb5&#xff09;\u3001SS&#xff08;\u5806\u6808\u6bb5&#xff09;\u3001DS&#xff08;\u6570\u636e\u6bb5&#xff09;\u3001ES\u3001FS \u548c GS\u3002\u6bcf\u4e2a\u6bb5\u5bc4\u5b58\u5668\u90fd\u6709\u4e00\u4e2a\u53ef\u89c1\u90e8\u5206&#xff08;\u5b58\u50a8\u6bb5\u9009\u62e9\u7b26&#xff09;\u548c\u4e00\u4e2a\u4e0d\u53ef\u89c1\u90e8\u5206&#xff08;\u63cf\u8ff0\u7b26\u7f13\u5b58&#xff09;\u3002\u5f53\u6bb5\u9009\u62e9\u7b26\u88ab\u52a0\u8f7d\u5230\u6bb5\u5bc4\u5b58\u5668\u4e2d\u65f6&#xff0c;\u5904\u7406\u5668\u4f1a\u81ea\u52a8\u5c06\u5bf9\u5e94\u7684\u6bb5\u63cf\u8ff0\u7b26\u52a0\u8f7d\u5230\u63cf\u8ff0\u7b26\u7f13\u5b58\u4e2d\u3002\u5728\u540e\u7eed\u7684\u5185\u5b58\u8bbf\u95ee\u4e2d&#xff0c;\u5904\u7406\u5668\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u63cf\u8ff0\u7b26\u7f13\u5b58\u4e2d\u7684\u4fe1\u606f&#xff0c;\u65e0\u9700\u518d\u6b21\u8bbf\u95ee\u5185\u5b58\u4e2d\u7684\u63cf\u8ff0\u7b26\u8868&#xff0c;\u4ece\u800c\u63d0\u9ad8\u4e86\u8bbf\u95ee\u6548\u7387\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728 x86 \u4fdd\u62a4\u6a21\u5f0f\u4e0b&#xff0c;\u5206\u6bb5\u673a\u5236\u901a\u8fc7\u6bb5\u9009\u62e9\u7b26\u548c\u6bb5\u63cf\u8ff0\u7b26\u7684\u914d\u5408&#xff0c;\u5b9e\u73b0\u4e86\u4ece\u903b\u8f91\u5730\u5740\u5230\u7ebf\u6027\u5730\u5740\u7684\u8f6c\u6362\u3002\u6bb5\u9009\u62e9\u7b26\u7528\u4e8e\u7d22\u5f15\u6bb5\u63cf\u8ff0\u7b26&#xff0c;\u6bb5\u63cf\u8ff0\u7b26\u63d0\u4f9b\u6bb5\u7684\u57fa\u5730\u5740\u548c\u8bbf\u95ee\u6743\u9650\u7b49\u4fe1\u606f\u3002\u5904\u7406\u5668\u5c06\u6bb5\u57fa\u5730\u5740\u4e0e\u6bb5\u5185\u504f\u79fb\u91cf\u76f8\u52a0&#xff0c;\u5f97\u5230\u7ebf\u6027\u5730\u5740\u3002\u901a\u8fc7\u63cf\u8ff0\u7b26\u7f13\u5b58\u7684\u673a\u5236&#xff0c;\u5904\u7406\u5668\u53ef\u4ee5\u9ad8\u6548\u5730\u8fdb\u884c\u5730\u5740\u8f6c\u6362&#xff0c;\u786e\u4fdd\u4e86\u5185\u5b58\u8bbf\u95ee\u7684\u5b89\u5168\u6027\u548c\u6027\u80fd\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h3 id=\"7.3%20Hello%E7%9A%84%E7%BA%BF%E6%80%A7%E5%9C%B0%E5%9D%80%E5%88%B0%E7%89%A9%E7%90%86%E5%9C%B0%E5%9D%80%E7%9A%84%E5%8F%98%E6%8D%A2-%E9%A1%B5%E5%BC%8F%E7%AE%A1%E7%90%86\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.3 Hello\u7684\u7ebf\u6027\u5730\u5740\u5230\u7269\u7406\u5730\u5740\u7684\u53d8\u6362-\u9875\u5f0f\u7ba1\u7406<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728 Linux \u7cfb\u7edf\u4e2d&#xff0c;\u865a\u62df\u5730\u5740\u5230\u7269\u7406\u5730\u5740\u7684\u8f6c\u6362\u4e3b\u8981\u4f9d\u8d56\u4e8e\u5206\u9875\u673a\u5236&#xff08;Paging&#xff09;&#xff0c;\u8fd9\u662f\u865a\u62df\u5185\u5b58\u7ba1\u7406\u7684\u6838\u5fc3\u7ec4\u6210\u90e8\u5206\u3002\u5206\u9875\u673a\u5236\u901a\u8fc7\u5c06\u865a\u62df\u5185\u5b58\u548c\u7269\u7406\u5185\u5b58\u5212\u5206\u4e3a\u56fa\u5b9a\u5927\u5c0f\u7684\u9875&#xff08;Page&#xff09;&#xff0c;\u5e76\u5229\u7528\u9875\u8868&#xff08;Page Table&#xff09;\u5efa\u7acb\u865a\u62df\u9875\u4e0e\u7269\u7406\u9875\u4e4b\u95f4\u7684\u6620\u5c04\u5173\u7cfb&#xff0c;\u4ece\u800c\u5b9e\u73b0\u9ad8\u6548\u7684\u5185\u5b58\u7ba1\u7406\u548c\u8bbf\u95ee\u63a7\u5236\u3002<\/p>\n<h4 id=\"7.3.1%E8%99%9A%E6%8B%9F%E5%86%85%E5%AD%98%E7%9A%84%E7%BB%84%E7%BB%87%E7%BB%93%E6%9E%84\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.3.1\u865a\u62df\u5185\u5b58\u7684\u7ec4\u7ec7\u7ed3\u6784<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4ece\u6982\u5ff5\u4e0a\u770b&#xff0c;\u865a\u62df\u5185\u5b58\u88ab\u7ec4\u7ec7\u4e3a\u4e00\u4e2a\u7531 N \u4e2a\u8fde\u7eed\u5b57\u8282\u5927\u5c0f\u7684\u5355\u5143\u7ec4\u6210\u7684\u6570\u7ec4&#xff0c;\u8fd9\u4e9b\u5355\u5143\u901a\u5e38\u5b58\u50a8\u5728\u78c1\u76d8\u4e0a\u3002\u4e3a\u4e86\u63d0\u9ad8\u8bbf\u95ee\u901f\u5ea6&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u5c06\u90e8\u5206\u865a\u62df\u9875\u7f13\u5b58\u5728\u7269\u7406\u5185\u5b58&#xff08;DRAM&#xff09;\u4e2d&#xff0c;\u8fd9\u4e9b\u7f13\u5b58\u7684\u5185\u5b58\u5757\u79f0\u4e3a\u9875&#xff08;Page&#xff09;&#xff0c;\u6bcf\u9875\u7684\u5927\u5c0f\u901a\u5e38\u4e3a 4KB&#xff0c;\u6709\u65f6\u4e5f\u53ef\u4ee5\u662f\u66f4\u5927\u7684 2MB \u6216 1GB\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u865a\u62df\u9875\u4f5c\u4e3a\u78c1\u76d8\u5185\u5bb9\u7684\u7f13\u5b58&#xff0c;\u5177\u6709\u4ee5\u4e0b\u7279\u70b9&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5168\u76f8\u8054\u6620\u5c04&#xff1a;\u4efb\u4f55\u865a\u62df\u9875\u90fd\u53ef\u4ee5\u6620\u5c04\u5230\u4efb\u4f55\u7269\u7406\u9875\u6846\u4e2d&#xff0c;\u8fd9\u9700\u8981\u4e00\u4e2a\u66f4\u590d\u6742\u7684\u6620\u5c04\u51fd\u6570\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5199\u56de\u7b56\u7565&#xff1a;DRAM \u7f13\u5b58\u901a\u5e38\u91c7\u7528\u5199\u56de&#xff08;Write-Back&#xff09;\u7b56\u7565&#xff0c;\u800c\u4e0d\u662f\u76f4\u5199&#xff08;Write-Through&#xff09;&#xff0c;\u4ee5\u51cf\u5c11\u5bf9\u5185\u5b58\u7684\u5199\u64cd\u4f5c\u6b21\u6570\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u66ff\u6362\u7b97\u6cd5&#xff1a;\u7531\u4e8e\u786c\u4ef6\u5b9e\u73b0\u590d\u6742\u7684\u66ff\u6362\u7b97\u6cd5\u5b58\u5728\u9650\u5236&#xff0c;DRAM \u7f13\u5b58\u7684\u66ff\u6362\u7b56\u7565\u901a\u5e38\u7531\u64cd\u4f5c\u7cfb\u7edf\u5728\u8f6f\u4ef6\u5c42\u9762\u7ba1\u7406\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u865a\u62df\u9875\u96c6\u5408\u88ab\u5212\u5206\u4e3a\u4e09\u4e2a\u4e0d\u76f8\u4ea4\u7684\u5b50\u96c6&#xff1a;<\/p>\n<li style=\"text-align:justify\">\u5df2\u7f13\u5b58&#xff08;Cached&#xff09;&#xff1a;\u5f53\u524d\u9a7b\u7559\u5728\u7269\u7406\u5185\u5b58\u4e2d\u7684\u9875\u3002<\/li>\n<li style=\"text-align:justify\">\u672a\u7f13\u5b58&#xff08;Uncached&#xff09;&#xff1a;\u5c1a\u672a\u52a0\u8f7d\u5230\u7269\u7406\u5185\u5b58\u4e2d\u7684\u9875\u3002<\/li>\n<li style=\"text-align:justify\">\u672a\u5206\u914d&#xff08;Unallocated&#xff09;&#xff1a;\u5c1a\u672a\u5206\u914d\u5b58\u50a8\u7a7a\u95f4\u7684\u9875\u3002<\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"163\" src=\"2025-06-10qaid4d4dxeu.jpg\" width=\"360\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe67 \u5185\u5b58\u6620\u5c04\u5173\u7cfb<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h4 id=\"7.3.2%E9%A1%B5%E8%A1%A8%E4%B8%8E%E5%9C%B0%E5%9D%80%E6%98%A0%E5%B0%84\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.3.2\u9875\u8868\u4e0e\u5730\u5740\u6620\u5c04<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u9875\u8868\u662f\u4e00\u4e2a\u7531\u9875\u8868\u6761\u76ee&#xff08;Page Table Entry, PTE&#xff09;\u7ec4\u6210\u7684\u6570\u7ec4&#xff0c;\u7528\u4e8e\u5c06\u865a\u62df\u9875\u5730\u5740\u6620\u5c04\u5230\u7269\u7406\u9875\u5730\u5740\u3002\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u6709\u81ea\u5df1\u7684\u9875\u8868&#xff0c;\u9875\u8868\u5e38\u9a7b\u4e8e\u4e3b\u5b58\u4e2d\u3002\u5728 x86 \u67b6\u6784\u4e2d&#xff0c;\u9875\u8868\u901a\u5e38\u91c7\u7528\u591a\u7ea7\u7ed3\u6784&#xff08;\u5982\u4e09\u7ea7\u6216\u56db\u7ea7\u9875\u8868&#xff09;&#xff0c;\u4ee5\u51cf\u5c11\u5185\u5b58\u5360\u7528\u5e76\u63d0\u9ad8\u67e5\u627e\u6548\u7387\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f53\u5904\u7406\u5668\u9700\u8981\u8bbf\u95ee\u67d0\u4e2a\u865a\u62df\u5730\u5740\u65f6&#xff0c;\u5730\u5740\u8f6c\u6362\u8fc7\u7a0b\u5982\u4e0b&#xff1a;<\/p>\n<li style=\"text-align:justify\">\u751f\u6210\u865a\u62df\u5730\u5740&#xff1a;CPU \u751f\u6210\u4e00\u4e2a\u865a\u62df\u5730\u5740&#xff0c;\u5e76\u5c06\u5176\u53d1\u9001\u7ed9\u5185\u5b58\u7ba1\u7406\u5355\u5143&#xff08;MMU&#xff09;\u3002<\/li>\n<li style=\"text-align:justify\">\u67e5\u627e\u9875\u8868&#xff1a;MMU \u4f7f\u7528\u865a\u62df\u5730\u5740\u4e2d\u7684\u9875\u76ee\u5f55\u7d22\u5f15\u548c\u9875\u8868\u7d22\u5f15&#xff0c;\u9010\u7ea7\u67e5\u627e\u5bf9\u5e94\u7684\u9875\u8868\u6761\u76ee&#xff08;PTE&#xff09;\u3002<\/li>\n<li style=\"text-align:justify\">\u83b7\u53d6\u7269\u7406\u5730\u5740&#xff1a;\u5982\u679c PTE \u6709\u6548&#xff0c;MMU \u63d0\u53d6\u5176\u4e2d\u7684\u7269\u7406\u9875\u6846\u53f7&#xff0c;\u5e76\u4e0e\u9875\u5185\u504f\u79fb\u91cf\u7ec4\u5408&#xff0c;\u5f62\u6210\u5b8c\u6574\u7684\u7269\u7406\u5730\u5740\u3002<\/li>\n<li style=\"text-align:justify\">\u8bbf\u95ee\u5185\u5b58&#xff1a;CPU \u4f7f\u7528\u7269\u7406\u5730\u5740\u8bbf\u95ee\u4e3b\u5b58&#xff0c;\u8bfb\u53d6\u6216\u5199\u5165\u6570\u636e\u3002<\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4e3a\u4e86\u52a0\u5feb\u5730\u5740\u8f6c\u6362\u901f\u5ea6&#xff0c;\u5904\u7406\u5668\u901a\u5e38\u914d\u5907\u4e86\u7ffb\u8bd1\u540e\u5907\u7f13\u51b2\u533a&#xff08;Translation Lookaside Buffer, TLB&#xff09;&#xff0c;\u7528\u4e8e\u7f13\u5b58\u6700\u8fd1\u4f7f\u7528\u7684\u865a\u62df\u5730\u5740\u5230\u7269\u7406\u5730\u5740\u7684\u6620\u5c04\u3002\u5982\u679c TLB \u547d\u4e2d&#xff0c;MMU \u53ef\u4ee5\u76f4\u63a5\u83b7\u5f97\u7269\u7406\u5730\u5740&#xff0c;\u907f\u514d\u8bbf\u95ee\u9875\u8868\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"220\" src=\"2025-06-10k0rhmuuyqtc.jpg\" width=\"369\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe68 \u9875\u8868\u7684\u5b9e\u73b0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4e0b\u56fe\u5c55\u793a\u4e86\u9875\u5f0f\u7ba1\u7406\u4e2d\u865a\u62df\u5730\u5740\u5230\u7269\u7406\u5730\u5740\u7684\u8f6c\u6362&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"260\" src=\"2025-06-10uft1qhr4oaq.png\" width=\"473\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe69 \u9875\u5f0f\u7ba1\u7406<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<h4 id=\"7.3.2%E7%BC%BA%E9%A1%B5%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.3.2\u7f3a\u9875\u5f02\u5e38\u5904\u7406<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f53\u8bbf\u95ee\u7684\u865a\u62df\u9875\u4e0d\u5728\u7269\u7406\u5185\u5b58\u4e2d&#xff0c;\u5373 PTE \u7684\u6709\u6548\u4f4d\u4e3a 0 \u65f6&#xff0c;\u4f1a\u89e6\u53d1\u7f3a\u9875\u5f02\u5e38&#xff08;Page Fault&#xff09;\u3002\u64cd\u4f5c\u7cfb\u7edf\u7684\u7f3a\u9875\u5f02\u5e38\u5904\u7406\u7a0b\u5e8f\u4f1a\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4&#xff1a;<\/p>\n<ul>\n<li style=\"text-align:justify\">\u4fdd\u5b58\u4e0a\u4e0b\u6587&#xff1a;\u4fdd\u5b58\u5f53\u524d\u8fdb\u7a0b\u7684\u72b6\u6001&#xff0c;\u4ee5\u4fbf\u5728\u5904\u7406\u5b8c\u5f02\u5e38\u540e\u6062\u590d\u3002<\/li>\n<li style=\"text-align:justify\">\u67e5\u627e\u9875\u6570\u636e&#xff1a;\u786e\u5b9a\u6240\u9700\u9875\u5728\u78c1\u76d8\u4e0a\u7684\u4f4d\u7f6e\u3002<\/li>\n<li style=\"text-align:justify\">\u9009\u62e9\u727a\u7272\u9875&#xff1a;\u5982\u679c\u7269\u7406\u5185\u5b58\u5df2\u6ee1&#xff0c;\u9009\u62e9\u4e00\u4e2a\u9875\u6846\u8fdb\u884c\u66ff\u6362&#xff08;\u53ef\u80fd\u9700\u8981\u5c06\u5176\u5199\u56de\u78c1\u76d8&#xff09;\u3002<\/li>\n<li style=\"text-align:justify\">\u52a0\u8f7d\u65b0\u9875&#xff1a;\u5c06\u6240\u9700\u9875\u4ece\u78c1\u76d8\u52a0\u8f7d\u5230\u7269\u7406\u5185\u5b58\u4e2d\u3002<\/li>\n<li style=\"text-align:justify\">\u66f4\u65b0\u9875\u8868&#xff1a;\u4fee\u6539\u5bf9\u5e94\u7684 PTE&#xff0c;\u6807\u8bb0\u5176\u4e3a\u6709\u6548&#xff0c;\u5e76\u66f4\u65b0\u7269\u7406\u9875\u6846\u53f7\u3002<\/li>\n<li style=\"text-align:justify\">\u6062\u590d\u6267\u884c&#xff1a;\u6062\u590d\u8fdb\u7a0b\u72b6\u6001&#xff0c;\u91cd\u65b0\u6267\u884c\u5bfc\u81f4\u7f3a\u9875\u7684\u6307\u4ee4\u3002<\/li>\n<\/ul>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4e0b\u9762\u4e24\u5f20\u56fe\u5c55\u793a\u4e86\u9875\u9762\u547d\u4e2d\u548c\u7f3a\u9875\u60c5\u51b5&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"147\" src=\"2025-06-1012bj0khteaw.jpg\" width=\"396\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe70 \u9875\u9762\u547d\u4e2d<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"178\" src=\"2025-06-10km3k2mqccdi.jpg\" width=\"380\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe71\u7f3a\u9875<\/p>\n<h3 id=\"\" style=\"margin-left:0;margin-right:0;text-align:justify\"><\/h3>\n<h3 id=\"7.4%20TLB%E4%B8%8E%E5%9B%9B%E7%BA%A7%E9%A1%B5%E8%A1%A8%E6%94%AF%E6%8C%81%E4%B8%8B%E7%9A%84VA%E5%88%B0PA%E7%9A%84%E5%8F%98%E6%8D%A2\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.4 TLB\u4e0e\u56db\u7ea7\u9875\u8868\u652f\u6301\u4e0b\u7684VA\u5230PA\u7684\u53d8\u6362<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4e3a\u4e86\u5c4f\u853d\u6bcf\u6b21 CPU \u751f\u6210\u865a\u62df\u5730\u5740\u65f6\u5bf9\u9875\u8868\u9879&#xff08;PTE&#xff09;\u8bbf\u95ee\u6240\u5f15\u53d1\u7684\u591a\u7ea7\u9875\u8868\u904d\u5386\u5ef6\u8fdf&#xff0c;\u73b0\u4ee3\u5904\u7406\u5668\u7684\u5185\u5b58\u7ba1\u7406\u5355\u5143&#xff08;MMU&#xff09;\u901a\u5e38\u96c6\u6210\u4e00\u4e2a\u4ee5\u5185\u5bb9\u53ef\u5bfb\u5740\u5b58\u50a8\u5668&#xff08;CAM&#xff09;\u5b9e\u73b0\u7684\u5168\u5173\u8054\u5c0f\u578b\u7f13\u5b58\u2014\u2014\u7ffb\u8bd1\u540e\u5907\u7f13\u51b2\u5668&#xff08;TLB&#xff09;&#xff0c;\u7528\u4e8e\u5b58\u50a8\u8fd1\u671f\u7684\u865a\u62df\u9875\u53f7&#xff08;VPN&#xff09;\u5230\u7269\u7406\u9875\u53f7&#xff08;PPN&#xff09;\u7684\u6620\u5c04&#xff0c;\u52a0\u901f\u5730\u5740\u8f6c\u6362\u6d41\u7a0b\u3002 \u8be5 TLB \u5728\u547d\u4e2d\u65f6\u4ec5\u9700\u6570\u4e2a\u65f6\u949f\u5468\u671f\u5373\u53ef\u5b8c\u6210 VPN\u2192PPN \u7684\u6620\u5c04&#xff0c;\u5176\u8bbf\u95ee\u5ef6\u8fdf\u5e38\u4f4e\u4e8e L1 \u7ea7\u6570\u636e\u7f13\u5b58\u7684\u8bbf\u95ee\u5ef6\u8fdf&#xff0c;\u4ece\u800c\u663e\u8457\u63d0\u5347\u5185\u5b58\u8bbf\u95ee\u7684\u6574\u4f53\u6027\u80fd\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"89\" src=\"2025-06-10ebvqpjcq2lp.png\" width=\"376\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe72 \u865a\u62df\u5730\u5740\u4e2d\u7528\u4ee5\u8bbf\u95eeTLB\u7684\u7ec4\u6210\u90e8\u5206<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">TLB \u5c06\u865a\u62df\u9875\u53f7&#xff08;VPN&#xff09;\u7684\u9ad8\u4f4d\u548c\u4f4e\u4f4d\u5206\u522b\u5212\u5206\u4e3a\u6807\u8bb0\u5b57\u6bb5&#xff08;TLBT&#xff09;\u4e0e\u7d22\u5f15\u5b57\u6bb5&#xff08;TLBI&#xff09;&#xff0c;\u5e76\u901a\u8fc7\u5185\u5bb9\u53ef\u5bfb\u5740\u5b58\u50a8\u5668&#xff08;CAM&#xff09;\u4ee5\u5168\u5173\u8054\u6216\u7ec4\u76f8\u8054\u65b9\u5f0f\u9ad8\u901f\u7f13\u5b58\u9875\u8868\u9879&#xff1b;MMU \u5728\u5730\u5740\u8f6c\u6362\u65f6\u9996\u5148\u6839\u636e TLBI \u5b9a\u4f4d\u5019\u9009\u96c6\u5408&#xff0c;\u518d\u901a\u8fc7 TLBT \u5b8c\u6210\u6807\u7b7e\u5339\u914d&#xff0c;\u82e5\u672a\u547d\u4e2d\u5219\u89e6\u53d1\u591a\u7ea7\u9875\u8868\u904d\u5386&#xff0c;\u5c06\u5bf9\u5e94\u7684\u9875\u8868\u9879&#xff08;PTE&#xff09;\u4ece\u5185\u5b58\u52a0\u8f7d\u5e76\u586b\u5145\u5230 TLB \u4e2d\u3002 \u00a0\u00a0\u00a0 \u4e3a\u907f\u514d\u5355\u7ea7\u9875\u8868\u5c3a\u5bf8\u8fc7\u5927\u5bfc\u81f4\u7684\u5185\u5b58\u6d6a\u8d39&#xff0c;x86\u201164&#xff08;\u5982 Intel Core\u00a0i7&#xff09;\u91c7\u7528\u56db\u7ea7\u9875\u8868\u7ed3\u6784&#xff0c;\u4f9d\u6b21\u7531 PML4\u3001PDPT\u3001PD \u53ca PT \u56db\u7ea7\u7d22\u5f15\u5b8c\u6210\u865a\u62df\u5730\u5740\u5230\u7269\u7406\u9875\u53f7&#xff08;PPN&#xff09;\u7684\u6620\u5c04\u3002 \u00a0\u00a0\u00a0 \u6b64\u5916&#xff0c;TLB \u7684\u8bbf\u95ee\u5ef6\u8fdf\u4ec5\u9700\u6570\u4e2a\u65f6\u949f\u5468\u671f&#xff0c;\u5176\u901f\u5ea6\u901a\u5e38\u4f18\u4e8e L1 \u6570\u636e\u7f13\u5b58&#xff0c;\u8fd9\u5f97\u76ca\u4e8e CAM \u7684\u5e76\u884c\u6807\u7b7e\u6bd4\u5bf9\u673a\u5236\u53ca\u786c\u4ef6\u9884\u53d6\u4f18\u5316&#xff0c;\u5927\u5e45\u63d0\u5347\u4e86\u865a\u62df\u5730\u5740\u8f6c\u6362\u7684\u6574\u4f53\u6027\u80fd<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"300\" src=\"2025-06-10ztqnan4tlud.jpg\" width=\"478\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe73 \u4e8c\u7ea7\u9875\u8868<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5728\u56db\u7ea7\u9875\u8868\u7ed3\u6784\u4e0b&#xff0c;\u865a\u62df\u5730\u5740\u88ab\u62c6\u5206\u4e3a\u56db\u6bb5\u865a\u62df\u9875\u53f7&#xff08;VPN\u2084\u3001VPN\u2083\u3001VPN\u2082\u3001VPN\u2081&#xff09;\u548c\u4e00\u6bb5\u9875\u5185\u504f\u79fb&#xff08;VPO&#xff09;\u3002\u5176\u4e2d&#xff0c;\u7b2c\u202fi\u202f\u7ea7\u9875\u8868\u7684\u7d22\u5f15\u5373\u5bf9\u5e94 VPN\u1d62&#xff0c;\u800c\u7b2c\u202fj\u202f\u7ea7\u9875\u8868\u4e2d\u7684\u6bcf\u4e2a\u9875\u8868\u9879&#xff08;PTE&#xff09;\u90fd\u5b58\u50a8\u7740\u7b2c\u202fj&#043;1\u202f\u7ea7\u9875\u8868\u7684\u7269\u7406\u57fa\u5740&#xff1b;\u5728\u7b2c\u202f4\u202f\u7ea7\u9875\u8868\u4e2d&#xff0c;PTE \u5219\u76f4\u63a5\u8bb0\u5f55\u4e86\u76ee\u6807\u7269\u7406\u9875\u6846\u53f7&#xff08;PPN&#xff09;&#xff0c;\u6216\u5728\u9700\u6c42\u4e0b\u6307\u5411\u78c1\u76d8\u4e0a\u7684\u9875\u4ea4\u6362\u533a\u3002\u5f53 MMU \u6267\u884c\u5730\u5740\u8f6c\u6362\u65f6&#xff0c;\u82e5 TLB \u672a\u547d\u4e2d&#xff0c;\u4fbf\u9700\u4f9d\u6b21\u8bfb\u53d6\u8fd9\u56db\u7ea7 PTE&#xff0c;\u76f4\u81f3\u83b7\u5f97\u6700\u7ec8\u7684 PPN&#xff0c;\u968f\u540e\u5c06\u5176\u4e0e\u9875\u5185\u504f\u79fb\u7ec4\u5408&#xff0c;\u751f\u6210\u5b8c\u6574\u7684\u7269\u7406\u5730\u5740\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"262\" src=\"2025-06-1041m1g0jwyyl.png\" width=\"448\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe74 \u56db\u7ea7\u9875\u8868<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7efc\u4e0a\u6240\u8ff0&#xff0c;\u5728\u56db\u7ea7\u9875\u8868\u4f53\u7cfb\u4e0b&#xff0c;MMU \u4f1a\u5148\u5229\u7528\u865a\u62df\u5730\u5740\u4e2d\u7684\u56db\u6bb5 VPN \u901a\u8fc7 TLB \u8fdb\u884c\u5feb\u901f\u67e5\u627e\u2014\u2014\u82e5\u547d\u4e2d\u5219\u76f4\u63a5\u83b7\u5f97\u4e0b\u4e00\u7ea7\u9875\u8868\u7684\u7269\u7406\u57fa\u5730\u5740\u6216\u6700\u7ec8\u7684\u7269\u7406\u9875\u6846\u53f7&#xff08;PPN&#xff09;&#xff1b;\u82e5\u672a\u547d\u4e2d&#xff0c;\u5219\u4f9d\u6b21\u8bbf\u95ee PML4\u3001PDPT\u3001PD \u548c PT \u56db\u7ea7\u9875\u8868\u9879\u83b7\u53d6 PPN&#xff0c;\u6700\u7ec8\u5c06\u8be5 PPN \u4e0e\u9875\u5185\u504f\u79fb&#xff08;VPO&#xff09;\u62fc\u63a5\u751f\u6210\u5b8c\u6574\u7684\u7269\u7406\u5730\u5740&#xff08;PA&#xff09;\u3002<\/p>\n<h3 id=\"7.5%20%E4%B8%89%E7%BA%A7Cache%E6%94%AF%E6%8C%81%E4%B8%8B%E7%9A%84%E7%89%A9%E7%90%86%E5%86%85%E5%AD%98%E8%AE%BF%E9%97%AE\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.5 \u4e09\u7ea7Cache\u652f\u6301\u4e0b\u7684\u7269\u7406\u5185\u5b58\u8bbf\u95ee<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">Core i7\u7684\u5185\u5b58\u7cfb\u7edf\u5982\u56fe\u6240\u793a\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"259\" src=\"2025-06-10cqrj1xckfpa.jpg\" width=\"322\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe75 \u5185\u5b58\u7cfb\u7edf<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u9996\u5148&#xff0c;\u6839\u636e\u7269\u7406\u5730\u5740\u7684 s \u4f4d\u7ec4\u7d22\u5f15\u7d22\u5f15\u5230 L1 cache\u4e2d\u7684\u67d0\u4e2a\u7ec4&#xff0c;\u7136\u540e\u5728\u8be5\u7ec4\u4e2d\u67e5\u627e\u662f\u5426\u6709\u67d0\u4e00\u884c\u7684\u6807\u8bb0\u7b49\u4e8e\u7269\u7406\u5730\u5740\u7684\u6807\u8bb0\u5e76\u4e14\u8be5\u884c\u7684\u6709\u6548\u4f4d\u4e3a 1&#xff0c;\u82e5\u6709&#xff0c;\u5219\u8bf4\u660e\u547d\u4e2d&#xff0c;\u4ece\u8fd9\u4e00\u884c\u5bf9\u5e94\u7269\u7406\u5730\u5740 b \u4f4d\u5757\u504f\u79fb\u7684\u4f4d\u7f6e\u53d6\u51fa\u4e00\u4e2a\u5b57\u8282&#xff0c;\u82e5\u4e0d\u6ee1\u8db3\u4e0a\u9762\u7684\u6761\u4ef6&#xff0c;\u5219\u8bf4\u660e\u4e0d\u547d\u4e2d&#xff0c;\u9700\u8981\u7ee7\u7eed\u8bbf\u95ee\u4e0b\u4e00\u7ea7 cache&#xff0c;\u8bbf\u95ee\u7684\u539f\u7406\u4e0e L1 \u76f8\u540c&#xff0c;\u82e5\u662f\u4e09\u7ea7 cache \u90fd\u6ca1\u6709\u8981\u8bbf\u95ee\u7684\u6570\u636e&#xff0c;\u5219\u9700\u8981\u8bbf\u95ee\u5185\u5b58&#xff0c;\u4ece\u5185\u5b58\u4e2d\u53d6\u51fa\u6570\u636e\u5e76\u653e\u5165cache\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"287\" src=\"2025-06-10gcv2a2c44zz.png\" width=\"253\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe76 Cache\u8bbf\u95ee<\/p>\n<h3 id=\"7.6%20hello%E8%BF%9B%E7%A8%8Bfork%E6%97%B6%E7%9A%84%E5%86%85%E5%AD%98%E6%98%A0%E5%B0%84\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.6 hello\u8fdb\u7a0bfork\u65f6\u7684\u5185\u5b58\u6620\u5c04<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f53fork\u51fd\u6570\u88ab\u5f53\u524d\u8fdb\u7a0b\u8c03\u7528\u65f6&#xff0c;\u5185\u6838\u4e3a\u65b0\u8fdb\u7a0b\u521b\u5efa\u5404\u79cd\u6570\u636e\u7ed3\u6784&#xff0c;\u5e76\u5206\u914d\u7ed9\u5b83\u4e00\u4e2a\u552f\u4e00\u7684PID\u3002\u4e3a\u4e86\u7ed9\u8fd9\u4e2a\u65b0\u8fdb\u7a0b\u521b\u5efa\u865a\u62df\u5185\u5b58&#xff0c;\u5b83\u521b\u5efa\u4e86\u5f53\u524d\u8fdb\u7a0b\u7684mm_struct\u3001\u533a\u57df\u7ed3\u6784\u548c\u9875\u8868\u7684\u539f\u6837\u526f\u672c\u3002\u5b83\u5c06\u4e24\u4e2a\u8fdb\u7a0b\u4e2d\u7684\u9875\u9762\u6807\u8bb0\u4e3a\u53ea\u8bfb&#xff0c;\u5e76\u5c06\u4e24\u4e2a\u8fdb\u7a0b\u4e2d\u7684\u6bcf\u4e2a\u533a\u57df\u7ed3\u6784\u90fd\u6807\u8bb0\u4e3a\u79c1\u6709\u7684\u5199\u65f6\u590d\u5236\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f53fork\u5728\u65b0\u8fdb\u7a0b\u4e2d\u8fd4\u56de\u65f6&#xff0c;\u65b0\u8fdb\u7a0b\u73b0\u5728\u7684\u865a\u62df\u5185\u5b58\u521a\u597d\u548c\u8c03\u7528fork\u65f6\u5b58\u5728\u7684\u865a\u62df\u5185\u5b58\u76f8\u540c\u3002\u5f53\u8fd9\u4e24\u4e2a\u8fdb\u7a0b\u4e2d\u7684\u4efb\u4e00\u4e2a\u540e\u6765\u8fdb\u884c\u5199\u64cd\u4f5c\u65f6&#xff0c;\u5199\u65f6\u590d\u5236\u673a\u5236\u5c31\u4f1a\u521b\u5efa\u65b0\u9875\u9762&#xff0c;\u56e0\u6b64&#xff0c;\u4e5f\u5c31\u4e3a\u6bcf\u4e2a\u8fdb\u7a0b\u4fdd\u6301\u4e86\u79c1\u6709\u5730\u5740\u7a7a\u95f4\u7684\u6982\u5ff5\u3002<\/p>\n<h4 id=\"7.6.1%20fork()%E6%97%B6%E7%9A%84%E5%86%85%E5%AD%98%E6%98%A0%E5%B0%84\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.6.1 fork()\u65f6\u7684\u5185\u5b58\u6620\u5c04<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">&#xff08;1&#xff09;\u8fdb\u7a0b\u521b\u5efa\u9636\u6bb5<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u64cd\u4f5c\u7cfb\u7edf\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u521b\u5efa\u5b50\u8fdb\u7a0b&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u65b0\u5efa\u72ec\u7acb\u7684\u8fdb\u7a0b\u63a7\u5236\u5757&#xff08;PCB&#xff09;&#xff0c;\u5efa\u7acb\u8fdb\u7a0b\u7ba1\u7406\u7ed3\u6784<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7ee7\u627f\u7236\u8fdb\u7a0b\u7684\u5173\u952e\u4e0a\u4e0b\u6587&#xff08;\u5305\u62ec\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u3001\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f\u3001\u5185\u5b58\u6620\u5c04\u8868\u7b49&#xff09;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">&#xff08;2&#xff09;\u865a\u62df\u5185\u5b58\u7ee7\u627f<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5b50\u8fdb\u7a0b\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u5171\u4eab\u7236\u8fdb\u7a0b\u5185\u5b58\u8d44\u6e90&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u83b7\u5f97\u4e0e\u7236\u8fdb\u7a0b\u5b8c\u5168\u4e00\u81f4\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4\u6620\u5c04\u8868<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6240\u6709\u865a\u62df\u9875\u8868\u9879\u521d\u59cb\u8bbe\u7f6e\u4e3a\u4e0e\u7236\u8fdb\u7a0b\u5171\u4eab\u7269\u7406\u9875\u5e27&#xff08;\u6b64\u65f6\u5c1a\u672a\u8fdb\u884c\u7269\u7406\u5185\u5b58\u590d\u5236&#xff09;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">&#xff08;3&#xff09;\u5199\u65f6\u590d\u5236\u4f18\u5316<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5185\u5b58\u8d44\u6e90\u7684\u52a8\u6001\u7ba1\u7406\u673a\u5236&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5171\u4eab\u7684\u7269\u7406\u5185\u5b58\u9875\u88ab\u6807\u8bb0\u4e3a\u5199\u4fdd\u62a4\u72b6\u6001<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f53\u4efb\u4e00\u8fdb\u7a0b&#xff08;\u7236\/\u5b50&#xff09;\u5c1d\u8bd5\u6267\u884c\u5199\u64cd\u4f5c\u65f6\u89e6\u53d1\u9875\u9519\u8bef\u5f02\u5e38<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5185\u6838\u62e6\u622a\u5f02\u5e38\u540e\u6267\u884c\u7269\u7406\u9875\u590d\u5236&#xff0c;\u4e3a\u4fee\u6539\u8fdb\u7a0b\u5206\u914d\u72ec\u7acb\u7684\u65b0\u7269\u7406\u9875<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4ec5\u590d\u5236\u88ab\u4fee\u6539\u7684\u7279\u5b9a\u5185\u5b58\u9875&#xff08;4KB\u7c92\u5ea6&#xff09;&#xff0c;\u4fdd\u6301\u672a\u4fee\u6539\u9875\u7684\u5171\u4eab\u72b6\u6001<\/p>\n<h4 id=\"7.6.2%20%E5%86%99%E6%97%B6%E5%A4%8D%E5%88%B6%EF%BC%88COW%EF%BC%89%E5%85%B7%E4%BD%93%E8%BF%87%E7%A8%8B\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.6.2 \u5199\u65f6\u590d\u5236&#xff08;COW&#xff09;\u5177\u4f53\u8fc7\u7a0b<\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">fork()\u8c03\u7528\u65f6&#xff0c;\u5b50\u8fdb\u7a0b\u4f1a\u7ee7\u627f\u7236\u8fdb\u7a0b\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4&#xff0c;\u4f46\u5e76\u4e0d\u4f1a\u7acb\u5373\u590d\u5236\u6240\u6709\u7269\u7406\u5185\u5b58\u3002\u901a\u8fc7\u5199\u65f6\u590d\u5236\u6280\u672f&#xff0c;\u7236\u5b50\u8fdb\u7a0b\u5171\u4eab\u76f8\u540c\u7684\u7269\u7406\u9875&#xff0c;\u76f4\u5230\u6709\u5199\u64cd\u4f5c\u53d1\u751f\u65f6&#xff0c;\u624d\u4f1a\u5206\u914d\u65b0\u7684\u7269\u7406\u9875\u3002\u8fd9\u6837\u53ef\u4ee5\u9ad8\u6548\u5730\u7ba1\u7406\u5185\u5b58&#xff0c;\u5e76\u51cf\u5c11 fork()\u7684\u5f00\u9500\u3002\u8fd9\u79cd\u673a\u5236\u5bf9\u4e8e\u521b\u5efa\u65b0\u8fdb\u7a0b\u548c\u9ad8\u6548\u5229\u7528\u5185\u5b58\u8d44\u6e90\u975e\u5e38\u91cd\u8981\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">(1)\u5199\u64cd\u4f5c\u89e6\u53d1\u9875\u9519\u8bef&#xff1a;\u5c1d\u8bd5\u5199\u5165\u53ea\u8bfb\u9875\u4f1a\u89e6\u53d1\u9875\u9519\u8bef\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">(2)\u64cd\u4f5c\u7cfb\u7edf\u5904\u7406\u9875\u9519\u8bef&#xff1a;\u64cd\u4f5c\u7cfb\u7edf\u68c0\u6d4b\u5230\u8fd9\u662f\u5199\u65f6\u590d\u5236\u60c5\u51b5\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">(3)\u590d\u5236\u7269\u7406\u9875&#xff1a;\u64cd\u4f5c\u7cfb\u7edf\u4e3a\u5199\u5165\u64cd\u4f5c\u5206\u914d\u4e00\u4e2a\u65b0\u7684\u7269\u7406\u9875&#xff0c;\u5e76\u5c06\u65e7\u9875\u7684\u6570\u636e\u590d\u5236\u5230\u65b0\u9875\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">(4)\u66f4\u65b0\u9875\u8868&#xff1a;\u66f4\u65b0\u8fdb\u7a0b\u7684\u9875\u8868&#xff0c;\u4f7f\u5f97\u8be5\u865a\u62df\u9875\u6620\u5c04\u5230\u65b0\u7684\u7269\u7406\u9875&#xff0c;\u5e76\u5c06\u9875\u6807\u8bb0\u4e3a\u53ef\u5199\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">(5)\u5b8c\u6210\u5199\u64cd\u4f5c&#xff1a;\u8fdb\u7a0b\u7ee7\u7eed\u6267\u884c\u5199\u64cd\u4f5c\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"215\" src=\"2025-06-10ro2w4fbupbo.png\" width=\"496\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe77 \u5199\u65f6\u590d\u5236<\/p>\n<h3 id=\"7.7%20hello%E8%BF%9B%E7%A8%8Bexecve%E6%97%B6%E7%9A%84%E5%86%85%E5%AD%98%E6%98%A0%E5%B0%84\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.7 hello\u8fdb\u7a0bexecve\u65f6\u7684\u5185\u5b58\u6620\u5c04<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">execve \u51fd\u6570\u8c03\u7528\u9a7b\u7559\u5728\u5185\u6838\u533a\u57df\u7684\u542f\u52a8\u52a0\u8f7d\u5668\u4ee3\u7801&#xff0c;\u5728\u5f53\u524d\u8fdb\u7a0b\u4e2d\u52a0\u8f7d\u5e76\u8fd0 \u884c\u5305\u542b\u5728\u53ef\u6267\u884c\u76ee\u6807\u6587\u4ef6 hello \u4e2d\u7684\u7a0b\u5e8f&#xff0c;\u7528 hello \u7a0b\u5e8f\u6709\u6548\u5730\u66ff\u4ee3\u4e86\u5f53\u524d\u7a0b\u5e8f\u3002 \u52a0\u8f7d\u5e76\u8fd0\u884c hello \u9700\u8981\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">1.\u7cfb\u7edf\u8c03\u7528\u8fdb\u5165\u4e0e\u6743\u9650\u68c0\u67e5<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u8fdb\u7a0b\u4ece\u7528\u6237\u6001\u89e6\u53d1 sys_execve&#xff0c;\u5207\u6362\u5230\u5185\u6838\u6001&#xff0c;\u5e76\u68c0\u67e5\u8c03\u7528\u8005\u5bf9\u76ee\u6807\u6587\u4ef6\u7684\u53ef\u6267\u884c\u6743\u9650\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u540c\u65f6\u6838\u5b9e\u5f53\u524d\u8fdb\u7a0b\u662f\u5426\u6709\u80fd\u529b\u6539\u53d8\u5176\u6620\u50cf&#xff08;\u5982\u662f\u5426\u88ab ptrace \u9644\u52a0\u3001\u662f\u5426\u4e3a set\u2011uid\/set\u2011gid \u7b49&#xff09;\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">2.\u6e05\u7406\u65e7\u7684\u7528\u6237\u7a7a\u95f4\u6620\u5c04<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5185\u6838\u8c03\u7528 mm_release() \u7b49\u51fd\u6570&#xff0c;\u64a4\u9500\u5f53\u524d\u8fdb\u7a0b\u6240\u6709\u8fdb\u7a0b\u7a7a\u95f4&#xff08;struct mm_struct&#xff09;\u4e2d\u7684\u7528\u6237\u6001\u5185\u5b58\u6620\u5c04&#xff08;VMA&#xff09;&#xff0c;\u5305\u62ec\u4ee3\u7801\u3001\u6570\u636e\u3001\u5806\u3001\u6808\u53ca\u4efb\u4f55\u533f\u540d\u6216\u6587\u4ef6\u6620\u5c04\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u8fd9\u610f\u5473\u7740\u6240\u6709\u539f\u6765\u6253\u5f00\u7684\u533f\u540d\u9875\u548c\u6587\u4ef6\u6620\u5c04\u90fd\u88ab\u5378\u8f7d&#xff0c;\u5f15\u7528\u8ba1\u6570\u51cf\u5c11&#xff0c;\u5fc5\u8981\u65f6\u56de\u6536\u9875\u9762\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">3.\u5efa\u7acb\u65b0\u7a0b\u5e8f\u7684\u5730\u5740\u7a7a\u95f4\u5e03\u5c40<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u89e3\u6790 ELF \u5934\u4e0e\u5404\u6bb5&#xff08;segment&#xff09;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5185\u6838\u8bfb\u53d6 ELF \u53ef\u6267\u884c\u6587\u4ef6\u5934&#xff08;ELF64_Ehdr&#xff09;&#xff0c;\u6839\u636e program header \u8868&#xff08;PHDR&#xff09;\u91cc\u5404 LOAD \u6bb5\u7684\u504f\u79fb\u548c\u5927\u5c0f&#xff0c;\u5206\u522b\u5728\u8fdb\u7a0b\u7684\u5730\u5740\u7a7a\u95f4\u4e2d\u521b\u5efa\u5bf9\u5e94\u7684 VMA&#xff0c;\u5e76\u8c03\u7528 do_mmap_pgoff() \u5c06 .text\u3001.data \u533a\u57df\u4ee5\u79c1\u6709\u5199\u65f6\u590d\u5236&#xff08;private COW&#xff09;\u7684\u65b9\u5f0f\u6620\u5c04\u5230\u6587\u4ef6\u5185\u5bb9\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">.bss \u548c \u5806\/\u6808 \u533a\u57df<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">.bss \u533a\u6bb5\u6ca1\u6709\u6587\u4ef6\u6570\u636e&#xff0c;\u53ea\u9700\u8981\u5728\u865a\u62df\u533a\u95f4\u5185\u8bf7\u6c42\u76f8\u5e94\u5927\u5c0f\u7684\u533f\u540d\u6620\u5c04&#xff08;\u5168\u96f6\u9875&#xff09;&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5806\u901a\u5e38\u4ece\u7b26\u53f7 brk \u5f00\u59cb&#xff0c;\u540e\u7eed\u52a8\u6001\u5206\u914d\u65f6\u6309\u9700\u6269\u5c55&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u7528\u6237\u6808&#xff08;ULOWER_STACK \u9644\u8fd1&#xff09;\u4e5f\u662f\u7528\u533f\u540d\u6620\u5c04&#xff0c;\u4f46\u521d\u59cb\u4ec5\u5206\u914d\u5c11\u91cf\u9875\u9762&#xff0c;\u540e\u7eed\u901a\u8fc7\u7f3a\u9875\u4e2d\u65ad\u81ea\u52a8\u6269\u5c55\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">4.\u52a0\u8f7d\u52a8\u6001\u94fe\u63a5\u5668\u4e0e\u5171\u4eab\u5e93<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5982\u679c\u8fd9\u4e2a ELF \u662f\u52a8\u6001\u53ef\u6267\u884c\u6587\u4ef6&#xff08;ET_DYN &#043; PT_INTERP&#xff09;&#xff0c;\u5185\u6838\u9996\u5148\u628a\u52a8\u6001\u94fe\u63a5\u5668&#xff08;\u5982 \/lib64\/ld\u2011linux\u2011x86\u201164.so.2&#xff09;\u6620\u5c04\u5230\u5730\u5740\u7a7a\u95f4&#xff0c;\u7136\u540e\u7531\u94fe\u63a5\u5668\u8d1f\u8d23\u52a0\u8f7d\u5e76\u91cd\u5b9a\u4f4d\u4f9d\u8d56\u7684\u5171\u4eab\u5bf9\u8c61&#xff08;\u5982 libc.so.6&#xff09;\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u94fe\u63a5\u5668\u5728\u7528\u6237\u6001&#xff08;\u800c\u975e\u5185\u6838\u6001&#xff09;\u5b8c\u6210\u7b26\u53f7\u89e3\u6790\u4e0e\u91cd\u5b9a\u4f4d&#xff0c;\u8bbe\u7f6e\u5404\u5171\u4eab\u5e93\u7684\u57fa\u5740\u548c GOT\/PLT \u7b49\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">5.\u6784\u9020\u6808\u5e27&#xff1a;argv\/envp\/auxv<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5185\u6838\u5728\u7528\u6237\u6808\u9876\u538b\u5165 argc\u3001argv \u5b57\u7b26\u4e32\u6307\u9488\u6570\u7ec4\u3001envp \u6570\u7ec4&#xff0c;\u4ee5\u53ca\u4e00\u7ec4\u8f85\u52a9\u5411\u91cf&#xff08;auxv&#xff09;&#xff0c;\u5305\u542b\u4e86\u8bf8\u5982\u5e73\u53f0\u6807\u8bc6\u3001\u9875\u5927\u5c0f\u3001\u7a0b\u5e8f\u5165\u53e3\u70b9\u3001\u52a8\u6001\u94fe\u63a5\u5668\u57fa\u5740\u7b49\u4fe1\u606f&#xff0c;\u4f9b\u52a8\u6001\u94fe\u63a5\u5668\u548c\u7a0b\u5e8f\u542f\u52a8\u65f6\u4f7f\u7528\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">6.\u8bbe\u7f6e\u8fdb\u7a0b\u4e0a\u4e0b\u6587\u5e76\u8df3\u8f6c\u5230\u5165\u53e3<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u66f4\u65b0 current-&gt;mm\u3001current-&gt;active_mm \u7b49\u6307\u9488&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u91cd\u7f6e\u4fe1\u53f7\u5904\u7406\u3001\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684 close-on-exec \u6807\u5fd7&#xff1b;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u6700\u540e&#xff0c;\u5c06\u7528\u6237\u6001\u5bc4\u5b58\u5668&#xff08;\u5305\u62ec\u7a0b\u5e8f\u8ba1\u6570\u5668 PC \/ RIP&#xff09;\u8bbe\u7f6e\u4e3a ELF \u5934\u4e2d\u6307\u5b9a\u7684 e_entry&#xff0c;\u7136\u540e\u6267\u884c return_to_user_mode()&#xff0c;\u5f00\u59cb\u6267\u884c hello \u7684\u7b2c\u4e00\u6761\u6307\u4ee4\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"370\" src=\"2025-06-10xpiob01cpnq.png\" width=\"327\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe78 \u865a\u62df\u5185\u5b58<\/p>\n<h3 id=\"7.8%20%E7%BC%BA%E9%A1%B5%E6%95%85%E9%9A%9C%E4%B8%8E%E7%BC%BA%E9%A1%B5%E4%B8%AD%E6%96%AD%E5%A4%84%E7%90%86\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.8 \u7f3a\u9875\u6545\u969c\u4e0e\u7f3a\u9875\u4e2d\u65ad\u5904\u7406<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7f3a\u9875\u6545\u969c\u662f\u64cd\u4f5c\u7cfb\u7edf\u7ba1\u7406\u865a\u62df\u5185\u5b58\u65f6\u7684\u4e00\u79cd\u6838\u5fc3\u673a\u5236&#xff0c;\u5f53\u7a0b\u5e8f\u8bd5\u56fe\u8bbf\u95ee\u5c1a\u672a\u52a0\u8f7d\u5230\u7269\u7406\u5185\u5b58\u7684\u865a\u62df\u5185\u5b58\u9875\u9762\u65f6\u4fbf\u4f1a\u89e6\u53d1\u3002\u73b0\u4ee3\u8ba1\u7b97\u673a\u901a\u8fc7\u865a\u62df\u5185\u5b58\u6280\u672f\u4e3a\u6bcf\u4e2a\u8fdb\u7a0b\u63d0\u4f9b\u72ec\u7acb\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4&#xff0c;\u4f7f\u5f97\u7a0b\u5e8f\u80fd\u591f\u4f7f\u7528\u6bd4\u5b9e\u9645\u7269\u7406\u5185\u5b58\u66f4\u5927\u7684\u5185\u5b58\u8d44\u6e90&#xff0c;\u4f46\u8fd9\u4e9b\u865a\u62df\u5185\u5b58\u9875\u9762\u53ef\u80fd\u5b58\u50a8\u5728\u7269\u7406\u5185\u5b58\u6216\u78c1\u76d8&#xff08;\u5982\u4ea4\u6362\u7a7a\u95f4&#xff09;\u4e2d\u3002\u5f53 CPU \u8bbf\u95ee\u67d0\u4e2a\u865a\u62df\u5730\u5740\u65f6&#xff0c;\u5185\u5b58\u7ba1\u7406\u5355\u5143&#xff08;MMU&#xff09;\u4f1a\u67e5\u8be2\u9875\u8868&#xff0c;\u82e5\u53d1\u73b0\u5bf9\u5e94\u7684\u9875\u8868\u9879\u6807\u8bb0\u4e3a\u201c\u65e0\u6548\u201d&#xff08;\u5373\u9875\u9762\u4e0d\u5728\u7269\u7406\u5185\u5b58\u4e2d&#xff09;&#xff0c;\u5219\u4f1a\u4ea7\u751f\u7f3a\u9875\u6545\u969c\u3002\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6b64\u65f6&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u6682\u505c\u5f53\u524d\u8fdb\u7a0b&#xff0c;\u8fdb\u5165\u5185\u6838\u6001\u5904\u7406\u8be5\u6545\u969c&#xff1a;\u9996\u5148\u68c0\u67e5\u8bbf\u95ee\u7684\u865a\u62df\u5730\u5740\u662f\u5426\u5408\u6cd5&#xff08;\u4f8b\u5982\u662f\u5426\u5b58\u5728\u8d8a\u754c\u6216\u6743\u9650\u9519\u8bef&#xff09;&#xff0c;\u82e5\u5408\u6cd5\u5219\u4ece\u7269\u7406\u5185\u5b58\u4e2d\u5206\u914d\u4e00\u4e2a\u7a7a\u95f2\u9875\u6846&#xff0c;\u82e5\u65e0\u7a7a\u95f2\u9875\u6846\u5219\u901a\u8fc7\u9875\u9762\u7f6e\u6362\u7b97\u6cd5&#xff08;\u5982 LRU\u3001FIFO&#xff09;\u5c06\u67d0\u4e2a\u9875\u9762\u6362\u51fa\u5230\u78c1\u76d8&#xff0c;\u968f\u540e\u4ece\u78c1\u76d8&#xff08;\u53ef\u80fd\u662f\u4ea4\u6362\u6587\u4ef6\u6216\u7a0b\u5e8f\u6587\u4ef6&#xff09;\u4e2d\u8bfb\u53d6\u76ee\u6807\u9875\u9762\u5230\u7269\u7406\u5185\u5b58&#xff0c;\u5e76\u66f4\u65b0\u9875\u8868\u4ee5\u6807\u8bb0\u8be5\u9875\u9762\u4e3a\u201c\u6709\u6548\u201d\u3002\u6700\u7ec8&#xff0c;\u7cfb\u7edf\u4f1a\u91cd\u65b0\u6267\u884c\u89e6\u53d1\u7f3a\u9875\u7684\u6307\u4ee4&#xff0c;\u4f7f\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u884c\u3002\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7f3a\u9875\u6545\u969c\u5206\u4e3a\u4e09\u79cd\u7c7b\u578b&#xff1a;\u6b21\u8981\u7f3a\u9875&#xff08;\u9875\u9762\u5df2\u5728\u5185\u5b58\u7f13\u5b58\u4e2d&#xff0c;\u4ec5\u9700\u66f4\u65b0\u9875\u8868&#xff0c;\u65e0\u78c1\u76d8 I\/O&#xff09;\u3001\u4e3b\u8981\u7f3a\u9875&#xff08;\u9700\u4ece\u78c1\u76d8\u52a0\u8f7d\u9875\u9762&#xff0c;\u8017\u65f6\u8f83\u957f&#xff09;\u548c\u65e0\u6548\u7f3a\u9875&#xff08;\u8bbf\u95ee\u975e\u6cd5\u5730\u5740\u5bfc\u81f4\u8fdb\u7a0b\u7ec8\u6b62&#xff0c;\u5982\u6bb5\u9519\u8bef&#xff09;\u3002\u5176\u5e38\u89c1\u539f\u56e0\u5305\u62ec\u7a0b\u5e8f\u521d\u6b21\u52a0\u8f7d\u4ee3\u7801\u6570\u636e\u3001\u5185\u5b58\u8bbf\u95ee\u7684\u5c40\u90e8\u6027\u53d8\u5316&#xff08;\u5982\u904d\u5386\u65b0\u6570\u7ec4&#xff09;\u6216\u7269\u7406\u5185\u5b58\u4e0d\u8db3\u5bfc\u81f4\u7684\u9891\u7e41\u9875\u9762\u7f6e\u6362&#xff08;\u5373\u201c\u6296\u52a8\u201d\u73b0\u8c61&#xff09;\u3002\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5c3d\u7ba1\u7f3a\u9875\u662f\u5185\u5b58\u6269\u5c55\u7684\u5fc5\u8981\u673a\u5236&#xff0c;\u4f46\u9891\u7e41\u7684\u4e3b\u8981\u7f3a\u9875&#xff08;\u5c24\u5176\u662f\u6d89\u53ca\u78c1\u76d8 I\/O \u65f6&#xff09;\u4f1a\u663e\u8457\u62d6\u6162\u7a0b\u5e8f\u6027\u80fd\u3002\u4f8b\u5982&#xff0c;\u5728\u9996\u6b21\u8bbf\u95ee\u52a8\u6001\u5206\u914d\u7684\u5927\u6570\u7ec4\u5143\u7d20\u65f6&#xff0c;\u82e5\u9875\u9762\u672a\u9884\u52a0\u8f7d&#xff0c;\u6bcf\u6b21\u8bbf\u95ee\u90fd\u53ef\u80fd\u89e6\u53d1\u7f3a\u9875\u3002\u4e3a\u4f18\u5316\u6027\u80fd&#xff0c;\u53ef\u901a\u8fc7\u9884\u52a0\u8f7d\u9875\u9762\u3001\u8c03\u6574\u9875\u9762\u5927\u5c0f\u3001\u51cf\u5c11\u5185\u5b58\u788e\u7247\u6216\u589e\u52a0\u7269\u7406\u5185\u5b58\u7b49\u624b\u6bb5\u964d\u4f4e\u7f3a\u9875\u9891\u7387&#xff0c;\u4ece\u800c\u63d0\u5347\u7cfb\u7edf\u6548\u7387\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4e0b\u56fe\u5bf9VP3\u7684\u5f15\u7528\u4e0d\u547d\u4e2d&#xff0c;\u4ece\u800c\u89e6\u53d1\u7f3a\u9875\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"276\" src=\"2025-06-101hwmwhmlfce.png\" width=\"418\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe79 \u7f3a\u9875<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7f3a\u9875\u4e4b\u540e&#xff0c;\u7f3a\u9875\u5904\u7406\u7a0b\u5e8f\u9009\u62e9VP4\u4f5c\u4e3a\u727a\u7272\u9875&#xff0c;\u5e76\u4ece\u78c1\u76d8\u4e0a\u7528VP3\u7684\u526f\u672c\u53d6\u4ee3\u5b83\u3002\u5728\u7f3a\u9875\u5904\u7406\u7a0b\u5e8f\u91cd\u65b0\u542f\u52a8\u5bfc\u81f4\u7f3a\u9875\u7684\u6307\u4ee4\u4e4b\u540e&#xff0c;\u8be5\u6307\u4ee4\u5c06\u4ece\u5185\u5b58\u4e2d\u6b63\u5e38\u5730\u8bfb\u53d6\u5b57&#xff0c;\u800c\u4e0d\u4f1a\u518d\u4ea7\u751f\u5f02\u5e38\u3002\u3001<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7f3a\u9875\u4e2d\u65ad\u5904\u7406\u662f\u64cd\u4f5c\u7cfb\u7edf\u5728\u7a0b\u5e8f\u8bbf\u95ee\u672a\u52a0\u8f7d\u5230\u7269\u7406\u5185\u5b58\u7684\u865a\u62df\u9875\u9762\u65f6\u89e6\u53d1\u7684\u6838\u5fc3\u673a\u5236\u3002\u5f53CPU\u901a\u8fc7\u9875\u8868\u53d1\u73b0\u76ee\u6807\u9875\u9762\u4e0d\u5728\u7269\u7406\u5185\u5b58\u65f6&#xff0c;\u4f1a\u6682\u505c\u5f53\u524d\u8fdb\u7a0b\u5e76\u4ea4\u7531\u64cd\u4f5c\u7cfb\u7edf\u5904\u7406&#xff1a;\u9996\u5148\u68c0\u67e5\u8bbf\u95ee\u5730\u5740\u7684\u5408\u6cd5\u6027&#xff0c;\u82e5\u5408\u6cd5\u5219\u5206\u914d\u7269\u7406\u9875\u6846&#xff0c;\u968f\u540e\u4ece\u78c1\u76d8\u52a0\u8f7d\u6240\u9700\u9875\u9762\u5230\u5185\u5b58&#xff0c;\u66f4\u65b0\u9875\u8868\u5e76\u6807\u8bb0\u4e3a\u201c\u6709\u6548\u201d&#xff0c;\u6700\u540e\u91cd\u65b0\u6267\u884c\u88ab\u4e2d\u65ad\u7684\u6307\u4ee4\u3002\u6b64\u8fc7\u7a0b\u82e5\u6d89\u53ca\u78c1\u76d8I\/O\u4f1a\u663e\u8457\u5ef6\u8fdf\u7a0b\u5e8f\u8fd0\u884c&#xff0c;\u800c\u9875\u9762\u5df2\u7f13\u5b58\u65f6\u5219\u65e0\u9700\u78c1\u76d8\u64cd\u4f5c&#xff0c;\u6548\u7387\u66f4\u9ad8\u3002\u8be5\u673a\u5236\u4fdd\u969c\u4e86\u865a\u62df\u5185\u5b58\u7684\u7075\u6d3b\u6027&#xff0c;\u4f46\u9891\u7e41\u7f3a\u9875\u4f1a\u4e25\u91cd\u62d6\u7d2f\u7cfb\u7edf\u6027\u80fd\u3002<\/p>\n<h3 id=\"7.9%E5%8A%A8%E6%80%81%E5%AD%98%E5%82%A8%E5%88%86%E9%85%8D%E7%AE%A1%E7%90%86\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.9\u52a8\u6001\u5b58\u50a8\u5206\u914d\u7ba1\u7406<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u52a8\u6001\u5185\u5b58\u5206\u914d\u5668\u4f5c\u4e3a\u5185\u5b58\u7ba1\u7406\u7684\u6838\u5fc3\u7ec4\u4ef6&#xff0c;\u4e3b\u8981\u8d1f\u8d23\u7ba1\u7406\u8fdb\u7a0b\u865a\u62df\u5185\u5b58\u4e2d\u7684\u5806\u533a\u57df\u3002\u8be5\u673a\u5236\u5c06\u5806\u7a7a\u95f4\u7ec4\u7ec7\u4e3a\u591a\u4e2a\u79bb\u6563\u7684\u5185\u5b58\u533a\u5757\u96c6\u5408&#xff0c;\u6bcf\u4e2a\u533a\u5757\u8868\u5f81\u4e00\u6bb5\u8fde\u7eed\u7684\u865a\u62df\u5185\u5b58\u5355\u5143&#xff0c;\u5176\u72b6\u6001\u53ef\u5206\u4e3a\u5df2\u5206\u914d&#xff08;allocated&#xff09;\u6216\u7a7a\u95f2&#xff08;free&#xff09;\u4e24\u79cd\u5f62\u6001\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5df2\u5206\u914d\u533a\u5757\u7531\u5e94\u7528\u7a0b\u5e8f\u663e\u5f0f\u58f0\u660e\u5360\u7528&#xff0c;\u8fd9\u4e9b\u5185\u5b58\u5355\u5143\u88ab\u9501\u5b9a\u4e3a\u4e13\u7528\u72b6\u6001\u76f4\u81f3\u91ca\u653e\u3002\u4e0e\u4e4b\u5bf9\u5e94\u7684\u7a7a\u95f2\u533a\u5757\u5219\u5904\u4e8e\u5f85\u5206\u914d\u72b6\u6001&#xff0c;\u5176\u5185\u5b58\u8d44\u6e90\u53ef\u88ab\u52a8\u6001\u8c03\u5ea6\u4ee5\u6ee1\u8db3\u65b0\u7684\u5185\u5b58\u8bf7\u6c42\u3002\u7279\u522b\u9700\u8981\u6307\u51fa\u7684\u662f&#xff0c;\u5185\u5b58\u533a\u5757\u7684\u72b6\u6001\u8f6c\u6362\u9075\u5faa\u660e\u786e\u7684\u89c4\u5219&#xff1a;\u7a7a\u95f2\u533a\u5757\u4ec5\u80fd\u901a\u8fc7\u663e\u5f0f\u7684\u5206\u914d\u8bf7\u6c42\u8f6c\u4e3a\u5360\u7528\u72b6\u6001&#xff0c;\u800c\u5df2\u5206\u914d\u533a\u5757\u7684\u91ca\u653e\u65e2\u53ef\u901a\u8fc7\u7a0b\u5e8f\u5458\u7684\u663e\u5f0f\u64cd\u4f5c\u5b8c\u6210&#xff0c;\u4e5f\u53ef\u80fd\u7531\u5185\u5b58\u5206\u914d\u5668\u901a\u8fc7\u5783\u573e\u56de\u6536\u7b49\u9690\u5f0f\u673a\u5236\u81ea\u52a8\u5b9e\u73b0\u3002\u8fd9\u79cd\u53cc\u6a21\u5f0f\u91ca\u653e\u673a\u5236\u6709\u6548\u5e73\u8861\u4e86\u5f00\u53d1\u7075\u6d3b\u6027\u4e0e\u5185\u5b58\u5b89\u5168\u6027&#xff0c;\u6784\u6210\u73b0\u4ee3\u5185\u5b58\u7ba1\u7406\u4f53\u7cfb\u7684\u91cd\u8981\u7279\u5f81\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5185\u5b58\u7ba1\u7406\u4e2d\u7684\u5206\u914d\u5668\u6280\u672f\u53ef\u5206\u4e3a\u4e24\u5927\u8303\u5f0f&#xff1a;\u663e\u5f0f\u5206\u914d\u5668\u4e0e\u9690\u5f0f\u5206\u914d\u5668&#xff0c;\u4e8c\u8005\u5728\u5185\u5b58\u56de\u6536\u673a\u5236\u4e0a\u5b58\u5728\u672c\u8d28\u5dee\u5f02\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">1. \u663e\u5f0f\u5206\u914d\u5668&#xff1a;\u91c7\u7528\u5f00\u53d1\u8005\u4e3b\u5bfc\u7684\u5185\u5b58\u7ba1\u7406\u6a21\u5f0f&#xff0c;\u8981\u6c42\u7a0b\u5e8f\u5458\u901a\u8fc7\u7279\u5b9a\u6307\u4ee4&#xff08;\u5982C\u8bed\u8a00\u7684free()&#xff09;\u4e3b\u52a8\u91ca\u653e\u4e0d\u518d\u4f7f\u7528\u7684\u5185\u5b58\u5757\u3002\u8fd9\u79cd\u673a\u5236\u5c06\u5185\u5b58\u751f\u547d\u5468\u671f\u7ba1\u7406\u7684\u8d23\u4efb\u8d4b\u4e88\u5f00\u53d1\u8005&#xff0c;\u867d\u80fd\u5b9e\u73b0\u7cbe\u51c6\u63a7\u5236&#xff0c;\u4f46\u4e5f\u5b58\u5728\u5185\u5b58\u6cc4\u6f0f&#xff08;Memory Leak&#xff09;\u6216\u91cd\u590d\u91ca\u653e&#xff08;Double Free&#xff09;\u7b49\u98ce\u9669&#xff0c;\u5178\u578b\u4ee3\u8868\u5305\u62ecC\u6807\u51c6\u5e93\u7684malloc\/free\u63a5\u53e3\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">2. \u9690\u5f0f\u5206\u914d\u5668&#xff1a;\u901a\u8fc7\u81ea\u52a8\u5783\u573e\u56de\u6536&#xff08;Garbage Collection, GC&#xff09;\u673a\u5236\u5b9e\u73b0\u5185\u5b58\u81ea\u6cbb&#xff0c;\u5176\u6838\u5fc3\u5728\u4e8e\u52a8\u6001\u8ffd\u8e2a\u5185\u5b58\u5757\u7684\u5f15\u7528\u72b6\u6001\u3002\u5f53\u5206\u914d\u5668\u68c0\u6d4b\u5230\u67d0\u5185\u5b58\u5757\u4e0d\u518d\u88ab\u4efb\u4f55\u6307\u9488\u5f15\u7528\u65f6&#xff0c;\u81ea\u52a8\u5c06\u5176\u6807\u8bb0\u4e3a\u53ef\u56de\u6536\u8d44\u6e90\u5e76\u91ca\u653e\u3002\u8be5\u673a\u5236\u6709\u6548\u907f\u514d\u4e86\u4eba\u4e3a\u7ba1\u7406\u5931\u8bef&#xff0c;\u4f46\u9700\u8981\u8fd0\u884c\u65f6\u7cfb\u7edf\u7ef4\u62a4\u5bf9\u8c61\u5f15\u7528\u56fe\u8c31&#xff08;\u5982Java\u865a\u62df\u673a&#xff09;&#xff0c;\u4e14\u53ef\u80fd\u5f15\u5165GC\u6682\u505c\u7b49\u6027\u80fd\u5f00\u9500\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5e26\u8fb9\u754c\u6807\u7b7e\u7684\u9690\u5f0f\u7a7a\u95f2\u94fe\u8868\u5206\u914d\u5668\u539f\u7406&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"155\" src=\"2025-06-10ytzhxcdwtfg.jpg\" width=\"541\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe80 \u9690\u5f0f\u7a7a\u95f2\u94fe\u8868\u5206\u914d\u5668<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6bcf\u4e2a\u5757\u53ef\u4ee5\u589e\u52a0\u56db\u5b57\u8282\u7684\u5934\u90e8\u548c\u56db\u5b57\u8282\u7684\u811a\u90e8\u4fdd\u5b58\u5757\u5927\u5c0f\u548c\u662f\u5426\u5206\u914d\u4fe1\u606f&#xff0c;\u53ef\u4ee5\u5728 \u5e38\u6570\u65f6\u95f4\u8bbf\u95ee\u5230\u6bcf\u4e2a\u5757\u7684\u4e0b\u4e00\u4e2a\u548c\u524d\u4e00\u4e2a\u5757&#xff0c;\u4f7f\u7a7a\u95f2\u5757\u7684\u5408\u5e76\u4e5f\u53d8\u4e3a\u5e38\u6570\u65f6\u95f4&#xff0c;\u800c\u4e14\u53ef\u4ee5\u904d\u5386\u6574\u4e2a\u94fe\u8868\u3002\u9690\u5f0f\u7a7a\u95f2\u94fe\u8868\u5373\u4e3a&#xff0c;\u5229\u7528\u8fb9\u754c\u6807\u7b7e\u533a\u5206\u5df2\u5206\u914d\u5757\u548c\u672a\u5206\u914d\u5757&#xff0c;\u6839\u636e\u4e0d\u540c\u7684\u5206\u914d\u7b56\u7565(\u9996\u6b21\u9002\u914d\u3001\u4e0b\u4e00\u6b21\u9002\u914d\u3001\u6700\u4f73\u9002\u914d)&#xff0c;\u904d\u5386\u6574\u4e2a\u94fe\u8868&#xff0c;\u4e00\u65e6\u627e\u5230\u7b26\u5408\u8981\u6c42\u7684\u7a7a\u95f2\u5757&#xff0c;\u5c31\u628a\u5b83\u7684\u5df2\u5206\u914d\u4f4d\u8bbe\u7f6e\u4e3a1&#xff0c;\u8fd4\u56de\u8fd9\u4e2a\u5757\u7684\u6307\u9488\u3002\u9690\u5f0f\u7a7a\u95f2\u94fe\u8868\u5e76\u4e0d\u662f\u771f\u6b63\u7684\u94fe\u8868&#xff0c;\u800c\u662f&#034;\u9690\u5f0f&#034;\u5730\u628a\u7a7a\u95f2\u5757\u8fde\u63a5\u4e86\u8d77\u6765(\u4e2d\u95f4\u5939\u6742\u7740\u5df2\u5206\u914d\u5757)\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u663e\u5f0f\u7a7a\u95f2\u94fe\u8868\u7684\u57fa\u672c\u539f\u7406&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"219\" src=\"2025-06-10du2xmmdatid.png\" width=\"477\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe81 \u663e\u5f0f\u7a7a\u95f2\u94fe\u8868\u5206\u914d\u5668<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4f7f\u7528\u53cc\u5411\u94fe\u8868\u800c\u4e0d\u662f\u9690\u5f0f\u7a7a\u95f2\u94fe\u8868&#xff0c;\u4f7f\u9996\u6b21\u9002\u914d\u7684\u5206\u914d\u65f6\u95f4\u4ece\u5757\u603b\u6570\u7684\u7ebf \u6027\u65f6\u95f4\u51cf\u5c11\u5230\u4e86\u7a7a\u95f2\u5757\u6570\u91cf\u7684\u7ebf\u6027\u65f6\u95f4\u3002\u79cd\u65b9\u6cd5\u4f7f\u7528\u540e\u8fdb\u5148\u51fa\u7684\u987a\u5e8f\u7ef4\u62a4\u94fe\u8868&#xff0c;\u5c06\u65b0\u91ca\u653e\u7684\u5757\u5728\u94fe\u8868\u7684\u5f00\u59cb\u5904\u3002\u4f7f\u7528LIFO\u7684\u987a\u5e8f\u548c\u9996\u6b21\u9002\u914d\u7684\u653e\u7f6e\u7b56\u7565&#xff0c;\u5206\u914d\u5668\u4f1a\u6700\u5148\u68c0\u67e5\u6700\u8fd1\u4f7f\u7528\u8fc7 \u7684\u5757&#xff0c;\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u91ca\u653e\u4e00\u4e2a\u5757\u53ef\u4ee5\u5728\u7ebf\u6027\u7684\u65f6\u95f4\u5185\u5b8c\u6210&#xff0c;\u5982\u679c\u4f7f\u7528\u4e86\u8fb9\u754c \u6807\u8bb0&#xff0c;\u90a3\u4e48\u5408\u5e76\u4e5f\u53ef\u4ee5\u5728\u5e38\u6570\u65f6\u95f4\u5185\u5b8c\u6210\u3002\u6309\u7167\u5730\u5740\u987a\u5e8f\u6765\u7ef4\u62a4\u94fe\u8868&#xff0c;\u5176\u4e2d\u94fe \u8868\u4e2d\u7684\u6bcf\u4e2a\u5757\u7684\u5730\u5740\u90fd\u5c0f\u4e8e\u5b83\u7684\u540e\u7ee7\u7684\u5730\u5740&#xff0c;\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u91ca\u653e\u4e00\u4e2a\u5757\u9700\u8981 \u7ebf\u6027\u65f6\u95f4\u7684\u641c\u7d22\u6765\u5b9a\u4f4d\u5408\u9002\u7684\u524d\u9a71\u3002\u5e73\u8861\u70b9\u5728\u4e8e&#xff0c;\u6309\u7167\u5730\u5740\u6392\u5e8f\u9996\u6b21\u9002\u914d\u6bd4 LIFO \u6392\u5e8f\u7684\u9996\u6b21\u9002\u914d\u6709\u7740\u66f4\u9ad8\u7684\u5185\u5b58\u5229\u7528\u7387&#xff0c;\u63a5\u8fd1\u6700\u4f73\u9002\u914d\u7684\u5229\u7528\u7387\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u52a8\u6001\u5185\u5b58\u7ba1\u7406\u901a\u8fc7\u4e24\u79cd\u57fa\u672c\u65b9\u6cd5\u5b9e\u73b0&#xff1a;\u663e\u5f0f\u7ba1\u7406\u7531\u5f00\u53d1\u8005\u624b\u52a8\u5206\u914d&#xff08;\u5982malloc&#xff09;\u548c\u91ca\u653e&#xff08;\u5982free&#xff09;\u5185\u5b58&#xff0c;\u7cbe\u51c6\u9ad8\u6548\u4f46\u6613\u5f15\u53d1\u6cc4\u6f0f\u6216\u9519\u8bef&#xff1b;\u9690\u5f0f\u7ba1\u7406\u5219\u4f9d\u8d56\u5783\u573e\u56de\u6536\u5668&#xff08;GC&#xff09;\u81ea\u52a8\u8ffd\u8e2a\u65e0\u5f15\u7528\u5185\u5b58\u5e76\u91ca\u653e&#xff0c;\u7b80\u5316\u5f00\u53d1\u4f46\u53ef\u80fd\u5f15\u5165\u6027\u80fd\u6ce2\u52a8\u3002\u6838\u5fc3\u7b56\u7565\u5305\u62ec&#xff1a;\u91c7\u7528\u9996\u6b21\u9002\u5e94\u3001\u6700\u4f73\u9002\u5e94\u7b49\u7b97\u6cd5\u641c\u7d22\u7a7a\u95f2\u5185\u5b58\u5757&#xff1b;\u901a\u8fc7\u5757\u5408\u5e76\u6216\u5185\u5b58\u538b\u7f29\u51cf\u5c11\u788e\u7247&#xff1b;\u5229\u7528\u5185\u5b58\u6c60\u9884\u5206\u914d\u8d44\u6e90\u63d0\u5347\u6548\u7387&#xff0c;\u6216\u901a\u8fc7\u5206\u79bb\u7a7a\u95f2\u94fe\u8868\u3001\u4f19\u4f34\u7cfb\u7edf\u5206\u5c42\u4f18\u5316\u5206\u914d\u3002\u4f8b\u5982&#xff0c; printf\u53ef\u80fd\u5728\u5904\u7406\u4e0d\u5b9a\u957f\u8f93\u51fa\u65f6\u8c03\u7528malloc\u52a8\u6001\u7533\u8bf7\u7f13\u51b2\u533a&#xff0c;\u6b64\u65f6\u5185\u5b58\u6c60\u6280\u672f\u53ef\u51cf\u5c11\u9891\u7e41\u5206\u914d\u7684\u5f00\u9500\u3002\u52a8\u6001\u5185\u5b58\u7ba1\u7406\u9700\u6743\u8861\u7a7a\u95f4\u4e0e\u65f6\u95f4\u6548\u7387&#xff0c;\u5728\u63a7\u5236\u788e\u7247\u3001\u964d\u4f4e\u5ef6\u8fdf\u548c\u4fdd\u8bc1\u7075\u6d3b\u6027\u4e4b\u95f4\u5bfb\u6c42\u5e73\u8861&#xff0c;\u662f\u7cfb\u7edf\u6027\u80fd\u4f18\u5316\u7684\u5173\u952e\u73af\u8282\u3002<\/p>\n<h3 id=\"7.10%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93\" style=\"margin-left:0;margin-right:0;text-align:justify\">7.10\u672c\u7ae0\u5c0f\u7ed3<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u672c\u7ae0\u5982\u540c\u6784\u5efa\u4e00\u5957\u201c\u57ce\u5e02\u7ea7\u5185\u5b58\u7ba1\u7406\u4f53\u7cfb\u201d&#xff1a;\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">1. \u865a\u62df\u5730\u5740\u7a7a\u95f4\u662f\u7a0b\u5e8f\u89c6\u89d2\u7684\u201c\u865a\u62df\u57ce\u5e02\u5730\u56fe\u201d&#xff0c;\u6bb5\u5f0f\u7ba1\u7406\u5982\u540c\u5c06\u57ce\u5e02\u5212\u5206\u4e3a\u5546\u4e1a\u533a\u3001\u4f4f\u5b85\u533a\u7b49\u4e13\u5c5e\u5206\u533a&#xff08;Intel\u5206\u6bb5\u673a\u5236&#xff09;&#xff0c;\u800c\u9875\u5f0f\u7ba1\u7406\u5219\u50cf\u5c06\u57ce\u5e02\u571f\u5730\u7ec6\u5316\u4e3a\u6807\u51c6\u5c3a\u5bf8\u7684\u6a21\u5757\u5316\u62fc\u56fe&#xff08;\u5185\u5b58\u5206\u9875&#xff09;&#xff0c;\u901a\u8fc7VA\u5230PA\u8f6c\u6362\u5b9e\u73b0\u201c\u865a\u62df\u5730\u56fe\u5750\u6807\u201d\u5230\u201c\u7269\u7406\u571f\u5730\u5b9a\u4f4d\u201d\u7684\u7cbe\u51c6\u6620\u5c04&#xff1b;\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">2. \u7269\u7406\u5185\u5b58\u8bbf\u95ee\u76f8\u5f53\u4e8e\u5728\u57ce\u5e02\u771f\u5b9e\u5730\u5757\u4e0a\u5efa\u8bbe\u65bd\u5de5&#xff0c;\u8fdb\u7a0bfork\/execve\u65f6\u7684\u5185\u5b58\u6620\u5c04\u5982\u540c\u4e3a\u65b0\u5efa\u57ce\u533a\u5feb\u901f\u590d\u5236\u6216\u91cd\u5efa\u89c4\u5212\u84dd\u56fe&#xff1b;\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">3. \u7f3a\u9875\u4e2d\u65ad\u7c7b\u4f3c\u65bd\u5de5\u65f6\u53d1\u73b0\u67d0\u5730\u5757\u672a\u5f00\u53d1&#xff0c;\u7acb\u5373\u89e6\u53d1\u201c\u7269\u6d41\u8865\u8d27\u7cfb\u7edf\u201d\u8c03\u62e8\u8d44\u6e90&#xff08;\u52a0\u8f7d\u7269\u7406\u9875&#xff09;&#xff0c;\u800c\u52a8\u6001\u5185\u5b58\u5206\u914d\u5219\u662f\u57ce\u5e02\u4e2d\u7075\u6d3b\u8c03\u914d\u4e34\u65f6\u4ed3\u5e93\u7684\u7269\u6d41\u8c03\u5ea6\u4e2d\u5fc3&#xff08;\u5806\u7ba1\u7406&#xff09;&#xff0c;\u534f\u8c03\u5185\u5b58\u8d44\u6e90\u7684\u5b9e\u65f6\u4f9b\u9700\u3002\u00a0<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fd9\u5957\u4f53\u7cfb\u4ece\u89c4\u5212\u5230\u6267\u884c&#xff0c;\u8d2f\u7a7f\u865a\u62df\u6784\u60f3\u3001\u7269\u7406\u5b9e\u65bd\u4e0e\u52a8\u6001\u8c03\u5ea6&#xff0c;\u6784\u5efa\u4e86\u7a0b\u5e8f\u8fd0\u884c\u7684\u201c\u5185\u5b58\u751f\u6001\u57ce\u5e02\u201d\u3002<\/p>\n<\/p>\n<h2 id=\"%E7%AC%AC8%E7%AB%A0%20hello%E7%9A%84IO%E7%AE%A1%E7%90%86\" style=\"margin-left:0;margin-right:0;text-align:justify\">\u7b2c8\u7ae0 hello\u7684IO\u7ba1\u7406<\/h2>\n<h3 id=\"8.1%20Linux%E7%9A%84IO%E8%AE%BE%E5%A4%87%E7%AE%A1%E7%90%86%E6%96%B9%E6%B3%95\" style=\"margin-left:0;margin-right:0;text-align:justify\">8.1 Linux\u7684IO\u8bbe\u5907\u7ba1\u7406\u65b9\u6cd5<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8bbe\u5907\u7684\u6a21\u578b\u5316&#xff1a;\u6587\u4ef6<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8bbe\u5907\u7ba1\u7406&#xff1a;unix io\u63a5\u53e3<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fd9\u79cd\u5c06\u8bbe\u5907\u6620\u5c04\u4e3a\u6587\u4ef6\u7684\u8bbe\u8ba1&#xff0c;\u4f7f\u5185\u6838\u80fd\u591f\u63d0\u4f9b\u4e00\u5957\u7b80\u5355\u800c\u7edf\u4e00\u7684\u5e94\u7528\u5c42\u63a5\u53e3&#xff0c;\u4e5f\u5c31\u662f\u7ecf\u5178\u7684 Unix I\/O\u3002\u65e0\u8bba\u662f\u78c1\u76d8\u3001\u7ec8\u7aef\u8fd8\u662f\u7f51\u7edc\u8bbe\u5907&#xff0c;\u5e94\u7528\u7a0b\u5e8f\u90fd\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u56db\u6b65\u4ee5\u4e00\u81f4\u7684\u65b9\u5f0f\u4e0e\u5b83\u4eec\u4ea4\u4e92&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6253\u5f00\u6587\u4ef6\u3001\u5b9a\u4f4d\u6587\u4ef6\u6307\u9488\u3001\u8bfb\u5199\u6570\u636e&#xff09;\u3001\u5173\u95ed\u6587\u4ef6<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u901a\u8fc7\u8fd9\u79cd\u201c\u4e07\u7269\u7686\u6587\u4ef6\u201d\u7684\u7406\u5ff5&#xff0c;Linux \u5b9e\u73b0\u4e86\u8bbe\u5907\u8bbf\u95ee\u7684\u9ad8\u5ea6\u6a21\u5757\u5316\u548c\u53ef\u6269\u5c55\u6027&#xff0c;\u4f7f\u5f97\u65b0\u8bbe\u5907\u7684\u63a5\u5165\u4ec5\u9700\u9075\u5faa\u6587\u4ef6\u63a5\u53e3\u89c4\u8303\u5373\u53ef&#xff0c;\u65e0\u9700\u4e3a\u6bcf\u79cd\u8bbe\u5907\u5f00\u53d1\u72ec\u7acb\u7684\u8c03\u7528\u63a5\u53e3\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h3 id=\"8.2%20%E7%AE%80%E8%BF%B0Unix%20IO%E6%8E%A5%E5%8F%A3%E5%8F%8A%E5%85%B6%E5%87%BD%E6%95%B0\" style=\"margin-left:0;margin-right:0;text-align:justify\">8.2 \u7b80\u8ff0Unix IO\u63a5\u53e3\u53ca\u5176\u51fd\u6570<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">Unix I\/O \u63a5\u53e3\u7684\u51e0\u79cd\u64cd\u4f5c&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">1. \u6253\u5f00\u4e0e\u521b\u5efa&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">open() \/ openat()\u6253\u5f00\u4e00\u4e2a\u5df2\u5b58\u5728\u7684\u6587\u4ef6\u6216\u8bbe\u5907&#xff0c;\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff1b;\u540c\u65f6\u53ef\u6307\u5b9a\u6807\u5fd7\u5982 O_RDONLY\u3001O_CREAT\u3001O_CLOEXEC \u7b49\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">creat()\u76f8\u5f53\u4e8e open(path, O_CREAT|O_WRONLY|O_TRUNC, mode) \u7684\u7b80\u5316\u63a5\u53e3&#xff0c;\u7528\u4e8e\u521b\u5efa\u5e76\u6253\u5f00\u65b0\u6587\u4ef6\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">2. \u5173\u95ed<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">close()\u5173\u95ed\u6307\u5b9a\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u91ca\u653e\u5185\u6838\u4e2d\u5bf9\u5e94\u7684\u6253\u5f00\u8868\u9879\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">3. \u6570\u636e\u4f20\u8f93<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">read()\u4ece\u6587\u4ef6\u63cf\u8ff0\u7b26\u5bf9\u5e94\u7684\u6587\u4ef6\u6216\u8bbe\u5907\u4e2d\u8bfb\u53d6\u6700\u591a nbytes \u5b57\u8282\u5230\u7528\u6237\u7f13\u51b2\u533a&#xff0c;\u8fd4\u56de\u5b9e\u9645\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">write()\u5c06\u7528\u6237\u7f13\u51b2\u533a\u4e2d\u7684\u6700\u591a nbytes \u5b57\u8282\u5199\u5165\u5230\u5bf9\u5e94\u7684\u6587\u4ef6\u6216\u8bbe\u5907&#xff0c;\u8fd4\u56de\u5b9e\u9645\u5199\u5165\u7684\u5b57\u8282\u6570\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">pread() \/ pwrite()\u4e0e read\/write \u7c7b\u4f3c&#xff0c;\u4f46\u5728\u4e0d\u6539\u53d8\u6587\u4ef6\u504f\u79fb\u91cf\u7684\u524d\u63d0\u4e0b\u6307\u5b9a\u8bfb\u53d6\/\u5199\u5165\u7684\u6587\u4ef6\u504f\u79fb\u4f4d\u7f6e\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">4. \u6587\u4ef6\u504f\u79fb\u5b9a\u4f4d<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">lseek()\u8c03\u6574\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u5f53\u524d\u504f\u79fb\u91cf&#xff0c;\u53ef\u7528\u4e8e\u968f\u673a\u8bbf\u95ee\u6216\u57fa\u4e8e\u5f53\u524d\u4f4d\u7f6e\/\u6587\u4ef6\u5f00\u5934\/\u6587\u4ef6\u672b\u5c3e\u7684\u5bfb\u5740\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">5. \u63a7\u5236\u4e0e\u5c5e\u6027\u67e5\u8be2<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">ioctl()\u5411\u8bbe\u5907\u6216\u6587\u4ef6\u63cf\u8ff0\u7b26\u53d1\u9001\u7279\u6b8a\u63a7\u5236\u6307\u4ee4&#xff0c;\u7528\u4e8e\u914d\u7f6e\u786c\u4ef6\u6216\u67e5\u8be2\u5e95\u5c42\u9a71\u52a8\u72b6\u6001\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">fcntl()\u5bf9\u6587\u4ef6\u63cf\u8ff0\u7b26\u6267\u884c\u5404\u79cd\u64cd\u4f5c&#xff0c;\u5982\u8bbe\u7f6e\u975e\u963b\u585e&#xff08;F_SETFL, O_NONBLOCK&#xff09;\u3001\u83b7\u53d6\/\u8bbe\u7f6e close-on-exec \u6807\u5fd7\u3001\u590d\u5236\u63cf\u8ff0\u7b26\u7b49\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">6. \u63cf\u8ff0\u7b26\u590d\u5236<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">dup() \/ dup2() \/ dup3()\u590d\u5236\u4e00\u4e2a\u5df2\u6709\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u751f\u6210\u65b0\u7684\u63cf\u8ff0\u7b26\u6307\u5411\u540c\u4e00\u5185\u6838\u6253\u5f00\u8868\u9879&#xff0c;\u53ef\u7528\u4e8e\u91cd\u5b9a\u5411\u6807\u51c6\u8f93\u5165\/\u8f93\u51fa\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">7. I\/O \u591a\u8def\u590d\u7528<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">select() \/ pselect()\u76d1\u89c6\u4e00\u7ec4\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u53ef\u8bfb\u3001\u53ef\u5199\u6216\u5f02\u5e38\u72b6\u6001&#xff0c;\u652f\u6301\u8d85\u65f6\u7b49\u5f85\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">poll() \u7c7b\u4f3c select&#xff0c;\u4f7f\u7528 pollfd \u6570\u7ec4\u5e76\u652f\u6301\u66f4\u591a\u4e8b\u4ef6\u7c7b\u578b&#xff0c;\u89e3\u51b3\u4e86\u6587\u4ef6\u63cf\u8ff0\u7b26\u6570\u91cf\u9650\u5236\u7684\u95ee\u9898\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">epoll&#xff08;Linux \u4e13\u6709&#xff1a;epoll_create1\u3001epoll_ctl\u3001epoll_wait&#xff09;\u9762\u5411\u5927\u89c4\u6a21\u5e76\u53d1\u573a\u666f\u8bbe\u8ba1\u7684\u9ad8\u6548\u591a\u8def\u590d\u7528\u63a5\u53e3\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">8. \u5185\u5b58\u6620\u5c04<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">mmap()\u5c06\u6587\u4ef6\u6216\u8bbe\u5907\u6620\u5c04\u5230\u8fdb\u7a0b\u865a\u62df\u5185\u5b58\u7a7a\u95f4&#xff0c;\u8bfb\u5199\u65f6\u76f4\u63a5\u5728\u5730\u5740\u7a7a\u95f4\u64cd\u4f5c&#xff0c;\u53ef\u7528\u4e8e\u9ad8\u6027\u80fd I\/O \u6216\u4e0e\u786c\u4ef6\u5171\u4eab\u5185\u5b58\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">munmap()\u53d6\u6d88\u5148\u524d\u7684\u6620\u5c04&#xff0c;\u91ca\u653e\u5bf9\u5e94\u7684\u865a\u62df\u5730\u5740\u533a\u95f4\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">Unix I\/O \u51fd\u6570&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">1. int open(const char *pathname, int flags, mode_t mode) open \u51fd\u6570\u7528\u6307\u5b9a\u7684 pathname \u6253\u5f00&#xff08;\u6216\u521b\u5efa&#xff09;\u4e00\u4e2a\u6587\u4ef6&#xff0c;\u5e76\u8fd4\u56de\u5bf9\u5e94\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002\u8fd4\u56de\u503c\u4e3a\u8fdb\u7a0b\u4e2d\u5c1a\u672a\u4f7f\u7528\u7684\u6700\u5c0f\u6574\u578b\u63cf\u8ff0\u7b26\u3002flags \u53c2\u6570\u6307\u5b9a\u8bbf\u95ee\u65b9\u5f0f&#xff08;\u5982\u53ea\u8bfb\u3001\u53ea\u5199\u3001\u521b\u5efa\u3001\u622a\u65ad\u3001\u5173\u95ed\u6267\u884c\u65f6\u7ee7\u627f\u7b49&#xff09;&#xff0c;mode \u53c2\u6570\u5219\u5728\u521b\u5efa\u65b0\u6587\u4ef6\u65f6\u5b9a\u4e49\u6587\u4ef6\u7684\u6743\u9650\u4f4d&#xff08;\u5982\u6240\u6709\u8005\u8bfb\u5199\u3001\u7ec4\u8bfb\u3001\u5176\u4ed6\u4eba\u8bfb\u7b49&#xff09;\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">2. int close(int fd); close \u51fd\u6570\u5173\u95ed\u53c2\u6570 fd \u6307\u5b9a\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u4f7f\u5176\u4e0d\u518d\u5f15\u7528\u4efb\u4f55\u6587\u4ef6\u6216\u8bbe\u5907&#xff0c;\u5e76\u5c06\u8be5\u63cf\u8ff0\u7b26\u8fd4\u8fd8\u7ed9\u7cfb\u7edf\u4ee5\u4f9b\u540e\u7eed open \u4f7f\u7528\u3002\u82e5\u8fd9\u662f\u6700\u540e\u4e00\u4e2a\u6307\u5411\u8be5\u6587\u4ef6\u7684\u63cf\u8ff0\u7b26&#xff0c;\u5219\u4f1a\u91ca\u653e\u76f8\u5173\u8d44\u6e90&#xff0c;\u4f8b\u5982\u79fb\u9664\u4efb\u4f55\u8bb0\u5f55\u9501&#xff0c;\u4e14\u82e5\u6587\u4ef6\u5df2\u88ab\u5220\u9664&#xff0c;\u5219\u6b64\u65f6\u624d\u771f\u6b63\u56de\u6536\u78c1\u76d8\u7a7a\u95f4\u3002\u64cd\u4f5c\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de -1 \u5e76\u8bbe\u7f6e errno\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">3. ssize_t read(int fd, void *buf, size_t count); read \u51fd\u6570\u5c1d\u8bd5\u4ece\u63cf\u8ff0\u7b26 fd \u5f53\u524d\u7684\u6587\u4ef6\u504f\u79fb\u4f4d\u7f6e\u8bfb\u53d6\u6700\u591a count \u5b57\u8282\u7684\u6570\u636e\u5230\u7528\u6237\u63d0\u4f9b\u7684\u7f13\u51b2\u533a buf\u3002\u8fd4\u56de\u503c\u4e3a\u5b9e\u9645\u8bfb\u53d6\u7684\u5b57\u8282\u6570&#xff1b;\u82e5\u8fd4\u56de 0 \u5219\u8868\u793a\u5df2\u5230\u8fbe\u6587\u4ef6\u672b\u5c3e (EOF)&#xff0c;\u8fd4\u56de -1 \u5219\u8868\u793a\u53d1\u751f\u9519\u8bef\u5e76\u8bbe\u7f6e errno\u3002\u5728\u652f\u6301\u968f\u673a\u5b9a\u4f4d\u7684\u6587\u4ef6\u4e0a&#xff0c;\u6bcf\u6b21\u8bfb\u53d6\u540e\u6587\u4ef6\u504f\u79fb\u91cf\u4f1a\u81ea\u52a8\u5411\u540e\u79fb\u52a8\u76f8\u5e94\u7684\u5b57\u8282\u6570\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">4. ssize_t write(int fd, const void *buf, size_t count); write \u51fd\u6570\u5c06\u7528\u6237\u7f13\u51b2\u533a buf \u4e2d\u6700\u591a count \u5b57\u8282\u7684\u6570\u636e\u5199\u5165\u5230\u63cf\u8ff0\u7b26 fd \u5bf9\u5e94\u7684\u6587\u4ef6\u6216\u8bbe\u5907\u3002\u8fd4\u56de\u503c\u4e3a\u5b9e\u9645\u5199\u5165\u7684\u5b57\u8282\u6570&#xff1b;\u82e5\u5199\u5165\u5931\u8d25\u5219\u8fd4\u56de -1 \u5e76\u8bbe\u7f6e errno\u3002\u5bf9\u4e8e\u975e\u963b\u585e\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u5199\u5165\u91cf\u53ef\u80fd\u5c11\u4e8e\u8bf7\u6c42\u91cf&#xff0c;\u8c03\u7528\u8005\u9700\u6839\u636e\u8fd4\u56de\u503c\u51b3\u5b9a\u540e\u7eed\u64cd\u4f5c\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h3 id=\"8.3%20printf%E7%9A%84%E5%AE%9E%E7%8E%B0%E5%88%86%E6%9E%90\" style=\"margin-left:0;margin-right:0;text-align:justify\">8.3 printf\u7684\u5b9e\u73b0\u5206\u6790<\/h3>\n<p style=\"margin-left:0px;margin-right:0px\">\u663e\u793a\u4fe1\u606f\u5148\u7531\u00a0vsprintf\u00a0\u751f\u6210&#xff0c;\u518d\u901a\u8fc7\u00a0write\u00a0\u7cfb\u7edf\u8c03\u7528\u8f93\u51fa&#xff0c;\u6700\u540e\u901a\u8fc7\u9677\u9631\u6307&#xff08;int\u00a00x80\u00a0\u6216\u00a0syscall&#xff09;\u8fdb\u5165\u5185\u6838\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5148\u627e\u5230 printf \u7684\u51fd\u6570\u5b9a\u4e49&#xff1a;<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"198\" src=\"2025-06-10ljght1kvc3p.png\" width=\"291\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe82 printf\u7684\u51fd\u6570\u5b9a\u4e49<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\">\u5176\u4e2d&#xff0c;va_start() \u4e0e va_end() \u7528\u4e8e\u5904\u7406\u53ef\u53d8\u53c2\u6570\u3002\u5728\u8bbf\u95ee\u4efb\u4f55\u53ef\u53d8\u53c2\u6570\u4e4b\u524d&#xff0c;\u5fc5\u987b\u5148\u901a\u8fc7 va_start(argptr, fmt) \u521d\u59cb\u5316\u53c2\u6570\u6307\u9488 argptr&#xff1b;\u968f\u540e&#xff0c;\u6bcf\u6b21\u8c03\u7528 va_arg(argptr, type) \u5373\u53ef\u6309\u6307\u5b9a\u7c7b\u578b\u4f9d\u6b21\u53d6\u51fa\u4e0b\u4e00\u4e2a\u53c2\u6570\u3002\u53c2\u6570\u53d6\u5b8c\u540e&#xff0c;\u51fd\u6570\u8fd4\u56de\u4e4b\u524d\u52a1\u5fc5\u8c03\u7528 va_end(argptr)&#xff0c;\u4ee5\u786e\u4fdd\u5806\u6808\u72b6\u6001\u5f97\u4ee5\u6b63\u786e\u6062\u590d\u3002\u4e4b\u540e&#xff0c;printf \u4f1a\u8c03\u7528 Unix I\/O \u51fd\u6570 write&#xff0c;\u5c06 printbuf \u7f13\u51b2\u533a\u4e2d\u957f\u5ea6\u4e3a i \u7684\u5b57\u8282\u8f93\u51fa\u5230\u5c4f\u5e55\u2014\u2014\u8fd9\u91cc i \u5373\u7531 vsprintf(printbuf, fmt, args) \u8fd4\u56de\u7684\u5b57\u7b26\u6570&#xff0c;\u56e0\u6b64 vsprintf \u7684\u4f5c\u7528\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"624\" src=\"2025-06-10hnus5lmpd41.png\" width=\"449\" \/><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\u56fe83 vsprintf\u4ee3\u7801<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:center\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">vsprintf \u7684\u4f5c\u7528\u662f\u6839\u636e printf \u7684\u683c\u5f0f\u5b57\u7b26\u4e32\u548c\u53c2\u6570&#xff0c;\u5c06\u683c\u5f0f\u5316\u540e\u7684\u7ed3\u679c\u5199\u5165\u7f13\u51b2\u533a buf \u4e2d&#xff0c;\u5e76\u8fd4\u56de\u751f\u6210\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u3002\u968f\u540e&#xff0c;write \u7cfb\u7edf\u8c03\u7528\u8d1f\u8d23\u8f93\u51fa&#xff1a;\u5728 Linux \u4e2d&#xff0c;write(fd, buf, count) \u7684\u7b2c\u4e00\u4e2a\u53c2\u6570 fd \u4e3a\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u5176\u4e2d 1 \u8868\u793a\u6807\u51c6\u8f93\u51fa\u3002\u5176\u6c47\u7f16\u5b9e\u73b0\u5148\u5c06 fd\u3001buf \u548c count \u5206\u522b\u52a0\u8f7d\u5230\u6307\u5b9a\u5bc4\u5b58\u5668&#xff0c;\u7136\u540e\u6267\u884c\u4e2d\u65ad\u6307\u4ee4&#xff08;\u5982 int 0x80 \u6216 syscall&#xff09;&#xff0c;\u89e6\u53d1\u5185\u6838\u7684\u7cfb\u7edf\u8c03\u7528\u5165\u53e3&#xff1b;\u5185\u6838\u5c06\u7f13\u51b2\u533a\u4e2d\u7684\u6570\u636e\u901a\u8fc7\u603b\u7ebf\u4f20\u9012\u81f3\u663e\u5b58&#xff08;VRAM&#xff09;\u3002\u663e\u793a\u82af\u7247\u4f9d\u7167\u5237\u65b0\u9891\u7387\u9010\u884c\u8bfb\u53d6 VRAM \u4e2d\u7684 RGB \u50cf\u7d20\u6570\u636e&#xff0c;\u5e76\u901a\u8fc7\u4fe1\u53f7\u7ebf\u5c06\u6bcf\u4e2a\u50cf\u7d20\u70b9\u4f20\u8f93\u81f3\u6db2\u6676\u663e\u793a\u5668&#xff0c;\u6700\u7ec8\u5c06\u683c\u5f0f\u5316\u540e\u7684\u5b57\u7b26\u4e32\u5448\u73b0\u4e8e\u5c4f\u5e55\u4e0a\u3002\u5b57\u7b26\u663e\u793a\u8fc7\u7a0b\u6d89\u53ca&#xff1a;\u5c06 ASCII \u7801\u6620\u5c04\u5230\u5b57\u6a21\u5e93&#xff0c;\u518d\u5c06\u5b57\u6a21\u70b9\u9635\u5199\u5165 VRAM&#xff0c;\u5b8c\u6210\u4ece\u5b57\u7b26\u5230\u5c4f\u5e55\u663e\u793a\u7684\u6574\u4e2a\u6d41\u6c34\u7ebf\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h3 id=\"\" style=\"margin-left:0;margin-right:0;text-align:justify\"><\/h3>\n<h3 id=\"8.4%20getchar%E7%9A%84%E5%AE%9E%E7%8E%B0%E5%88%86%E6%9E%90\" style=\"margin-left:0;margin-right:0;text-align:justify\">8.4 getchar\u7684\u5b9e\u73b0\u5206\u6790<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u5f53\u7528\u6237\u6309\u4e0b\u6309\u952e\u65f6&#xff0c;\u952e\u76d8\u63a7\u5236\u5668\u4f1a\u751f\u6210\u5bf9\u5e94\u7684\u626b\u63cf\u7801\u5e76\u89e6\u53d1\u4e00\u4e2a\u4e2d\u65ad\u8bf7\u6c42&#xff0c;\u5185\u6838\u968f\u5373\u6682\u505c\u5f53\u524d\u8fdb\u7a0b&#xff0c;\u8f6c\u800c\u6267\u884c\u952e\u76d8\u4e2d\u65ad\u5904\u7406\u7a0b\u5e8f\u3002\u8be5\u7a0b\u5e8f\u9996\u5148\u4ece\u952e\u76d8\u63a7\u5236\u5668\u8bfb\u53d6\u626b\u63cf\u7801&#xff0c;\u5c06\u5176\u8f6c\u6362\u4e3a ASCII \u7801&#xff0c;\u7136\u540e\u5c06\u5f97\u5230\u7684\u5b57\u7b26\u653e\u5165\u7cfb\u7edf\u7684\u952e\u76d8\u7f13\u51b2\u533a\u4e2d\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u518d\u6765\u770b getchar \u7684\u5b9e\u73b0&#xff1a;<\/p>\n<p>int getchar(void)<br \/>\n{<br \/>\nstatic char buf[BUFSIZ];<br \/>\nstatic char* bb&#061;buf;<br \/>\nstatic int n&#061;0;<br \/>\nif(n&#061;&#061;0)<br \/>\n{<br \/>\nn&#061;read(0,buf,BUFSIZ);<br \/>\nbb&#061;buf;<br \/>\n}<br \/>\nreturn(&#8211;n&gt;&#061;0)?(unsigned char)*bb&#043;&#043;:EOF;<br \/>\n}<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fd9\u91cc&#xff0c;getchar \u8c03\u7528\u4e86 read&#xff0c;\u800c read \u53c8\u901a\u8fc7\u7cfb\u7edf\u8c03\u7528 (int 0x80 \u6216 syscall) \u5c06\u7f13\u51b2\u533a\u4e2d\u4fdd\u5b58\u7684 ASCII \u5b57\u7b26\u8bfb\u5165\u5230\u7528\u6237\u7a7a\u95f4\u3002read \u4f1a\u4e00\u76f4\u8bfb\u53d6&#xff0c;\u76f4\u5230\u78b0\u5230\u56de\u8f66\u7b26&#xff08;\u6216\u8fbe\u5230\u7f13\u51b2\u533a\u5927\u5c0f&#xff09;&#xff0c;\u7136\u540e\u8fd4\u56de\u5b9e\u9645\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002getchar \u5219\u6bcf\u6b21\u53ea\u53d6\u51fa\u5176\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5b57\u7b26&#xff0c;\u5176\u4f59\u5b57\u7b26\u4ecd\u7559\u5728\u8f93\u5165\u7f13\u51b2\u533a&#xff0c;\u4f9b\u540e\u7eed\u8c03\u7528\u4f7f\u7528\u3002<\/p>\n<h3 id=\"8.5%E6%9C%AC%E7%AB%A0%E5%B0%8F%E7%BB%93\" style=\"margin-left:0;margin-right:0;text-align:justify\">8.5\u672c\u7ae0\u5c0f\u7ed3<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">Linux I\/O \u8bbe\u5907\u7ba1\u7406\u65b9\u6cd5 \u4ecb\u7ecd\u4e86 Linux \u5982\u4f55\u5c06\u6240\u6709 I\/O \u8bbe\u5907\u7edf\u4e00\u62bd\u8c61\u4e3a\u6587\u4ef6&#xff08;\u201c\u4e07\u7269\u7686\u6587\u4ef6\u201d&#xff09;&#xff0c;\u5e76\u901a\u8fc7\u6587\u4ef6\u6a21\u578b\u5bf9\u8bbe\u5907\u8fdb\u884c\u7ba1\u7406&#xff0c;\u5305\u62ec block \u8bbe\u5907\u3001\u5b57\u7b26\u8bbe\u5907\u548c\u7f51\u7edc\u8bbe\u5907\u7684\u6302\u8f7d\u4e0e\u8bbf\u95ee\u65b9\u5f0f\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">Unix I\/O \u63a5\u53e3\u53ca\u5176\u7cfb\u7edf\u8c03\u7528 \u9610\u8ff0\u4e86 Unix I\/O \u7684\u56db\u5927\u57fa\u672c\u6d41\u7a0b&#xff1a;\u6253\u5f00&#xff08;open&#xff09;\u3001\u5b9a\u4f4d&#xff08;lseek&#xff09;\u3001\u8bfb\u5199&#xff08;read\/write&#xff09;\u548c\u5173\u95ed&#xff08;close&#xff09;&#xff0c;\u5e76\u8865\u5145\u4e86\u591a\u8def\u590d\u7528&#xff08;select\/poll\/epoll&#xff09;\u3001\u63a7\u5236\u64cd\u4f5c&#xff08;ioctl\/fcntl&#xff09;\u3001\u5185\u5b58\u6620\u5c04&#xff08;mmap&#xff09;\u7b49\u6269\u5c55\u63a5\u53e3\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">printf \u51fd\u6570\u5b9e\u73b0\u5206\u6790 \u89e3\u6790\u4e86 printf \u5185\u90e8\u5982\u4f55\u501f\u52a9 vsprintf \u5c06\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u4e0e\u53c2\u6570\u8f6c\u6362\u751f\u6210\u8f93\u51fa\u6587\u672c&#xff0c;\u968f\u540e\u8c03\u7528 write \u7cfb\u7edf\u8c03\u7528\u901a\u8fc7\u4e2d\u65ad\u9677\u9631&#xff08;int\u00a00x80 \u6216 syscall&#xff09;\u5c06\u6570\u636e\u5199\u5165\u6807\u51c6\u8f93\u51fa&#xff0c;\u5e76\u6700\u7ec8\u7531\u663e\u5b58\u548c\u663e\u793a\u786c\u4ef6\u5b8c\u6210\u5c4f\u5e55\u663e\u793a\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">getchar \u51fd\u6570\u5b9e\u73b0\u539f\u7406 \u63cf\u8ff0\u4e86\u952e\u76d8\u4e2d\u65ad\u5904\u7406\u6d41\u7a0b\u2014\u2014\u626b\u63cf\u7801\u8bfb\u53d6\u3001\u8f6c\u6362\u4e3a ASCII \u5e76\u5b58\u5165\u5185\u6838\u7f13\u51b2\u533a&#xff1b;\u4ee5\u53ca\u7528\u6237\u6001 getchar \u5982\u4f55\u901a\u8fc7\u4e00\u6b21 read \u7cfb\u7edf\u8c03\u7528\u6279\u91cf\u8bfb\u53d6\u7f13\u51b2\u533a\u5185\u5bb9&#xff0c;\u518d\u9010\u5b57\u7b26\u8fd4\u56de&#xff0c;\u5269\u4f59\u5b57\u7b26\u7559\u5728\u8f93\u5165\u7f13\u51b2\u533a\u4e2d\u4ee5\u4f9b\u540e\u7eed\u8c03\u7528\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u901a\u8fc7\u672c\u7ae0\u5b66\u4e60&#xff0c;\u5168\u9762\u638c\u63e1 Linux \u5185\u6838\u5bf9 I\/O \u8bbe\u5907\u7684\u62bd\u8c61\u4e0e\u7ba1\u7406\u673a\u5236&#xff0c;Unix I\/O \u63a5\u53e3\u7684\u4f7f\u7528\u8303\u5f0f&#xff0c;\u4ee5\u53ca\u5e38\u7528 C \u6807\u51c6\u5e93\u51fd\u6570&#xff08;printf\u3001getchar&#xff09;\u5e95\u5c42\u8c03\u7528\u6d41\u7a0b\u7684\u5b9e\u73b0\u7ec6\u8282\u3002<\/p>\n<h2 id=\"%E7%BB%93%E8%AE%BA\" style=\"margin-left:0;margin-right:0;text-align:center\">\u7ed3\u8bba<\/h2>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4e00&#xff0e;hello.c \u7684\u751f\u547d\u5468\u671f\u6982\u89c8<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">1.\u9884\u5904\u7406\u9636\u6bb5<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">hello.c \u7ecf\u7531\u9884\u5904\u7406\u5668&#xff08;cpp&#xff09;\u5c55\u5f00\u5b8f\u3001\u5904\u7406 #include \u548c\u6761\u4ef6\u7f16\u8bd1&#xff0c;\u751f\u6210\u7eaf\u6587\u672c\u7684\u4e2d\u95f4\u6587\u4ef6 hello.i\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">2.\u7f16\u8bd1\u9636\u6bb5<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7f16\u8bd1\u5668\u524d\u7aef&#xff08;\u5982 gcc -S&#xff09;\u5c06 hello.i \u8f6c\u6362\u4e3a\u6c47\u7f16\u4ee3\u7801 hello.s&#xff0c;\u5b8c\u6210\u8bed\u6cd5\u5206\u6790\u4e0e\u4e2d\u95f4\u4ee3\u7801\u751f\u6210\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">3.\u6c47\u7f16\u9636\u6bb5<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u6c47\u7f16\u5668&#xff08;\u5982 as&#xff09;\u5c06 hello.s \u6c47\u7f16\u6210\u673a\u5668\u7801&#xff0c;\u4ea7\u51fa\u53ef\u91cd\u5b9a\u4f4d\u7684\u76ee\u6807\u6587\u4ef6 hello.o&#xff0c;\u5e76\u5728\u7b26\u53f7\u8868\u4e2d\u8bb0\u5f55\u5916\u90e8\u5f15\u7528\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">4.\u94fe\u63a5\u9636\u6bb5<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u94fe\u63a5\u5668&#xff08;ld&#xff09;\u628a hello.o \u4e0e\u6240\u4f9d\u8d56\u7684\u5e93&#xff08;\u9759\u6001\u6216\u52a8\u6001&#xff09;\u5408\u5e76&#xff0c;\u89e3\u51b3\u7b26\u53f7\u5f15\u7528&#xff0c;\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6 hello\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">5.\u8fd0\u884c\u9636\u6bb5<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">Shell \u8fdb\u7a0b\u8c03\u7528 fork() \u590d\u5236\u51fa\u5b50\u8fdb\u7a0b&#xff0c;\u518d\u901a\u8fc7 execve(&#034;hello&#034;, \u2026) \u5c06\u65b0\u8fdb\u7a0b\u7684\u5730\u5740\u7a7a\u95f4\u66ff\u6362\u4e3a hello \u7684\u6620\u50cf\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u8fd0\u884c\u4e2d&#xff0c;\u865a\u62df\u5730\u5740\u88ab\u52a0\u8f7d\u5e76\u91cd\u5b9a\u4f4d\u81f3\u7269\u7406\u5185\u5b58&#xff08;\u6700\u7ec8\u6620\u5c04\u4e3a\u7269\u7406\u5730\u5740 PA&#xff09;&#xff0c;\u7a0b\u5e8f\u8c03\u7528\u8bf8\u5982 printf\u3001getchar \u7b49\u51fd\u6570&#xff0c;\u4e0e Linux \u7684 I\/O \u5b50\u7cfb\u7edf\u4ea4\u4e92\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">6.\u9000\u51fa\u4e0e\u56de\u6536<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u7a0b\u5e8f\u7ed3\u675f\u540e\u7531\u7236\u8fdb\u7a0b&#xff08;Shell&#xff09;\u901a\u8fc7 wait() \u6536\u96c6\u5b50\u8fdb\u7a0b\u7684\u9000\u51fa\u72b6\u6001&#xff0c;\u5185\u6838\u56de\u6536\u5176\u6240\u6709\u8d44\u6e90&#xff0c;\u5305\u62ec\u9875\u8868\u3001\u6587\u4ef6\u63cf\u8ff0\u7b26\u548c\u5185\u5b58\u6620\u5c04\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4e8c&#xff0e;\u6df1\u5ea6\u4f53\u9a8c\u4e0e\u6536\u83b7<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">1.\u6bcf\u4e00\u6b65\u90fd\u975e\u201c\u9ed1\u7bb1\u201d<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4ece\u7b80\u5355\u7684\u4e00\u884c printf(&#034;Hello\\\\n&#034;)&#xff0c;\u5176\u5b9e\u80cc\u540e\u8981\u7ecf\u5386\u9884\u5904\u7406\u3001\u7f16\u8bd1\u3001\u6c47\u7f16\u3001\u94fe\u63a5\u3001\u7cfb\u7edf\u8c03\u7528\u3001\u5185\u5b58\u7ba1\u7406\u7b49\u591a\u9053\u5de5\u5e8f&#xff0c;\u65b9\u80fd\u5c55\u73b0\u5728\u5c4f\u5e55\u4e0a\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u53ea\u6709\u4eb2\u81ea\u8ddf\u8e2a\u8fc7\u5404\u4e2a\u4e2d\u95f4\u6587\u4ef6\u4e0e\u5de5\u5177\u8f93\u51fa&#xff0c;\u624d\u80fd\u771f\u6b63\u7406\u89e3\u7f16\u8bd1\u94fe&#xff08;toolchain&#xff09;\u7684\u4e25\u8c28\u4e0e\u9b54\u529b\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">2.\u7cfb\u7edf\u8bbe\u8ba1\u7684\u7cbe\u5de7\u4e0e\u4e25\u5bc6<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u94fe\u63a5\u5668\u7684\u7b26\u53f7\u89e3\u6790\u3001\u52a8\u6001\u94fe\u63a5\u7684\u91cd\u5b9a\u4f4d\u673a\u5236\u3001\u5199\u65f6\u590d\u5236&#xff08;COW&#xff09;\u7b56\u7565\u3001\u6bb5\u5f0f\u5730\u5740\u7a7a\u95f4\u7ba1\u7406\u3001I\/O \u7684\u201c\u4e07\u7269\u7686\u6587\u4ef6\u201d\u62bd\u8c61\u2026\u2026\u6bcf\u4e2a\u7ec6\u8282\u90fd\u4f53\u73b0\u4e86\u7cfb\u7edf\u8bbe\u8ba1\u8005\u7684\u667a\u6167\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4ece\u903b\u8f91\u5230\u6027\u80fd&#xff0c;\u5185\u6838\u4e0e\u8fd0\u884c\u65f6\u5e93\u65e0\u7f1d\u534f\u4f5c&#xff0c;\u4fdd\u969c\u4e86\u7a0b\u5e8f\u7684\u53ef\u79fb\u690d\u6027\u3001\u53ef\u7ef4\u62a4\u6027\u4e0e\u9ad8\u6548\u6027\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">3.\u7406\u8bba\u4e0e\u5b9e\u8df5\u7684\u7ed3\u5408<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">CSAPP&#xff08;\u300a\u6df1\u5165\u7406\u89e3\u8ba1\u7b97\u673a\u7cfb\u7edf\u300b&#xff09;\u4e0d\u4ec5\u505c\u7559\u5728\u7eb8\u9762\u6982\u5ff5&#xff0c;\u800c\u662f\u8981\u6c42\u6211\u4eec\u52a8\u624b\u9a8c\u8bc1\u3001\u5728\u771f\u5b9e\u73af\u5883\u4e2d\u6392\u9519&#xff0c;\u624d\u80fd\u5c06\u62bd\u8c61\u77e5\u8bc6\u8f6c\u5316\u4e3a\u76f4\u89c2\u611f\u53d7\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4f8b\u5982&#xff0c;\u67e5\u770b\u6c47\u7f16\u8f93\u51fa\u53d1\u73b0\u8c03\u7528\u7ea6\u5b9a\u3001\u53c2\u6570\u4f20\u9012\u4e0e\u6808\u5e27\u5e03\u5c40\u7684\u5dee\u5f02&#xff0c;\u52a0\u6df1\u4e86\u5bf9 CPU \u67b6\u6784\u4e0e ABI \u7684\u7406\u89e3\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">4.\u5b66\u4e60\u8def\u7a0b\u7684\u610f\u4e49<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4ece\u6e90\u4ee3\u7801\u5230\u673a\u5668\u6307\u4ee4&#xff0c;\u518d\u5230\u786c\u4ef6\u663e\u793a\u8fc7\u7a0b&#xff0c;\u6bcf\u4e00\u6b65\u90fd\u51dd\u805a\u4e86\u8ba1\u7b97\u673a\u7cfb\u7edf\u7684\u590d\u6742\u6027&#xff0c;\u4e5f\u5c55\u73b0\u4e86\u5176\u53ef\u63a7\u6027\u4e0e\u53ef\u9884\u6d4b\u6027\u3002\u6b63\u5982\u6d41\u6c34\u7ebf\u4e2d\u6bcf\u4e2a\u5fae\u5c0f\u5468\u671f\u90fd\u7cbe\u786e\u8ba1\u7b97\u3001\u7f13\u5b58\u5c42\u7ea7\u5de7\u5999\u52a0\u901f&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u4e0e\u7f16\u8bd1\u5668\u540c\u6837\u4e3a\u6211\u4eec\u7684\u7a0b\u5e8f\u62a4\u822a\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u4e09\u3001\u81f4\u8c22\u4e0e\u5c55\u671b<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\u56de\u987e\u8fd9\u4e00\u5b66\u671f\u7684\u5b66\u4e60\u65c5\u7a0b&#xff0c;\u6df1\u611f\u8ba1\u7b97\u673a\u7cfb\u7edf\u7684\u535a\u5927\u7cbe\u6df1&#xff0c;\u4e5f\u4f53\u4f1a\u5230\u4e0d\u65ad\u94bb\u7814\u4e0e\u52a8\u624b\u5b9e\u9a8c\u7684\u91cd\u8981\u6027\u3002\u8877\u5fc3\u611f\u8c22\u6388\u8bfe\u6559\u5e08\u7684\u8010\u5fc3\u8bb2\u89e3\u4e0e\u7b54\u7591&#xff0c;\u4e5f\u611f\u8c22\u540c\u5b66\u4eec\u7684\u76f8\u4e92\u8ba8\u8bba\u3002\u867d\u7136\u6211\u4eec\u521a\u521a\u8e0f\u4e0a\u5f81\u9014&#xff0c;\u4f46\u6b63\u662f\u8fd9\u4e9b\u57fa\u7840\u5960\u5b9a\u4e86\u672a\u6765\u63a2\u7d22\u66f4\u6df1\u5c42\u6b21\u7cfb\u7edf\u7f16\u7a0b\u3001\u64cd\u4f5c\u7cfb\u7edf\u539f\u7406\u4e0e\u7f16\u8bd1\u6280\u672f\u7684\u4fe1\u5fc3\u4e0e\u52a8\u529b\u3002<\/p>\n<h2 id=\"%E9%99%84%E4%BB%B6\" style=\"margin-left:0;margin-right:0;text-align:center\">\u9644\u4ef6<\/h2>\n<table border=\"1\" cellspacing=\"0\" style=\"width:432.95pt\">\n<tr>\n<td style=\"background-color:#eff3f5;border-color:#dddddd;height:19.55pt;width:125.45pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">\u6587\u4ef6\u540d\u79f0<\/span><\/p>\n<\/td>\n<td style=\"background-color:#eff3f5;border-color:#dddddd;height:19.55pt;width:307.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">\u63cf\u8ff0\u4ecb\u7ecd<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:white;border-color:#dddddd;height:19.55pt;width:125.45pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">hello.c<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;height:19.55pt;width:307.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">\u6e90\u7a0b\u5e8f\u6587\u4ef6<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:white;border-color:#dddddd;height:19.55pt;width:125.45pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">hello.i<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;height:19.55pt;width:307.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">hello.c<\/span><span style=\"color:black\">\u901a\u8fc7\u9884\u5904\u7406\u5668<\/span><span style=\"color:black\">cpp<\/span><span style=\"color:black\">\u9884\u5904\u7406\u540e\u7684\u6587\u672c\u6587\u4ef6<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:white;border-color:#dddddd;height:19.7pt;width:125.45pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">hello.s<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;height:19.7pt;width:307.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">hello.i<\/span><span style=\"color:black\">\u901a\u8fc7\u7f16\u8bd1\u5668<\/span><span style=\"color:black\">ccl<\/span><span style=\"color:black\">\u7f16\u8bd1\u540e\u7684\u6c47\u7f16\u7a0b\u5e8f<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:white;border-color:#dddddd;height:19.7pt;width:125.45pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">hello.o<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;height:19.7pt;width:307.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">hello.s<\/span><span style=\"color:black\">\u901a\u8fc7\u6c47\u7f16\u5668<\/span><span style=\"color:black\">as<\/span><span style=\"color:black\">\u6c47\u7f16\u540e\u7684\u6587\u4ef6<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:white;border-color:#dddddd;height:19.7pt;width:125.45pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">hello<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;height:19.7pt;width:307.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">hello.o<\/span><span style=\"color:black\">\u901a\u8fc7\u94fe\u63a5\u5668<\/span><span style=\"color:black\">ld<\/span><span style=\"color:black\">\u94fe\u63a5\u540e\u7684\u53ef\u6267\u884c\u6587\u4ef6<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:white;border-color:#dddddd;height:19.7pt;width:125.45pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:black\">Objdump_hello.ohello.o<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;height:19.7pt;width:307.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">\u53cd\u6c47\u7f16\u6587\u4ef6<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:white;border-color:#dddddd;height:19.7pt;width:125.45pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">Objdump_hello hello<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;height:19.7pt;width:307.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:center\"><span style=\"color:black\">\u53cd\u6c47\u7f16\u6587\u4ef6<\/span><\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2 id=\"%E5%8F%82%E8%80%83%E6%96%87%E7%8C%AE\" style=\"margin-left:0;margin-right:0;text-align:center\">\u53c2\u8003\u6587\u732e<\/h2>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">[1] CSDN_\u4e13\u4e1a\u5f00\u53d1\u8005\u793e\u533a_\u5df2\u63a5\u5165DeepSeekR1\u6ee1\u8840\u7248<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">[2]DeepSeek | \u6df1\u5ea6\u6c42\u7d22<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">[3] https:\/\/github.com.<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">[4]Randal E.Bryant David R.O&#039;Hallaron.\u6df1\u5165\u7406\u89e3\u8ba1\u7b97\u673a\u7cfb\u7edf&#xff08;\u7b2c\u4e09\u7248&#xff09;.\u673a\u68b0\u5de5\u4e1a\u51fa\u7248\u793e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.3k\u6b21\uff0c\u70b9\u8d5e32\u6b21\uff0c\u6536\u85cf9\u6b21\u3002\u672c\u6587\u5256\u6790\u201cHello\u201d\u7a0b\u5e8f\u4ece\u6e90\u7801\u5230\u6267\u884c\u7684\u5168\u6d41\u7a0b\uff1a\u9884\u5904\u7406\u5c55\u5f00\u5b8f\u751f\u6210hello.i\uff0c\u7f16\u8bd1\u8f6c\u6362\u4e3a\u6c47\u7f16\u4ee3\u7801hello.s\uff0c\u6c47\u7f16\u751f\u6210\u76ee\u6807\u6587\u4ef6hello.o\uff0c\u94fe\u63a5\u6574\u5408\u5e93\u5f62\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002\u8fd0\u884c\u65f6Shell\u901a\u8fc7fork-exec\u52a0\u8f7d\u8fdb\u7a0b\uff0cMMU\u5b8c\u6210\u865a\u62df\u5730\u5740\u8f6c\u6362\u3002\u89e3\u6790printf\u7684\u7cfb\u7edf\u8c03\u7528\u673a\u5236\u4e0egetchar\u8f93\u5165\u7f13\u51b2\u539f\u7406\uff0c\u63ed\u793aLinux\u5c06\u8bbe\u5907\u62bd\u8c61\u4e3a\u6587\u4ef6\u7684\u6838\u5fc3\u7406\u5ff5\u3002\u901a\u8fc7\u56db\u9636\u6bb5\u7f16\u8bd1\u8f6c\u6362\u53ca\u8fdb\u7a0b\u7ba1\u7406\u3001\u5185\u5b58\u6620\u5c04\u7b49\u7cfb\u7edf\u673a\u5236\uff0c\u5b8c\u6574\u5448\u73b0\u9ad8\u7ea7\u8bed\u8a00\u5411\u673a\u5668\u6307\u4ee4\u7684\u8f6c\u5316\u8def\u5f84\uff0c\u4f53\u73b0\u64cd\u4f5c\u7cfb\u7edf\u534f\u8c03\u8f6f\u786c\u4ef6\u8d44\u6e90\u7684\u5e95\u5c42\u903b\u8f91\u3002<\/p>\n","protected":false},"author":2,"featured_media":42673,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,103,125],"topic":[],"class_list":["post-42693","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-ubuntu","tag-125"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010HITCSAPP \u54c8\u5de5\u5927\u8ba1\u7b97\u673a\u7cfb\u7edf\u671f\u672b\u5927\u4f5c\u4e1a\u3011 \u7a0b\u5e8f\u4eba\u751f-Hello\u2019s P2P - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/42693.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010HITCSAPP \u54c8\u5de5\u5927\u8ba1\u7b97\u673a\u7cfb\u7edf\u671f\u672b\u5927\u4f5c\u4e1a\u3011 \u7a0b\u5e8f\u4eba\u751f-Hello\u2019s P2P - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.3k\u6b21\uff0c\u70b9\u8d5e32\u6b21\uff0c\u6536\u85cf9\u6b21\u3002\u672c\u6587\u5256\u6790\u201cHello\u201d\u7a0b\u5e8f\u4ece\u6e90\u7801\u5230\u6267\u884c\u7684\u5168\u6d41\u7a0b\uff1a\u9884\u5904\u7406\u5c55\u5f00\u5b8f\u751f\u6210hello.i\uff0c\u7f16\u8bd1\u8f6c\u6362\u4e3a\u6c47\u7f16\u4ee3\u7801hello.s\uff0c\u6c47\u7f16\u751f\u6210\u76ee\u6807\u6587\u4ef6hello.o\uff0c\u94fe\u63a5\u6574\u5408\u5e93\u5f62\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002\u8fd0\u884c\u65f6Shell\u901a\u8fc7fork-exec\u52a0\u8f7d\u8fdb\u7a0b\uff0cMMU\u5b8c\u6210\u865a\u62df\u5730\u5740\u8f6c\u6362\u3002\u89e3\u6790printf\u7684\u7cfb\u7edf\u8c03\u7528\u673a\u5236\u4e0egetchar\u8f93\u5165\u7f13\u51b2\u539f\u7406\uff0c\u63ed\u793aLinux\u5c06\u8bbe\u5907\u62bd\u8c61\u4e3a\u6587\u4ef6\u7684\u6838\u5fc3\u7406\u5ff5\u3002\u901a\u8fc7\u56db\u9636\u6bb5\u7f16\u8bd1\u8f6c\u6362\u53ca\u8fdb\u7a0b\u7ba1\u7406\u3001\u5185\u5b58\u6620\u5c04\u7b49\u7cfb\u7edf\u673a\u5236\uff0c\u5b8c\u6574\u5448\u73b0\u9ad8\u7ea7\u8bed\u8a00\u5411\u673a\u5668\u6307\u4ee4\u7684\u8f6c\u5316\u8def\u5f84\uff0c\u4f53\u73b0\u64cd\u4f5c\u7cfb\u7edf\u534f\u8c03\u8f6f\u786c\u4ef6\u8d44\u6e90\u7684\u5e95\u5c42\u903b\u8f91\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/42693.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-10T00:54:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825d3802b.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"21 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/42693.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/42693.html\",\"name\":\"\u3010HITCSAPP \u54c8\u5de5\u5927\u8ba1\u7b97\u673a\u7cfb\u7edf\u671f\u672b\u5927\u4f5c\u4e1a\u3011 \u7a0b\u5e8f\u4eba\u751f-Hello\u2019s P2P - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-10T00:54:55+00:00\",\"dateModified\":\"2025-06-10T00:54:55+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/42693.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/42693.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/42693.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010HITCSAPP \u54c8\u5de5\u5927\u8ba1\u7b97\u673a\u7cfb\u7edf\u671f\u672b\u5927\u4f5c\u4e1a\u3011 \u7a0b\u5e8f\u4eba\u751f-Hello\u2019s P2P\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010HITCSAPP \u54c8\u5de5\u5927\u8ba1\u7b97\u673a\u7cfb\u7edf\u671f\u672b\u5927\u4f5c\u4e1a\u3011 \u7a0b\u5e8f\u4eba\u751f-Hello\u2019s P2P - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/42693.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010HITCSAPP \u54c8\u5de5\u5927\u8ba1\u7b97\u673a\u7cfb\u7edf\u671f\u672b\u5927\u4f5c\u4e1a\u3011 \u7a0b\u5e8f\u4eba\u751f-Hello\u2019s P2P - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.3k\u6b21\uff0c\u70b9\u8d5e32\u6b21\uff0c\u6536\u85cf9\u6b21\u3002\u672c\u6587\u5256\u6790\u201cHello\u201d\u7a0b\u5e8f\u4ece\u6e90\u7801\u5230\u6267\u884c\u7684\u5168\u6d41\u7a0b\uff1a\u9884\u5904\u7406\u5c55\u5f00\u5b8f\u751f\u6210hello.i\uff0c\u7f16\u8bd1\u8f6c\u6362\u4e3a\u6c47\u7f16\u4ee3\u7801hello.s\uff0c\u6c47\u7f16\u751f\u6210\u76ee\u6807\u6587\u4ef6hello.o\uff0c\u94fe\u63a5\u6574\u5408\u5e93\u5f62\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002\u8fd0\u884c\u65f6Shell\u901a\u8fc7fork-exec\u52a0\u8f7d\u8fdb\u7a0b\uff0cMMU\u5b8c\u6210\u865a\u62df\u5730\u5740\u8f6c\u6362\u3002\u89e3\u6790printf\u7684\u7cfb\u7edf\u8c03\u7528\u673a\u5236\u4e0egetchar\u8f93\u5165\u7f13\u51b2\u539f\u7406\uff0c\u63ed\u793aLinux\u5c06\u8bbe\u5907\u62bd\u8c61\u4e3a\u6587\u4ef6\u7684\u6838\u5fc3\u7406\u5ff5\u3002\u901a\u8fc7\u56db\u9636\u6bb5\u7f16\u8bd1\u8f6c\u6362\u53ca\u8fdb\u7a0b\u7ba1\u7406\u3001\u5185\u5b58\u6620\u5c04\u7b49\u7cfb\u7edf\u673a\u5236\uff0c\u5b8c\u6574\u5448\u73b0\u9ad8\u7ea7\u8bed\u8a00\u5411\u673a\u5668\u6307\u4ee4\u7684\u8f6c\u5316\u8def\u5f84\uff0c\u4f53\u73b0\u64cd\u4f5c\u7cfb\u7edf\u534f\u8c03\u8f6f\u786c\u4ef6\u8d44\u6e90\u7684\u5e95\u5c42\u903b\u8f91\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/42693.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-10T00:54:55+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250610005453-6847825d3802b.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"21 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/42693.html","url":"https:\/\/www.wsisp.com\/helps\/42693.html","name":"\u3010HITCSAPP \u54c8\u5de5\u5927\u8ba1\u7b97\u673a\u7cfb\u7edf\u671f\u672b\u5927\u4f5c\u4e1a\u3011 \u7a0b\u5e8f\u4eba\u751f-Hello\u2019s P2P - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-10T00:54:55+00:00","dateModified":"2025-06-10T00:54:55+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/42693.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/42693.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/42693.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010HITCSAPP \u54c8\u5de5\u5927\u8ba1\u7b97\u673a\u7cfb\u7edf\u671f\u672b\u5927\u4f5c\u4e1a\u3011 \u7a0b\u5e8f\u4eba\u751f-Hello\u2019s P2P"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/42693","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=42693"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/42693\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/42673"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=42693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=42693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=42693"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=42693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}