{"id":156211,"date":"2020-09-17T02:00:35","date_gmt":"2020-09-16T18:00:35","guid":{"rendered":"http:\/\/4563.org\/?p=156211"},"modified":"2020-09-17T02:00:35","modified_gmt":"2020-09-16T18:00:35","slug":"%e5%85%b3%e4%ba%8e-go-%e5%9c%a8-linux-amd64-%e5%b9%b3%e5%8f%b0%e4%b8%8b%e7%9a%84%e7%b3%bb%e7%bb%9f%e8%b0%83%e7%94%a8%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=156211","title":{"rendered":"\u5173\u4e8e go \u5728 Linux , amd64 \u5e73\u53f0\u4e0b\u7684\u7cfb\u7edf\u8c03\u7528\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5173\u4e8e go \u5728 Linux , amd64 \u5e73\u53f0\u4e0b\u7684\u7cfb\u7edf\u8c03\u7528\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chanchancl <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6b63\u5e38\u6765\u8bf4\uff0c\u7cfb\u7edf\u8c03\u7528\u4f20\u53c2\u987a\u5e8f\u662f<\/p>\n<p>EDI, ESI, EDX, ECX, R8, R9<\/p>\n<p>\u770bclone\u7684\u7cfb\u7edf\u8c03\u7528\u65f6\uff0c\u53d1\u73b0\u4f20\u53c2\u987a\u5e8f\u4e3a EDI, ESI, EDX, R10, R8, R9, R12<\/p>\n<p>\u8bf7\u95ee\u6709\u4ec0\u4e48\u539f\u56e0\u5417<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3323294\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : chanchancl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6bd4\u8f83\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0\u6211\u624b\u91cc\u7684 go1.15.1 \u7684\u6e90\u7801\uff0c\u548c\u8fde\u63a5\u91cc\u7684 go1.15.2 \u7684\u4ee3\u7801\u53c8\u4e0d\u4e00\u6837\u4e86\u3002\u3002\u3002<br \/>\u8fd9\u4e9b\u5bc4\u5b58\u5668\u91cc\u5230\u5e95\u54ea\u4e9b\u662f\u4f20\u53c2\u7684\u3002\u3002\u54ea\u4e9b\u662f\u4f5c\u4e3a\u5171\u4eab\u7528\u7684\u5462\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3323295\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : chanchancl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4ee5 1.15 branch \u4f5c\u4e3a\u6807\u51c6<\/p>\n<p>[clone]( https:\/\/github.com\/golang\/go\/blob\/release-branch.go1.15\/src\/runtime\/sys_linux_amd64.s#L592)<\/p>\n<p>\u4ece\u8fd9\u91cc\u6765\u770b\uff0cR8, R9, R12 \u90fd\u88ab\u540e\u9762\u65b0\u521b\u5efa\u7684 client thread \u4f7f\u7528\u4e86<\/p>\n<p>[clone system call]( https:\/\/man7.org\/linux\/man-pages\/man2\/clone.2.html)<\/p>\n<p>\u4ece man page \u770b clone \u7cfb\u7edf\u8c03\u7528\u6709 4 \u4e2a\u53c2\u6570\u3002\u3002\u3002\u4e4b\u524d\u770b\u9519\u4e86\u3002\u3002\u3002\u4e00\u76f4\u4ee5\u4e3a clone \u6709 7 \u4e2a\u53c2\u6570<\/p>\n<p>\u90a3\u4e48\u521a\u597d\u5bf9\u5e94 DI, SI, DX R10\uff0c\u5206\u522b\u662f int (*fn)(void *), void *stack, int flags, void *arg<\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u5927\u4f53\u4e0a\u662f\u89e3\u51b3\u4e86<\/p>\n<p>\u5269\u4e0b\u7684\u4e00\u4e2a\u5c0f\u95ee\u9898\u5c31\u662f\uff0c \u4e3a\u4ec0\u4e48\u4e0d\u7528 CX \u548c R11<\/p>\n<p>\u6ce8\u91ca\u91cc\u6709\u8bf4<\/p>\n<p>\/\/ Careful: Linux system call clobbers CX and R11.<\/p>\n<p>\u8fd9\u6709\u4ec0\u4e48\u539f\u56e0\u5417\uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3323296\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : katsusan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             linux \u5185\u6838\u6587\u6863\u5199\u7684\u5f88\u6e05\u695a,RCX \u548c R11 \u4f1a\u5728 x86_64 \u7cfb\u7edf\u8c03\u7528\u65f6\u88ab\u5185\u6838\u4f7f\u7528\u3002<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;arch\/x86\/entry.S&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/> * 64-bit SYSCALL saves rip to rcx, clears rflags.RF, then saves rflags to r11,<br \/> * then loads new ss, cs, and rip from previously programmed MSRs.<br \/> * rflags gets masked by a value from another MSR (so CLD and CLAC<br \/> * are not needed). SYSCALL does not save anything on the stack<br \/> * and does not change rsp.<br \/> *<br \/> * Registers on entry:<br \/> * rax system call number<br \/> * rcx return address<br \/> * r11 saved rflags (note: r11 is callee-clobbered register in C ABI)<br \/> * rdi arg0<br \/> * rsi arg1<br \/> * rdx arg2<br \/> * r10 arg3 (needs to be moved to rcx to conform to C ABI)<br \/> * r8 arg4<br \/> * r9 arg5<br \/> * (note: r12-r15, rbp, rbx are callee-preserved in C ABI)<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3323297\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Mohanson <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528\u6237\u6a21\u5f0f\u8c03\u7528\u7ea6\u5b9a( calling convention ) \u662f EDI, ESI, EDX, ECX, R8, R9<\/p>\n<p>\u5185\u6838\u6a21\u5f0f\u8c03\u7528\u7ea6\u5b9a( \u7cfb\u7edf\u8c03\u7528 ) \u662f rdi\uff0crsi\uff0crdx\uff0cr10\uff0cr8 \u548c r9<\/p>\n<p>\u4f60\u7528 c \u5199\u4e2a printf \u7684\u7a0b\u5e8f\u770b\u4e0b\u6c47\u7f16\u5c31\u61c2\u4e86\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3323298\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : chanchancl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @katsusan @Mohanson \u591a\u8c22\u5404\u4f4d\u7684\u89e3\u7b54\uff0c\u539f\u6765\u8c03\u7528\u666e\u901a\u51fd\u6570\u548c\u7cfb\u7edf\u8c03\u7528\u7684\u4f20\u53c2\u987a\u5e8f\u4e5f\u4e0d\u4e00\u6837                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e go \u5728 Linux , a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/156211"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=156211"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/156211\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=156211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=156211"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=156211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}