Commit bf6f2cc7 by Richard Biener Committed by Richard Biener

re PR lto/81968 (early lto debug objects make Solaris ld SEGV)

2018-01-11  Richard Biener  <rguenther@suse.de>
	Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR lto/81968
	libiberty/
	* simple-object-common.h (struct simple_object_functions):
	Change copy_lto_debug_sections callback signature.
	* simple-object-elf.c (SHN_HIRESERVE, SHT_SYMTAB_SHNDX,
	SHF_INFO_LINK): Add defines.
	(simple_object_elf_copy_lto_debug_sections): Instead of
	leaving not to be copied sections empty unnamed SHT_NULL
	remove them from the target section headers and adjust section
	reference everywhere.  Handle SHN_XINDEX in the symbol table
	processing properly.
	* simple-object.c (handle_lto_debug_sections): Change
	interface to return a modified string and handle renaming
	of relocation sections.

Co-Authored-By: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>

From-SVN: r256528
parent ec538483
2018-01-11 Richard Biener <rguenther@suse.de>
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR lto/81968
* simple-object-common.h (struct simple_object_functions):
Change copy_lto_debug_sections callback signature.
* simple-object-elf.c (SHN_HIRESERVE, SHT_SYMTAB_SHNDX,
SHF_INFO_LINK): Add defines.
(simple_object_elf_copy_lto_debug_sections): Instead of
leaving not to be copied sections empty unnamed SHT_NULL
remove them from the target section headers and adjust section
reference everywhere. Handle SHN_XINDEX in the symbol table
processing properly.
* simple-object.c (handle_lto_debug_sections): Change
interface to return a modified string and handle renaming
of relocation sections.
2018-01-10 Daniel van Gerpen <daniel@vangerpen.de> 2018-01-10 Daniel van Gerpen <daniel@vangerpen.de>
* argv.c (expandargv): Correct check for dynamically * argv.c (expandargv): Correct check for dynamically
......
...@@ -145,7 +145,7 @@ struct simple_object_functions ...@@ -145,7 +145,7 @@ struct simple_object_functions
/* Copy LTO debug sections. */ /* Copy LTO debug sections. */
const char *(*copy_lto_debug_sections) (simple_object_read *sobj, const char *(*copy_lto_debug_sections) (simple_object_read *sobj,
simple_object_write *dobj, simple_object_write *dobj,
int (*pfn) (const char **), char *(*pfn) (const char *),
int *err); int *err);
}; };
......
...@@ -253,30 +253,38 @@ simple_object_find_section (simple_object_read *sobj, const char *name, ...@@ -253,30 +253,38 @@ simple_object_find_section (simple_object_read *sobj, const char *name,
/* Callback to identify and rename LTO debug sections by name. /* Callback to identify and rename LTO debug sections by name.
Returns 1 if NAME is a LTO debug section, 0 if not. */ Returns 1 if NAME is a LTO debug section, 0 if not. */
static int static char *
handle_lto_debug_sections (const char **name) handle_lto_debug_sections (const char *name)
{ {
char *newname = XCNEWVEC (char, strlen (name) + 1);
/* ??? So we can't use .gnu.lto_ prefixed sections as the assembler /* ??? So we can't use .gnu.lto_ prefixed sections as the assembler
complains about bogus section flags. Which means we need to arrange complains about bogus section flags. Which means we need to arrange
for that to be fixed or .gnu.debuglto_ marked as SHF_EXCLUDE (to make for that to be fixed or .gnu.debuglto_ marked as SHF_EXCLUDE (to make
fat lto object tooling work for the fat part). */ fat lto object tooling work for the fat part). */
/* ??? For now this handles both .gnu.lto_ and .gnu.debuglto_ prefixed /* Also include corresponding reloc sections. */
sections. */ if (strncmp (name, ".rela", sizeof (".rela") - 1) == 0)
/* Copy LTO debug sections and rename them to their non-LTO name. */
if (strncmp (*name, ".gnu.debuglto_", sizeof (".gnu.debuglto_") - 1) == 0)
{ {
*name = *name + sizeof (".gnu.debuglto_") - 1; strncpy (newname, name, sizeof (".rela") - 1);
return 1; name += sizeof (".rela") - 1;
} }
else if (strncmp (*name, ".gnu.lto_.debug_", sizeof (".gnu.lto_.debug_") -1) == 0) else if (strncmp (name, ".rel", sizeof (".rel") - 1) == 0)
{ {
*name = *name + sizeof (".gnu.lto_") - 1; strncpy (newname, name, sizeof (".rel") - 1);
return 1; name += sizeof (".rel") - 1;
} }
/* ??? For now this handles both .gnu.lto_ and .gnu.debuglto_ prefixed
sections. */
/* Copy LTO debug sections and rename them to their non-LTO name. */
if (strncmp (name, ".gnu.debuglto_", sizeof (".gnu.debuglto_") - 1) == 0)
return strcat (newname, name + sizeof (".gnu.debuglto_") - 1);
else if (strncmp (name, ".gnu.lto_.debug_",
sizeof (".gnu.lto_.debug_") -1) == 0)
return strcat (newname, name + sizeof (".gnu.lto_") - 1);
/* Copy over .note.GNU-stack section under the same name if present. */ /* Copy over .note.GNU-stack section under the same name if present. */
else if (strcmp (*name, ".note.GNU-stack") == 0) else if (strcmp (name, ".note.GNU-stack") == 0)
return 1; return strcpy (newname, name);
return 0; return NULL;
} }
/* Copy LTO debug sections. */ /* Copy LTO debug sections. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment