{"id":88470,"date":"2026-08-01T08:25:37","date_gmt":"2026-08-01T00:25:37","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/88470.html"},"modified":"2026-08-01T08:25:37","modified_gmt":"2026-08-01T00:25:37","slug":"linux%e7%b3%bb%e7%bb%9f%e7%af%8722%ef%bc%9a-%e6%96%87%e4%bb%b6%ef%bc%88%e5%85%ad%ef%bc%89%ef%bc%9a%e7%9b%ae%e6%a0%87%e6%96%87%e4%bb%b6%e4%b8%8eelf%e6%b7%b1%e5%ba%a6%e8%a7%a3%e6%9e%90","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/88470.html","title":{"rendered":"Linux\u7cfb\u7edf\u7bc722\uff1a\u2014\u2014\u6587\u4ef6\uff08\u516d\uff09\uff1a\u76ee\u6807\u6587\u4ef6\u4e0eELF\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u7f16\u8bd1\u5230\u52a0\u8f7d\u7684\u5168\u666f\u63ed\u79d8"},"content":{"rendered":"<p style=\"text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"300\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002529-6a6d3cf9ea0d6.jpg\" width=\"300\" \/><\/p>\n<p style=\"text-align:center\">\u4e0a\u4e00\u671f\u4ecb\u7ecd\u4e86\u52a8\u9759\u6001\u5e93\u7684\u4f7f\u7528\u539f\u7406\u4ee5\u53ca\u4e24\u8005\u7684\u533a\u522b&#xff0c;\u4f46\u662f\u4f60\u662f\u5426\u56f0\u60d1\u8fc7&#xff1a;gcc -c \u51fa\u6765\u7684<span style=\"color:#fe2c24\"> .o \u6587\u4ef6<\/span>\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;\u5b83<span style=\"color:#ff9900\">\u548c .so\u3001a.out \u6709\u4ec0\u4e48\u533a\u522b<\/span>&#xff1f;<span style=\"color:#fe2c24\">ELF<\/span> \u53c8\u662f\u4f55\u65b9\u795e\u5723&#xff1f;\u94fe\u63a5\u5668\u51ed\u4ec0\u4e48\u80fd<span style=\"color:#a2e043\">\u4fee\u6b63\u51fd\u6570\u5730\u5740<\/span>&#xff1f;\u8fd9\u7bc7\u6587\u7ae0\u4ece\u76ee\u6807\u6587\u4ef6\u8bb2\u8d77&#xff0c;\u5e26\u4f60\u5c42\u5c42\u6df1\u5165 ELF \u7684\u9aa8\u9ad3\u3002<\/p>\n<hr \/>\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E5%BC%80%E7%AF%87%EF%BC%9A%E4%B8%80%E6%AE%B5%E4%BB%A3%E7%A0%81%E7%9A%84%E7%BC%96%E8%AF%91%E4%B9%8B%E6%97%85-toc\" style=\"margin-left:0px\">\u5f00\u7bc7&#xff1a;\u4e00\u6bb5\u4ee3\u7801\u7684\u7f16\u8bd1\u4e4b\u65c5<\/p>\n<p id=\"%E4%B8%80%E3%80%81%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%EF%BC%88.o%EF%BC%89%E2%80%94%E2%80%94%E7%BC%96%E8%AF%91%E7%9A%84%22%E5%8D%8A%E6%88%90%E5%93%81%22-toc\" style=\"margin-left:0px\">\u4e00\u3001\u76ee\u6807\u6587\u4ef6&#xff08;.o&#xff09;\u2014\u2014\u7f16\u8bd1\u7684&#034;\u534a\u6210\u54c1&#034;<\/p>\n<p id=\"1.1%20%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%EF%BC%9F-toc\" style=\"margin-left:40px\">1.1 \u4e3a\u4ec0\u4e48\u9700\u8981\u76ee\u6807\u6587\u4ef6&#xff1f;<\/p>\n<p id=\"1.2%20%E5%A6%82%E4%BD%95%E7%94%9F%E6%88%90%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6-toc\" style=\"margin-left:40px\">1.2 \u5982\u4f55\u751f\u6210\u76ee\u6807\u6587\u4ef6<\/p>\n<p id=\"1.3%20%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%E7%9A%84%E6%9C%AC%E8%B4%A8-toc\" style=\"margin-left:40px\">1.3 \u76ee\u6807\u6587\u4ef6\u7684\u672c\u8d28<\/p>\n<p id=\"%E4%BA%8C%E3%80%81ELF%20%E6%96%87%E4%BB%B6%E2%80%94%E2%80%94%E7%BB%9F%E4%B8%80%E4%B8%80%E5%88%87%E7%9A%84%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%A0%BC%E5%BC%8F-toc\" style=\"margin-left:0px\">\u4e8c\u3001ELF \u6587\u4ef6\u2014\u2014\u7edf\u4e00\u4e00\u5207\u7684\u4e8c\u8fdb\u5236\u683c\u5f0f<\/p>\n<p id=\"2.1%20ELF%20%E7%9A%84%E5%AE%9A%E4%B9%89-toc\" style=\"margin-left:40px\">2.1 ELF \u7684\u5b9a\u4e49<\/p>\n<p id=\"%E4%B8%89%E3%80%81ELF%20%E6%96%87%E4%BB%B6%E7%9A%84%E8%A7%A3%E5%89%96%E2%80%94%E2%80%94%E5%9B%9B%E5%A4%A7%E9%83%A8%E5%88%86-toc\" style=\"margin-left:0px\">\u4e09\u3001ELF \u6587\u4ef6\u7684\u89e3\u5256\u2014\u2014\u56db\u5927\u90e8\u5206<\/p>\n<p id=\"3.1%20ELF%20%E5%A4%B4%EF%BC%88ELF%20Header%EF%BC%89%E2%80%94%E2%80%94%E6%96%87%E4%BB%B6%E7%9A%84%E8%BA%AB%E4%BB%BD%E8%AF%81-toc\" style=\"margin-left:40px\">3.1 ELF \u5934&#xff08;ELF Header&#xff09;\u2014\u2014\u6587\u4ef6\u7684\u8eab\u4efd\u8bc1<\/p>\n<p id=\"1.%E8%AF%BB%E5%8F%96%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%E7%9A%84ELF%E6%96%87%E4%BB%B6%E5%A4%B4%E9%83%A8%E4%BF%A1%E6%81%AF-toc\" style=\"margin-left:80px\">1.\u8bfb\u53d6\u76ee\u6807\u6587\u4ef6\u7684ELF\u6587\u4ef6\u5934\u90e8\u4fe1\u606f<\/p>\n<p id=\"3.2%20%E7%A8%8B%E5%BA%8F%E5%A4%B4%E8%A1%A8%EF%BC%88Program%20Header%20Table%EF%BC%89%E2%80%94%E2%80%94%E6%89%A7%E8%A1%8C%E8%A7%86%E5%9B%BE-toc\" style=\"margin-left:40px\">3.2 \u7a0b\u5e8f\u5934\u8868&#xff08;Program Header Table&#xff09;\u2014\u2014\u6267\u884c\u89c6\u56fe<\/p>\n<p id=\"1.%E6%9F%A5%E7%9C%8B%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6%E7%9A%84%E6%AE%B5%20(Segment)%E4%BF%A1%E6%81%AF-toc\" style=\"margin-left:80px\">1.\u67e5\u770b\u53ef\u6267\u884c\u6587\u4ef6\u7684\u6bb5 (Segment)\u4fe1\u606f<\/p>\n<p id=\"-toc\" style=\"margin-left:80px\">\n<p id=\"3.3%20%E8%8A%82%E5%A4%B4%E8%A1%A8%EF%BC%88Section%20Header%20Table%EF%BC%89%E2%80%94%E2%80%94%E9%93%BE%E6%8E%A5%E8%A7%86%E5%9B%BE-toc\" style=\"margin-left:40px\">3.3 \u8282\u5934\u8868&#xff08;Section Header Table&#xff09;\u2014\u2014\u94fe\u63a5\u89c6\u56fe<\/p>\n<p id=\"1.%E6%89%93%E5%8D%B0%E3%80%90%E8%8A%82%E5%A4%B4%E8%A1%A8%20Section%20Header%20Table%E3%80%91%EF%BC%8C%E5%88%97%E5%87%BA%20ELF%20%E5%86%85%E9%83%A8%E6%89%80%E6%9C%89%E8%8A%82%20(Section)-toc\" style=\"margin-left:80px\">1.\u6253\u5370\u3010\u8282\u5934\u8868 Section Header Table\u3011&#xff0c;\u5217\u51fa ELF \u5185\u90e8\u6240\u6709\u8282 (Section)<\/p>\n<p id=\"3.4%20%E8%8A%82%EF%BC%88Sections%EF%BC%89%E2%80%94%E2%80%94%E7%9C%9F%E6%AD%A3%E7%9A%84%E6%95%B0%E6%8D%AE%E4%BB%93%E5%BA%93-toc\" style=\"margin-left:40px\">3.4 \u8282&#xff08;Sections&#xff09;\u2014\u2014\u771f\u6b63\u7684\u6570\u636e\u4ed3\u5e93<\/p>\n<p id=\"%E5%9B%9B%E3%80%81ELF%20%E7%9A%84%E5%BD%A2%E6%88%90%E2%80%94%E2%80%94%E4%BB%8E%E6%BA%90%E4%BB%A3%E7%A0%81%E5%88%B0%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6-toc\" style=\"margin-left:0px\">\u56db\u3001ELF \u7684\u5f62\u6210\u2014\u2014\u4ece\u6e90\u4ee3\u7801\u5230\u53ef\u6267\u884c\u6587\u4ef6<\/p>\n<p id=\"4.1%20%E7%BC%96%E8%AF%91%E4%B8%8E%E9%93%BE%E6%8E%A5%E7%9A%84%E4%B8%A4%E6%AD%A5%E8%B5%B0-toc\" style=\"margin-left:40px\">4.1 \u7f16\u8bd1\u4e0e\u94fe\u63a5\u7684\u4e24\u6b65\u8d70<\/p>\n<p id=\"4.2%20Section%20%E7%9A%84%E5%90%88%E5%B9%B6%E2%80%94%E2%80%94%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81%20Segment%EF%BC%9F-toc\" style=\"margin-left:40px\">4.2 Section \u7684\u5408\u5e76\u2014\u2014\u4e3a\u4ec0\u4e48\u9700\u8981 Segment&#xff1f;<\/p>\n<p id=\"1.%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E5%90%88%E5%B9%B6%EF%BC%9F-toc\" style=\"margin-left:80px\">1.\u4e3a\u4ec0\u4e48\u8981\u5408\u5e76&#xff1f;<\/p>\n<p id=\"%E4%BA%94%E3%80%81ELF%20%E7%9A%84%E4%B8%A4%E4%B8%AA%E8%A7%86%E5%9B%BE%E2%80%94%E2%80%94%E9%93%BE%E6%8E%A5%E5%99%A8%E7%9C%8B%20vs%20%E5%8A%A0%E8%BD%BD%E5%99%A8%E7%9C%8B-toc\" style=\"margin-left:0px\">\u4e94\u3001ELF \u7684\u4e24\u4e2a\u89c6\u56fe\u2014\u2014\u94fe\u63a5\u5668\u770b vs \u52a0\u8f7d\u5668\u770b<\/p>\n<p id=\"1.%E4%BB%8E%E9%93%BE%E6%8E%A5%E8%A7%86%E5%9B%BE%E7%9C%8B-toc\" style=\"margin-left:40px\">1.\u4ece\u94fe\u63a5\u89c6\u56fe\u770b<\/p>\n<p id=\"2.%E4%BB%8E%E6%89%A7%E8%A1%8C%E8%A7%86%E5%9B%BE%E7%9C%8B-toc\" style=\"margin-left:40px\">2.\u4ece\u6267\u884c\u89c6\u56fe\u770b<\/p>\n<p id=\"3.%E4%B8%89%E6%9D%A1%E5%91%BD%E4%BB%A4%E7%BB%88%E6%9E%81%E6%B1%87%E6%80%BB-toc\" style=\"margin-left:40px\">3.\u4e09\u6761\u547d\u4ee4\u7ec8\u6781\u6c47\u603b<\/p>\n<p id=\"%E5%85%AD%E3%80%81%E9%80%8F%E5%BD%BB%E7%90%86%E8%A7%A3%E9%93%BE%E6%8E%A5%E2%80%94%E2%80%94%E9%9D%99%E6%80%81%E9%93%BE%E6%8E%A5%E7%9A%84%E5%85%A8%E8%BF%87%E7%A8%8B-toc\" style=\"margin-left:0px\">\u516d\u3001\u900f\u5f7b\u7406\u89e3\u94fe\u63a5\u2014\u2014\u9759\u6001\u94fe\u63a5\u7684\u5168\u8fc7\u7a0b<\/p>\n<p id=\"6.1%20%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%E4%B9%8B%E9%97%B4%22%E4%BA%92%E4%B8%8D%E7%9B%B8%E8%AF%86%22-toc\" style=\"margin-left:40px\">6.1 \u76ee\u6807\u6587\u4ef6\u4e4b\u95f4&#034;\u4e92\u4e0d\u76f8\u8bc6&#034;<\/p>\n<p id=\"6.2%20%E7%AC%A6%E5%8F%B7%E8%A1%A8%E2%80%94%E2%80%94%E6%A0%87%E8%AE%B0%22%E6%9C%AA%E5%AE%9A%E4%B9%89%22%E7%9A%84%E7%AC%A6%E5%8F%B7-toc\" style=\"margin-left:40px\">6.2 \u7b26\u53f7\u8868\u2014\u2014\u6807\u8bb0&#034;\u672a\u5b9a\u4e49&#034;\u7684\u7b26\u53f7<\/p>\n<p id=\"6.3%20%E9%93%BE%E6%8E%A5%E6%97%B6%E7%9A%84%E9%87%8D%E5%AE%9A%E4%BD%8D-toc\" style=\"margin-left:40px\">6.3 \u94fe\u63a5\u65f6\u7684\u91cd\u5b9a\u4f4d<\/p>\n<p id=\"6.4%20%E9%9D%99%E6%80%81%E9%93%BE%E6%8E%A5%E7%9A%84%E6%9C%AC%E8%B4%A8-toc\" style=\"margin-left:40px\">6.4 \u9759\u6001\u94fe\u63a5\u7684\u672c\u8d28<\/p>\n<p id=\"%E4%B8%83%E3%80%81%E8%99%9A%E6%8B%9F%E5%9C%B0%E5%9D%80%E7%A9%BA%E9%97%B4%E2%80%94%E2%80%94%E9%93%BE%E6%8E%A5%E6%97%B6%E5%B0%B1%E5%B7%B2%E7%BC%96%E5%A5%BD%E5%9D%80-toc\" style=\"margin-left:0px\">\u4e03\u3001\u865a\u62df\u5730\u5740\u7a7a\u95f4\u2014\u2014\u94fe\u63a5\u65f6\u5c31\u5df2\u7f16\u597d\u5740<\/p>\n<p id=\"7.1%20%E4%B8%80%E4%B8%AA%E5%8F%8D%E7%9B%B4%E8%A7%89%E7%9A%84%E4%BA%8B%E5%AE%9E-toc\" style=\"margin-left:40px\">7.1 \u4e00\u4e2a\u53cd\u76f4\u89c9\u7684\u4e8b\u5b9e<\/p>\n<p id=\"7.2%20%E8%BF%9B%E7%A8%8B%E5%9C%B0%E5%9D%80%E7%A9%BA%E9%97%B4%E7%9A%84%E6%95%B0%E6%8D%AE%E4%BB%8E%E5%93%AA%E9%87%8C%E6%9D%A5%EF%BC%9F-toc\" style=\"margin-left:40px\">7.2 \u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4\u7684\u6570\u636e\u4ece\u54ea\u91cc\u6765&#xff1f;<\/p>\n<p id=\"%E5%85%AB%E3%80%81%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E2%80%94%E2%80%94%E8%BF%90%E8%A1%8C%E6%97%B6%E6%89%8D%E8%A7%81%E7%9C%9F%E7%AB%A0-toc\" style=\"margin-left:0px\">\u516b\u3001\u52a8\u6001\u94fe\u63a5\u2014\u2014\u8fd0\u884c\u65f6\u624d\u89c1\u771f\u7ae0<\/p>\n<p id=\"8.1%20%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%EF%BC%9F-toc\" style=\"margin-left:40px\">8.1 \u4e3a\u4ec0\u4e48\u9700\u8981\u52a8\u6001\u94fe\u63a5&#xff1f;<\/p>\n<p id=\"8.2%20%E7%A8%8B%E5%BA%8F%E5%90%AF%E5%8A%A8%E7%9A%84%E5%AE%8C%E6%95%B4%E6%B5%81%E7%A8%8B-toc\" style=\"margin-left:40px\">8.2 \u7a0b\u5e8f\u542f\u52a8\u7684\u5b8c\u6574\u6d41\u7a0b<\/p>\n<p id=\"8.3%20%E5%8A%A8%E6%80%81%E5%BA%93%E7%9A%84PIC%E5%8E%9F%E7%90%86-toc\" style=\"margin-left:40px\">8.3 \u52a8\u6001\u5e93\u7684PIC\u539f\u7406<\/p>\n<p id=\"8.4%20GOT%EF%BC%88%E5%85%A8%E5%B1%80%E5%81%8F%E7%A7%BB%E8%A1%A8%EF%BC%89%E2%80%94%E2%80%94%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E7%9A%84%E5%9F%BA%E7%9F%B3-toc\" style=\"margin-left:40px\">8.4 GOT&#xff08;\u5168\u5c40\u504f\u79fb\u8868&#xff09;\u2014\u2014\u52a8\u6001\u94fe\u63a5\u7684\u57fa\u77f3<\/p>\n<p id=\"8.5%20PLT%EF%BC%88%E8%BF%87%E7%A8%8B%E9%93%BE%E6%8E%A5%E8%A1%A8%EF%BC%89%E2%80%94%E2%80%94%E5%BB%B6%E8%BF%9F%E7%BB%91%E5%AE%9A-toc\" style=\"margin-left:40px\">8.5 PLT&#xff08;\u8fc7\u7a0b\u94fe\u63a5\u8868&#xff09;\u2014\u2014\u5ef6\u8fdf\u7ed1\u5b9a<\/p>\n<p id=\"%E4%B9%9D%E3%80%81%E6%80%BB%E7%BB%93%E5%AF%B9%E6%AF%94%E2%80%94%E2%80%94%E9%9D%99%E6%80%81%E9%93%BE%E6%8E%A5%20vs%20%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5-toc\" style=\"margin-left:0px\">\u4e5d\u3001\u603b\u7ed3\u5bf9\u6bd4\u2014\u2014\u9759\u6001\u94fe\u63a5 vs \u52a8\u6001\u94fe\u63a5<\/p>\n<p id=\"%E5%AE%83%E4%BB%AC%E5%85%B1%E5%90%8C%E7%9A%84%E6%A0%B9%E2%80%94%E2%80%94ELF-toc\" style=\"margin-left:80px\">\u5b83\u4eec\u5171\u540c\u7684\u6839\u2014\u2014ELF<\/p>\n<hr id=\"hr-toc\" \/>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1023\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002530-6a6d3cfa2d989.png\" width=\"1817\" \/><\/p>\n<\/p>\n<h2 id=\"%E5%BC%80%E7%AF%87%EF%BC%9A%E4%B8%80%E6%AE%B5%E4%BB%A3%E7%A0%81%E7%9A%84%E7%BC%96%E8%AF%91%E4%B9%8B%E6%97%85\">\u5f00\u7bc7&#xff1a;\u4e00\u6bb5\u4ee3\u7801\u7684\u7f16\u8bd1\u4e4b\u65c5<\/h2>\n<p>$ gcc -c hello.c<br \/>\n$ gcc -c code.c<br \/>\n$ ls<br \/>\ncode.c  code.o  hello.c  hello.o <\/p>\n<p>\u5f53\u4f60\u6267\u884c gcc -c&#xff0c;\u7f16\u8bd1\u5668\u628a\u6e90\u4ee3\u7801\u7ffb\u8bd1\u6210 CPU \u80fd\u76f4\u63a5\u8fd0\u884c\u7684\u673a\u5668\u7801&#xff0c;\u8f93\u51fa\u4e00\u4e2a\u6269\u5c55\u540d\u4e3a .o \u7684\u6587\u4ef6\u2014\u2014\u8fd9\u5c31\u662f\u76ee\u6807\u6587\u4ef6&#xff08;Object File&#xff09;\u3002<\/p>\n<p>\u4f46\u95ee\u9898\u6765\u4e86&#xff1a;<\/p>\n<ul>\n<li>\u4e3a\u4ec0\u4e48\u4e0d\u662f\u76f4\u63a5\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6&#xff0c;\u800c\u662f\u5148\u751f\u6210 .o&#xff1f;<\/li>\n<li>.o \u91cc\u9762\u5230\u5e95\u88c5\u4e86\u4ec0\u4e48&#xff1f;<\/li>\n<li>\u4e3a\u4ec0\u4e48\u7528 file \u547d\u4ee4\u67e5\u770b&#xff0c;\u8bf4\u5b83\u662f &#034;ELF&#034;&#xff1f;<\/li>\n<\/ul>\n<p>\u522b\u6025&#xff0c;\u8fd9\u7bc7\u6587\u7ae0\u5168\u90e8\u7ed9\u4f60\u8bb2\u6e05\u695a\u3002<\/p>\n<h2 id=\"%E4%B8%80%E3%80%81%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%EF%BC%88.o%EF%BC%89%E2%80%94%E2%80%94%E7%BC%96%E8%AF%91%E7%9A%84%22%E5%8D%8A%E6%88%90%E5%93%81%22\">\u4e00\u3001\u76ee\u6807\u6587\u4ef6&#xff08;.o&#xff09;\u2014\u2014\u7f16\u8bd1\u7684&#034;\u534a\u6210\u54c1&#034;<\/h2>\n<h3 id=\"1.1%20%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%EF%BC%9F\">1.1 \u4e3a\u4ec0\u4e48\u9700\u8981\u76ee\u6807\u6587\u4ef6&#xff1f;<\/h3>\n<p>\u5047\u8bbe\u4e00\u4e2a\u9879\u76ee\u6709\u51e0\u5341\u4e2a\u6e90\u6587\u4ef6&#xff0c;\u4f60\u53ea\u4fee\u6539\u4e86\u5176\u4e2d\u4e00\u4e2a\u3002\u5982\u679c\u6bcf\u6b21\u90fd\u8981\u91cd\u65b0\u7f16\u8bd1\u6240\u6709\u6587\u4ef6&#xff0c;<span style=\"color:#ff9900\">\u6548\u7387\u6781\u4f4e\u3002<\/span>\u800c\u5f15\u5165\u76ee\u6807\u6587\u4ef6\u540e&#xff1a;<\/p>\n<p>\u4fee\u6539 hello.c \u2192 \u53ea\u9700\u8981\u91cd\u65b0\u7f16\u8bd1 hello.c \u2192 \u91cd\u65b0\u94fe\u63a5\u5373\u53ef<\/p>\n<p>\u8fd9\u5c31\u662f<span style=\"color:#fe2c24\">\u589e\u91cf\u7f16\u8bd1<\/span>\u7684\u601d\u60f3\u2014\u2014\u7f16\u8bd1\u662f\u5355\u4e2a\u6587\u4ef6\u7684\u4e8b&#xff0c;\u94fe\u63a5\u624d\u662f\u5168\u5c40\u7684\u4e8b\u3002<\/p>\n<h3 id=\"1.2%20%E5%A6%82%E4%BD%95%E7%94%9F%E6%88%90%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6\">1.2 \u5982\u4f55\u751f\u6210\u76ee\u6807\u6587\u4ef6<\/h3>\n<p>\/\/ hello.c<br \/>\n#include&lt;stdio.h&gt;<br \/>\nvoid run();<br \/>\nint main() {<br \/>\n    printf(&#034;hello world!\\\\n&#034;);<br \/>\n    run();<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\/\/ code.c<br \/>\n#include&lt;stdio.h&gt;<br \/>\nvoid run() {<br \/>\n    printf(&#034;running&#8230;\\\\n&#034;);<br \/>\n}<br \/>\n$ gcc -c hello.c    # \u2192 hello.o<br \/>\n$ gcc -c code.c     # \u2192 code.o<br \/>\n$ ls<br \/>\ncode.c  code.o  hello.c  hello.o <\/p>\n<p><span style=\"color:#ff9900\">gcc -c <\/span>\u7684\u542b\u4e49\u662f&#xff1a;<span style=\"color:#ff9900\">\u53ea\u7f16\u8bd1&#xff08;compile&#xff09;&#xff0c;\u4e0d\u94fe\u63a5&#xff08;no link&#xff09;\u3002<\/span><\/p>\n<h3 id=\"1.3%20%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%E7%9A%84%E6%9C%AC%E8%B4%A8\">1.3 \u76ee\u6807\u6587\u4ef6\u7684\u672c\u8d28<\/h3>\n<p>file hello.o <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"51\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002531-6a6d3cfbea26f.png\" width=\"846\" \/><\/p>\n<p><span style=\"color:#ff9900\">file \u547d\u4ee4\u7528\u4e8e\u8fa8\u8bc6\u6587\u4ef6\u7c7b\u578b\u3002<\/span><\/p>\n<p>\u76ee\u6807\u6587\u4ef6\u662f\u4e00\u4e2a\u4e8c\u8fdb\u5236\u7684\u6587\u4ef6&#xff0c;\u5b83\u7684\u683c\u5f0f\u662f ELF&#xff08;Executable and Linkable Format&#xff09;\u2014\u2014\u5bf9\u4e8c\u8fdb\u5236\u4ee3\u7801\u7684\u4e00\u79cd\u5c01\u88c5\u3002<\/p>\n<p>\u6ce8\u610f\u8fd9\u91cc\u7684\u63cf\u8ff0&#xff1a;relocatable&#xff08;\u53ef\u91cd\u5b9a\u4f4d&#xff09;&#xff0c;\u8fd9\u662f\u76ee\u6807\u6587\u4ef6\u7684\u7075\u9b42\u5c5e\u6027\u3002\u610f\u5473\u7740\u5176\u4e2d\u7684<span style=\"color:#38d8f0\">\u5730\u5740<\/span><span style=\"color:#fe2c24\">\u5c1a\u672a\u56fa\u5b9a&#xff0c;\u53ef\u4ee5\u5728\u94fe\u63a5\u65f6\u88ab\u91cd\u65b0\u5b9a\u4f4d\u3002<\/span><\/p>\n<h2 id=\"%E4%BA%8C%E3%80%81ELF%20%E6%96%87%E4%BB%B6%E2%80%94%E2%80%94%E7%BB%9F%E4%B8%80%E4%B8%80%E5%88%87%E7%9A%84%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%A0%BC%E5%BC%8F\">\u4e8c\u3001ELF \u6587\u4ef6\u2014\u2014\u7edf\u4e00\u4e00\u5207\u7684\u4e8c\u8fdb\u5236\u683c\u5f0f<\/h2>\n<h3 id=\"2.1%20ELF%20%E7%9A%84%E5%AE%9A%E4%B9%89\">2.1 ELF \u7684\u5b9a\u4e49<\/h3>\n<p>ELF&#xff08;Executable and Linkable Format&#xff0c;\u53ef\u6267\u884c\u4e0e\u53ef\u94fe\u63a5\u683c\u5f0f&#xff09;\u662f Linux \u4e0b\u53ef\u6267\u884c\u6587\u4ef6\u3001\u76ee\u6807\u6587\u4ef6\u3001\u5171\u4eab\u5e93\u3001\u6838\u5fc3\u8f6c\u50a8\u7684\u7edf\u4e00\u6587\u4ef6\u683c\u5f0f\u6807\u51c6\u3002<\/p>\n<p>\u8981\u7406\u89e3\u7f16\u8bd1\u548c\u94fe\u63a5\u7684\u7ec6\u8282&#xff0c;\u6211\u4eec\u5fc5\u987b\u4e86\u89e3 ELF\u3002<\/p>\n<p>\u5b9e\u9645\u4e0a&#xff0c;\u4ee5\u4e0b\u56db\u79cd\u6587\u4ef6\u90fd\u662f ELF \u6587\u4ef6&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"592\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002532-6a6d3cfc00a08.png\" width=\"2388\" \/><\/p>\n<table>\n<tr>\u6587\u4ef6\u7c7b\u578b\u6269\u5c55\u540d\/\u540d\u79f0\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u53ef\u91cd\u5b9a\u4f4d\u6587\u4ef6<\/td>\n<td>.o<\/td>\n<td>\u5305\u542b\u9002\u5408\u4e0e\u5176\u4ed6\u76ee\u6807\u6587\u4ef6\u94fe\u63a5\u6765\u521b\u5efa\u53ef\u6267\u884c\u6587\u4ef6\u6216\u5171\u4eab\u76ee\u6807\u6587\u4ef6\u7684\u4ee3\u7801\u548c\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td>\u53ef\u6267\u884c\u6587\u4ef6<\/td>\n<td>\u65e0\u6269\u5c55\u540d \/ a.out<\/td>\n<td>\u5373\u53ef\u6267\u884c\u7a0b\u5e8f&#xff0c;\u7ecf\u8fc7\u5b8c\u6574\u94fe\u63a5&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u52a0\u8f7d\u8fd0\u884c<\/td>\n<\/tr>\n<tr>\n<td>\u5171\u4eab\u76ee\u6807\u6587\u4ef6<\/td>\n<td>.so<\/td>\n<td>\u52a8\u6001\u94fe\u63a5\u5e93&#xff0c;\u5305\u542b\u53ef\u5728\u8fd0\u884c\u65f6\u88ab\u52a8\u6001\u94fe\u63a5\u5668\u52a0\u8f7d\u548c\u94fe\u63a5\u7684\u4ee3\u7801\u548c\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u6838\u8f6c\u50a8<\/td>\n<td>core<\/td>\n<td>\u5b58\u653e\u5f53\u524d\u8fdb\u7a0b\u7684\u6267\u884c\u4e0a\u4e0b\u6587&#xff0c;\u7528\u4e8e dump \u4fe1\u53f7\u89e6\u53d1\u540e\u7684\u8c03\u8bd5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6838\u5fc3\u601d\u60f3&#xff1a;<span style=\"color:#ff9900\">\u65e0\u8bba\u662f .o\u3001.so\u3001a.out&#xff0c;\u5b83\u4eec\u9aa8\u5b50\u91cc\u90fd\u662f ELF&#xff01;<\/span><\/p>\n<h2 id=\"%E4%B8%89%E3%80%81ELF%20%E6%96%87%E4%BB%B6%E7%9A%84%E8%A7%A3%E5%89%96%E2%80%94%E2%80%94%E5%9B%9B%E5%A4%A7%E9%83%A8%E5%88%86\">\u4e09\u3001ELF \u6587\u4ef6\u7684\u89e3\u5256\u2014\u2014\u56db\u5927\u90e8\u5206<\/h2>\n<p>\u4e00\u4e2a ELF \u6587\u4ef6\u7531\u4ee5\u4e0b\u56db\u90e8\u5206\u7ec4\u6210&#xff1a;<\/p>\n<ul>\n<li>ELF \u5934 (ELF header)&#xff1a;<span style=\"color:#ff9900\">\u63cf\u8ff0\u6587\u4ef6\u7684\u4e3b\u8981\u7279\u6027<\/span>\u3002\u5176\u4f4d\u4e8e\u6587\u4ef6\u7684\u5f00\u59cb\u4f4d\u7f6e&#xff0c;\u5b83\u7684\u4e3b\u8981\u76ee\u7684\u662f<span style=\"color:#ff9900\">\u5b9a\u4f4d\u6587\u4ef6\u7684\u5176\u4ed6\u90e8\u5206<\/span>\u3002<\/li>\n<li>\u7a0b\u5e8f\u5934\u8868 (Program header table)&#xff1a;\u5217\u4e3e\u4e86<span style=\"color:#ff9900\">\u6240\u6709\u6709\u6548\u7684\u6bb5 (segments) \u548c\u4ed6\u4eec\u7684\u5c5e\u6027<\/span>\u3002\u8868\u91cc\u8bb0\u7740<span style=\"color:#ff9900\">\u6bcf\u4e2a\u6bb5\u7684\u5f00\u59cb\u7684\u4f4d\u7f6e\u548c\u4f4d\u79fb&#xff08;offset&#xff09;\u3001\u957f\u5ea6&#xff0c;<\/span>\u6bd5\u7adf\u8fd9\u4e9b\u6bb5&#xff0c;\u90fd\u662f\u7d27\u5bc6\u7684\u653e\u5728\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e2d&#xff0c;\u9700\u8981\u6bb5\u8868\u7684\u63cf\u8ff0\u4fe1\u606f&#xff0c;\u624d\u80fd\u628a\u4ed6\u4eec\u6bcf\u4e2a\u6bb5\u5206\u5272\u5f00\u3002<\/li>\n<li>\u8282\u5934\u8868 (Section header table)&#xff1a;\u5305\u542b<span style=\"color:#ff9900\">\u5bf9\u8282 (sections) \u7684\u63cf\u8ff0<\/span>\u3002<\/li>\n<li>\u8282&#xff08;Section&#xff09;&#xff1a;<span style=\"color:#a2e043\">ELF \u6587\u4ef6\u4e2d\u7684\u57fa\u672c\u7ec4\u6210\u5355\u4f4d<\/span>&#xff0c;\u5305\u542b\u4e86\u7279\u5b9a\u7c7b\u578b\u7684\u6570\u636e\u3002<span style=\"color:#ff9900\">ELF \u6587\u4ef6\u7684\u5404\u79cd\u4fe1\u606f\u548c\u6570\u636e\u90fd\u5b58\u50a8\u5728\u4e0d\u540c\u7684\u8282\u4e2d<\/span>&#xff0c;\u5982\u4ee3\u7801\u8282\u5b58\u50a8\u4e86\u53ef\u6267\u884c\u4ee3\u7801&#xff0c;\u6570\u636e\u8282\u5b58\u50a8\u4e86\u5168\u5c40\u53d8\u91cf\u548c\u9759\u6001\u6570\u636e\u7b49\u3002<\/li>\n<\/ul>\n<p>\u8865\u5145&#xff1a;<span style=\"color:#38d8f0\">\u4e00\u4e2a Segment&#xff08;\u6bb5&#xff09;\u901a\u5e38\u7531\u82e5\u5e72\u4e2a Section&#xff08;\u8282&#xff09;\u5408\u5e76\u6784\u6210\u3002<\/span><\/p>\n<p><span style=\"color:#956fe7\">\u6700\u5e38\u89c1\u7684\u8282&#xff1a;<\/span><\/p>\n<ul>\n<li>\u4ee3\u7801\u8282&#xff08;.text&#xff09;&#xff1a;\u7528\u4e8e\u4fdd\u5b58\u673a\u5668\u6307\u4ee4&#xff0c;\u662f\u7a0b\u5e8f\u7684\u4e3b\u8981\u6267\u884c\u90e8\u5206\u3002<\/li>\n<li>\u6570\u636e\u8282&#xff08;.data&#xff09;&#xff1a;\u4fdd\u5b58\u5df2\u521d\u59cb\u5316\u7684\u5168\u5c40\u53d8\u91cf\u548c\u5c40\u90e8\u9759\u6001\u53d8\u91cf\u3002<\/li>\n<\/ul>\n<p>size code.o <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"67\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002532-6a6d3cfc94498.png\" width=\"564\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1007\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002532-6a6d3cfc9ca44.png\" width=\"561\" \/><\/p>\n<h3 id=\"3.1%20ELF%20%E5%A4%B4%EF%BC%88ELF%20Header%EF%BC%89%E2%80%94%E2%80%94%E6%96%87%E4%BB%B6%E7%9A%84%E8%BA%AB%E4%BB%BD%E8%AF%81\">3.1 ELF \u5934&#xff08;ELF Header&#xff09;\u2014\u2014\u6587\u4ef6\u7684\u8eab\u4efd\u8bc1<\/h3>\n<p>\u4f4d\u7f6e&#xff1a;<span style=\"color:#a2e043\">\u6587\u4ef6\u7684\u6700\u5f00\u59cb\u4f4d\u7f6e<\/span>\u3002<\/p>\n<p>\u4f5c\u7528&#xff1a;<span style=\"color:#a2e043\">\u63cf\u8ff0\u6587\u4ef6\u7684\u4e3b\u8981\u7279\u6027&#xff0c;\u5b9a\u4f4d\u6587\u4ef6\u7684\u5176\u4ed6\u90e8\u5206<\/span><span style=\"color:#a2e043\">\u3002<\/span><\/p>\n<h4 id=\"1.%E8%AF%BB%E5%8F%96%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%E7%9A%84ELF%E6%96%87%E4%BB%B6%E5%A4%B4%E9%83%A8%E4%BF%A1%E6%81%AF\">1.\u8bfb\u53d6\u76ee\u6807\u6587\u4ef6\u7684ELF\u6587\u4ef6\u5934\u90e8\u4fe1\u606f<\/h4>\n<p>$ readelf -h hello.o<br \/>\nELF Header:<br \/>\nMagic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00  # ELF\u9b54\u6570&#xff0c;7f&#043;ELF&#xff0c;\u7528\u6765\u6807\u8bc6\u8fd9\u662fELF\u6587\u4ef6<br \/>\n  Class:                             ELF64                  # ELF\u7c7b\u522b&#xff1a;64\u4f4d\u7a0b\u5e8f&#xff1b;ELF32\u4ee3\u886832\u4f4d<br \/>\n  Data:                              2&#039;s complement, little endian  # \u5b57\u8282\u5e8f&#xff1a;\u5c0f\u7aef\u5e8f&#xff0c;\u8865\u7801\u5b58\u50a8<br \/>\n  Version:                           1 (current)            # ELF\u683c\u5f0f\u7248\u672c\u53f7&#xff0c;\u56fa\u5b9a\u4e3a1<br \/>\n  OS\/ABI:                            UNIX &#8211; System V        # \u76ee\u6807\u64cd\u4f5c\u7cfb\u7edfABI\u89c4\u8303&#xff0c;Linux\u9075\u5faaSystem V<br \/>\n  ABI Version:                       0                      # ABI\u7248\u672c<br \/>\n  Type:                              REL (Relocatable file) # \u6587\u4ef6\u7c7b\u578b&#xff1a;REL&#061;\u53ef\u91cd\u5b9a\u4f4d\u6587\u4ef6&#xff08;*.o\u76ee\u6807\u6587\u4ef6&#xff09;<br \/>\n  Machine:                           Advanced Micro Devices X86-64 # \u76ee\u6807CPU\u67b6\u6784 x86_64<br \/>\n  Version:                           0x1                    # \u76ee\u6807\u6587\u4ef6\u7248\u672c<br \/>\n  Entry point address:               0x0                    # \u7a0b\u5e8f\u5165\u53e3\u5730\u5740&#xff1b;.o\u6587\u4ef6\u6ca1\u6709\u5165\u53e3&#xff0c;\u586b0<br \/>\n  Start of program headers:          0 (bytes into file)    # \u7a0b\u5e8f\u5934\u8868\u5728\u6587\u4ef6\u5185\u504f\u79fb&#xff1b;\u5f53\u524d\u4e3a0&#061;\u4e0d\u5b58\u5728\u7a0b\u5e8f\u5934\u8868<br \/>\n  Start of section headers:          672 (bytes into file)  # \u8282\u5934\u8868\u5728\u6587\u4ef6\u4e2d\u7684\u8d77\u59cb\u504f\u79fb\u4f4d\u7f6e<br \/>\n  Flags:                             0x0                    # \u67b6\u6784\u76f8\u5173\u6807\u5fd7\u4f4d&#xff0c;x86_64\u4e00\u822c\u4e3a0<br \/>\n  Size of this header:               64 (bytes)             # ELF\u5934\u90e8\u81ea\u8eab\u5927\u5c0f&#xff0c;64\u4f4dELF\u56fa\u5b9a64\u5b57\u8282<br \/>\n  Size of program headers:           0 (bytes)              # \u5355\u4e2a\u7a0b\u5e8f\u5934\u8868\u9879\u5927\u5c0f&#xff1b;0\u4ee3\u8868\u65e0\u7a0b\u5e8f\u5934<br \/>\n  Number of program headers:         0                      # \u7a0b\u5e8f\u5934\u8868\u6761\u76ee\u6570\u91cf&#xff0c;0&#061;\u6ca1\u6709\u7a0b\u5e8f\u5934<br \/>\n  Size of section headers:           64 (bytes)             # \u5355\u4e2a\u8282\u5934\u8868\u9879\u5927\u5c0f&#xff0c;64\u4f4dELF\u56fa\u5b9a64\u5b57\u8282<br \/>\n  Number of section headers:         13                     # \u8282\u5934\u8868\u603b\u5171\u670913\u4e2a\u6761\u76ee&#xff08;13\u4e2a\u8282&#xff09;<br \/>\n  Section header string table index: 12                     # \u8282\u540d\u5b57\u7b26\u4e32\u8868&#xff0c;\u662f\u7b2c12\u53f7\u8282\u5934 <\/p>\n<p>\u4f5c\u4e3a\u5bf9\u6bd4&#xff0c;\u770b\u4e0b\u53ef\u6267\u884c\u6587\u4ef6\u7684 ELF \u5934&#xff1a;<\/p>\n<p>$ readelf -h a.out<br \/>\nELF Header:<br \/>\nMagic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00  # ELF\u9b54\u6570&#xff0c;0x7f&#043;&#034;ELF&#034;&#xff0c;\u6807\u8bc6\u8be5\u6587\u4ef6\u4e3aELF\u683c\u5f0f<br \/>\nClass:                             ELF64                  # ELF\u7c7b\u578b&#xff1a;64\u4f4dELF\u6587\u4ef6<br \/>\nData:                              2&#039;s complement, little endian  # \u6570\u636e\u7f16\u7801&#xff1a;\u8865\u7801\u3001\u5c0f\u7aef\u5b57\u8282\u5e8f<br \/>\nVersion:                           1 (current)            # ELF\u6807\u51c6\u7248\u672c&#xff0c;\u56fa\u5b9a\u4e3a1<br \/>\nOS\/ABI:                            UNIX &#8211; System V        # \u9075\u5faaSystem V ABI\u6807\u51c6&#xff08;Linux\u4f7f\u7528&#xff09;<br \/>\nABI Version:                       0                      # ABI\u7248\u672c\u53f7<br \/>\nType:                              EXEC (Executable file) # \u6587\u4ef6\u7c7b\u578b&#xff1a;EXEC&#061;\u53ef\u6267\u884c\u6587\u4ef6&#xff08;a.out&#xff0c;\u80fd\u76f4\u63a5.\/\u8fd0\u884c&#xff09;<br \/>\nMachine:                           Advanced Micro Devices X86-64 # \u76ee\u6807CPU\u67b6\u6784 x86_64<br \/>\nVersion:                           0x1                    # \u5bf9\u8c61\u6587\u4ef6\u7248\u672c<br \/>\nEntry point address:               0x401040               # \u7a0b\u5e8f\u5165\u53e3\u865a\u62df\u5730\u5740&#xff0c;\u5185\u6838\u4ece\u6b64\u5904\u5f00\u59cb\u6267\u884c\u4ee3\u7801<br \/>\nStart of program headers:          64 (bytes into file)   # \u7a0b\u5e8f\u5934\u8868\u5728\u6587\u4ef6\u5185\u7684\u8d77\u59cb\u504f\u79fb&#xff08;ELF\u5934\u5927\u5c0f64\u5b57\u8282&#xff0c;\u7d27\u8ddf\u5176\u540e&#xff09;<br \/>\nStart of section headers:          23928 (bytes into file)# \u8282\u5934\u8868\u5728\u6587\u4ef6\u5185\u7684\u8d77\u59cb\u504f\u79fb<br \/>\nFlags:                             0x0                    # \u5904\u7406\u5668\u76f8\u5173\u6807\u5fd7\u4f4d&#xff0c;x86_64\u5e73\u53f0\u901a\u5e38\u4e3a0<br \/>\nSize of this header:               64 (bytes)             # ELF\u5934\u90e8\u81ea\u8eab\u5927\u5c0f&#xff0c;64\u4f4dELF\u56fa\u5b9a64\u5b57\u8282<br \/>\nSize of program headers:           56 (bytes)             # \u5355\u4e2a\u7a0b\u5e8f\u5934\u8868\u9879\u7684\u5927\u5c0f&#xff0c;64\u4f4dELF\u56fa\u5b9a56\u5b57\u8282<br \/>\nNumber of program headers:         11                     # \u4e00\u5171\u670911\u4e2a\u7a0b\u5e8f\u5934&#xff08;\u5bf9\u5e9411\u4e2aSegment\u6bb5&#xff09;<br \/>\nSize of section headers:           64 (bytes)             # \u5355\u4e2a\u8282\u5934\u8868\u9879\u5927\u5c0f&#xff0c;64\u4f4dELF\u56fa\u5b9a64\u5b57\u8282<br \/>\nNumber of section headers:         30                     # \u8282\u5934\u8868\u4e00\u517130\u4e2a\u6761\u76ee&#xff08;30\u4e2aSection\u8282&#xff09;<br \/>\nSection header string table index: 29                     # \u8282\u540d\u79f0\u5b57\u7b26\u4e32\u8868&#xff0c;\u662f\u7b2c29\u53f7\u8282 <\/p>\n<p>hello.o \u662fREL \u53ef\u91cd\u5b9a\u4f4d\u76ee\u6807\u6587\u4ef6&#xff0c;<span style=\"color:#a2e043\">\u65e0\u7a0b\u5e8f\u5934\u8868\u3001\u7a0b\u5e8f\u5165\u53e3\u5730\u5740\u4e3a 0<\/span>&#xff0c;\u4ec5\u63d0\u4f9b\u8282\u4fe1\u606f\u4f9b\u94fe\u63a5\u5668\u4f7f\u7528&#xff1b;<\/p>\n<p>a.out \u662fEXEC \u53ef\u6267\u884c\u6587\u4ef6&#xff0c;<span style=\"color:#a2e043\">\u62e5\u6709\u7a0b\u5e8f\u5934\u8868\u4e0e\u6709\u6548\u7a0b\u5e8f\u5165\u53e3\u5730\u5740&#xff0c;\u540c\u65f6\u5305\u542b\u8282\u4e0e\u6bb5\u4fe1\u606f<\/span>&#xff0c;\u53ef\u4f9b\u64cd\u4f5c\u7cfb\u7edf\u52a0\u8f7d\u8fd0\u884c\u3002<\/p>\n<p>\u603b\u7ed3&#xff1a;<\/p>\n<p>ELF \u5934\u4e2d\u6700\u6838\u5fc3\u7684\u4fe1\u606f&#xff1a;\u6587\u4ef6\u7c7b\u578b&#xff08;REL\/EXEC\/DYN&#xff09;&#043; \u5165\u53e3\u70b9\u5730\u5740 &#043; \u7a0b\u5e8f\u5934\u8868\u548c\u8282\u5934\u8868\u7684\u4f4d\u7f6e\u3002<\/p>\n<h3 id=\"3.2%20%E7%A8%8B%E5%BA%8F%E5%A4%B4%E8%A1%A8%EF%BC%88Program%20Header%20Table%EF%BC%89%E2%80%94%E2%80%94%E6%89%A7%E8%A1%8C%E8%A7%86%E5%9B%BE\">3.2 \u7a0b\u5e8f\u5934\u8868&#xff08;Program Header Table&#xff09;\u2014\u2014\u6267\u884c\u89c6\u56fe<\/h3>\n<p>\u4f5c\u7528&#xff1a;<span style=\"color:#ff9900\">\u5217\u4e3e\u6240\u6709\u6709\u6548\u7684\u6bb5&#xff08;Segments&#xff09;\u548c\u5b83\u4eec\u7684\u5c5e\u6027<\/span>\u3002\u6807\u8bb0<span style=\"color:#a2e043\">\u6bcf\u4e2a\u6bb5\u7684\u8d77\u59cb\u4f4d\u7f6e\u3001\u504f\u79fb\u91cf\u3001\u957f\u5ea6\u548c\u6743\u9650\u3002<\/span> \u8fd9\u6b63\u662f\u64cd\u4f5c\u7cfb\u7edf\u7684\u52a0\u8f7d\u5668\u6240\u5173\u6ce8\u7684\u5185\u5bb9\u2014\u2014\u5b83\u544a\u8bc9 OS \u600e\u4e48\u628a\u8fd9\u4e2a\u6587\u4ef6\u52a0\u8f7d\u5230\u5185\u5b58\u3002<\/p>\n<h4 id=\"1.%E6%9F%A5%E7%9C%8B%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6%E7%9A%84%E6%AE%B5%20(Segment)%E4%BF%A1%E6%81%AF\">1.\u67e5\u770b\u53ef\u6267\u884c\u6587\u4ef6\u7684\u6bb5 (Segment)\u4fe1\u606f<\/h4>\n<p>\u200breadelf -l a.out<br \/>\nElf file type is EXEC (Executable file)          # \u6587\u4ef6\u7c7b\u578b&#xff1a;\u53ef\u6267\u884c\u7a0b\u5e8f<br \/>\nEntry point 0x401040                             # \u8fdb\u7a0b\u542f\u52a8\u865a\u62df\u5165\u53e3\u5730\u5740<br \/>\nThere are 11 program headers, starting at offset 64  # \u517111\u4e2a\u6bb5\u63cf\u8ff0\u9879&#xff0c;\u7a0b\u5e8f\u5934\u8868\u5728\u6587\u4ef6\u504f\u79fb0x40\u5904<\/p>\n<p>Program Headers:<br \/>\n  Type           Offset             VirtAddr           PhysAddr<br \/>\n                 FileSiz            MemSiz              Flags  Align<br \/>\n  PHDR           0x0000000000000040 0x0000000000400040 0x0000000000400040<br \/>\n                 0x0000000000000268 0x0000000000000268  R      0x8<br \/>\n  # PHDR\u6bb5&#xff1a;\u7a0b\u5e8f\u5934\u8868\u81ea\u8eab&#xff0c;\u52a0\u8f7d\u5230\u5185\u5b58&#xff0c;\u53ea\u8bfb<\/p>\n<p>  INTERP         0x00000000000002a8 0x00000000004002a8 0x00000000004002a8<br \/>\n                 0x000000000000001c 0x000000000000001c  R      0x1<br \/>\n      [Requesting program interpreter: \/lib64\/ld-linux-x86-64.so.2]<br \/>\n  # INTERP\u6bb5&#xff1a;\u6307\u5b9a\u52a8\u6001\u94fe\u63a5\u5668&#xff08;\u89e3\u91ca\u5668&#xff09;&#xff0c;\u8d1f\u8d23\u52a0\u8f7dlibc\u7b49\u52a8\u6001\u5e93<\/p>\n<p>  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000<br \/>\n                 0x0000000000000438 0x0000000000000438  R      0x1000<br \/>\n  # PT_LOAD \u53ef\u8bfb\u5185\u5b58\u6bb5&#xff0c;\u6620\u5c04\u8f85\u52a9\u4fe1\u606f\u8282<\/p>\n<p>  LOAD           0x0000000000001000 0x0000000000401000 0x0000000000401000<br \/>\n                 0x00000000000001e5 0x00000000000001e5  R E    0x1000<br \/>\n  # PT_LOAD \u53ef\u8bfb&#043;\u53ef\u6267\u884c\u6bb5\u3010\u4ee3\u7801\u6bb5\u3011&#xff0c;\u627f\u8f7d .text .plt \u673a\u5668\u6307\u4ee4<\/p>\n<p>  LOAD           0x0000000000002000 0x0000000000402000 0x0000000000402000<br \/>\n                 0x0000000000000168 0x0000000000000168  R      0x1000<br \/>\n  # PT_LOAD \u53ea\u8bfb\u6bb5\u3010\u5e38\u91cf\u6bb5\u3011&#xff0c;\u627f\u8f7d .rodata \u5b57\u7b26\u4e32\u5e38\u91cf<\/p>\n<p>  LOAD           0x0000000000002e10 0x0000000000403e10 0x0000000000403e10<br \/>\n                 0x0000000000000220 0x0000000000000228  RW     0x1000<br \/>\n  # PT_LOAD \u53ef\u8bfb\u53ef\u5199\u6bb5\u3010\u6570\u636e\u6bb5\u3011&#xff0c;\u627f\u8f7d .data .bss \u5168\u5c40\u53d8\u91cf&#xff1b;MemSiz &gt; FileSiz \u5bf9\u5e94.bss&#xff08;\u6587\u4ef6\u4e0d\u5360\u7a7a\u95f4&#xff0c;\u5185\u5b58\u6e05\u96f6&#xff09;<\/p>\n<p>  DYNAMIC        0x0000000000002e20 0x0000000000403e20 0x0000000000403e20<br \/>\n                 0x00000000000001d0 0x00000000000001d0  RW     0x8<br \/>\n  # DYNAMIC\u6bb5&#xff1a;\u52a8\u6001\u94fe\u63a5\u4fe1\u606f&#xff0c;\u7b26\u53f7\u3001\u4f9d\u8d56\u5e93\u3001\u91cd\u5b9a\u4f4d\u76f8\u5173\u6570\u636e<\/p>\n<p>  NOTE           0x00000000000002c4 0x00000000004002c4 0x00000000004002c4<br \/>\n                 0x0000000000000044 0x0000000000000044  R      0x4<br \/>\n  # NOTE\u6bb5&#xff1a;\u7a0b\u5e8f\u7248\u672c\u3001ABI\u6807\u8bb0\u7b49\u9644\u52a0\u4fe1\u606f<\/p>\n<p>  GNU_EH_FRAME   0x000000000000201c 0x000000000040201c 0x000000000040201c<br \/>\n                 0x0000000000000044 0x0000000000000044  R      0x4<br \/>\n  # GNU_EH_FRAME&#xff1a;C&#043;&#043;\u5f02\u5e38\u5904\u7406\u6808\u5c55\u5f00\u4fe1\u606f<\/p>\n<p>  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000<br \/>\n                 0x0000000000000000 0x0000000000000000  RW     0x10<br \/>\n  # GNU_STACK&#xff1a;\u6807\u8bc6\u6808\u6743\u9650 RW&#xff0c;\u8bf4\u660e\u6808**\u4e0d\u53ef\u6267\u884c**&#xff08;\u9632\u62a4\u7f13\u51b2\u533a\u6ea2\u51fa&#xff09;<\/p>\n<p>  GNU_RELRO      0x0000000000002e10 0x0000000000403e10 0x0000000000403e10<br \/>\n                 0x00000000000001f0 0x00000000000001f0  R      0x1<br \/>\n  # GNU_RELRO&#xff1a;\u5ef6\u8fdf\u91cd\u5b9a\u4f4d\u533a\u57df&#xff0c;\u91cd\u5b9a\u4f4d\u5b8c\u6210\u540e\u5185\u5b58\u6539\u4e3a\u53ea\u8bfb&#xff0c;\u5b89\u5168\u9632\u62a4<\/p>\n<p> Section to Segment mapping:<br \/>\n  # \u3010\u91cd\u70b9&#xff01;\u8282(Section) \u6620\u5c04\u5230 \u6bb5(Segment)\u3011\u76f4\u89c2\u5370\u8bc1&#xff1a;\u591a\u4e2a\u8282\u6253\u5305\u5408\u5e76\u6210\u4e00\u4e2a\u6bb5<br \/>\n  Segment Sections&#8230;<br \/>\n   00<br \/>\n   01     .interp<br \/>\n   02     .interp .note.gnu.build-id .note.ABI-tag .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt<br \/>\n   03     .init .plt .text .fini               # \u4ee3\u7801\u6bb5R&#043;E&#xff1a;\u591a\u4e2a\u4ee3\u7801\u76f8\u5173\u8282\u5408\u5e76<br \/>\n   04     .rodata .eh_frame_hdr .eh_frame      # \u53ea\u8bfb\u5e38\u91cf\u8282\u96c6\u5408<br \/>\n   05     .init_array .fini_array .dynamic .got .got.plt .data .bss # \u8bfb\u5199\u6570\u636e\u76f8\u5173\u8282<br \/>\n   06     .dynamic<br \/>\n   07     .note.gnu.build-id .note.ABI-tag<br \/>\n   08     .eh_frame_hdr<br \/>\n   09 <\/p>\n<h4 id=\"\"><\/h4>\n<p>\u7a0b\u5e8f\u5934\u7684\u7c7b\u578b\u542b\u4e49&#xff1a;<\/p>\n<table>\n<tr>\u7c7b\u578b\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>LOAD<\/td>\n<td>\u9700\u8981\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u7684\u6bb5&#xff0c;\u662f\u52a0\u8f7d\u7684\u6838\u5fc3<\/td>\n<\/tr>\n<tr>\n<td>INTERP<\/td>\n<td>\u6307\u5b9a\u52a8\u6001\u94fe\u63a5\u5668\u7684\u8def\u5f84&#xff08;\u5982 \/lib64\/ld-linux-x86-64.so.2&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>DYNAMIC<\/td>\n<td>\u52a8\u6001\u94fe\u63a5\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td>NOTE<\/td>\n<td>\u8f85\u52a9\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td>GNU_STACK<\/td>\n<td>\u6808\u7684\u53ef\u6267\u884c\u5c5e\u6027<\/td>\n<\/tr>\n<tr>\n<td>GNU_RELRO<\/td>\n<td>\u53ea\u8bfb\u91cd\u5b9a\u4f4d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"3.3%20%E8%8A%82%E5%A4%B4%E8%A1%A8%EF%BC%88Section%20Header%20Table%EF%BC%89%E2%80%94%E2%80%94%E9%93%BE%E6%8E%A5%E8%A7%86%E5%9B%BE\">3.3 \u8282\u5934\u8868&#xff08;Section Header Table&#xff09;\u2014\u2014\u94fe\u63a5\u89c6\u56fe<\/h3>\n<p>\u4f5c\u7528&#xff1a;\u5305\u542b\u5bf9<span style=\"color:#ff9900\">\u6240\u6709\u8282&#xff08;Sections&#xff09;\u7684\u8be6\u7ec6\u63cf\u8ff0&#xff0c;\u5305\u62ec\u8282\u540d\u79f0\u3001\u7c7b\u578b\u3001\u5730\u5740\u3001\u504f\u79fb\u3001\u5927\u5c0f\u7b49\u4fe1\u606f\u3002<\/span><\/p>\n<p>\u8fd9\u662f\u94fe\u63a5\u5668\u548c\u7f16\u8bd1\u5668\u6240\u5173\u6ce8\u7684\u5185\u5bb9\u3002<\/p>\n<h4 id=\"1.%E6%89%93%E5%8D%B0%E3%80%90%E8%8A%82%E5%A4%B4%E8%A1%A8%20Section%20Header%20Table%E3%80%91%EF%BC%8C%E5%88%97%E5%87%BA%20ELF%20%E5%86%85%E9%83%A8%E6%89%80%E6%9C%89%E8%8A%82%20(Section)\">1.\u6253\u5370\u3010\u8282\u5934\u8868 Section Header Table\u3011&#xff0c;\u5217\u51fa ELF \u5185\u90e8\u6240\u6709\u8282 (Section)<\/h4>\n<p>readelf -S hello.o<\/p>\n<p>There are 13 section headers, starting at offset 0x2e0:  # \u4e00\u517113\u4e2a\u8282&#xff0c;\u8282\u5934\u8868\u5728\u6587\u4ef6\u504f\u79fb0x2e0\u4f4d\u7f6e<\/p>\n<p>Section Headers:<br \/>\n  [Nr] Name              Type             Address           Offset<br \/>\n       Size              EntSize          Flags  Link  Info  Align<br \/>\n  [ 0]                   NULL             0000000000000000  00000000<br \/>\n       0000000000000000  0000000000000000           0     0     0<br \/>\n  # 0\u53f7\u8282\u56fa\u5b9a\u662f\u7a7a\u8282&#xff0c;\u5360\u4f4d\u4fdd\u7559<\/p>\n<p>  [ 1] .text             PROGBITS         0000000000000000  00000040<br \/>\n       000000000000001f  0000000000000000  AX       0     0     1<br \/>\n  # .text\u4ee3\u7801\u8282&#xff1a;\u5b58\u653e\u51fd\u6570\u673a\u5668\u6307\u4ee4&#xff1b;AX&#061;\u53ef\u5206\u914d\u5185\u5b58\u3001\u53ef\u6267\u884c<\/p>\n<p>  [ 2] .rela.text        RELA             0000000000000000  00000218<br \/>\n       0000000000000048  0000000000000018   I      10     1     8<br \/>\n  # .rela.text&#xff1a;.text\u8282\u5bf9\u5e94\u7684\u91cd\u5b9a\u4f4d\u8868&#xff0c;\u94fe\u63a5\u65f6\u4fee\u6b63\u7b26\u53f7\u5730\u5740<\/p>\n<p>  [ 3] .data             PROGBITS         0000000000000000  0000005f<br \/>\n       0000000000000000  0000000000000000  WA       0     0     1<br \/>\n  # .data\u6570\u636e\u8282&#xff1a;\u5b58\u653e\u5df2\u521d\u59cb\u5316\u5168\u5c40\/\u9759\u6001\u53d8\u91cf&#xff1b;WA&#061;\u53ef\u5206\u914d\u3001\u53ef\u5199&#xff1b;\u5f53\u524dsize\u4e3a0\u4ee3\u8868\u6ca1\u6709\u8fd9\u7c7b\u53d8\u91cf<\/p>\n<p>  [ 4] .bss              NOBITS           0000000000000000  0000005f<br \/>\n       0000000000000000  0000000000000000  WA       0     0     1<br \/>\n  # .bss&#xff1a;\u672a\u521d\u59cb\u5316\u5168\u5c40\/\u9759\u6001\u53d8\u91cf&#xff1b;NOBITS&#061;\u78c1\u76d8\u6587\u4ef6\u4e0d\u5360\u7528\u7a7a\u95f4&#xff1b;size&#061;0\u8bf4\u660e\u65e0\u5bf9\u5e94\u53d8\u91cf<\/p>\n<p>  [ 5] .rodata           PROGBITS         0000000000000000  0000005f<br \/>\n       000000000000000d  0000000000000000   A       0     0     1<br \/>\n  # .rodata\u53ea\u8bfb\u6570\u636e\u8282&#xff1a;\u5b58\u653e\u5b57\u7b26\u4e32\u5e38\u91cf\u3001const\u5e38\u91cf&#xff1b;A&#061;\u8fd0\u884c\u65f6\u5206\u914d\u5185\u5b58<\/p>\n<p>  [ 6] .comment          PROGBITS         0000000000000000  0000006c<br \/>\n       0000000000000036  0000000000000001  MS       0     0     1<br \/>\n  # .comment&#xff1a;\u7f16\u8bd1\u5668\u7248\u672c\u6ce8\u91ca\u4fe1\u606f&#xff0c;\u8fd0\u884c\u65f6\u4e0d\u52a0\u8f7d<\/p>\n<p>  [ 7] .note.GNU-stack   PROGBITS         0000000000000000  000000a2<br \/>\n       0000000000000000  0000000000000000           0     0     1<br \/>\n  # \u6808\u5c5e\u6027\u6807\u8bb0&#xff0c;\u6807\u8bc6\u6808\u4e0d\u53ef\u6267\u884c&#xff08;\u5b89\u5168\u4fdd\u62a4&#xff09;<\/p>\n<p>  [ 8] .eh_frame         PROGBITS         0000000000000000  000000a8<br \/>\n       0000000000000038  0000000000000000   A       0     0     8<br \/>\n  # C\/C&#043;&#043;\u5f02\u5e38\u5904\u7406\u3001\u6808\u56de\u6eaf\u4fe1\u606f<\/p>\n<p>  [ 9] .rela.eh_frame    RELA             0000000000000000  00000260<br \/>\n       0000000000000018  0000000000000018   I      10     8     8<br \/>\n  # .eh_frame\u8282\u5bf9\u5e94\u7684\u91cd\u5b9a\u4f4d\u4fe1\u606f<\/p>\n<p>  [10] .symtab           SYMTAB           0000000000000000  000000e0<br \/>\n       0000000000000120  0000000000000018          11     9     8<br \/>\n  # .symtab\u7b26\u53f7\u8868&#xff1a;\u4fdd\u5b58\u51fd\u6570\u540d\u3001\u53d8\u91cf\u540d\u7b49\u7b26\u53f7\u4fe1\u606f&#xff0c;\u4f9b\u94fe\u63a5\u5668\u4f7f\u7528<\/p>\n<p>  [11] .strtab           STRTAB           0000000000000000  00000200<br \/>\n       0000000000000017  0000000000000000           0     0     1<br \/>\n  # .strtab&#xff1a;\u7b26\u53f7\u540d\u5b57\u7b26\u4e32\u8868&#xff0c;\u914d\u5408symtab\u4f7f\u7528<\/p>\n<p>  [12] .shstrtab         STRTAB           0000000000000000  00000278<br \/>\n       0000000000000061  0000000000000000           0     0     1<br \/>\n  # .shstrtab&#xff1a;\u8282\u540d\u79f0\u5b57\u7b26\u4e32\u8868&#xff0c;\u4fdd\u5b58.text\/.data\u8fd9\u7c7b\u8282\u540d\u5b57<\/p>\n<p>Key to Flags:<br \/>\n  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),<br \/>\n  L (link order), O (extra OS processing required), G (group), T (TLS),<br \/>\n  C (compressed), x (unknown), o (OS specific), E (exclude),<br \/>\n  l (large), p (processor specific) <\/p>\n<p>\u67e5\u770b\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8282\u6570<\/p>\n<p>readelf -S a.out<\/p>\n<p>There are 30 section headers, starting at offset 0x5d78:<br \/>\n# \u4e00\u5171\u670930\u4e2a\u8282&#xff0c;\u8282\u5934\u8868\u5728ELF\u6587\u4ef6\u5185\u504f\u79fb0x5d78\u7684\u4f4d\u7f6e <\/p>\n<p>\u6ce8\u610f\u5bf9\u6bd4&#xff1a;hello.o \u6709 13 \u4e2a\u8282&#xff0c;\u800c a.out \u6709 31 \u4e2a\u8282\u2014\u2014<span style=\"color:#38d8f0\">\u94fe\u63a5\u540e\u7684\u53ef\u6267\u884c\u6587\u4ef6\u66f4\u590d\u6742<\/span>\u3002<\/p>\n<h3 id=\"3.4%20%E8%8A%82%EF%BC%88Sections%EF%BC%89%E2%80%94%E2%80%94%E7%9C%9F%E6%AD%A3%E7%9A%84%E6%95%B0%E6%8D%AE%E4%BB%93%E5%BA%93\">3.4 \u8282&#xff08;Sections&#xff09;\u2014\u2014\u771f\u6b63\u7684\u6570\u636e\u4ed3\u5e93<\/h3>\n<p>\u8282\u662f ELF \u6587\u4ef6\u4e2d\u7684\u57fa\u672c\u7ec4\u6210\u5355\u4f4d&#xff0c;\u5305\u542b\u4e86\u7279\u5b9a\u7c7b\u578b\u7684\u6570\u636e\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u6700\u5e38\u89c1\u7684\u51e0\u4e2a\u8282&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1856\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002532-6a6d3cfcb9738.png\" width=\"1172\" \/><\/p>\n<p>\u5404\u8282\u8be6\u7ec6\u8bf4\u660e&#xff1a;<\/p>\n<table>\n<tr>\u8282\u540d\u79f0\u5168\u79f0\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>.text<\/td>\n<td>\u4ee3\u7801\u8282<\/td>\n<td>\u4fdd\u5b58\u7a0b\u5e8f\u6307\u4ee4&#xff08;\u673a\u5668\u7801&#xff09;&#xff0c;\u662f\u4e3b\u8981\u6267\u884c\u90e8\u5206<\/td>\n<\/tr>\n<tr>\n<td>.data<\/td>\n<td>\u6570\u636e\u8282<\/td>\n<td>\u4fdd\u5b58\u5df2\u521d\u59cb\u5316\u7684\u5168\u5c40\u53d8\u91cf\u548c\u5c40\u90e8\u9759\u6001\u53d8\u91cf<\/td>\n<\/tr>\n<tr>\n<td>.rodata<\/td>\n<td>\u53ea\u8bfb\u6570\u636e\u8282<\/td>\n<td>\u4fdd\u5b58\u53ea\u8bfb\u6570\u636e&#xff0c;\u5982\u5b57\u7b26\u4e32\u5e38\u91cf\u3002\u53ea\u5728\u53ea\u8bfb\u6bb5&#xff08;text\u6bb5&#xff09;\u4e2d<\/td>\n<\/tr>\n<tr>\n<td>.bss<\/td>\n<td>\u672a\u521d\u59cb\u5316\u6570\u636e\u8282<\/td>\n<td>\u4e3a\u672a\u521d\u59cb\u5316\u7684\u5168\u5c40\u53d8\u91cf\u548c\u5c40\u90e8\u9759\u6001\u53d8\u91cf\u9884\u7559\u7a7a\u95f4&#xff0c;\u52a0\u8f7d\u65f6\u6e05\u96f6<\/td>\n<\/tr>\n<tr>\n<td>.symtab<\/td>\n<td>\u7b26\u53f7\u8868<\/td>\n<td>\u6e90\u7801\u4e2d\u7684\u51fd\u6570\u540d\u3001\u53d8\u91cf\u540d\u4e0e\u5730\u5740\u7684\u5bf9\u5e94\u5173\u7cfb<\/td>\n<\/tr>\n<tr>\n<td>.strtab<\/td>\n<td>\u5b57\u7b26\u4e32\u8868<\/td>\n<td>\u5b58\u653e\u7b26\u53f7\u540d\u79f0\u7684\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n<tr>\n<td>.got \/ .got.plt<\/td>\n<td>\u5168\u5c40\u504f\u79fb\u8868<\/td>\n<td>\u4fdd\u5b58\u5168\u5c40\u504f\u79fb\u8868&#xff0c;\u63d0\u4f9b\u5bf9\u5bfc\u5165\u5171\u4eab\u5e93\u51fd\u6570\u7684\u8bbf\u95ee\u5165\u53e3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u67e5\u770b\u5404\u8282\u5927\u5c0f<\/p>\n<p>size code.o <\/p>\n<h2 id=\"%E5%9B%9B%E3%80%81ELF%20%E7%9A%84%E5%BD%A2%E6%88%90%E2%80%94%E2%80%94%E4%BB%8E%E6%BA%90%E4%BB%A3%E7%A0%81%E5%88%B0%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6\">\u56db\u3001ELF \u7684\u5f62\u6210\u2014\u2014\u4ece\u6e90\u4ee3\u7801\u5230\u53ef\u6267\u884c\u6587\u4ef6<\/h2>\n<h3 id=\"4.1%20%E7%BC%96%E8%AF%91%E4%B8%8E%E9%93%BE%E6%8E%A5%E7%9A%84%E4%B8%A4%E6%AD%A5%E8%B5%B0\">4.1 \u7f16\u8bd1\u4e0e\u94fe\u63a5\u7684\u4e24\u6b65\u8d70<\/h3>\n<ul>\n<li>Step 1&#xff1a;\u5c06\u591a\u4efd C\/C&#043;&#043; \u6e90\u4ee3\u7801&#xff0c;\u7ffb\u8bd1\u6210\u4e3a\u76ee\u6807 .o \u6587\u4ef6 &#043; \u52a8\u9759\u6001\u5e93(ELF)<\/li>\n<li>Step 2&#xff1a;\u5c06\u591a\u4efd .o \u6587\u4ef6\u7684 Section \u8fdb\u884c<span style=\"color:#fe2c24\">\u5408\u5e76\u548c\u91cd\u5b9a\u4f4d<\/span>&#xff0c;\u5f62\u6210\u53ef\u6267\u884c\u6587\u4ef6<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"747\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002533-6a6d3cfd83364.png\" width=\"1145\" \/><\/p>\n<h3 id=\"4.2%20Section%20%E7%9A%84%E5%90%88%E5%B9%B6%E2%80%94%E2%80%94%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81%20Segment%EF%BC%9F\">4.2 Section \u7684\u5408\u5e76\u2014\u2014\u4e3a\u4ec0\u4e48\u9700\u8981 Segment&#xff1f;<\/h3>\n<p>\u5408\u5e76\u539f\u5219&#xff1a;\u76f8\u540c\u5c5e\u6027\u5408\u5e76\u2014\u2014\u53ef\u8bfb\u3001\u53ef\u5199\u3001\u53ef\u6267\u884c\u3001\u9700\u8981\u52a0\u8f7d\u65f6\u7533\u8bf7\u7a7a\u95f4\u7b49\u3002<\/p>\n<h4 id=\"1.%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E5%90%88%E5%B9%B6%EF%BC%9F\">1.\u4e3a\u4ec0\u4e48\u8981\u5408\u5e76&#xff1f;<\/h4>\n<p>\u4e24\u4e2a\u6838\u5fc3\u539f\u56e0&#xff1a;<\/p>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" style=\"width:500px\">\n<tbody>\n<tr>\n<td>\u539f\u56e0<\/td>\n<td>\u8bf4\u660e<\/td>\n<\/tr>\n<tr>\n<td>\u51cf\u5c11\u5185\u5b58\u788e\u7247<\/td>\n<td>\u5047\u8bbe\u9875\u9762\u5927\u5c0f\u4e3a 4096 \u5b57\u8282&#xff08;\u5185\u5b58\u5757\u57fa\u672c\u5927\u5c0f&#xff0c;\u52a0\u8f7d&#xff0c;\u7ba1\u7406\u7684\u57fa\u672c\u5355\u4f4d&#xff09;&#xff0c;.text \u4e3a 4097 \u5b57\u8282&#xff0c;.init \u4e3a 512 \u5b57\u8282\u3002\u4e0d\u5408\u5e76\u4f1a\u7528 3 \u4e2a\u9875\u9762&#xff0c;\u5408\u5e76\u540e\u53ea\u7528 2 \u4e2a<\/td>\n<\/tr>\n<tr>\n<td>\u7edf\u4e00\u6743\u9650\u63a7\u5236<\/td>\n<td>\u5c06\u6240\u6709\u53ea\u8bfb\u53ef\u6267\u884c\u7684 Section \u653e\u5728\u4e00\u8d77\u7edf\u4e00\u8bbe\u7f6e\u4e3a RE&#xff0c;\u6240\u6709\u53ef\u8bfb\u5199\u7684\u653e\u5728\u4e00\u8d77\u8bbe\u7f6e\u4e3a RW&#xff0c;\u4f18\u5316\u5185\u5b58\u7ba1\u7406\u548c\u6743\u9650\u63a7\u5236<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"color:#ff9900\">\u5408\u5e76\u89c4\u5219\u5728 ELF \u7f16\u7ece\u65f6\u5c31\u5df2\u7ecf\u786e\u5b9a<\/span>&#xff0c;\u88ab\u8bb0\u5f55\u5728<span style=\"color:#fe2c24\">\u7a0b\u5e8f\u5934\u8868<\/span>&#xff08;Program Header Table&#xff09;\u7684 Section to Segment mapping \u4e2d&#xff1a;<\/p>\n<p>Section to Segment mapping:<br \/>\n  Segment Sections&#8230;<br \/>\n   02   .interp .note.ABI-tag .gnu.hash .dynsym .dynstr .init .plt .text .fini .rodata &#8230;  # \u7b2c02\u53f7\u6bb5&#xff0c;\u96c6\u5408\u5404\u7c7b\u53ea\u8bfb\u3001\u53ef\u8bfb\u53ef\u6267\u884c\u8282&#xff0c;\u5185\u5b58\u6743\u9650R\/RE<br \/>\n   03   .init_array .fini_array .dynamic .got .got.plt .data .bss                            # \u7b2c03\u53f7\u6bb5&#xff0c;\u96c6\u5408\u5404\u7c7b\u8fd0\u884c\u65f6\u9700\u8981\u8bfb\u5199\u7684\u8282&#xff0c;\u5185\u5b58\u6743\u9650RW <\/p>\n<h2 id=\"%E4%BA%94%E3%80%81ELF%20%E7%9A%84%E4%B8%A4%E4%B8%AA%E8%A7%86%E5%9B%BE%E2%80%94%E2%80%94%E9%93%BE%E6%8E%A5%E5%99%A8%E7%9C%8B%20vs%20%E5%8A%A0%E8%BD%BD%E5%99%A8%E7%9C%8B\">\u4e94\u3001ELF \u7684\u4e24\u4e2a\u89c6\u56fe\u2014\u2014\u94fe\u63a5\u5668\u770b vs \u52a0\u8f7d\u5668\u770b<\/h2>\n<p>ELF \u63d0\u4f9b 2 \u4e2a\u4e0d\u540c\u7684\u89c6\u89d2\u6765\u89c2\u5bdf\u81ea\u5df1&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1093\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002533-6a6d3cfde8250.png\" width=\"1086\" \/><\/p>\n<table>\n<tr>\u89c6\u56fe\u5bf9\u5e94\u8868\u4f7f\u7528\u573a\u666f\u7c92\u5ea6\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>\u94fe\u63a5\u89c6\u56fe<\/td>\n<td>\u8282\u5934\u8868<\/td>\n<td>\u7f16\u8bd1\/\u94fe\u63a5\u65f6<\/td>\n<td>\u7ec6&#xff08;Section&#xff09;<\/td>\n<td>\u6309\u529f\u80fd\u6a21\u5757\u5212\u5206&#xff0c;\u94fe\u63a5\u5668\u5206\u6790\u7b26\u53f7\u4f9d\u8d56<\/td>\n<\/tr>\n<tr>\n<td>\u6267\u884c\u89c6\u56fe<\/td>\n<td>\u7a0b\u5e8f\u5934\u8868<\/td>\n<td>\u52a0\u8f7d\/\u8fd0\u884c\u65f6<\/td>\n<td>\u7c97&#xff08;Segment&#xff09;<\/td>\n<td>\u544a\u8bc9 OS \u5982\u4f55\u52a0\u8f7d\u3001\u8bbe\u7f6e\u6743\u9650<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e00\u53e5\u8bdd\u603b\u7ed3&#xff1a;\u4e00\u4e2a\u5728\u94fe\u63a5\u65f6\u7528&#xff0c;\u4e00\u4e2a\u5728\u8fd0\u884c\u65f6\u7528\u3002<\/p>\n<h3 id=\"1.%E4%BB%8E%E9%93%BE%E6%8E%A5%E8%A7%86%E5%9B%BE%E7%9C%8B\">1.\u4ece\u94fe\u63a5\u89c6\u56fe\u770b<\/h3>\n<p>$ readelf -S hello.o    # \u67e5\u770b\u76ee\u6807\u6587\u4ef6\u7684\u8282\u5934\u8868 <\/p>\n<p><span style=\"color:#fe2c24\">\u94fe\u63a5\u5668<\/span>\u5173\u6ce8\u7684\u662f\u4e00\u4e2a\u4e2a\u7684<span style=\"color:#fe2c24\"> Section<\/span>&#xff1a;<\/p>\n<ul>\n<li>\u5c06\u540c\u540d Section \u5408\u5e76&#xff08;\u5982\u591a\u4e2a .o \u7684 .text \u5408\u5e76\u6210\u4e00\u4e2a\u5927\u7684 .text&#xff09;<\/li>\n<li>\u89e3\u6790\u7b26\u53f7\u8868&#xff0c;\u5b9a\u4f4d\u5916\u90e8\u7b26\u53f7<\/li>\n<li>\u6839\u636e\u91cd\u5b9a\u4f4d\u8868\u4fee\u6b63\u5730\u5740<\/li>\n<\/ul>\n<h3 id=\"2.%E4%BB%8E%E6%89%A7%E8%A1%8C%E8%A7%86%E5%9B%BE%E7%9C%8B\">2.\u4ece\u6267\u884c\u89c6\u56fe\u770b<\/h3>\n<p>$ readelf -l a.out       # \u67e5\u770b\u53ef\u6267\u884c\u6587\u4ef6\u7684\u7a0b\u5e8f\u5934\u8868 <\/p>\n<p><span style=\"color:#fe2c24\">\u64cd\u4f5c\u7cfb\u7edf<\/span>\u5173\u6ce8\u7684\u662f\u4e00\u4e2a\u4e2a\u7684<span style=\"color:#fe2c24\"> Segment<\/span>&#xff1a;<\/p>\n<ul>\n<li>\u54ea\u4e9b\u6a21\u5757\u9700\u8981\u52a0\u8f7d\u8fdb\u5185\u5b58&#xff08;LOAD \u7c7b\u578b\u7684 Segment&#xff09;<\/li>\n<li>\u52a0\u8f7d\u8fdb\u5185\u5b58\u540e&#xff0c;\u54ea\u4e9b\u6bb5\u53ef\u8bfb\u53ef\u5199&#xff0c;\u54ea\u4e9b\u53ea\u8bfb&#xff0c;\u54ea\u4e9b\u53ef\u6267\u884c<\/li>\n<li>\u5165\u53e3\u70b9\u5730\u5740\u5728\u54ea<\/li>\n<\/ul>\n<h3 id=\"3.%E4%B8%89%E6%9D%A1%E5%91%BD%E4%BB%A4%E7%BB%88%E6%9E%81%E6%B1%87%E6%80%BB\">3.\u4e09\u6761\u547d\u4ee4\u7ec8\u6781\u6c47\u603b<\/h3>\n<p>readelf -h \u6587\u4ef6\u540d  # -h&#xff1a;\u67e5\u770bELF\u5934\u90e8&#xff08;\u6587\u4ef6\u57fa\u7840\u5143\u4fe1\u606f&#xff09;<br \/>\nreadelf -S \u6587\u4ef6\u540d  # \u5927\u5199S&#xff1a;\u67e5\u770b\u8282\u5934\u8868 Section&#xff08;\u94fe\u63a5\u5668\u89c6\u89d2&#xff09;<br \/>\nreadelf -l \u6587\u4ef6\u540d  # \u5c0f\u5199L&#xff1a;\u67e5\u770b\u7a0b\u5e8f\u5934\u8868 Segment&#xff08;\u64cd\u4f5c\u7cfb\u7edf\u52a0\u8f7d\u89c6\u89d2&#xff09; <\/p>\n<h2 id=\"%E5%85%AD%E3%80%81%E9%80%8F%E5%BD%BB%E7%90%86%E8%A7%A3%E9%93%BE%E6%8E%A5%E2%80%94%E2%80%94%E9%9D%99%E6%80%81%E9%93%BE%E6%8E%A5%E7%9A%84%E5%85%A8%E8%BF%87%E7%A8%8B\">\u516d\u3001\u900f\u5f7b\u7406\u89e3\u94fe\u63a5\u2014\u2014\u9759\u6001\u94fe\u63a5\u7684\u5168\u8fc7\u7a0b<\/h2>\n<h3 id=\"6.1%20%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%E4%B9%8B%E9%97%B4%22%E4%BA%92%E4%B8%8D%E7%9B%B8%E8%AF%86%22\">6.1 \u76ee\u6807\u6587\u4ef6\u4e4b\u95f4&#034;\u4e92\u4e0d\u76f8\u8bc6&#034;<\/h3>\n<p>\u4ee5\u4e4b\u524d\u7684 hello.c \u548c code.c \u4e3a\u4f8b\u3002\u7f16\u8bd1\u540e\u7684\u4e24\u4e2a .o \u6587\u4ef6\u5404\u81ea\u72ec\u7acb&#xff0c;<span style=\"color:#fe2c24\">\u5f7c\u6b64\u4e0d\u77e5\u9053\u5bf9\u65b9\u7684\u5b58\u5728&#xff1a;<\/span><\/p>\n<p>\u5bf9\u76ee\u6807\u6587\u4ef6 hello.o \u8fdb\u884c\u53cd\u6c47\u7f16&#xff1a;<\/p>\n<p>objdump -d hello.o <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"375\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002534-6a6d3cfe72246.png\" width=\"663\" \/><\/p>\n<p>\u53ef\u4ee5\u770b\u5230&#xff0c;\u8fd9\u91cc\u7684 call \u6307\u4ee4\u5bf9\u5e94\u7684 printf \u548c run \u51fd\u6570&#xff0c;\u8df3\u8f6c\u5730\u5740\u90fd\u88ab\u8bbe\u4e3a\u4e86 0x00000000\u3002\u56e0\u4e3a\u7f16\u8bd1\u5668\u5728\u7f16\u8bd1 hello.c \u65f6&#xff0c;\u5b8c\u5168\u4e0d\u77e5\u9053 printf \u548c run \u51fd\u6570\u4f4d\u4e8e\u5185\u5b58\u7684\u54ea\u4e2a\u4f4d\u7f6e&#xff0c;\u751a\u81f3\u6839\u672c\u4e0d\u77e5\u9053\u5b83\u4eec\u7684\u4ee3\u7801\u957f\u4ec0\u4e48\u6837\u3002<\/p>\n<h3 id=\"6.2%20%E7%AC%A6%E5%8F%B7%E8%A1%A8%E2%80%94%E2%80%94%E6%A0%87%E8%AE%B0%22%E6%9C%AA%E5%AE%9A%E4%B9%89%22%E7%9A%84%E7%AC%A6%E5%8F%B7\">6.2 \u7b26\u53f7\u8868\u2014\u2014\u6807\u8bb0&#034;\u672a\u5b9a\u4e49&#034;\u7684\u7b26\u53f7<\/h3>\n<p>readelf -s hello.o <\/p>\n<p><span style=\"color:#fe2c24\">\u6ce8\u610f&#xff1a;S\u548cs\u5bf9\u5e94\u7684\u4e0d\u540c\u7684\u547d\u4ee4<\/span><\/p>\n<p>readelf -s hello.o   # \u5c0f\u5199s&#xff1a;&#8211;symbols&#xff0c;\u3010\u67e5\u770b\u7b26\u53f7\u8868\u3011&#xff08;\u7b26\u53f7\u540d\u3001\u5168\u5c40\/\u5c40\u90e8\u3001\u51fd\u6570\/\u53d8\u91cf&#xff09;<br \/>\nreadelf -S hello.o   # \u5927\u5199S&#xff1a;&#8211;section-headers&#xff0c;\u3010\u67e5\u770b\u6bb5\u5934\u8868&#xff08;\u8282\u8868&#xff09;\u3011.text\/.data\/.bss\/.rodata\u8fd9\u4e9bsection<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"362\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002534-6a6d3cfe818e6.png\" width=\"752\" \/><\/p>\n<p>\u518d\u770b code.o\u6587\u4ef6&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"362\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002534-6a6d3cfe92981.png\" width=\"752\" \/><\/p>\n<p>UND&#xff08;undefine&#xff09; \u8868\u793a\u672c .o \u6587\u4ef6\u627e\u4e0d\u5230\u8fd9\u4e2a\u7b26\u53f7\u3002hello.o \u7684 run \u662f UND&#xff0c;code.o \u7684 run \u662f\u5df2\u5b9a\u4e49\u7684\u2014\u2014\u94fe\u63a5\u5668\u5728\u94fe\u63a5\u65f6\u4f1a\u5c06\u5b83\u4eec\u5339\u914d\u8d77\u6765\u3002<\/p>\n<h3 id=\"6.3%20%E9%93%BE%E6%8E%A5%E6%97%B6%E7%9A%84%E9%87%8D%E5%AE%9A%E4%BD%8D\">6.3 \u94fe\u63a5\u65f6\u7684\u91cd\u5b9a\u4f4d<\/h3>\n<p>\u00a0\u518d\u770b\u770b\u4e24\u8005\u94fe\u63a5\u5f62\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6&#xff1a;&#xff08;\u8fd9\u91cc\u592a\u957f&#xff0c;\u53ea\u5c55\u793a\u90e8\u5206&#xff09;<\/p>\n<p>readelf -s a.out <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"363\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002534-6a6d3cfea3622.png\" width=\"981\" \/><\/p>\n<p><span style=\"color:#fe2c24\">run \u51fd\u6570\u6240\u5728\u7684 section \u88ab\u5408\u5e76\u6700\u7ec8\u7684\u90a3\u4e00\u4e2a section \u4e2d\u4e86&#xff0c;13\u5c31\u662f\u4e0b\u6807&#xff08;\u548cmain\u51fd\u6570\u5728\u4e00\u8d77&#xff09;<\/span><\/p>\n<p>\u770b\u4e00\u4e0ba.out\u7684\u53cd\u6c47\u7f16\u4ee3\u7801&#xff08;\u5df2\u7ecf\u6709\u4e86\u5730\u5740&#xff09;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"135\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002534-6a6d3cfec0223.png\" width=\"672\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"33\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002534-6a6d3cfec974f.png\" width=\"735\" \/><\/p>\n<table>\n<tr>\u5bf9\u6bd4\u94fe\u63a5\u524d&#xff08;hello.o&#xff09;\u94fe\u63a5\u540e&#xff08;a.out&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>run \u7684\u5730\u5740<\/td>\n<td>00 00 00 00<\/td>\n<td>0x401145<\/td>\n<\/tr>\n<tr>\n<td>printf \u7684\u5730\u5740<\/td>\n<td>00 00 00 00<\/td>\n<td>0x401130&#xff08;puts&#064;plt&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>Section \u7f16\u53f7<\/td>\n<td>\u5404\u81ea\u7684 .text&#xff08;Nr 1&#xff09;<\/td>\n<td>\u5408\u5e76\u540e\u7684 .text&#xff08;Nr 13&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"6.4%20%E9%9D%99%E6%80%81%E9%93%BE%E6%8E%A5%E7%9A%84%E6%9C%AC%E8%B4%A8\">6.4 \u9759\u6001\u94fe\u63a5\u7684\u672c\u8d28<\/h3>\n<p>\u9759\u6001\u94fe\u63a5 &#061; \u5408\u5e76\u6240\u6709 .o \u7684 Section &#043; \u5730\u5740\u4fee\u6b63 <\/p>\n<p>\u65e0\u8bba\u662f\u4f60\u81ea\u5df1\u7684 .o&#xff0c;\u8fd8\u662f\u9759\u6001\u5e93\u4e2d\u7684 .o&#xff0c;\u672c\u8d28\u4e0a\u90fd\u662f\u628a .o \u6587\u4ef6\u8fdb\u884c\u8fde\u63a5\u3002\u94fe\u63a5\u5668\u4f1a\u6839\u636e\u91cd\u5b9a\u4f4d\u8868\u627e\u5230\u90a3\u4e9b\u9700\u8981\u88ab\u91cd\u5b9a\u4f4d\u7684\u51fd\u6570\u548c\u5168\u5c40\u53d8\u91cf&#xff0c;<span style=\"color:#fe2c24\">\u4fee\u6b63\u5b83\u4eec\u7684\u5730\u5740<\/span>\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"981\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002534-6a6d3cfed0c93.png\" width=\"1086\" \/><\/p>\n<h2 id=\"%E4%B8%83%E3%80%81%E8%99%9A%E6%8B%9F%E5%9C%B0%E5%9D%80%E7%A9%BA%E9%97%B4%E2%80%94%E2%80%94%E9%93%BE%E6%8E%A5%E6%97%B6%E5%B0%B1%E5%B7%B2%E7%BC%96%E5%A5%BD%E5%9D%80\">\u4e03\u3001\u865a\u62df\u5730\u5740\u7a7a\u95f4\u2014\u2014\u94fe\u63a5\u65f6\u5c31\u5df2\u7f16\u597d\u5740<\/h2>\n<h3 id=\"7.1%20%E4%B8%80%E4%B8%AA%E5%8F%8D%E7%9B%B4%E8%A7%89%E7%9A%84%E4%BA%8B%E5%AE%9E\">7.1 \u4e00\u4e2a\u53cd\u76f4\u89c9\u7684\u4e8b\u5b9e<\/h3>\n<p><span style=\"color:#fe2c24\">\u4e00\u4e2a ELF \u7a0b\u5e8f&#xff0c;\u5728\u6ca1\u6709\u88ab\u52a0\u8f7d\u5230\u5185\u5b58\u7684\u65f6\u5019&#xff0c;\u5c31\u5df2\u7ecf\u6709\u5730\u5740\u4e86&#xff01;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"382\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002535-6a6d3cff4cd0c.png\" width=\"720\" \/><\/p>\n<p>$ readelf -h a.out<br \/>\n  Entry point address:               0x1060 <\/p>\n<p>\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5165\u53e3\u5730\u5740\u5728\u7f16\u8bd1\u94fe\u63a5\u65f6\u5c31\u5df2\u786e\u5b9a&#xff0c;\u8fd9\u4e0d\u662f\u7269\u7406\u5185\u5b58\u5730\u5740&#xff0c;\u800c\u662f\u865a\u62df\u5730\u5740\u3002<\/p>\n<p>\u5f53\u4ee3\u8ba1\u7b97\u673a\u90fd\u91c7\u7528 \u5e73\u5766\u6a21\u5f0f \u5de5\u4f5c&#xff0c;\u6240\u4ee5 ELF \u5bf9\u81ea\u5df1\u7684\u4ee3\u7801\u548c\u6570\u636e\u8fdb\u884c\u4e86\u7edf\u4e00\u7f16\u5740\u3002\u53cd\u6c47\u7f16\u51fa\u6765\u7684\u6700\u5de6\u4fa7\u4e00\u5217\u5c31\u662f <span style=\"color:#ff9900\">ELF \u7684\u865a\u62df\u5730\u5740&#xff08;\u903b\u8f91\u5730\u5740&#061;\u8d77\u59cb\u5730\u5740&#043;\u504f\u79fb\u91cf&#xff09;<\/span>\u3002<\/p>\n<h3 id=\"7.2%20%E8%BF%9B%E7%A8%8B%E5%9C%B0%E5%9D%80%E7%A9%BA%E9%97%B4%E7%9A%84%E6%95%B0%E6%8D%AE%E4%BB%8E%E5%93%AA%E9%87%8C%E6%9D%A5%EF%BC%9F\">7.2 \u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4\u7684\u6570\u636e\u4ece\u54ea\u91cc\u6765&#xff1f;<\/h3>\n<p>\u7b54\u6848&#xff1a;\u4ece ELF \u7684\u5404\u4e2a Segment \u6765\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"840\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002535-6a6d3cff5d21a.png\" width=\"1145\" \/><\/p>\n<p>\u6bcf\u4e2a Segment \u6709\u81ea\u5df1\u7684<span style=\"color:#ff9900\">\u8d77\u59cb\u5730\u5740\u548c\u957f\u5ea6<\/span>&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u7528\u5b83\u6765\u521d\u59cb\u5316\u5185\u6838\u7ed3\u6784\u4e2d\u7684 [start, end] \u8303\u56f4\u6570\u636e&#xff0c;\u53e6\u5916\u8fd8\u7528\u66f4\u8be6\u7ec6\u7684\u5730\u5740\u586b\u5145\u9875\u8868\u3002<\/p>\n<p>\u7ed3\u8bba&#xff1a;\u865a\u62df\u5730\u5740\u673a\u5236&#xff0c;\u4e0d\u5149 OS \u8981\u652f\u6301&#xff0c;\u7f16\u8bd1\u5668\u4e5f\u8981\u652f\u6301\u3002<\/p>\n<h2 id=\"%E5%85%AB%E3%80%81%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E2%80%94%E2%80%94%E8%BF%90%E8%A1%8C%E6%97%B6%E6%89%8D%E8%A7%81%E7%9C%9F%E7%AB%A0\">\u516b\u3001\u52a8\u6001\u94fe\u63a5\u2014\u2014\u8fd0\u884c\u65f6\u624d\u89c1\u771f\u7ae0<\/h2>\n<h3 id=\"8.1%20%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%EF%BC%9F\">8.1 \u4e3a\u4ec0\u4e48\u9700\u8981\u52a8\u6001\u94fe\u63a5&#xff1f;<\/h3>\n<p>\u9759\u6001\u94fe\u63a5\u4f1a\u4ea7\u751f\u5de8\u5927\u7684\u53ef\u6267\u884c\u6587\u4ef6&#xff0c;\u5e76\u4e14\u591a\u4e2a\u7a0b\u5e8f\u5982\u679c\u90fd\u5305\u542b\u76f8\u540c\u7684\u5e93\u4ee3\u7801&#xff08;\u5982 printf&#xff09;&#xff0c;\u5185\u5b58\u4e2d\u4f1a\u6709\u5927\u91cf\u526f\u672c&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1384\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002535-6a6d3cffb6517.png\" width=\"1390\" \/><\/p>\n<p>\u52a8\u6001\u94fe\u63a5\u5c06\u7b26\u53f7\u89e3\u6790\u548c\u5730\u5740\u91cd\u5b9a\u4f4d\u4ece\u7f16\u8bd1\u65f6\u63a8\u8fdf\u5230\u7a0b\u5e8f\u52a0\u8f7d\u8fd0\u884c\u7684\u65f6\u5019&#xff0c;\u8fd9\u662f\u6027\u4ef7\u6bd4\u6781\u9ad8\u7684\u53d6\u820d<\/p>\n<h3 id=\"8.2%20%E7%A8%8B%E5%BA%8F%E5%90%AF%E5%8A%A8%E7%9A%84%E5%AE%8C%E6%95%B4%E6%B5%81%E7%A8%8B\">8.2 \u7a0b\u5e8f\u542f\u52a8\u7684\u5b8c\u6574\u6d41\u7a0b<\/h3>\n<p>\u4f60\u4ee5\u4e3a\u662f main() \u5f00\u59cb\u4e00\u5207&#xff1f;\u5b9e\u9645\u4e0a\u5728 main \u4e4b\u524d\u6709\u4e00\u6bb5&#034;\u9690\u85cf\u5267\u60c5&#034;&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"2500\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002536-6a6d3d00439bc.png\" width=\"628\" \/><\/p>\n<table>\n<tr>\u9636\u6bb5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>_start<\/td>\n<td>C \u8fd0\u884c\u65f6\u5e93&#xff08;glibc&#xff09;\u6216\u94fe\u63a5\u5668\u63d0\u4f9b\u7684\u7279\u6b8a\u51fd\u6570&#xff0c;\u7a0b\u5e8f\u7684\u771f\u6b63\u5165\u53e3<\/td>\n<\/tr>\n<tr>\n<td>\u52a8\u6001\u94fe\u63a5\u5668<\/td>\n<td>ld-linux.so&#xff0c;\u89e3\u6790\u7a0b\u5e8f\u4f9d\u8d56\u7684\u6240\u6709\u52a8\u6001\u5e93\u5e76\u52a0\u8f7d\u5230\u5185\u5b58<\/td>\n<\/tr>\n<tr>\n<td>__libc_start_main<\/td>\n<td>glibc \u63d0\u4f9b\u7684\u51fd\u6570&#xff0c;\u5b8c\u6210\u989d\u5916\u521d\u59cb\u5316\u540e\u8c03\u7528 main<\/td>\n<\/tr>\n<tr>\n<td>main<\/td>\n<td>\u7a0b\u5e8f\u5458\u7f16\u5199\u7684\u5165\u53e3\u51fd\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"8.3%20%E5%8A%A8%E6%80%81%E5%BA%93%E7%9A%84PIC%E5%8E%9F%E7%90%86\">8.3 \u52a8\u6001\u5e93\u7684PIC\u539f\u7406<\/h3>\n<p>\u52a8\u6001\u5e93\u4e3a\u4e86\u80fd\u52a0\u8f7d\u5230\u4efb\u610f\u8fdb\u7a0b\u7684\u4efb\u610f\u5730\u5740&#xff0c;\u5fc5\u987b\u91c7\u7528\u76f8\u5bf9\u5730\u5740\u7f16\u5740\u2014\u2014PIC&#xff08;Position Independent Code&#xff0c;\u4f4d\u7f6e\u65e0\u5173\u7801&#xff09;\u6240\u6709\u5730\u5740\u90fd\u662f\u76f8\u5bf9\u4e8e\u5f53\u524d\u6307\u4ee4\u6307\u9488\u7684\u504f\u79fb\u91cf\u3002\u8fd9\u4e5f\u5c31\u662f\u4e3a\u4ec0\u4e48<span style=\"color:#ff9900\">\u7f16\u8bd1\u52a8\u6001\u5e93\u65f6\u5fc5\u987b\u6307\u5b9a -fPIC&#xff1a;<\/span><\/p>\n<p>libmystdio.so: my_stdio.o my_string.o<br \/>\n    gcc -o $&#064; $^ -shared<br \/>\n%.o:%.c<br \/>\n    gcc -fPIC -c $&lt; <\/p>\n<h3 id=\"8.4%20GOT%EF%BC%88%E5%85%A8%E5%B1%80%E5%81%8F%E7%A7%BB%E8%A1%A8%EF%BC%89%E2%80%94%E2%80%94%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E7%9A%84%E5%9F%BA%E7%9F%B3\">8.4 GOT&#xff08;\u5168\u5c40\u504f\u79fb\u8868&#xff09;\u2014\u2014\u52a8\u6001\u94fe\u63a5\u7684\u57fa\u77f3<\/h3>\n<p>\u52a8\u6001\u94fe\u63a5\u9762\u4e34\u4e00\u4e2a\u6838\u5fc3\u77db\u76fe&#xff1a;\u4ee3\u7801\u6bb5\u662f\u53ea\u8bfb\u7684\u4e0d\u80fd\u6539&#xff0c;\u4f46\u51fd\u6570\u5730\u5740\u53c8\u9700\u8981\u5728\u52a0\u8f7d\u65f6\u4fee\u6b63\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\u5c31\u662f\u5728 .data \u6bb5&#xff08;\u53ef\u8bfb\u5199&#xff09;\u4e2d\u9884\u7559\u4e00\u5757\u533a\u57df\u6765\u5b58\u653e\u51fd\u6570\u7684\u8df3\u8f6c\u5730\u5740\u2014\u2014\u8fd9\u5c31\u662f GOT&#xff08;Global Offset Table&#xff0c;\u5168\u5c40\u504f\u79fb\u8868&#xff09;<\/p>\n<p>$ readelf -S a.out<br \/>\n  [24] .got    PROGBITS  0000000000003fb8  00002fb8<br \/>\n       0000000000000048  0000000000000008  WA  0  0  8   # WA &#061; \u53ef\u5199&#043;\u53ef\u5206\u914d <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1392\" src=\"2026-08-01nstvfi2w2wn.png\" width=\"701\" \/><\/p>\n<\/p>\n<p>GOT \u7684\u56db\u5927\u8981\u70b9&#xff1a;<\/p>\n<table>\n<tr>\u8981\u70b9\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>\u7531\u4e8e\u4ee3\u7801\u6bb5\u53ea\u8bfb&#xff0c;\u4e0d\u80fd\u76f4\u63a5\u4fee\u6539\u3002GOT \u5728\u53ef\u8bfb\u5199\u6bb5&#xff0c;\u53ef\u5728\u8fd0\u884c\u65f6\u66f4\u65b0<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>\u5728\u5355\u4e2a .so \u4e0b&#xff0c;GOT \u4e0e .text \u7684\u76f8\u5bf9\u4f4d\u7f6e\u56fa\u5b9a&#xff0c;CPU \u53ef\u901a\u8fc7\u76f8\u5bf9\u5bfb\u5740\u627e\u5230 GOT<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>\u8c03\u7528\u51fd\u6570\u65f6\u5148\u67e5 GOT \u8868&#xff0c;\u6839\u636e\u8868\u4e2d\u5730\u5740\u8df3\u8f6c&#xff0c;\u5730\u5740\u5728\u52a0\u8f7d\u65f6\u88ab\u4fee\u6539<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>\u8fd9\u79cd\u673a\u5236\u5c31\u662f PIC&#xff08;\u4f4d\u7f6e\u65e0\u5173\u7801&#xff09;&#061; \u76f8\u5bf9\u7f16\u5740 &#043; GOT<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"8.5%20PLT%EF%BC%88%E8%BF%87%E7%A8%8B%E9%93%BE%E6%8E%A5%E8%A1%A8%EF%BC%89%E2%80%94%E2%80%94%E5%BB%B6%E8%BF%9F%E7%BB%91%E5%AE%9A\">8.5 PLT&#xff08;\u8fc7\u7a0b\u94fe\u63a5\u8868&#xff09;\u2014\u2014\u5ef6\u8fdf\u7ed1\u5b9a<\/h3>\n<p>\u5982\u679c\u7a0b\u5e8f\u542f\u52a8\u65f6\u5bf9\u6240\u6709\u5e93\u51fd\u6570\u90fd\u8fdb\u884c\u91cd\u5b9a\u4f4d&#xff0c;\u542f\u52a8\u901f\u5ea6\u4f1a\u975e\u5e38\u6162\u3002\u56e0\u6b64\u5f15\u5165\u4e86 PLT&#xff08;Procedure Linkage Table&#xff09;\u2014\u2014\u5ef6\u8fdf\u7ed1\u5b9a&#xff1a;<\/p>\n<p>\u4e0e\u5176\u4e00\u5f00\u59cb\u5c31\u5bf9\u6240\u6709\u51fd\u6570\u91cd\u5b9a\u4f4d&#xff0c;\u4e0d\u5982\u5c06\u8fd9\u4e2a\u8fc7\u7a0b\u63a8\u8fdf\u5230\u51fd\u6570\u7b2c\u4e00\u6b21\u88ab\u8c03\u7528\u7684\u65f6\u5019\u3002<span style=\"color:#a2e043\">\u56e0\u4e3a\u7edd\u5927\u591a\u6570\u52a8\u6001\u5e93\u4e2d\u7684\u51fd\u6570\u53ef\u80fd\u5728\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u4e00\u6b21\u90fd\u4e0d\u4f1a\u88ab\u7528\u5230<\/span>&#xff01;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1892\" src=\"2026-08-01rsthgfv5c03.png\" width=\"2382\" \/><\/p>\n<h2 id=\"%E4%B9%9D%E3%80%81%E6%80%BB%E7%BB%93%E5%AF%B9%E6%AF%94%E2%80%94%E2%80%94%E9%9D%99%E6%80%81%E9%93%BE%E6%8E%A5%20vs%20%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5\">\u4e5d\u3001\u603b\u7ed3\u5bf9\u6bd4\u2014\u2014\u9759\u6001\u94fe\u63a5 vs \u52a8\u6001\u94fe\u63a5<\/h2>\n<table>\n<tr>\u7ef4\u5ea6\u9759\u6001\u94fe\u63a5\u52a8\u6001\u94fe\u63a5<\/tr>\n<tbody>\n<tr>\n<td>\u94fe\u63a5\u65f6\u673a<\/td>\n<td>\u7f16\u8bd1\u65f6\u94fe\u63a5<\/td>\n<td>\u52a0\u8f7d\u8fd0\u884c\u65f6\u94fe\u63a5<\/td>\n<\/tr>\n<tr>\n<td>\u53ef\u6267\u884c\u6587\u4ef6\u5927\u5c0f<\/td>\n<td>\u5927&#xff08;\u5305\u542b\u6240\u6709\u5e93\u4ee3\u7801&#xff09;<\/td>\n<td>\u5c0f&#xff08;\u53ea\u5305\u542b\u5f15\u7528\u4fe1\u606f&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u78c1\u76d8\u7a7a\u95f4\u5360\u7528<\/td>\n<td>\u6bcf\u4e2a\u7a0b\u5e8f\u72ec\u7acb\u5305\u542b\u5e93\u4ee3\u7801 \u2192 \u6d6a\u8d39<\/td>\n<td>\u591a\u4e2a\u7a0b\u5e8f\u5171\u4eab\u5e93\u6587\u4ef6 \u2192 \u8282\u7701<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u5360\u7528<\/td>\n<td>\u6bcf\u4e2a\u7a0b\u5e8f\u72ec\u4eab\u4e00\u4efd\u5e93\u4ee3\u7801<\/td>\n<td>\u7269\u7406\u5185\u5b58\u4e2d\u4e00\u4efd\u5e93&#xff0c;\u88ab\u6240\u6709\u8fdb\u7a0b\u5171\u4eab<\/td>\n<\/tr>\n<tr>\n<td>\u8fd0\u884c\u65f6\u4f9d\u8d56<\/td>\n<td>\u65e0\u4f9d\u8d56&#xff0c;\u72ec\u7acb\u8fd0\u884c<\/td>\n<td>\u9700\u8981\u7cfb\u7edf\u4e2d\u5b58\u5728\u5bf9\u5e94\u7684 .so \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>\u66f4\u65b0\u7ef4\u62a4<\/td>\n<td>\u66ff\u6362\u5e93\u540e\u9700\u91cd\u65b0\u94fe\u63a5\u6574\u4e2a\u7a0b\u5e8f<\/td>\n<td>\u66ff\u6362 .so \u6587\u4ef6\u5373\u53ef&#xff0c;\u65e0\u9700\u91cd\u65b0\u7f16\u8bd1<\/td>\n<\/tr>\n<tr>\n<td>\u5730\u5740\u4fee\u6b63\u65b9\u5f0f<\/td>\n<td>\u7f16\u8bd1\u91cd\u5b9a\u4f4d&#xff08;\u9759\u6001\u91cd\u5b9a\u4f4d&#xff09;<\/td>\n<td>\u52a0\u8f7d\u91cd\u5b9a\u4f4d&#xff08;\u52a8\u6001\u91cd\u5b9a\u4f4d&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u6027\u80fd<\/td>\n<td>\u65e0\u989d\u5916\u52a0\u8f7d\u5f00\u9500<\/td>\n<td>\u9700\u542f\u52a8\u52a8\u6001\u94fe\u63a5\u5668&#xff0c;\u6709\u989d\u5916\u5f00\u9500<\/td>\n<\/tr>\n<tr>\n<td>\u6838\u5fc3\u673a\u5236<\/td>\n<td>\u91cd\u5b9a\u4f4d\u8868 &#043; Section \u5408\u5e76<\/td>\n<td>GOT &#043; PLT &#043; \u76f8\u5bf9\u7f16\u5740&#xff08;PIC&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"%E5%AE%83%E4%BB%AC%E5%85%B1%E5%90%8C%E7%9A%84%E6%A0%B9%E2%80%94%E2%80%94ELF\">\u5b83\u4eec\u5171\u540c\u7684\u6839\u2014\u2014ELF<\/h3>\n<p>\u56de\u987e\u5168\u6587&#xff0c;\u4f60\u4f1a\u53d1\u73b0&#xff1a;<\/p>\n<p><span style=\"color:#fe2c24\">\u65e0\u8bba\u662f .o \u76ee\u6807\u6587\u4ef6\u3001.a \u9759\u6001\u5e93\u3001.so \u52a8\u6001\u5e93&#xff0c;\u8fd8\u662f a.out \u53ef\u6267\u884c\u6587\u4ef6\u2014\u2014\u5b83\u4eec\u5168\u90e8\u90fd\u662f ELF \u6587\u4ef6&#xff01;<\/span><\/p>\n<p>\u53ea\u4e0d\u8fc7\u540c\u4e00\u4efd ELF \u683c\u5f0f&#xff0c;\u901a\u8fc7**\u94fe\u63a5\u89c6\u56fe&#xff08;\u8282\u5934\u8868&#xff09;\u670d\u52a1\u4e8e\u7f16\u8bd1\u5668\u548c\u94fe\u63a5\u5668&#xff0c;\u901a\u8fc7\u6267\u884c\u89c6\u56fe&#xff08;\u7a0b\u5e8f\u5934\u8868&#xff09;**\u670d\u52a1\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u7684\u52a0\u8f7d\u5668&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"788\" src=\"2026-08-01qs2sj1bno3f.png\" width=\"1527\" \/><\/p>\n<p>\u638c\u63e1\u4e86 ELF&#xff0c;\u5c31\u638c\u63e1\u4e86 Linux \u4e0b\u7a0b\u5e8f\u4ece\u6e90\u4ee3\u7801 \u2192 \u7f16\u8bd1 \u2192 \u94fe\u63a5 \u2192 \u52a0\u8f7d \u2192 \u8fd0\u884c\u7684\u5b8c\u6574\u94fe\u8def\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u4e00\u671f\u4ecb\u7ecd\u4e86\u52a8\u9759\u6001\u5e93\u7684\u4f7f\u7528\u539f\u7406\u4ee5\u53ca\u4e24\u8005\u7684\u533a\u522b&#xff0c;\u4f46\u662f\u4f60\u662f\u5426\u56f0\u60d1\u8fc7&#xff1a;gcc -c \u51fa\u6765\u7684 .o \u6587\u4ef6\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;\u5b83\u548c .so\u3001a.out \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;ELF \u53c8\u662f\u4f55\u65b9\u795e\u5723&#xff1f;\u94fe\u63a5\u5668\u51ed\u4ec0\u4e48\u80fd\u4fee\u6b63\u51fd\u6570\u5730\u5740&#xff1f;\u8fd9\u7bc7\u6587\u7ae0\u4ece\u76ee\u6807\u6587\u4ef6\u8bb2\u8d77&#xff0c;\u5e26\u4f60\u5c42\u5c42\u6df1\u5165 ELF \u7684\u9aa8\u9ad3\u3002 \u76ee\u5f55 \u5f00\u7bc7&#xff1a;\u4e00\u6bb5\u4ee3\u7801\u7684\u7f16\u8bd1\u4e4b\u65c5 \u4e00\u3001\u76ee\u6807\u6587\u4ef6&#xff08;.o&#xff09;\u2014\u2014\u7f16\u8bd1\u7684\\&#8221;\u534a\u6210\u54c1\\&#8221; 1.1 \u4e3a\u4ec0\u4e48<\/p>\n","protected":false},"author":2,"featured_media":88450,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,43,44],"topic":[],"class_list":["post-88470","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux\u7cfb\u7edf\u7bc722\uff1a\u2014\u2014\u6587\u4ef6\uff08\u516d\uff09\uff1a\u76ee\u6807\u6587\u4ef6\u4e0eELF\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u7f16\u8bd1\u5230\u52a0\u8f7d\u7684\u5168\u666f\u63ed\u79d8 - \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\/88470.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux\u7cfb\u7edf\u7bc722\uff1a\u2014\u2014\u6587\u4ef6\uff08\u516d\uff09\uff1a\u76ee\u6807\u6587\u4ef6\u4e0eELF\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u7f16\u8bd1\u5230\u52a0\u8f7d\u7684\u5168\u666f\u63ed\u79d8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e0a\u4e00\u671f\u4ecb\u7ecd\u4e86\u52a8\u9759\u6001\u5e93\u7684\u4f7f\u7528\u539f\u7406\u4ee5\u53ca\u4e24\u8005\u7684\u533a\u522b&#xff0c;\u4f46\u662f\u4f60\u662f\u5426\u56f0\u60d1\u8fc7&#xff1a;gcc -c \u51fa\u6765\u7684 .o \u6587\u4ef6\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;\u5b83\u548c .so\u3001a.out \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;ELF \u53c8\u662f\u4f55\u65b9\u795e\u5723&#xff1f;\u94fe\u63a5\u5668\u51ed\u4ec0\u4e48\u80fd\u4fee\u6b63\u51fd\u6570\u5730\u5740&#xff1f;\u8fd9\u7bc7\u6587\u7ae0\u4ece\u76ee\u6807\u6587\u4ef6\u8bb2\u8d77&#xff0c;\u5e26\u4f60\u5c42\u5c42\u6df1\u5165 ELF \u7684\u9aa8\u9ad3\u3002 \u76ee\u5f55 \u5f00\u7bc7&#xff1a;\u4e00\u6bb5\u4ee3\u7801\u7684\u7f16\u8bd1\u4e4b\u65c5 \u4e00\u3001\u76ee\u6807\u6587\u4ef6&#xff08;.o&#xff09;\u2014\u2014\u7f16\u8bd1\u7684&quot;\u534a\u6210\u54c1&quot; 1.1 \u4e3a\u4ec0\u4e48\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/88470.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-01T00:25:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002529-6a6d3cf9ea0d6.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=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/88470.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/88470.html\",\"name\":\"Linux\u7cfb\u7edf\u7bc722\uff1a\u2014\u2014\u6587\u4ef6\uff08\u516d\uff09\uff1a\u76ee\u6807\u6587\u4ef6\u4e0eELF\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u7f16\u8bd1\u5230\u52a0\u8f7d\u7684\u5168\u666f\u63ed\u79d8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-01T00:25:37+00:00\",\"dateModified\":\"2026-08-01T00:25:37+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/88470.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/88470.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/88470.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\u7cfb\u7edf\u7bc722\uff1a\u2014\u2014\u6587\u4ef6\uff08\u516d\uff09\uff1a\u76ee\u6807\u6587\u4ef6\u4e0eELF\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u7f16\u8bd1\u5230\u52a0\u8f7d\u7684\u5168\u666f\u63ed\u79d8\"}]},{\"@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":"Linux\u7cfb\u7edf\u7bc722\uff1a\u2014\u2014\u6587\u4ef6\uff08\u516d\uff09\uff1a\u76ee\u6807\u6587\u4ef6\u4e0eELF\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u7f16\u8bd1\u5230\u52a0\u8f7d\u7684\u5168\u666f\u63ed\u79d8 - \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\/88470.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux\u7cfb\u7edf\u7bc722\uff1a\u2014\u2014\u6587\u4ef6\uff08\u516d\uff09\uff1a\u76ee\u6807\u6587\u4ef6\u4e0eELF\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u7f16\u8bd1\u5230\u52a0\u8f7d\u7684\u5168\u666f\u63ed\u79d8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e0a\u4e00\u671f\u4ecb\u7ecd\u4e86\u52a8\u9759\u6001\u5e93\u7684\u4f7f\u7528\u539f\u7406\u4ee5\u53ca\u4e24\u8005\u7684\u533a\u522b&#xff0c;\u4f46\u662f\u4f60\u662f\u5426\u56f0\u60d1\u8fc7&#xff1a;gcc -c \u51fa\u6765\u7684 .o \u6587\u4ef6\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;\u5b83\u548c .so\u3001a.out \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;ELF \u53c8\u662f\u4f55\u65b9\u795e\u5723&#xff1f;\u94fe\u63a5\u5668\u51ed\u4ec0\u4e48\u80fd\u4fee\u6b63\u51fd\u6570\u5730\u5740&#xff1f;\u8fd9\u7bc7\u6587\u7ae0\u4ece\u76ee\u6807\u6587\u4ef6\u8bb2\u8d77&#xff0c;\u5e26\u4f60\u5c42\u5c42\u6df1\u5165 ELF \u7684\u9aa8\u9ad3\u3002 \u76ee\u5f55 \u5f00\u7bc7&#xff1a;\u4e00\u6bb5\u4ee3\u7801\u7684\u7f16\u8bd1\u4e4b\u65c5 \u4e00\u3001\u76ee\u6807\u6587\u4ef6&#xff08;.o&#xff09;\u2014\u2014\u7f16\u8bd1\u7684\"\u534a\u6210\u54c1\" 1.1 \u4e3a\u4ec0\u4e48","og_url":"https:\/\/www.wsisp.com\/helps\/88470.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-01T00:25:37+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801002529-6a6d3cf9ea0d6.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/88470.html","url":"https:\/\/www.wsisp.com\/helps\/88470.html","name":"Linux\u7cfb\u7edf\u7bc722\uff1a\u2014\u2014\u6587\u4ef6\uff08\u516d\uff09\uff1a\u76ee\u6807\u6587\u4ef6\u4e0eELF\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u7f16\u8bd1\u5230\u52a0\u8f7d\u7684\u5168\u666f\u63ed\u79d8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-01T00:25:37+00:00","dateModified":"2026-08-01T00:25:37+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/88470.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/88470.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/88470.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux\u7cfb\u7edf\u7bc722\uff1a\u2014\u2014\u6587\u4ef6\uff08\u516d\uff09\uff1a\u76ee\u6807\u6587\u4ef6\u4e0eELF\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u7f16\u8bd1\u5230\u52a0\u8f7d\u7684\u5168\u666f\u63ed\u79d8"}]},{"@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\/88470","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=88470"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/88470\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/88450"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=88470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=88470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=88470"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=88470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}