英文:
How to interpret alignment in map file? (Tasking compiler)
问题
你能解释一下地图文件中的对齐是如何工作的吗?
我认为对齐的工作原理是这样的:
我有一个大小为一个字节的变量/段,但由于对齐需要4个字节,它占据了4个字节的空间。
但根据截图中的地图文件,“OS_DATA_CORE0_VAR_INIT_PAD”部分从地址开始,应该分配给“OS_DATA_CORE0_VAR_INIT_SEC”部分,因为它需要16个字节的对齐。
英文:
Could you explain how alignment in map file works?
I thought that alignment works like that:
I have a variable/section that is one byte in size, but due to 4 bytes of alignment it occupies 4 bytes.
But according to the map file from the screenshot, "OS_DATA_CORE0_VAR_INIT_PAD" section starts in the address that should be assigned to "OS_DATA_CORE0_VAR_INIT_SEC" section due to the 16 bytes of alignment.
答案1
得分: 1
我认为对齐工作方式如下:我有一个大小为一个字节的变量/部分,但由于4字节的对齐,它占据4个字节。
实际上,如果你有一个对齐为4的部分,它会从地址开始,该地址是4的倍数,因此这种对齐会在前面的部分和该部分之间引入一个间隙,除非前面的部分以4的倍数地址结束。
英文:
>I thought that alignment works like that: I have a variable/section that is one byte in size, but due to 4 bytes of alignment it occupies 4 bytes.
It's rather that if you have a section with alignment e. g. 4, this starts at an address which is a multiple of 4, so this alignment introduces a gap between the preceding section and this section unless the preceding section ends at an address divisible by 4.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论