summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2005-05-26 18:51:37 +0000
committerMaciej W. Rozycki <macro@linux-mips.org>2005-05-26 18:51:37 +0000
commitb0431ad0ba26002438b304adbc0a76fa42e821ba (patch)
tree680c5eb5ed1188a6931bfd187f668b3e20ee5e11
parent056c793cc61ce0dd8c906e356b615ffad5ed74e0 (diff)
downloadgdb-b0431ad0ba26002438b304adbc0a76fa42e821ba.tar.gz
* elfxx-mips.c (_bfd_mips_elf_section_processing): Warn and
stop processing of options if one of invalid size is encountered. (_bfd_mips_elf_section_from_shdr): Likewise. (_bfd_mips_elf_fake_sections): Reset the type of empty special sections.
-rw-r--r--bfd/ChangeLog10
-rw-r--r--bfd/elfxx-mips.c22
2 files changed, 32 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index d9a076642f2..a38a8cd8335 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,13 @@
+2005-05-26 Mark Kettenis <kettenis@gnu.org>
+ Maciej W. Rozycki <macro@linux-mips.org>
+
+ * elfxx-mips.c (_bfd_mips_elf_section_processing): Warn and
+ stop processing of options if one of invalid size is
+ encountered.
+ (_bfd_mips_elf_section_from_shdr): Likewise.
+ (_bfd_mips_elf_fake_sections): Reset the type of empty special
+ sections.
+
2005-05-22 Richard Henderson <rth@redhat.com>
* elf64-alpha.c (elf64_alpha_relax_section): Ignore non-allocated
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 1f9cf8e54fa..d98b317fd56 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -4990,6 +4990,13 @@ _bfd_mips_elf_section_processing (bfd *abfd, Elf_Internal_Shdr *hdr)
bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
&intopt);
+ if (intopt.size < sizeof (Elf_External_Options))
+ {
+ (*_bfd_error_handler)
+ (_("%B: Warning: bad `%s' option size %u smaller than its header"),
+ abfd, MIPS_ELF_OPTIONS_SECTION_NAME (abfd), intopt.size);
+ break;
+ }
if (ABI_64_P (abfd) && intopt.kind == ODK_REGINFO)
{
bfd_byte buf[8];
@@ -5202,6 +5209,13 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd, Elf_Internal_Shdr *hdr,
bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
&intopt);
+ if (intopt.size < sizeof (Elf_External_Options))
+ {
+ (*_bfd_error_handler)
+ (_("%B: Warning: bad `%s' option size %u smaller than its header"),
+ abfd, MIPS_ELF_OPTIONS_SECTION_NAME (abfd), intopt.size);
+ break;
+ }
if (ABI_64_P (abfd) && intopt.kind == ODK_REGINFO)
{
Elf64_Internal_RegInfo intreg;
@@ -5240,8 +5254,10 @@ bfd_boolean
_bfd_mips_elf_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec)
{
register const char *name;
+ unsigned int sh_type;
name = bfd_get_section_name (abfd, sec);
+ sh_type = hdr->sh_type;
if (strcmp (name, ".liblist") == 0)
{
@@ -5343,6 +5359,12 @@ _bfd_mips_elf_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec)
hdr->sh_entsize = 8;
}
+ /* In the unlikely event a special section is empty it has to lose its
+ special meaning. This may happen e.g. when using `strip' with the
+ "--only-keep-debug" option. */
+ if (sec->size > 0 && !(sec->flags & SEC_HAS_CONTENTS))
+ hdr->sh_type = sh_type;
+
/* The generic elf_fake_sections will set up REL_HDR using the default
kind of relocations. We used to set up a second header for the
non-default kind of relocations here, but only NewABI would use