GNU Binutils with patches for OS216
リビジョン | c35b4e8cee990d0d1c33b631912333e623a37477 (tree) |
---|---|
日時 | 2017-09-16 04:26:43 |
作者 | H.J. Lu <hjl.tools@gmai...> |
コミッター | H.J. Lu |
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.
@@ -6721,6 +6721,11 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd) | ||
6721 | 6721 | } |
6722 | 6722 | } |
6723 | 6723 | |
6724 | + /* Remove the segment from output if all sections in input have | |
6725 | + been removed. */ | |
6726 | + if (first_section != NULL && section_count == 0) | |
6727 | + continue; | |
6728 | + | |
6724 | 6729 | /* Allocate a segment map big enough to contain |
6725 | 6730 | all of the sections we have selected. */ |
6726 | 6731 | amt = sizeof (struct elf_segment_map); |
@@ -4206,6 +4206,8 @@ strip_main (int argc, char *argv[]) | ||
4206 | 4206 | break; |
4207 | 4207 | case OPTION_ONLY_KEEP_DEBUG: |
4208 | 4208 | strip_symbols = STRIP_NONDEBUG; |
4209 | + /* Also remove invalid .dynamic section. */ | |
4210 | + handle_remove_section_option (".dynamic"); | |
4209 | 4211 | break; |
4210 | 4212 | case OPTION_KEEP_FILE_SYMBOLS: |
4211 | 4213 | keep_file_symbols = 1; |
@@ -4582,6 +4584,8 @@ copy_main (int argc, char *argv[]) | ||
4582 | 4584 | |
4583 | 4585 | case OPTION_ONLY_KEEP_DEBUG: |
4584 | 4586 | strip_symbols = STRIP_NONDEBUG; |
4587 | + /* Also remove invalid .dynamic section. */ | |
4588 | + handle_remove_section_option (".dynamic"); | |
4585 | 4589 | break; |
4586 | 4590 | |
4587 | 4591 | case OPTION_KEEP_FILE_SYMBOLS: |