* elfxx-mips.c (_bfd_mips_elf_section_processing): Warn and
authorMaciej W. Rozycki <macro@linux-mips.org>
Thu, 26 May 2005 18:51:11 +0000 (18:51 +0000)
committerMaciej W. Rozycki <macro@linux-mips.org>
Thu, 26 May 2005 18:51:11 +0000 (18:51 +0000)
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.

bfd/ChangeLog
bfd/elfxx-mips.c

index 25bef0f6a3ee70eadfcd234bd6f9d03c4818a17f..ca696decca7991ae392d3f87d3ad6e3385ada2da 100644 (file)
@@ -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-26  Richard Henderson  <rth@redhat.com>
 
        * elf64-alpha.c (struct alpha_elf_link_hash_entry): Remove 
index c0bcfc5512cc221a0905624494a0a1288f0afb15..55d5f75f23224e087f4496e4444aaa4fe7167904 100644 (file)
@@ -4987,6 +4987,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];
@@ -5201,6 +5208,13 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd,
 
          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;
@@ -5239,8 +5253,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)
     {
@@ -5342,6 +5358,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
This page took 0.032171 seconds and 4 git commands to generate.