its sh_link points to the null section.  */
        if (((abfd->flags & (DYNAMIC | EXEC_P)) != 0
             && (hdr->sh_flags & SHF_ALLOC) != 0)
+           || (hdr->sh_flags & SHF_COMPRESSED) != 0
            || hdr->sh_type == SHT_RELR
            || hdr->sh_link == SHN_UNDEF
            || hdr->sh_link != elf_onesymtab (abfd)
   for (s = abfd->sections; s != NULL; s = s->next)
     if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
        && (elf_section_data (s)->this_hdr.sh_type == SHT_REL
-           || elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
+           || elf_section_data (s)->this_hdr.sh_type == SHT_RELA)
+       && (elf_section_data (s)->this_hdr.sh_flags & SHF_COMPRESSED) == 0)
       {
-       ext_rel_size += s->size;
-       if (ext_rel_size < s->size)
+       ext_rel_size += elf_section_data (s)->this_hdr.sh_size;
+       if (ext_rel_size < elf_section_data (s)->this_hdr.sh_size)
          {
            bfd_set_error (bfd_error_file_truncated);
            return -1;
          }
-       count += s->size / elf_section_data (s)->this_hdr.sh_entsize;
+       count += NUM_SHDR_ENTRIES (&elf_section_data (s)->this_hdr);
        if (count > LONG_MAX / sizeof (arelent *))
          {
            bfd_set_error (bfd_error_file_too_big);
     {
       if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
          && (elf_section_data (s)->this_hdr.sh_type == SHT_REL
-             || elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
+             || elf_section_data (s)->this_hdr.sh_type == SHT_RELA)
+         && (elf_section_data (s)->this_hdr.sh_flags & SHF_COMPRESSED) == 0)
        {
          arelent *p;
          long count, i;
 
          if (! (*slurp_relocs) (abfd, s, syms, true))
            return -1;
-         count = s->size / elf_section_data (s)->this_hdr.sh_entsize;
+         count = NUM_SHDR_ENTRIES (&elf_section_data (s)->this_hdr);
          p = s->relocation;
          for (i = 0; i < count; i++)
            *storage++ = p++;
   if (! (*slurp_relocs) (abfd, relplt, dynsyms, true))
     return -1;
 
-  count = relplt->size / hdr->sh_entsize;
+  count = NUM_SHDR_ENTRIES (hdr);
   size = count * sizeof (asymbol);
   p = relplt->relocation;
   for (i = 0; i < count; i++, p += bed->s->int_rels_per_ext_rel)
 
   /* Calculating the exact amount of space required for symbols would
      require two passes over the PLT, so just pessimise assuming two
      PLT slots per relocation.  */
-  count = relplt->size / hdr->sh_entsize;
+  count = NUM_SHDR_ENTRIES (hdr);
   counti = count * bed->s->int_rels_per_ext_rel;
   size = 2 * count * sizeof (asymbol);
   size += count * (sizeof (mipssuffix) +