Compare commits

...

1 Commits

Author SHA1 Message Date
H.J. Lu
c35b4e8cee Remove invalid .dynamic section with --only-keep-debug
Remove invalid .dynamic section with --only-keep-debug.

bfd/

	PR binutils/22101
	* elf.c (rewrite_elf_program_header): Remove the segment from
	output if all sections in input have been removed.

binutils/x

	PR binutils/22101
	* objcopy.c (strip_main): Also remove invalid .dynamic section
	with --only-keep-debug.
	(copy_main): Likewise.
2017-09-15 12:26:43 -07:00
2 changed files with 9 additions and 0 deletions

View File

@@ -6721,6 +6721,11 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
}
}
/* Remove the segment from output if all sections in input have
been removed. */
if (first_section != NULL && section_count == 0)
continue;
/* Allocate a segment map big enough to contain
all of the sections we have selected. */
amt = sizeof (struct elf_segment_map);

View File

@@ -4206,6 +4206,8 @@ strip_main (int argc, char *argv[])
break;
case OPTION_ONLY_KEEP_DEBUG:
strip_symbols = STRIP_NONDEBUG;
/* Also remove invalid .dynamic section. */
handle_remove_section_option (".dynamic");
break;
case OPTION_KEEP_FILE_SYMBOLS:
keep_file_symbols = 1;
@@ -4582,6 +4584,8 @@ copy_main (int argc, char *argv[])
case OPTION_ONLY_KEEP_DEBUG:
strip_symbols = STRIP_NONDEBUG;
/* Also remove invalid .dynamic section. */
handle_remove_section_option (".dynamic");
break;
case OPTION_KEEP_FILE_SYMBOLS: