{"id":1750,"date":"2025-11-17T10:05:42","date_gmt":"2025-11-17T10:05:42","guid":{"rendered":"http:\/\/www.recologypower.com:9080\/?p=1750"},"modified":"2025-11-17T10:05:42","modified_gmt":"2025-11-17T10:05:42","slug":"armversion-magic-5-6-0-rc5-smp-mod_unload-should-be-%e9%97%ae%e9%a2%98%e7%a0%94%e7%a9%b6","status":"publish","type":"post","link":"http:\/\/www.recologypower.com:9080\/?p=1750","title":{"rendered":"[Arm]version magic \u20185.6.0-rc5+ SMP mod_unload \u2018 should be&#8230;\u95ee\u9898\u7814\u7a76"},"content":{"rendered":"\n<p>1, \u9996\u5148\uff0c\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u4fee\u6539\u4e86kernel\u91cd\u65b0\u7f16\u8bd1\u540emagic num\u6539\u53d8<br>\u5185\u6838\u7248\u672c\u662f\u5982\u4f55\u751f\u6210\u7684\uff1a<\/p>\n\n\n\n<p>Linux \u5185\u6838\u5728\u8fdb\u884c\u6a21\u5757\u88c5\u8f7d\u65f6\u5148\u5b8c\u6210\u6a21\u5757\u7684 CRC \u503c\u6821\u9a8c\uff0c\u518d\u6838\u5bf9 vermagic \u4e2d\u7684\u5b57\u7b26\u4fe1\u606f\uff0clinux\u7248\u672c\u5728 include\/generated\/utsrelease.h\u4e2d\u5b9a\u4e49\uff0c\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define UTS_RELEASE \"4.9.123\"\r\n<\/code><\/pre>\n\n\n\n<p><strong>utsrelease.h\u662fkernel\u7f16\u8bd1\u540e\u81ea\u52a8\u751f\u6210\u7684\uff0c\u7528\u6237\u66f4\u6539\u91cc\u9762\u7684\u5185\u5bb9\u4e0d\u4f1a\u6709\u6548\u679c\u3002<\/strong><br>\u8fd9\u4e2a\u503c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u6700\u9876\u5c42\u7684Makefile\u6587\u4ef6\u6765\u4fee\u6539\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>VERSION = 4\r\nPATCHLEVEL = 9                \r\nSUBLEVEL = 123                \r\nEXTRAVERSION =\r\n...\r\n<\/code><\/pre>\n\n\n\n<p>\u5728<code>init\/version.c<\/code>\u4e2d\uff0c\u5b9a\u4e49\u4e86kernel\u542f\u52a8\u65f6\u7684\u7b2c\u4e00\u6761\u6253\u5370\u4fe1\u606f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* FIXED STRINGS! Don't touch! *\/\r\nconst char linux_banner&#91;] =\r\n  \"Linux version \" UTS_RELEASE \" (\" LINUX_COMPILE_BY \"@\"\r\n  LINUX_COMPILE_HOST \") (\" LINUX_COMPILER \") \" UTS_VERSION \"\\n\";\r\n\r\nconst char linux_proc_banner&#91;] =\r\n  \"%s version %s\"\r\n  \" (\" LINUX_COMPILE_BY \"@\" LINUX_COMPILE_HOST \")\"\r\n  \" (\" LINUX_COMPILER \") %s\\n\";\r\n<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91ccUTS_RELEASE\u5728kernel\u7f16\u8bd1\u65f6\u81ea\u52a8\u751f\u6210<\/p>\n\n\n\n<p>\u5728<code>init\/main.c<\/code>\u7684<code>asmlinkage __visible void __init start_kernel(void)<\/code>\u51fd\u6570\u4e2d\uff0c\u6709kernel\u542f\u52a8\u7684\u7b2c\u4e00\u6761\u6253\u5370\u4fe1\u606f\uff0c\u8fd9\u6761\u4fe1\u606f\u662fdmesg\u547d\u4ee4\u6253\u5370\u51fa\u6765\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pr_notice(\"%s\", linux_banner);\r\n<\/code><\/pre>\n\n\n\n<p><strong>\u9a71\u52a8\u6a21\u5757\u7684version magic\u4fe1\u606f\u662f\u600e\u4e48\u751f\u6210\u7684\uff1a<\/strong><\/p>\n\n\n\n<p>4.x \u5185\u6838\u4e0b\uff0c\u5728<code>include\/linux\/vermagic.h<\/code>\u4e2d\u5b9a\u4e49\u6709<code>VERMAGIC_STRING<\/code>\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;generated\/utsrelease.h>\r\n              \r\n\/* Simply sanity version stamp for modules. *\/\r\n#ifdef CONFIG_SMP\r\n#define MODULE_VERMAGIC_SMP \"SMP \"\r\n#else\r\n#define MODULE_VERMAGIC_SMP \"\"\r\n#endif\r\n#ifdef CONFIG_PREEMPT\r\n#define MODULE_VERMAGIC_PREEMPT \"preempt \"\r\n#else\r\n#define MODULE_VERMAGIC_PREEMPT \"\"\r\n#endif\r\n#ifdef CONFIG_MODULE_UNLOAD\r\n#define MODULE_VERMAGIC_MODULE_UNLOAD \"mod_unload \"\r\n#else\r\n#define MODULE_VERMAGIC_MODULE_UNLOAD \"\"\r\n#endif \r\n#ifdef CONFIG_MODVERSIONS\r\n#define MODULE_VERMAGIC_MODVERSIONS \"modversions \"\r\n#else\r\n#define MODULE_VERMAGIC_MODVERSIONS \"\"\r\n#endif\r\n#ifndef MODULE_ARCH_VERMAGIC\r\n#define MODULE_ARCH_VERMAGIC \"\"\r\n#endif  \r\n\r\n#define VERMAGIC_STRING             \\\r\n  UTS_RELEASE \" \"             \\\r\n  MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT       \\\r\n  MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \\\r\n  MODULE_ARCH_VERMAGIC\r\n<\/code><\/pre>\n\n\n\n<p><code>VERMAGIC_STRING<\/code>\u4e0d\u4ec5\u5305\u542b\u5185\u6838\u7248\u672c\u53f7\uff0c\u8fd8\u5305\u542b\u6709\u5185\u6838\u4f7f\u7528\u7684SMP\u4e0epreempt, MODULE_UNLOAD, \u67b6\u6784\u7b49\u914d\u7f6e\u4fe1\u606f\u3002\u6a21\u5757\u5728\u7f16\u8bd1\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5c4f\u5e55\u4e0a\u4f1a\u663e\u793a&#8221;MODPOST&#8221;\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  &lt;~\/Documents\/Demo\/driver\/debugfs> make\r\nmake -C ~\/kernel\/ SUBDIRS=~\/Documents\/Demo\/driver\/debugfs modules\r\nmake&#91;1]: Entering directory '~\/kernel'\r\n  CC &#91;M]  ~\/Documents\/Demo\/driver\/debugfs\/my_debugfs.o\r\n  Building modules, stage 2.\r\n  MODPOST 1 modules\r\n  CC      ~\/Documents\/Demo\/driver\/debugfs\/my_debugfs.mod.o\r\n  LD &#91;M]  ~\/Documents\/Demo\/driver\/debugfs\/my_debugfs.ko\r\nmake&#91;1]: Leaving directory '~\/kernel'\r\n<\/code><\/pre>\n\n\n\n<p>\u5728\u6b64\u9636\u6bb5\uff0c\u00a0<code>VERMAGIC_STRING<\/code>\u4f1a\u6dfb\u52a0\u5230\u6a21\u5757\u7684<code>modinfo<\/code>\u6bb5\u3002\u5728\u5185\u6838\u6e90\u7801\u76ee\u5f55\u4e0b<code>scripts\\mod\\modpost.c<\/code>\u6587\u4ef6\u4e2d\u53ef\u4ee5\u770b\u5230\u6a21\u5757\u540e\u7eed\u5904\u7406\u90e8\u5206\u7684\u4ee3\u7801\u3002\u6a21\u5757\u7f16\u8bd1\u751f\u6210\u540e\uff0c\u901a\u8fc7<code>modinfo my_debugfs.ko<\/code>\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u6b64\u6a21\u5757\u7684vermagic\u7b49\u4fe1\u606f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  &lt;~\/Documents\/Demo\/driver\/debugfs> modinfo my_debugfs.ko \r\nfilename:      ~\/Documents\/Demo\/driver\/debugfs\/my_debugfs.ko\r\nlicense:        GPL\r\ndepends:        \r\nvermagic:       4.9.123 SMP preempt mod_unload aarch64\r\n<\/code><\/pre>\n\n\n\n<p>4.x \u5185\u6838\u4e0b\u7684\u6a21\u5757\u88c5\u8f7d\u5668\u91cc\u4fdd\u5b58\u6709\u5185\u6838\u7684\u7248\u672c\u4fe1\u606f\uff0c\u5728\u88c5\u8f7d\u6a21\u5757\u65f6\uff0c\u88c5\u8f7d\u5668\u4f1a\u6bd4\u8f83\u6240\u4fdd\u5b58\u7684\u5185\u6838vermagic\u4e0e\u6b64\u6a21\u5757\u7684modinfo\u6bb5\u91cc\u4fdd\u5b58\u7684vermagic\u4fe1\u606f\u662f\u5426\u4e00\u81f4\uff0c\u4e24\u8005\u4e00\u81f4\u65f6\uff0c\u6a21\u5757\u624d\u80fd\u88ab\u88c5\u8f7d\u3002<\/p>\n\n\n\n<p>\u4e3a\u4e86\u4f7f\u4e24\u4e2a\u7248\u672c\u4e00\u81f4\uff1a\u53ef\u4ee5\u628a \u4f9d\u8d56\u6e90\u7801\u4e2d\u7684include\/linux\/vermagic.h\u4e2d\u7684UTS_RELEASE\u4fee\u6539\u6210\u4e0e\u76ee\u6807\u673a\u5668\u7684\u7248\u672c\u4e00\u81f4\uff0c\u8fd9\u6837\uff0c\u518d\u6b21\u7f16\u8bd1\u6a21\u5757\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n\n\n\n<p>\u5185\u6838\u6a21\u5757\u7248\u672c\u548c\u5185\u6838\u7248\u672c\u4e0d\u4e00\u81f4\u7684\u5904\u7406\u65b9\u6cd5<\/p>\n\n\n\n<p>2, \u53d1\u73b0\u7248\u672c\u53f7\u4f1a\u8ffd\u52a0git\u7684\u7248\u672c\u53f7\uff0c\u8fd8\u6709\u4e2a\u201c+\u201d<br>\u5411linux\u5185\u6838\u7248\u672c\u53f7\u6dfb\u52a0\u5b57\u7b26\/\u4e3a\u4f55\u6709\u65f6\u4f1a\u81ea\u52a8\u6dfb\u52a0\u201c+\u201d\u53f7\uff0c\u6839\u636e\u8fd9\u7bc7\u6587\u7ae0\uff0c\u4e00\u6b65\u4e00\u6b65\u8bd5\u4e00\u4e0b<\/p>\n\n\n\n<p>\u7b2c\u4e00\u6b65\uff1a\u53bb\u6389git\u7684\u9644\u52a0\u4fe1\u606f<br>\u5148\u5728menuconfig\u4e2d\u627e\u5230<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  \u2502 Symbol: LOCALVERSION &#91;=]                                                                                                                                                                                   \u2502  \r\n  \u2502 Type  : string                                                                                                                                                                                             \u2502  \r\n  \u2502 Prompt: Local version - append to kernel release                                                                                                                                                           \u2502  \r\n  \u2502   Location:                                                                                                                                                                                                \u2502  \r\n  \u2502 (1) -> General setup                                                                                                                                                                                       \u2502  \r\n  \u2502   Defined at init\/Kconfig:81                                                                                                                                                                               \u2502  \r\n  \u2502                                                                                                                                                                                                            \u2502  \r\n  \u2502                                                                                                                                                                                                            \u2502  \r\n  \u2502 Symbol: LOCALVERSION_AUTO &#91;=n]                                                                                                                                                                             \u2502  \r\n  \u2502 Type  : boolean                                                                                                                                                                                            \u2502  \r\n  \u2502 Prompt: Automatically append version information to the version string                                                                                                                                     \u2502  \r\n  \u2502   Location:                                                                                                                                                                                                \u2502  \r\n  \u2502 (2) -> General setup                                                                                                                                                                                       \u2502  \r\n  \u2502   Defined at init\/Kconfig:91                                                                                                                                                                               \u2502  \r\n  \u2502   Depends on: !COMPILE_TEST &#91;=n]                                                                                                                                                                           \u2502  \r\n  \u2502                                                           \r\n<\/code><\/pre>\n\n\n\n<p>\u5173\u6389<code>LOCALVERSION_AUTO<\/code>\u5e76\u7559\u7a7a<code>LOCALVERSION<\/code>\uff0c\u53d1\u73b0git\u7248\u672c\u786e\u5b9e\u662f\u4e0d\u89c1\u4e86\uff0c\u4f46\u662f\u2018+\u2019\u8fd8\u662f\u5b58\u5728\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a><\/a><a><\/a>\u7b2c\u4e8c\u6b65\uff1a\u53bb\u6389\u201c+\u201d\u53f7<\/h4>\n\n\n\n<p>\u5728<code>scripts\/setlocalversion<\/code>\u6587\u4ef6\u4e2d\uff0c\u627e\u5230\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># CONFIG_LOCALVERSION and LOCALVERSION (if set)\r\nres=\"${res}${CONFIG_LOCALVERSION}${LOCALVERSION}\"\r\n\r\n# scm version string if not at a tagged commit\r\nif test \"$CONFIG_LOCALVERSION_AUTO\" = \"y\"; then\r\n  # full scm version string\r\n  res=\"$res$(scm_version)\"\r\nelse\r\n  # append a plus sign if the repository is not in a clean\r\n  # annotated or signed tagged state (as git describe only\r\n  # looks at signed or annotated tags - git tag -a\/-s) and\r\n  # LOCALVERSION= is not specified\r\n  if test \"${LOCALVERSION+set}\" != \"set\"; then\r\n    scm=$(scm_version --short)\r\n   # res=\"$res${scm:++}\"\t\/\/\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u6ce8\u91ca\u6389\u8fd9\u53e5\u8bdd\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\r\n  fi\r\nfi\r\n<\/code><\/pre>\n\n\n\n<p>\u4e0b\u9762\u662f\u6ce8\u91ca\u524d\u540e\u7684\u5bf9\u6bd4<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i-blog.csdnimg.cn\/blog_migrate\/03a6b76d68fd9a00bbb40986b1b0533e.png\" alt=\"\u6ce8\u91ca\u524d\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i-blog.csdnimg.cn\/blog_migrate\/03a75555e3d11bf335755892feadbee5.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\"\/><\/figure>\n\n\n\n<p>\u95ee\u9898\u89e3\u51b3\u3002<\/p>\n\n\n\n<p><h3 style=\"box-sizing: border-box; outline: 0px; margin: 24px 0px 8px; padding: 0px; font-weight: 600; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 18px; color: rgb(79, 79, 79); line-height: 28px; font-synthesis-style: auto; overflow-wrap: break-word; font-variant-ligatures: no-common-ligatures; white-space-collapse: collapse;\">Note\uff1a\u5728\u7f51\u4e0a\u8fd8\u770b\u5230\u4e24\u79cd\u65b9\u6cd5\uff0c\u5199\u5728\u4e0b\u9762\uff1a<a id=\"menuconfig_MODVERSIONS_156\" style=\"box-sizing: border-box; outline-style: none; outline-width: initial; margin: 0px; padding: 0px; font-weight: normal; cursor: pointer; background-color: transparent; color: rgb(78, 161, 219); font-synthesis-style: auto; overflow-wrap: break-word;\"><\/a>\u7b2c\u4e00\u79cd\uff1amenuconfig \u7684\u65f6\u5019\u4e0d\u8981\u52fe\u9009\uff0c\u76f4\u63a5\u641c<code style=\"box-sizing: border-box; outline: 0px; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 18px; line-height: 22px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 2px; padding: 2px 4px; font-synthesis-style: auto; overflow-wrap: break-word;\">MODVERSIONS<\/code><\/h3><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"564\" height=\"205\" src=\"http:\/\/www.recologypower.com:9080\/wp-content\/uploads\/2025\/11\/1.png\" alt=\"\" class=\"wp-image-1751\" srcset=\"http:\/\/www.recologypower.com:9080\/wp-content\/uploads\/2025\/11\/1.png 564w, http:\/\/www.recologypower.com:9080\/wp-content\/uploads\/2025\/11\/1-300x109.png 300w\" sizes=\"(max-width: 564px) 100vw, 564px\" \/><\/figure>\n\n\n\n<p>\u6ce8\u610f\u4e0d\u8981\u9009\u56fe\u4e2d\u90a3\u884c<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><a><\/a>\u7b2c\u4e8c\u79cd\uff1amodprobe &#8211;force-vermagic helloworld.ko<\/h5>\n\n\n\n<p>\u8fd9\u4e2a\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u5c1d\u8bd5\u4e00\u4e0b<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"slide-text-bg2\">\n<h3>1, \u9996\u5148\uff0c\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u4fee\u6539\u4e86kerne<\/h3>\n<\/div>\n<div class=\"flex-btn-div\"><a href=\"http:\/\/www.recologypower.com:9080\/?p=1750\" class=\"btn1 flex-btn\">\u9605\u8bfb\u66f4\u591a<\/a><\/div>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts\/1750"}],"collection":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1750"}],"version-history":[{"count":1,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts\/1750\/revisions"}],"predecessor-version":[{"id":1752,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts\/1750\/revisions\/1752"}],"wp:attachment":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1750"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}