This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix gcc.dg/debug/pr41893-1.c with Solaris ld (PR lto/81968)
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 13 Apr 2018 10:13:58 +0200
- Subject: Fix gcc.dg/debug/pr41893-1.c with Solaris ld (PR lto/81968)
The last LTO early debug related failure on Solaris 11 is
FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 (test for excess errors)
FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O (test for excess errors)
FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O3 (test for excess errors)
Excess errors:
ld: fatal: relocation error: R_386_32: file /var/tmp//ccyfLclbdebugobjtem: section [6].rel.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [7].debug_macro
As detailed in the PR, the rewritten objects lto-wrapper passes to ld -r
for a partial link violate the ELF gABI access rules for COMDAT
sections. On closer inspection, however, the input objects do so, too.
Solaris ld has heuristics to relax the rules in objects produced by GCC,
which trigger on the presence of a .comment section containing the
string "GCC: (GNU)". This same relaxation can be enabled with
-z relaxreloc/-z relax=comdat if need be.
Right now, simple_object_elf_copy_lto_debug_sections doesn't copy
.comment sections, so the heuristic doesn't trigger. Fixed trivially by
keeping .comment sections in the output.
Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11. Approved by Richard in the PR, installed on
mainline.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2018-04-11 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR lto/81968
* simple-object.c (handle_lto_debug_sections): Keep .comment
section.
# HG changeset patch
# Parent 6314816f4181dd47c34310bc29a5996d925c9b8d
Fix gcc.dg/debug/pr41893-1.c with Solaris ld (PR lto/81968)
libiberty:
PR lto/81968
* simple-object.c (handle_lto_debug_sections): Keep .comment
section.
diff --git a/libiberty/simple-object.c b/libiberty/simple-object.c
--- a/libiberty/simple-object.c
+++ b/libiberty/simple-object.c
@@ -284,6 +284,11 @@ handle_lto_debug_sections (const char *n
/* Copy over .note.GNU-stack section under the same name if present. */
else if (strcmp (name, ".note.GNU-stack") == 0)
return strcpy (newname, name);
+ /* Copy over .comment section under the same name if present. Solaris
+ ld uses them to relax its checking of ELF gABI access rules for
+ COMDAT sections in objects produced by GCC. */
+ else if (strcmp (name, ".comment") == 0)
+ return strcpy (newname, name);
return NULL;
}