I crosscompile for cortex M microcontroller using arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi
I compile using -fdata-sections
and link using -Wl,--gc-sections -Wl,--sort-section=alignment
In map file I found something I cannot understand:
[...] *(SORT_BY_ALIGNMENT(.rodata*str1.4)) .rodata.saiPrintHeader.str1.4 0x3004a558 0x192e1 build/src/main_task.c.o 0x58 (size before relaxing) .rodata.saiPrintData.str1.4 0x30063839 0x1f build/src/main_task.c.o .rodata.main_Task.str1.4 0x30063839 0x143 build/src/main_task.c.o .rodata.main_Task_Init.str1.4 0x30063839 0x36 build/src/main_task.c.o .rodata.__qassert_fail.str1.4 0x30063839 0x21 build/src/qassert.c.o .rodata.sampleCollector_FindByName.str1.4 0x30063839 0x25 build/src/sampleCollector.c.o[...]
I don't understand why .rodata.saiPrintHeader.str1.4
is so big after the relaxing, and I don't understand why the other sibols are all at the same address.
with a hex editor I saw that at address 0x3004a558 there are all the strings, so it's like the linker merges all the strings together.
What is the benefit of doing such a thing? Is it possible to make it so that in the elf each string has its own address?