https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81968
--- Comment #77 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot Uni-Bielefeld.DE> --- > --- Comment #62 from Richard Biener <rguenth at gcc dot gnu.org> --- > Waiting for Solaris engineer input... (or a machine to be able to debug this > directly - is there one on the CF?). We're finally getting to the bottom of this: * The original analysis of the objects rewritten by lto-wrapper and passed to ld -r (which cause the relocation error) pointed out that they were in violation of the ELF gABI access rules for COMDAT sections: https://docs.oracle.com/cd/E53394_01/html/E54813/chapter7-26.html#scrolltoc (the first bullet point). * However, while checking the input objects passed to lto-wrapper, I determined they have the same problem, but don't trigger the error. * It turned out that this happened because Solaris ld has heuristics to implicitly relax that check for gcc objects, as can be done explicitly with -z relax=comdat/-z relaxreloc. It checks for a .comment section containing the string "GCC: (GNU)". However, unlike the input objects, that section isn't copied by simple_object_copy_lto_debug_sections. Since trying to fix the initial issue is out of scope for GCC 8, there are two possible fixes: * Just copy the .comment section as well. Turns out to be trivial, and the attached patch does just that. * Pass -z relaxreloc to the ld -r invocation in lto-wrapper. This is uglier and needs more code.