Georg-Johann Lay <a...@gjlay.de> writes: > Implementing TARGET_ASM_FUNCTION_RODATA_SECTION hook I wonder that will go > into these sections an I > am a but unsure as the internals don't say a word about that. From the only > two uses of that hook > in final.c I would conclude that it's only used for jump tables generated by > switch/case statements. > > The default returns readonly_data_section which is not correct for AVR; the > avr BE did override this > to switch to appropriate section in ASM_OUTPUT_ADDR_VEC_ELT and > ASM_OUTPUT_BEFORE_CASE_LABEL. > ASM_OUTPUT_BEFORE_CASE_LABEL alone won't do because the switch to > function_rodata_section takes > place after that hook. > > So I'd like to reassure me that the function_rodata_hook is only used for > jump tables and not for > other stuff so that I can clean up the avr BE at that point. From what I > found it's not used for > vtables, but for all the linkonce stuff I couldn't find comprehensive > explanantion.
TARGET_ASM_FUNCTION_RODATA_SECTION is in principle used for any read-only data associated only with a specific function. For most targets this is chosen so that the rodata is grouped with the function, so that if the function is discarded the associated rodata is also discarded. That grouping is what the linkonce stuff is about. In practice you are correct that the only read-only data associated with a specific function is the jump table (for targets for which JUMP_TABLES_IN_TEXT_SECTION is false). In principle the section could be used for targets with function-specific constant pools, but targets which use those tend to put the constant pool in the text section anyhow. TARGET_ASM_FUNCTION_RODATA_SECTION is not used for vtables. That would not make sense, as vtables are not function-specific. Ian