{"id":221,"date":"2021-04-01T19:11:23","date_gmt":"2021-04-01T11:11:23","guid":{"rendered":"https:\/\/blogs.gongqilin.cn\/?p=221"},"modified":"2021-04-01T19:11:36","modified_gmt":"2021-04-01T11:11:36","slug":"%e4%bd%bf%e7%94%a8gcc%e7%bc%96%e8%af%91stm32%e7%9a%84%e5%af%b9%e7%9a%84-ld-map%e6%96%87%e4%bb%b6%e7%9a%84%e7%90%86%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/blogs.gongqilin.cn\/?p=221","title":{"rendered":"\u4f7f\u7528gcc\u7f16\u8bd1STM32\u7684\u5bf9\u7684.ld .map\u6587\u4ef6\u7684\u7406\u89e3"},"content":{"rendered":"<p>\u4f7f\u7528arm-none-eabi-gcc (Sourcery G++ Lite For AMR\uff09\u7f16\u8bd1STM32\u7684C++\u7a0b\u5e8f\u540e\u7684.ld .map\u6587\u4ef6\u7684\u7406\u89e3<br \/>\n\u4ee5stm32f030rct6\u4e3a\u4f8b\uff0c\u5728stm32f0_stm32f030xc.ld\uff0c\u6709\u5982\u4e0b\u4e00\u6bb5\u811a\u672c\u3002<\/p>\n<pre class=\"prettyprint linenums\">\/* Entry Point *\/\r\nENTRY(Reset_Handler)\r\n\r\n\/* Highest address of the user mode stack *\/\r\n_estack = 0x20008000;    \/* end of 32K RAM *\/\r\n\r\n\/* Generate a link error if heap and stack don&#039;t fit into RAM *\/\r\n_Min_Heap_Size = 0;      \/* required amount of heap  *\/\r\n_Min_Stack_Size = 0x200; \/* required amount of stack *\/\r\n\r\n\/* Specify the memory areas *\/\r\n\/*ORIGIN = 0x08006000, LENGTH = 232K*\/\r\nMEMORY\r\n{\r\n  FLASH (rx)      : ORIGIN = 0x08006000, LENGTH = 232K\r\n  RAM (xrw)       : ORIGIN = 0x200000C0, LENGTH = 32K\r\n  MEMORY_B1 (rx)  : ORIGIN = 0x60000000, LENGTH = 0K\r\n}\r\n<\/pre>\n<p>\u8fd9\u91cc\u5c31\u6307\u5b9a\u4e86\u7a0b\u5e8f\u7684\u5165\u53e3\u5c31\u662f\u5728Reset_Handler\uff0c\u6307\u5b9a\u6808\u9876\u7a7a\u95f4\u4e3a0x20008000;\u5806\u6808\u5927\u5c0f\uff0c\u5b9a\u4e49Flash\u8d77\u59cb\u5730\u57400x08006000\uff0c\u539f\u672c0x08000000\uff0c\u5206\u51fa0x6000\u4f5c\u4e3aBootLoader\u7684\u5f15\u5bfc\u7a0b\u5e8f\u3002\u5269\u4f59\u7684flash\u5927\u5c0f 256 &#8211; \uff080x6000\/1024\uff09=232 \uff08f030rct6\u53ea\u6709256KB\u7684flash\uff09\u3002<a href=\"https:\/\/blogs.gongqilin.cn\/?p=226\">\u539f\u56e0\u8bf7\u67e5\u770b\u8fd9\u91cc <img src=\"https:\/\/blogs.gongqilin.cn\/wp-content\/themes\/git\/assets\/img\/smilies\/icon_evil.gif\" alt=\":evil:\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> <\/a><br \/>\n\u5728\u751f\u6210\u7684.map\u6587\u4ef6,\u6211\u4eec\u53ef\u4ee5\u5728Linker script and memory map\uff08\u94fe\u63a5\u5668\u811a\u672c\u548c\u5185\u5b58\u6620\u5c04\uff09\u6bb5\u67e5\u627e\u5230<\/p>\n<pre class=\"prettyprint linenums\">              \r\n                0x20008000                _estack = 0x20008000\r\n                0x00000000                _Min_Heap_Size = 0x0\r\n                0x00000200                _Min_Stack_Size = 0x200\r\n<\/pre>\n<p>\u63a5\u4e0b\u6765\u7ee7\u7eed\u770b\u5728stm32f0_stm32f030xc.ld\uff0c\u6709\u5982\u4e0b\u4e00\u6bb5\u811a\u672c\u3002<\/p>\n<pre class=\"prettyprint linenums\"> \/* The startup code goes first into FLASH *\/\r\n  .isr_vector :\r\n  {\r\n    . = ALIGN(4);\r\n    KEEP(*(.isr_vector)) \/* Startup code *\/\r\n    . = ALIGN(4);\r\n  } &gt;FLASH\r\n\r\n  \/* The program code and other data goes into FLASH *\/\r\n  .text :\r\n  {\r\n    . = ALIGN(4);\r\n    *(.text)           \/* .text sections (code) *\/\r\n    *(.text*)          \/* .text* sections (code) *\/\r\n    *(.glue_7)         \/* glue arm to thumb code *\/\r\n    *(.glue_7t)        \/* glue thumb to arm code *\/\r\n    *(.eh_frame)\r\n\r\n    KEEP (*(.init))\r\n    KEEP (*(.fini))\r\n\r\n    . = ALIGN(4);\r\n    _etext = .;        \/* define a global symbols at end of code *\/\r\n  } &gt;FLASH\r\n<\/pre>\n<p>\u8fd9\u91cc\u6307\u5b9a\u5f00\u59cb\u6587\u4ef6\u7f16\u8bd1\u751f\u6210\u7684\u6587\u4ef6\u653e\u5728 .isr_vector\u6bb5\uff0c\u5176\u5b9e\u8fd9\u4e00\u6bb5\u5c31\u662f\u5b58\u653e\u7684F030RC\u768447\u4e2a\u4e2d\u65ad\u5411\u91cf\u5730\u5740\uff0c\u5177\u4f53\u7684\u53ef\u4ee5\u5728\u542f\u52a8\u6587\u4ef6startup_stm32f030xc.s\u4e2d\u67e5\u627e\uff0c\u5b57\u8282\u5bf9\u9f50\u540e\u5c31\u662f188\u5b57\u8282\uff080xbc\uff09\uff0c\u7f16\u8bd1\u540e\u5728map\u6587\u4ef6\uff0c\u6211\u4e5f\u53ef\u4ee5\u770b\u5230\u5982\u4e0b\u63cf\u8ff0\uff0c.isr_vector\u5f00\u59cb\u5730\u5740\u4e3a0x08006000\uff0c4\u5b57\u8282\u5bf9\u9f50\uff0c\u5927\u5c0f0xbc\uff0c\u4e0e\u6211\u4eec\u8ba1\u7b97\u7684\u543b\u5408\u3002.text\u4ee3\u7801\u6bb5\u8d77\u59cb\u5730\u5740\u4e3a 0x080060c0\uff08<a href=\"http:\/\/mail.qq.com\/cgi-bin\/qm_share?t=qm_mailme&amp;email=7YqcgdzU1Njd2t3crZycw46CgA\">\u4e3a\u5565\u5462 <img src=\"https:\/\/blogs.gongqilin.cn\/wp-content\/themes\/git\/assets\/img\/smilies\/icon_question.gif\" alt=\":?:\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> \uff0c\u8fd9\u91cc\u6709\u4ec0\u4e48\u5360\u7528\u4e864\u4e2a\u5b57\u8282\u76ee\u524d\u4e0d\u6e05\u695a\uff0c\u5982\u679c\u54ea\u4f4d\u5927\u4f6c\u770b\u5230\u4e86\u8bf7\u7ed9\u6211\u8bf4\u4e0b<\/a>\uff09\u8fd9\u91cc\u4ee3\u7801\u6bb5\u5360\u75280x1a6a8\u5b57\u8282\uff0c\u63a5\u4e0b\u6765map\u6587\u4ef6\u5c31\u4f1a\u63a5\u53d7\u90a3\u4e2a\u51fd\u6570\u7f16\u8bd1\u540e\u5360\u7528\u7684flash\u5927\u5c0f\u4e86\uff0c<\/p>\n<pre class=\"prettyprint linenums\">.isr_vector     0x08006000       0xbc\r\n                0x08006000                . = ALIGN (0x4)\r\n *(.isr_vector)\r\n .isr_vector    0x08006000       0xbc OutPut\/startup_stm32f030xc.o\r\n                0x08006000                g_pfnVectors\r\n                0x080060bc                . = ALIGN (0x4)\r\n\r\n.text           0x080060c0    0x1a6a8\r\n                0x080060c0                . = ALIGN (0x4)\r\n<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\u524d\u9762\u4e0e\u6211\u4eec\u7684\u914d\u7f6e\u4fe1\u606f\u76f8\u540c\u3002\u6bd4\u5982\u4e0b\u9762\u662f\/syscalls.c\u6587\u4ef6\u7f16\u8bd1\u51fasyscalls.o\u6587\u4ef6\uff0c\u5176\u4e2d_exit\u51fd\u6570\u8d77\u59cb\u5730\u5740 0x08019e5c\uff0c\u5927\u5c0f0x4\uff0c\u8981\u8bbf\u95ee\u51fd\u6570_exit\uff0c\u8bbf\u95ee\u5730\u57400x08019e5c\u5373\u53ef\u3002<\/p>\n<pre class=\"prettyprint linenums\" >\r\n .text._exit    0x08019e5c        0x4 OutPut\/syscalls.o\r\n                0x08019e5c                _exit\r\n .text._getpid  0x08019e60        0x4 OutPut\/syscalls.o\r\n                0x08019e60                _getpid\r\n .text._sbrk    0x08019e64       0x30 OutPut\/syscalls.o\r\n                0x08019e64                _sbrk\r\n<\/pre>\n<p>\u7ee7\u7eed\u770bstm32f0_stm32f030xc.ld\uff0c\u5c31\u4f1a\u5b9a\u4e49.rodata\u3001.ARM.extab\u3001.preinit_array\u3001.init_array\u3001.fini_array\u3001.data\u3001.bss\u3001._user_heap_stack\u7b49\u6570\u636e\u6bb5<br \/>\n\u5176\u4e2d.rodata\u6bb5\u5b58\u653e\u53ea\u8bfb\u6570\u636e\u5982\u5e38\u91cf\u3001\u5b57\u7b26\u4e32\u7b49\u3002.ARM.extab\uff0c.preinit_array\u3001.init_array\u3001.fini_array\u6bcd\u9e21\u5440\u3002.data\u5c5e\u4e8e\u5df2\u7ecf\u521d\u59cb\u5316\u597d\u7684\u6570\u636e\u6bb5\uff0c.bss\u662f\u672a\u521d\u59cb\u5316\u7684\u6570\u636e\u6bb5\u3002\u8fd9\u4e9b\u4fe1\u606f\u90fd\u53ef\u4ee5\u5728map\u6587\u4ef6\u770b\u5230\uff0c\u4e0b\u9762\u6765\u770b\u770b\u7f16\u8bd1\u94fe\u63a5\u540e\u7684\u4fe1\u606f<\/p>\n<pre class=\"prettyprint linenums\">section               size        addr\r\n.isr_vector            188   134242304\r\n.text               108200   134242496\r\n.rodata              11084   134350696\r\n.ARM.extab            1280   134361780\r\n.ARM                  1448   134363060\r\n.init_array             24   134364508\r\n.fini_array              4   134364532\r\n.data                 2272   536871104\r\n.bss                  7152   536873376\r\n._user_heap_stack      512   536880528\r\n.ARM.attributes         41           0\r\n<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230.isr_vecto\u8d77\u59cb\u5730\u5740134242304(0x8000000),\u5927\u5c0f\u90fd\u4e0emap\u6587\u4ef6\u543b\u5408\u3002.data\u6bb5\u7684\u65e2\u4f1a\u5b58\u653e\u5728flash\u4e2d\uff0c\u4e5f\u4f1a\u5b58\u653e\u5728RAM\u4e2d\uff0c\u8d77\u59cb\u5730\u5740\u5c31\u662f536871104\uff080x200000C0\uff09\u4e0e\u524d\u9762\u7684\u63cf\u8ff0\u4e5f\u543b\u5408\u3002<br \/>\n\u5b58\u653e\u5728flash\u7684\u6709.isr_vector\u3001.text\u3001.rodata\u3001.ARM.extab\u3001.preinit_array\u3001.init_array\u3001.fini_array\u3001.data\uff0c\u4ed6\u4eec\u7684\u603b\u548c\u5c31\u662f\u751f\u6210\u7684bin\u6587\u4ef6\u5927\u5c0f\uff0c\u8be5\u662f188+4\uff08\u524d\u9762\u63d0\u4e86\u8fd9\u4e2a\u7591\u95ee\uff09+108200+11084+1280+1448+24+4+2272+7152=124504\u4e2a\u5b57\u8282\uff08\u2248122KB\uff09\u4e0d\u80fd\u5927\u4e8eflash\u5927\u5c0f256KB\uff0c\u4f46\u662f\u7531\u4e8e\u4f7f\u7528\u4e86IAP\uff0c\u6240\u4ee5\u4e0d\u80fd\u5927\u4e8e\u524d\u9762\u8ba1\u7b97\u7684232KB\u3002<br \/>\n\u5360\u7528\u7684RAM\u5c31\u662f.data\uff0c.bss\u7684\u603b\u548c\u603b\u8ba12272+7152=9424\u5b57\u8282\uff08\u4e0d\u80fd\u5927\u4e8ef030\u7684RAM32KB\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528arm-none-eabi-gcc (Sourcery G++ Lite For AMR\uff09\u7f16\u8bd1STM32\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,7],"tags":[],"class_list":["post-221","post","type-post","status-publish","format-standard","hentry","category-c","category-stm32"],"_links":{"self":[{"href":"https:\/\/blogs.gongqilin.cn\/index.php?rest_route=\/wp\/v2\/posts\/221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.gongqilin.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gongqilin.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gongqilin.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gongqilin.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=221"}],"version-history":[{"count":6,"href":"https:\/\/blogs.gongqilin.cn\/index.php?rest_route=\/wp\/v2\/posts\/221\/revisions"}],"predecessor-version":[{"id":235,"href":"https:\/\/blogs.gongqilin.cn\/index.php?rest_route=\/wp\/v2\/posts\/221\/revisions\/235"}],"wp:attachment":[{"href":"https:\/\/blogs.gongqilin.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gongqilin.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gongqilin.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}