When disable lto, you should link case with option -Wl,--gc-sections. You will find that foo get inlined and its section is discarded in final elf file. If we follow the opinion that foo shouldn't be inlined because it is in another section, then .section1 won't be discarded even with -Wl,--gc-sections.
When disable lto, you should link case with option -Wl,--gc-sections. You will find that foo get inlined and its section is discarded in final elf file. If we follow the opinion that foo shouldn't be inlined because it is in another section, then .section1 won't be discarded even with -Wl,--gc-sections.