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.
2 files changed