{"id":270,"date":"2021-07-20T22:01:51","date_gmt":"2021-07-20T14:01:51","guid":{"rendered":"http:\/\/pareto.fun\/?p=270"},"modified":"2021-12-01T14:23:46","modified_gmt":"2021-12-01T06:23:46","slug":"%e5%86%85%e9%83%a8%e6%a8%a1%e5%9d%97%e5%8f%98%e9%87%8f%e7%9a%84%e9%87%8d%e5%ae%9a%e4%bd%8d","status":"publish","type":"post","link":"http:\/\/pareto.fun\/?p=270","title":{"rendered":"\u5185\u90e8\u6a21\u5757\u53d8\u91cf\u7684\u91cd\u5b9a\u4f4d"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u901a\u8fc7\u672a\u521d\u59cb\u5316\u7684\u5168\u5c40\u6307\u9488\u8bbf\u95ee\u3002<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n\nchar * str = \"Hello World\";\nint main(void){\n    puts(str);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u53cd\u6c47\u7f16\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   0x000011e0 &lt;+19>:\tcall   0x120d &lt;__x86.get_pc_thunk.ax>\n   0x000011e5 &lt;+24>:\tadd    eax,0x2df3\n   0x000011ea &lt;+29>:\tmov    edx,DWORD PTR &#91;eax+0x30]\n   0x000011f0 &lt;+35>:\tsub    esp,0xc\n   0x000011f3 &lt;+38>:\tpush   edx\n   0x000011f4 &lt;+39>:\tmov    ebx,eax\n   0x000011f6 &lt;+41>:\tcall   0x1070 &lt;puts@plt><\/code><\/pre>\n\n\n\n<p>\u518d\u770b\u91cd\u5b9a\u4f4d\u8868\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p@ubuntu:~\/Templates$ readelf -r Hello\n\nRelocation section '.rel.dyn' at offset 0x3a4 contains 9 entries:\n Offset     Info    Type            Sym.Value  Sym. Name\n00003ed8  00000008 R_386_RELATIVE   # init_array\n00003edc  00000008 R_386_RELATIVE   # fini_array\n00003ff8  00000008 R_386_RELATIVE   \n00004004  00000008 R_386_RELATIVE   \n00004008  00000008 R_386_RELATIVE   # \u8fd9\u91cc\u5c31\u662f\u6211\u4eecstr\u5168\u5c40\u53d8\u91cf\u3002\u8be5\u5730\u5740\u5728data\u6bb5\n00003fec  00000106 R_386_GLOB_DAT    00000000   _ITM_deregisterTMClone\n00003ff0  00000206 R_386_GLOB_DAT    00000000   __cxa_finalize@GLIBC_2.1.3\n00003ff4  00000406 R_386_GLOB_DAT    00000000   __gmon_start__\n00003ffc  00000606 R_386_GLOB_DAT    00000000   _ITM_registerTMCloneTa\n\nRelocation section '.rel.plt' at offset 0x3ec contains 2 entries:\n Offset     Info    Type            Sym.Value  Sym. Name\n00003fe4  00000307 R_386_JUMP_SLOT   00000000   puts@GLIBC_2.0\n00003fe8  00000507 R_386_JUMP_SLOT   00000000   __libc_start_main@GLIBC_2.0\n<\/code><\/pre>\n\n\n\n<p>\u786e\u5b9e\u901a\u8fc7ip relative \u6765\u5b9a\u4f4d\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u5e76\u4e0d\u5e94\u8be5\u9700\u8981\u91cd\u5b9a\u4f4d\uff0c\u4f46\u53ea\u80fd\u5b9a\u4f4d\u5230\u6307\u5411&#8221;helloWorld&#8221;\u5b57\u7b26\u4e32\u5168\u5c40\u6307\u9488\u3002\u4f46\u662f\u8fd9\u4e2a\u5168\u5c40\u6307\u9488\u9700\u8981\u91cd\u5b9a\u4f4d\uff0c\u5c06\u6307\u5411\u76f8\u5bf9\u6587\u4ef6\u504f\u79fb\u7684\u5730\u5740\u8f6c\u5316\u4e3a\u6307\u5411\u5185\u5b58\u504f\u79fb\u7684\u5730<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u901a\u8fc7\u672a\u521d\u59cb\u5316\u7684\u5168\u5c40\u6307\u9488\u8bbf\u95ee\u3002<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\nchar * str2;\nint main(void){\n    str2 = \"Hello World\" ;\n    puts(str2);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u53cd\u6c47\u7f16\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   0x000011e0 &lt;+19>:\tcall   0x1219 &lt;__x86.get_pc_thunk.ax>\n   0x000011e5 &lt;+24>:\tadd    eax,0x2df3\n   0x000011ea &lt;+29>:\tlea    edx,&#91;eax-0x1fd0]\n   0x000011f0 &lt;+35>:\tmov    DWORD PTR &#91;eax+0x34],edx\n   0x000011f6 &lt;+41>:\tmov    edx,DWORD PTR &#91;eax+0x34]\n   0x000011fc &lt;+47>:\tsub    esp,0xc\n   0x000011ff &lt;+50>:\tpush   edx\n   0x00001200 &lt;+51>:\tmov    ebx,eax\n   0x00001202 &lt;+53>:\tcall   0x1070 &lt;puts@plt><\/code><\/pre>\n\n\n\n<p>\u6ca1\u6709\u91cd\u5b9a\u4f4d\uff0c\u61c2\u5f97\u90fd\u61c2\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c40\u90e8\u53d8\u91cf\u4f7f\u7528\u8bbf\u95ee\u6a21\u5757\u5185\u90e8\u5168\u5c40\u53d8\u91cf\u6307\u9488\u3002<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>char * str = \"Hello World\";\nint main(void){\n    char * str2 = str ;\n    puts(str2);\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<p>\u53cd\u6c47\u7f16\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> 0x000011e0 &lt;+19>:\tsub    esp,0x10\n   0x000011e3 &lt;+22>:\tcall   0x1215 &lt;__x86.get_pc_thunk.ax>\n   0x000011e8 &lt;+27>:\tadd    eax,0x2df0\n   0x000011ed &lt;+32>:\tmov    edx,DWORD PTR &#91;eax+0x30]\n   0x000011f3 &lt;+38>:\tmov    DWORD PTR &#91;ebp-0xc],edx\n   0x000011f6 &lt;+41>:\tsub    esp,0xc\n   0x000011f9 &lt;+44>:\tpush   DWORD PTR &#91;ebp-0xc]\n   0x000011fc &lt;+47>:\tmov    ebx,eax\n   0x000011fe &lt;+49>:\tcall   0x1070 &lt;puts@plt><\/code><\/pre>\n\n\n\n<p>\u901a\u8fc7ip relative \u6307\u4ee4\u5b9a\u4f4d\u52300x4008\uff0c\u8be5\u5730\u5740\u7684\u503c\u6307\u5411&#8221;Hello World&#8221;\u5b57\u7b26\u4e32\uff0c<\/p>\n\n\n\n<p>\u67e5\u770b\u91cd\u5b9a\u4f4d\u8868<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p@ubuntu:~\/Templates$ readelf -r Hello\n\nRelocation section '.rel.dyn' at offset 0x3a4 contains 9 entries:\n Offset     Info    Type            Sym.Value  Sym. Name\n00003ed8  00000008 R_386_RELATIVE   \n00003edc  00000008 R_386_RELATIVE   \n00003ff8  00000008 R_386_RELATIVE   \n00004004  00000008 R_386_RELATIVE   \n00004008  00000008 R_386_RELATIVE   # \u8fd9\u6b21\u5c06\u5b58\u50a8\u5b57\u7b26\u4e32\u7684\u6307\u9488\u5b58\u653e\u5728\u8be5\u5904\n00003fec  00000106 R_386_GLOB_DAT    00000000   _ITM_deregisterTMClone\n00003ff0  00000206 R_386_GLOB_DAT    00000000   __cxa_finalize@GLIBC_2.1.3\n00003ff4  00000406 R_386_GLOB_DAT    00000000   __gmon_start__\n00003ffc  00000606 R_386_GLOB_DAT    00000000   _ITM_registerTMCloneTa\n\nRelocation section '.rel.plt' at offset 0x3ec contains 2 entries:\n Offset     Info    Type            Sym.Value  Sym. Name\n00003fe4  00000307 R_386_JUMP_SLOT   00000000   puts@GLIBC_2.0\n00003fe8  00000507 R_386_JUMP_SLOT   00000000   __libc_start_main@GLIBC_2.0<\/code><\/pre>\n\n\n\n<p>\u8be5\u5904\u4e3adata\u6bb5\u3002<\/p>\n\n\n\n<p>\u4e14\u8be5\u5730\u5740\u7684\u503c\u4e3a0x2008 \uff0c \u521a\u597d\u4e3a\u201chello world&#8221; \u5b57\u7b26\u4e32\u7684\u6587\u4ef6\u504f\u79fb\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u76f4\u63a5\u8bbf\u95ee<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\nint main(void){\n    puts(\"Hello World\");\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u540c\u672a\u521d\u59cb\u5316\u7684\u5168\u5c40\u6307\u9488\u8bbf\u95ee\u3002\u90a3\u5fc5\u7136\u4e0d\u9700\u8981\u91cd\u5b9a\u4f4d\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7ed3\u8bba<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u6a21\u5757\u5185\u90e8\u53d8\u91cf\u6307\u9488<\/th><th><\/th><th><\/th><th>\u7c7b\u578b<\/th><th><\/th><th>\u91cd\u5b9a\u4f4d\u5730\u5740<\/th><\/tr><\/thead><tbody><tr><td>\u76f4\u63a5\u8bbf\u95ee<\/td><td><\/td><td><\/td><td>\u65e0<\/td><td><\/td><td><\/td><\/tr><tr><td>\u5168\u5c40\u51fd\u6570\u6307\u9488\u8c03\u7528<\/td><td><\/td><td><\/td><td>R_386_RELATIVE<\/td><td><\/td><td>data\u6bb5<\/td><\/tr><tr><td>\u672a\u521d\u59cb\u5316\u5168\u5c40\u6307\u9488\u8bbf\u95ee<\/td><td><\/td><td><\/td><td>\u65e0<\/td><td><\/td><td><\/td><\/tr><tr><td>\u5c40\u90e8\u6307\u9488\u8bbf\u95ee<\/td><td><\/td><td><\/td><td>R_386_RELATIVE<\/td><td><\/td><td>data\u6bb5<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u5230\u8fd9\u91cc\uff0c\u6709\u4e2a\u4f53\u4f1a\uff0c\u91cd\u5b9a\u4f4d\u7684\u5bf9\u8c61\u90fd\u662f\u6307\u9488\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u8fc7\u672a\u521d\u59cb\u5316\u7684\u5168\u5c40\u6307\u9488\u8bbf\u95ee\u3002 \u53cd\u6c47\u7f16\u4ee3\u7801\uff1a \u518d\u770b\u91cd\u5b9a\u4f4d\u8868\u3002 \u786e\u5b9e\u901a\u8fc7ip relative \u6765\u5b9a\u4f4d\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19,9],"tags":[25,29],"_links":{"self":[{"href":"http:\/\/pareto.fun\/index.php?rest_route=\/wp\/v2\/posts\/270"}],"collection":[{"href":"http:\/\/pareto.fun\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pareto.fun\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pareto.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pareto.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=270"}],"version-history":[{"count":3,"href":"http:\/\/pareto.fun\/index.php?rest_route=\/wp\/v2\/posts\/270\/revisions"}],"predecessor-version":[{"id":273,"href":"http:\/\/pareto.fun\/index.php?rest_route=\/wp\/v2\/posts\/270\/revisions\/273"}],"wp:attachment":[{"href":"http:\/\/pareto.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pareto.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pareto.fun\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}