I noticed something peculiar while inspecting a map file produced with the -Map=mapfile
option of the GNU linker. It listed a couple of symbols as belonging to the .text
section, whereas the binary's symbol table lists them as part of the .rodata
section. I suspect that this is some sort of cheeky optimization, as the compiler probably determined that those symbols are only ever read, but what surprises me is that the map file doesn't reflect that. My understanding is the linking is pretty much the final stage of the compilation process and all optimization happens before it. Is that correct? Why were these symbols optimized afterwards?
As you've probably inferred, the toolchain is GCC. The source code is written in C.