我用一个包含一些网站的常量数组从一个.c文件构建一个.bin文件,我想使用arm-none-eabi-toolchain刷新到我的STM32M7。将.o文件与.ld文件链接在一起时,我转储了.map文件。在数组之后的.map文件末尾,我认识到一些其他部分。对于我的应用程序,当.bin恰好在数组的结尾处结束时将是有益的。
我在编译和链接时尝试了一些不同的技巧,但是这些部分仍然存在。
.map文件的结尾看起来像这样:
.rodata.file__status_html
0x00000000080cfb2c 0x14 build/file.o
0x00000000080cfb2c file__status_html
.rodata.file__style_css
0x00000000080cfb40 0x14 build/file.o
0x00000000080cfb40 file__style_css
.comment 0x00000000080cfb54 0x7b build/file.o
0x7c (size before relaxing)
.ARM.attributes
0x00000000080cfbcf 0x30 build/file.o
.iplt 0x00000000080cfbff 0x0 build/file.o
.rel.iplt 0x00000000080cfbff 0x0 build/file.o
.igot.plt 0x00000000080cfbff 0x0 build/file.o
0x00000000080cfbff __website_section_end__ = .
OUTPUT(build/file.elf elf32-littlearm)
我运行以下命令来获取.map文件
arm-none-eabi-gcc file.c -std=gnu11 -g0 -DUSE_HAL_DRIVER -DSTM32F756xx -c -I "./inc/" -O2 -ffunction-sections -fdata-sections -Wall -Wunused-const-variable=0 -MMD -MP -MT"build/file.o" -MF"build/file.d" --specs=nano.specs -o "build/file.o"
arm-none-eabi-gcc -o "build/file.elf" "build/file.o" -mcpu=cortex-m7 -T"my_linker_script.ld" -nostdlib -Wl,-Map,build/file.map
链接描述文件如下:
/* Memories definition */
MEMORY
{
WEBSITE_MEMORY (rx) : ORIGIN = 0x080C0000,LENGTH = 256K
}
/* Sections */
SECTIONS
{
.website_section :
{
. = ALIGN(4);
__website_section_start__ = .;
*(.website_section*)
*file.o
__website_section_end__ = .;
} > WEBSITE_MEMORY
}
我宁愿得到这样的东西:
.rodata.file__status_html
0x00000000080cfb2c 0x14 build/file.o
0x00000000080cfb2c file__status_html
.rodata.file__style_css
0x00000000080cfb40 0x14 build/file.o
0x00000000080cfb40 file__style_css
0x00000000080cfb54 __website_section_end__ = .
OUTPUT(build/file.elf elf32-littlearm)
如何摆脱.comment,.ARM.attributes,.iplt,.rel.iplt,.igot.plt部分?