diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2005-04-01 03:49:46 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2005-04-01 03:49:46 +0000 |
commit | 01b3c8abd1990d27f28e2b90d118fd259993d895 (patch) | |
tree | 1fdb1b1b7cb48e5570d1e70f3ccc44231bbd1540 /bfd/elf.c | |
parent | 35090471860b6c110a9090aba7ff901ec019de2b (diff) | |
download | fsf-binutils-gdb-01b3c8abd1990d27f28e2b90d118fd259993d895.zip fsf-binutils-gdb-01b3c8abd1990d27f28e2b90d118fd259993d895.tar.gz fsf-binutils-gdb-01b3c8abd1990d27f28e2b90d118fd259993d895.tar.bz2 |
2005-03-31 H.J. Lu <hongjiu.lu@intel.com>
* elf-bfd.h (_bfd_elf_check_kept_section): New.
* elf.c (assign_section_numbers): When sh_link points to a
discarded section, call _bfd_elf_check_kept_section to see if
the kept section can be used. Otherwise reject sh_link
pointing to discarded section.
* elflink.c (_bfd_elf_check_kept_section): New.
(elf_link_input_bfd): Use it.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -2919,7 +2919,25 @@ assign_section_numbers (bfd *abfd) } else { - s = elf_shdrp[elfsec]->bfd_section->output_section; + s = elf_shdrp[elfsec]->bfd_section; + if (elf_discarded_section (s)) + { + asection *kept; + (*_bfd_error_handler) + (_("%B: sh_link of section `%A' points to discarded section `%A' of `%B'"), + abfd, d->this_hdr.bfd_section, + s, s->owner); + /* Point to the kept section if it has + the same size as the discarded + one. */ + kept = _bfd_elf_check_kept_section (s); + if (kept == NULL) + { + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + } + s = s->output_section; BFD_ASSERT (s != NULL); d->this_hdr.sh_link = elf_section_data (s)->this_idx; } |