https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124365
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- It is not about debug info, but about linker behaving differently if all the linked *.o objects don't have the marking they are looking for. That is why we e.g. copy over .note.GNU-stack section, or .note.gnu.property. E.g. if we didn't copy .note.GNU-stack, the linked binary would be marked as (potentially) having executable stack because we couldn't prove otherwise (because *.debug.temp.o files wouldn't tell). Note, while I've tested the patch on x86_64-linux and i686-linux so far (where it doesn't break anything, quite obviously) and bootstrapped on aarch64-linux, I'm still in make check there and only when that is over will test whether it fixed the actual problem (that -flto -g compiled/linked binaries don't have the expected features).
