]> git.pld-linux.org Git - packages/elfutils.git/blobdiff - elfutils-robustify.patch
- really remove am patch
[packages/elfutils.git] / elfutils-robustify.patch
index 19764cbbe8e4434a0980ce8093ecaf84dd185f32..8359a9b62d1d704ad1915a3cb7fd52b23345cffe 100644 (file)
@@ -1,6 +1,50 @@
+--- elfutils/libdwfl/ChangeLog
++++ elfutils/libdwfl/ChangeLog
+@@ -256,6 +256,11 @@
+       * dwfl_module_getdwarf.c (open_elf): Clear errno before CBFAIL.
+       Reported by Kurt Roeckx <kurt@roeckx.be>.
++2011-03-23  Petr Machata  <pmachata@redhat.com>
++
++      * relocate.c (relocate_section): Use gelf_fsize instead of relying
++      on shdr->sh_entsize.
++
+ 2011-02-11  Roland McGrath  <roland@redhat.com>
+       * linux-kernel-modules.c (try_kernel_name): Try .gz, .bz2, .xz
+--- elfutils/libdwfl/relocate.c
++++ elfutils/libdwfl/relocate.c
+@@ -1,5 +1,5 @@
+ /* Relocate debug information.
+-   Copyright (C) 2005-2010 Red Hat, Inc.
++   Copyright (C) 2005-2011 Red Hat, Inc.
+    This file is part of elfutils.
+    This file is free software; you can redistribute it and/or modify
+@@ -456,7 +456,10 @@ relocate_section (Dwfl_Module *mod, Elf
+       }
+   }
+-  size_t nrels = shdr->sh_size / shdr->sh_entsize;
++  size_t sh_entsize
++    = gelf_fsize (relocated, shdr->sh_type == SHT_REL ? ELF_T_REL : ELF_T_RELA,
++                1, EV_CURRENT);
++  size_t nrels = shdr->sh_size / sh_entsize;
+   size_t complete = 0;
+   if (shdr->sh_type == SHT_REL)
+     for (size_t relidx = 0; !result && relidx < nrels; ++relidx)
+@@ -558,7 +561,7 @@ relocate_section (Dwfl_Module *mod, Elf
+         nrels = next;
+       }
+-      shdr->sh_size = reldata->d_size = nrels * shdr->sh_entsize;
++      shdr->sh_size = reldata->d_size = nrels * sh_entsize;
+       gelf_update_shdr (scn, shdr);
+     }
 --- elfutils/libelf/ChangeLog
 +++ elfutils/libelf/ChangeLog
 --- elfutils/libelf/ChangeLog
 +++ elfutils/libelf/ChangeLog
-@@ -663,10 +663,53 @@
+@@ -715,10 +715,53 @@
        If section content hasn't been read yet, do it before looking for the
        block size.  If no section data present, infer size of section header.
  
        If section content hasn't been read yet, do it before looking for the
        block size.  If no section data present, infer size of section header.
  
        * elf.h: Update from glibc.
 --- elfutils/libelf/elf32_getphdr.c
 +++ elfutils/libelf/elf32_getphdr.c
        * elf.h: Update from glibc.
 --- elfutils/libelf/elf32_getphdr.c
 +++ elfutils/libelf/elf32_getphdr.c
-@@ -114,6 +114,16 @@ __elfw2(LIBELFBITS,getphdr_wrlock) (elf)
+@@ -93,6 +93,16 @@ __elfw2(LIBELFBITS,getphdr_wrlock) (elf)
  
        if (elf->map_address != NULL)
        {
  
        if (elf->map_address != NULL)
        {
                             + elf->start_offset + ehdr->e_phoff);
 --- elfutils/libelf/elf32_getshdr.c
 +++ elfutils/libelf/elf32_getshdr.c
                             + elf->start_offset + ehdr->e_phoff);
 --- elfutils/libelf/elf32_getshdr.c
 +++ elfutils/libelf/elf32_getshdr.c
-@@ -1,5 +1,5 @@
- /* Return section header.
--   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2009 Red Hat, Inc.
-+   Copyright (C) 1998-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
-    Written by Ulrich Drepper <drepper@redhat.com>, 1998.
-@@ -81,7 +81,8 @@ load_shdr_wrlock (Elf_Scn *scn)
+@@ -60,7 +60,8 @@ load_shdr_wrlock (Elf_Scn *scn)
      goto out;
  
    size_t shnum;
      goto out;
  
    size_t shnum;
      goto out;
    size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr));
  
      goto out;
    size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr));
  
-@@ -98,6 +99,16 @@ load_shdr_wrlock (Elf_Scn *scn)
+@@ -77,6 +78,16 @@ load_shdr_wrlock (Elf_Scn *scn)
  
    if (elf->map_address != NULL)
      {
  
    if (elf->map_address != NULL)
      {
        /* All the data is already mapped.  If we could use it
 --- elfutils/libelf/elf32_newphdr.c
 +++ elfutils/libelf/elf32_newphdr.c
        /* All the data is already mapped.  If we could use it
 --- elfutils/libelf/elf32_newphdr.c
 +++ elfutils/libelf/elf32_newphdr.c
-@@ -135,6 +135,12 @@ elfw2(LIBELFBITS,newphdr) (elf, count)
+@@ -114,6 +114,12 @@ elfw2(LIBELFBITS,newphdr) (elf, count)
           || count == PN_XNUM
           || elf->state.ELFW(elf,LIBELFBITS).phdr == NULL)
      {
           || count == PN_XNUM
           || elf->state.ELFW(elf,LIBELFBITS).phdr == NULL)
      {
        result = (ElfW2(LIBELFBITS,Phdr) *)
 --- elfutils/libelf/elf32_updatefile.c
 +++ elfutils/libelf/elf32_updatefile.c
        result = (ElfW2(LIBELFBITS,Phdr) *)
 --- elfutils/libelf/elf32_updatefile.c
 +++ elfutils/libelf/elf32_updatefile.c
-@@ -223,6 +223,9 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf
+@@ -202,6 +202,9 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf
    /* Write all the sections.  Well, only those which are modified.  */
    if (shnum > 0)
      {
    /* Write all the sections.  Well, only those which are modified.  */
    if (shnum > 0)
      {
        Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns;
        Elf_Scn **scns = (Elf_Scn **) alloca (shnum * sizeof (Elf_Scn *));
        char *const shdr_start = ((char *) elf->map_address + elf->start_offset
        Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns;
        Elf_Scn **scns = (Elf_Scn **) alloca (shnum * sizeof (Elf_Scn *));
        char *const shdr_start = ((char *) elf->map_address + elf->start_offset
-@@ -645,6 +648,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf
+@@ -624,6 +627,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf
    /* Write all the sections.  Well, only those which are modified.  */
    if (shnum > 0)
      {
    /* Write all the sections.  Well, only those which are modified.  */
    if (shnum > 0)
      {
        xfct_t shdr_fctp = __elf_xfctstom[__libelf_version - 1][EV_CURRENT - 1][ELFW(ELFCLASS, LIBELFBITS) - 1][ELF_T_SHDR];
 --- elfutils/libelf/elf_begin.c
 +++ elfutils/libelf/elf_begin.c
        xfct_t shdr_fctp = __elf_xfctstom[__libelf_version - 1][EV_CURRENT - 1][ELFW(ELFCLASS, LIBELFBITS) - 1][ELF_T_SHDR];
 --- elfutils/libelf/elf_begin.c
 +++ elfutils/libelf/elf_begin.c
-@@ -165,7 +165,8 @@ get_shnum (void *map_address, unsigned c
+@@ -144,7 +144,8 @@ get_shnum (void *map_address, unsigned c
  
        if (unlikely (result == 0) && ehdr.e32->e_shoff != 0)
        {
  
        if (unlikely (result == 0) && ehdr.e32->e_shoff != 0)
        {
            /* Cannot read the first section header.  */
            return 0;
  
            /* Cannot read the first section header.  */
            return 0;
  
-@@ -213,7 +214,8 @@ get_shnum (void *map_address, unsigned c
+@@ -192,7 +193,8 @@ get_shnum (void *map_address, unsigned c
  
        if (unlikely (result == 0) && ehdr.e64->e_shoff != 0)
        {
  
        if (unlikely (result == 0) && ehdr.e64->e_shoff != 0)
        {
            /* Cannot read the first section header.  */
            return 0;
  
            /* Cannot read the first section header.  */
            return 0;
  
-@@ -285,6 +287,15 @@ file_read_elf (int fildes, void *map_add
+@@ -264,6 +266,15 @@ file_read_elf (int fildes, void *map_add
      /* Could not determine the number of sections.  */
      return NULL;
  
      /* Could not determine the number of sections.  */
      return NULL;
  
    /* We can now allocate the memory.  Even if there are no section headers,
       we allocate space for a zeroth section in case we need it later.  */
    const size_t scnmax = (scncnt ?: (cmd == ELF_C_RDWR || cmd == ELF_C_RDWR_MMAP)
    /* We can now allocate the memory.  Even if there are no section headers,
       we allocate space for a zeroth section in case we need it later.  */
    const size_t scnmax = (scncnt ?: (cmd == ELF_C_RDWR || cmd == ELF_C_RDWR_MMAP)
-@@ -324,6 +335,16 @@ file_read_elf (int fildes, void *map_add
+@@ -303,6 +314,16 @@ file_read_elf (int fildes, void *map_add
        {
          /* We can use the mmapped memory.  */
          elf->state.elf32.ehdr = ehdr;
        {
          /* We can use the mmapped memory.  */
          elf->state.elf32.ehdr = ehdr;
          elf->state.elf32.shdr
            = (Elf32_Shdr *) ((char *) ehdr + ehdr->e_shoff);
  
          elf->state.elf32.shdr
            = (Elf32_Shdr *) ((char *) ehdr + ehdr->e_shoff);
  
-@@ -410,6 +431,11 @@ file_read_elf (int fildes, void *map_add
+@@ -389,6 +410,11 @@ file_read_elf (int fildes, void *map_add
        {
          /* We can use the mmapped memory.  */
          elf->state.elf64.ehdr = ehdr;
        {
          /* We can use the mmapped memory.  */
          elf->state.elf64.ehdr = ehdr;
  
 --- elfutils/libelf/elf_getarsym.c
 +++ elfutils/libelf/elf_getarsym.c
  
 --- elfutils/libelf/elf_getarsym.c
 +++ elfutils/libelf/elf_getarsym.c
-@@ -179,6 +179,9 @@ elf_getarsym (elf, ptr)
+@@ -183,6 +183,9 @@ elf_getarsym (elf, ptr)
        size_t index_size = atol (tmpbuf);
  
        if (SARMAG + sizeof (struct ar_hdr) + index_size > elf->maximum_size
 +#if SIZE_MAX <= 4294967295U
 +        || n >= SIZE_MAX / sizeof (Elf_Arsym)
 +#endif
        size_t index_size = atol (tmpbuf);
  
        if (SARMAG + sizeof (struct ar_hdr) + index_size > elf->maximum_size
 +#if SIZE_MAX <= 4294967295U
 +        || n >= SIZE_MAX / sizeof (Elf_Arsym)
 +#endif
-         || n * sizeof (uint32_t) > index_size)
+         || n * w > index_size)
        {
          /* This index table cannot be right since it does not fit into
 --- elfutils/libelf/elf_getshdrstrndx.c
 +++ elfutils/libelf/elf_getshdrstrndx.c
        {
          /* This index table cannot be right since it does not fit into
 --- elfutils/libelf/elf_getshdrstrndx.c
 +++ elfutils/libelf/elf_getshdrstrndx.c
-@@ -125,10 +125,25 @@ elf_getshdrstrndx (elf, dst)
+@@ -104,10 +104,25 @@ elf_getshdrstrndx (elf, dst)
              if (elf->map_address != NULL
                  && elf->state.elf32.ehdr->e_ident[EI_DATA] == MY_ELFDATA
                  && (ALLOW_UNALIGNED
              if (elf->map_address != NULL
                  && elf->state.elf32.ehdr->e_ident[EI_DATA] == MY_ELFDATA
                  && (ALLOW_UNALIGNED
              else
                {
                  /* We avoid reading in all the section headers.  Just read
              else
                {
                  /* We avoid reading in all the section headers.  Just read
-@@ -163,10 +178,25 @@ elf_getshdrstrndx (elf, dst)
+@@ -142,10 +157,25 @@ elf_getshdrstrndx (elf, dst)
              if (elf->map_address != NULL
                  && elf->state.elf64.ehdr->e_ident[EI_DATA] == MY_ELFDATA
                  && (ALLOW_UNALIGNED
              if (elf->map_address != NULL
                  && elf->state.elf64.ehdr->e_ident[EI_DATA] == MY_ELFDATA
                  && (ALLOW_UNALIGNED
                  /* We avoid reading in all the section headers.  Just read
 --- elfutils/libelf/elf_newscn.c
 +++ elfutils/libelf/elf_newscn.c
                  /* We avoid reading in all the section headers.  Just read
 --- elfutils/libelf/elf_newscn.c
 +++ elfutils/libelf/elf_newscn.c
-@@ -104,10 +104,18 @@ elf_newscn (elf)
+@@ -83,10 +83,18 @@ elf_newscn (elf)
    else
      {
        /* We must allocate a new element.  */
    else
      {
        /* We must allocate a new element.  */
  /* Get information from dynamic table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
  /* Get information from dynamic table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -93,7 +93,7 @@ gelf_getdyn (data, ndx, dst)
+@@ -72,7 +72,7 @@ gelf_getdyn (data, ndx, dst)
         table entries has to be adopted.  The user better has provided
         a buffer where we can store the information.  While copying the
         data we are converting the format.  */
         table entries has to be adopted.  The user better has provided
         a buffer where we can store the information.  While copying the
         data we are converting the format.  */
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
-@@ -114,7 +114,7 @@ gelf_getdyn (data, ndx, dst)
+@@ -93,7 +93,7 @@ gelf_getdyn (data, ndx, dst)
  
        /* The data is already in the correct form.  Just make sure the
         index is OK.  */
  
        /* The data is already in the correct form.  Just make sure the
         index is OK.  */
  /* Get library from table at the given index.
 -   Copyright (C) 2004 Red Hat, Inc.
 +   Copyright (C) 2004-2009 Red Hat, Inc.
  /* Get library from table at the given index.
 -   Copyright (C) 2004 Red Hat, Inc.
 +   Copyright (C) 2004-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2004.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2004.
  
-@@ -86,7 +86,7 @@ gelf_getlib (data, ndx, dst)
+@@ -65,7 +65,7 @@ gelf_getlib (data, ndx, dst)
    /* The data is already in the correct form.  Just make sure the
       index is OK.  */
    GElf_Lib *result = NULL;
    /* The data is already in the correct form.  Just make sure the
       index is OK.  */
    GElf_Lib *result = NULL;
  /* Get move structure at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
  /* Get move structure at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -83,7 +83,7 @@ gelf_getmove (data, ndx, dst)
+@@ -62,7 +62,7 @@ gelf_getmove (data, ndx, dst)
  
    /* The data is already in the correct form.  Just make sure the
       index is OK.  */
  
    /* The data is already in the correct form.  Just make sure the
       index is OK.  */
  /* Get RELA relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
  /* Get RELA relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -71,12 +71,6 @@ gelf_getrela (data, ndx, dst)
+@@ -50,12 +50,6 @@ gelf_getrela (data, ndx, dst)
    if (data_scn == NULL)
      return NULL;
  
    if (data_scn == NULL)
      return NULL;
  
    if (unlikely (data_scn->d.d_type != ELF_T_RELA))
      {
        __libelf_seterrno (ELF_E_INVALID_HANDLE);
    if (unlikely (data_scn->d.d_type != ELF_T_RELA))
      {
        __libelf_seterrno (ELF_E_INVALID_HANDLE);
-@@ -93,7 +87,7 @@ gelf_getrela (data, ndx, dst)
+@@ -72,7 +66,7 @@ gelf_getrela (data, ndx, dst)
    if (scn->elf->class == ELFCLASS32)
      {
        /* We have to convert the data.  */
    if (scn->elf->class == ELFCLASS32)
      {
        /* We have to convert the data.  */
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          result = NULL;
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          result = NULL;
-@@ -114,7 +108,7 @@ gelf_getrela (data, ndx, dst)
+@@ -93,7 +87,7 @@ gelf_getrela (data, ndx, dst)
      {
        /* Simply copy the data after we made sure we are actually getting
         correct data.  */
      {
        /* Simply copy the data after we made sure we are actually getting
         correct data.  */
  /* Get REL relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
  /* Get REL relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -71,12 +71,6 @@ gelf_getrel (data, ndx, dst)
+@@ -50,12 +50,6 @@ gelf_getrel (data, ndx, dst)
    if (data_scn == NULL)
      return NULL;
  
    if (data_scn == NULL)
      return NULL;
  
    if (unlikely (data_scn->d.d_type != ELF_T_REL))
      {
        __libelf_seterrno (ELF_E_INVALID_HANDLE);
    if (unlikely (data_scn->d.d_type != ELF_T_REL))
      {
        __libelf_seterrno (ELF_E_INVALID_HANDLE);
-@@ -93,7 +87,7 @@ gelf_getrel (data, ndx, dst)
+@@ -72,7 +66,7 @@ gelf_getrel (data, ndx, dst)
    if (scn->elf->class == ELFCLASS32)
      {
        /* We have to convert the data.  */
    if (scn->elf->class == ELFCLASS32)
      {
        /* We have to convert the data.  */
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          result = NULL;
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          result = NULL;
-@@ -113,7 +107,7 @@ gelf_getrel (data, ndx, dst)
+@@ -92,7 +86,7 @@ gelf_getrel (data, ndx, dst)
      {
        /* Simply copy the data after we made sure we are actually getting
         correct data.  */
      {
        /* Simply copy the data after we made sure we are actually getting
         correct data.  */
  /* Get symbol information from symbol table at the given index.
 -   Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 1999-2009 Red Hat, Inc.
  /* Get symbol information from symbol table at the given index.
 -   Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 1999-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 1999.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 1999.
  
-@@ -90,7 +90,7 @@ gelf_getsym (data, ndx, dst)
+@@ -69,7 +69,7 @@ gelf_getsym (data, ndx, dst)
         table entries has to be adopted.  The user better has provided
         a buffer where we can store the information.  While copying the
         data we are converting the format.  */
         table entries has to be adopted.  The user better has provided
         a buffer where we can store the information.  While copying the
         data we are converting the format.  */
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
-@@ -119,7 +119,7 @@ gelf_getsym (data, ndx, dst)
+@@ -98,7 +98,7 @@ gelf_getsym (data, ndx, dst)
  
        /* The data is already in the correct form.  Just make sure the
         index is OK.  */
  
        /* The data is already in the correct form.  Just make sure the
         index is OK.  */
  /* Get additional symbol information from symbol table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
  /* Get additional symbol information from symbol table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -84,7 +84,7 @@ gelf_getsyminfo (data, ndx, dst)
+@@ -63,7 +63,7 @@ gelf_getsyminfo (data, ndx, dst)
  
    /* The data is already in the correct form.  Just make sure the
       index is OK.  */
  
    /* The data is already in the correct form.  Just make sure the
       index is OK.  */
     at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
     at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -90,7 +90,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
+@@ -69,7 +69,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
       section index table.  */
    if (likely (shndxdata_scn != NULL))
      {
       section index table.  */
    if (likely (shndxdata_scn != NULL))
      {
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
-@@ -110,7 +110,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
+@@ -89,7 +89,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
         table entries has to be adopted.  The user better has provided
         a buffer where we can store the information.  While copying the
         data we are converting the format.  */
         table entries has to be adopted.  The user better has provided
         a buffer where we can store the information.  While copying the
         data we are converting the format.  */
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
-@@ -139,7 +139,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
+@@ -118,7 +118,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
  
        /* The data is already in the correct form.  Just make sure the
         index is OK.  */
  
        /* The data is already in the correct form.  Just make sure the
         index is OK.  */
  /* Get symbol version information at the given index.
 -   Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 1999-2009 Red Hat, Inc.
  /* Get symbol version information at the given index.
 -   Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 1999-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 1999.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 1999.
  
-@@ -92,7 +92,7 @@ gelf_getversym (data, ndx, dst)
+@@ -71,7 +71,7 @@ gelf_getversym (data, ndx, dst)
  
    /* The data is already in the correct form.  Just make sure the
       index is OK.  */
  
    /* The data is already in the correct form.  Just make sure the
       index is OK.  */
  /* Update information in dynamic table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
  /* Update information in dynamic table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -71,12 +71,6 @@ gelf_update_dyn (data, ndx, src)
+@@ -50,12 +50,6 @@ gelf_update_dyn (data, ndx, src)
    if (data == NULL)
      return 0;
  
    if (data == NULL)
      return 0;
  
    if (unlikely (data_scn->d.d_type != ELF_T_DYN))
      {
        /* The type of the data better should match.  */
    if (unlikely (data_scn->d.d_type != ELF_T_DYN))
      {
        /* The type of the data better should match.  */
-@@ -102,7 +96,7 @@ gelf_update_dyn (data, ndx, src)
+@@ -81,7 +75,7 @@ gelf_update_dyn (data, ndx, src)
        }
  
        /* Check whether we have to resize the data buffer.  */
        }
  
        /* Check whether we have to resize the data buffer.  */
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
-@@ -116,7 +110,7 @@ gelf_update_dyn (data, ndx, src)
+@@ -95,7 +89,7 @@ gelf_update_dyn (data, ndx, src)
    else
      {
        /* Check whether we have to resize the data buffer.  */
    else
      {
        /* Check whether we have to resize the data buffer.  */
  /* Update library in table at the given index.
 -   Copyright (C) 2004 Red Hat, Inc.
 +   Copyright (C) 2004-2009 Red Hat, Inc.
  /* Update library in table at the given index.
 -   Copyright (C) 2004 Red Hat, Inc.
 +   Copyright (C) 2004-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2004.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2004.
  
-@@ -68,12 +68,6 @@ gelf_update_lib (data, ndx, src)
+@@ -47,12 +47,6 @@ gelf_update_lib (data, ndx, src)
    if (data == NULL)
      return 0;
  
    if (data == NULL)
      return 0;
  
    Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data;
    if (unlikely (data_scn->d.d_type != ELF_T_LIB))
      {
    Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data;
    if (unlikely (data_scn->d.d_type != ELF_T_LIB))
      {
-@@ -87,7 +81,7 @@ gelf_update_lib (data, ndx, src)
+@@ -66,7 +60,7 @@ gelf_update_lib (data, ndx, src)
  
    /* Check whether we have to resize the data buffer.  */
    int result = 0;
  
    /* Check whether we have to resize the data buffer.  */
    int result = 0;
  /* Update move structure at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
  /* Update move structure at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -75,8 +75,7 @@ gelf_update_move (data, ndx, src)
+@@ -54,8 +54,7 @@ gelf_update_move (data, ndx, src)
    assert (sizeof (GElf_Move) == sizeof (Elf64_Move));
  
    /* Check whether we have to resize the data buffer.  */
    assert (sizeof (GElf_Move) == sizeof (Elf64_Move));
  
    /* Check whether we have to resize the data buffer.  */
  /* Update RELA relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
  /* Update RELA relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -68,12 +68,6 @@ gelf_update_rela (Elf_Data *dst, int ndx
+@@ -47,12 +47,6 @@ gelf_update_rela (Elf_Data *dst, int ndx
    if (dst == NULL)
      return 0;
  
    if (dst == NULL)
      return 0;
  
    if (unlikely (data_scn->d.d_type != ELF_T_RELA))
      {
        /* The type of the data better should match.  */
    if (unlikely (data_scn->d.d_type != ELF_T_RELA))
      {
        /* The type of the data better should match.  */
-@@ -101,7 +95,7 @@ gelf_update_rela (Elf_Data *dst, int ndx
+@@ -80,7 +74,7 @@ gelf_update_rela (Elf_Data *dst, int ndx
        }
  
        /* Check whether we have to resize the data buffer.  */
        }
  
        /* Check whether we have to resize the data buffer.  */
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
-@@ -117,7 +111,7 @@ gelf_update_rela (Elf_Data *dst, int ndx
+@@ -96,7 +90,7 @@ gelf_update_rela (Elf_Data *dst, int ndx
    else
      {
        /* Check whether we have to resize the data buffer.  */
    else
      {
        /* Check whether we have to resize the data buffer.  */
  /* Update REL relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
  /* Update REL relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -68,12 +68,6 @@ gelf_update_rel (Elf_Data *dst, int ndx,
+@@ -47,12 +47,6 @@ gelf_update_rel (Elf_Data *dst, int ndx,
    if (dst == NULL)
      return 0;
  
    if (dst == NULL)
      return 0;
  
    if (unlikely (data_scn->d.d_type != ELF_T_REL))
      {
        /* The type of the data better should match.  */
    if (unlikely (data_scn->d.d_type != ELF_T_REL))
      {
        /* The type of the data better should match.  */
-@@ -99,7 +93,7 @@ gelf_update_rel (Elf_Data *dst, int ndx,
+@@ -78,7 +72,7 @@ gelf_update_rel (Elf_Data *dst, int ndx,
        }
  
        /* Check whether we have to resize the data buffer.  */
        }
  
        /* Check whether we have to resize the data buffer.  */
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
-@@ -114,7 +108,7 @@ gelf_update_rel (Elf_Data *dst, int ndx,
+@@ -93,7 +87,7 @@ gelf_update_rel (Elf_Data *dst, int ndx,
    else
      {
        /* Check whether we have to resize the data buffer.  */
    else
      {
        /* Check whether we have to resize the data buffer.  */
  /* Update symbol information in symbol table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
  /* Update symbol information in symbol table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -72,12 +72,6 @@ gelf_update_sym (data, ndx, src)
+@@ -51,12 +51,6 @@ gelf_update_sym (data, ndx, src)
    if (data == NULL)
      return 0;
  
    if (data == NULL)
      return 0;
  
    if (unlikely (data_scn->d.d_type != ELF_T_SYM))
      {
        /* The type of the data better should match.  */
    if (unlikely (data_scn->d.d_type != ELF_T_SYM))
      {
        /* The type of the data better should match.  */
-@@ -102,7 +96,7 @@ gelf_update_sym (data, ndx, src)
+@@ -81,7 +75,7 @@ gelf_update_sym (data, ndx, src)
        }
  
        /* Check whether we have to resize the data buffer.  */
        }
  
        /* Check whether we have to resize the data buffer.  */
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
-@@ -125,7 +119,7 @@ gelf_update_sym (data, ndx, src)
+@@ -104,7 +98,7 @@ gelf_update_sym (data, ndx, src)
    else
      {
        /* Check whether we have to resize the data buffer.  */
    else
      {
        /* Check whether we have to resize the data buffer.  */
  /* Update additional symbol information in symbol table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
  /* Update additional symbol information in symbol table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -72,12 +72,6 @@ gelf_update_syminfo (data, ndx, src)
+@@ -51,12 +51,6 @@ gelf_update_syminfo (data, ndx, src)
    if (data == NULL)
      return 0;
  
    if (data == NULL)
      return 0;
  
    if (unlikely (data_scn->d.d_type != ELF_T_SYMINFO))
      {
        /* The type of the data better should match.  */
    if (unlikely (data_scn->d.d_type != ELF_T_SYMINFO))
      {
        /* The type of the data better should match.  */
-@@ -93,7 +87,7 @@ gelf_update_syminfo (data, ndx, src)
+@@ -72,7 +66,7 @@ gelf_update_syminfo (data, ndx, src)
    rwlock_wrlock (scn->elf->lock);
  
    /* Check whether we have to resize the data buffer.  */
    rwlock_wrlock (scn->elf->lock);
  
    /* Check whether we have to resize the data buffer.  */
     given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
     given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
-@@ -77,12 +77,6 @@ gelf_update_symshndx (symdata, shndxdata
+@@ -56,12 +56,6 @@ gelf_update_symshndx (symdata, shndxdata
    if (symdata == NULL)
      return 0;
  
    if (symdata == NULL)
      return 0;
  
    if (unlikely (symdata_scn->d.d_type != ELF_T_SYM))
      {
        /* The type of the data better should match.  */
    if (unlikely (symdata_scn->d.d_type != ELF_T_SYM))
      {
        /* The type of the data better should match.  */
-@@ -128,7 +122,7 @@ gelf_update_symshndx (symdata, shndxdata
+@@ -107,7 +101,7 @@ gelf_update_symshndx (symdata, shndxdata
        }
  
        /* Check whether we have to resize the data buffer.  */
        }
  
        /* Check whether we have to resize the data buffer.  */
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
-@@ -151,7 +145,7 @@ gelf_update_symshndx (symdata, shndxdata
+@@ -130,7 +124,7 @@ gelf_update_symshndx (symdata, shndxdata
    else
      {
        /* Check whether we have to resize the data buffer.  */
    else
      {
        /* Check whether we have to resize the data buffer.  */
  /* Update symbol version information.
 -   Copyright (C) 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2001-2009 Red Hat, Inc.
  /* Update symbol version information.
 -   Copyright (C) 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2001-2009 Red Hat, Inc.
-    This file is part of Red Hat elfutils.
+    This file is part of elfutils.
     Written by Ulrich Drepper <drepper@redhat.com>, 2001.
  
     Written by Ulrich Drepper <drepper@redhat.com>, 2001.
  
-@@ -75,8 +75,7 @@ gelf_update_versym (data, ndx, src)
+@@ -54,8 +54,7 @@ gelf_update_versym (data, ndx, src)
    assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym));
  
    /* Check whether we have to resize the data buffer.  */
    assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym));
  
    /* Check whether we have to resize the data buffer.  */
        return 0;
 --- elfutils/libelf/libelfP.h
 +++ elfutils/libelf/libelfP.h
        return 0;
 --- elfutils/libelf/libelfP.h
 +++ elfutils/libelf/libelfP.h
-@@ -608,4 +608,8 @@ extern uint32_t __libelf_crc32 (uint32_t
+@@ -587,4 +587,8 @@ extern uint32_t __libelf_crc32 (uint32_t
  /* Align offset to 4 bytes as needed for note name and descriptor data.  */
  #define NOTE_ALIGN(n) (((n) + 3) & -4U)
  
  /* Align offset to 4 bytes as needed for note name and descriptor data.  */
  #define NOTE_ALIGN(n) (((n) + 3) & -4U)
  
  #endif  /* libelfP.h */
 --- elfutils/src/ChangeLog
 +++ elfutils/src/ChangeLog
  #endif  /* libelfP.h */
 --- elfutils/src/ChangeLog
 +++ elfutils/src/ChangeLog
-@@ -1686,6 +1686,16 @@
+@@ -504,6 +504,12 @@
+       * readelf.c (dwarf_attr_string): Grok DW_AT_GNU_odr_signature.
++2011-03-23  Petr Machata  <pmachata@redhat.com>
++
++      * readelf.c (handle_dynamic, handle_relocs_rel)
++      (handle_relocs_rela, handle_versym, print_liblist):
++      Use gelf_fsize instead of relying on shdr->sh_entsize.
++
+ 2011-02-11  Roland McGrath  <roland@redhat.com>
+       * elfcmp.c (verbose): New variable.
+@@ -2216,6 +2222,16 @@
        object symbols or symbols with unknown type.
        (check_rel): Likewise.
  
        object symbols or symbols with unknown type.
        (check_rel): Likewise.
  
  2005-06-08  Roland McGrath  <roland@redhat.com>
  
        * readelf.c (print_ops): Add consts.
  2005-06-08  Roland McGrath  <roland@redhat.com>
  
        * readelf.c (print_ops): Add consts.
-@@ -1731,6 +1741,19 @@
+@@ -2261,6 +2277,19 @@
  
        * readelf.c (dwarf_tag_string): Add new tags.
  
  
        * readelf.c (dwarf_tag_string): Add new tags.
  
        * strip.c (handle_elf): Don't translate hash and versym data formats,
 --- elfutils/src/elflint.c
 +++ elfutils/src/elflint.c
        * strip.c (handle_elf): Don't translate hash and versym data formats,
 --- elfutils/src/elflint.c
 +++ elfutils/src/elflint.c
-@@ -131,6 +131,10 @@ static uint32_t shstrndx;
+@@ -123,6 +123,10 @@ static uint32_t shstrndx;
  /* Array to count references in section groups.  */
  static int *scnref;
  
  /* Array to count references in section groups.  */
  static int *scnref;
  
  
  int
  main (int argc, char *argv[])
  
  int
  main (int argc, char *argv[])
-@@ -319,10 +323,19 @@ section_name (Ebl *ebl, int idx)
+@@ -311,10 +315,19 @@ section_name (Ebl *ebl, int idx)
  {
    GElf_Shdr shdr_mem;
    GElf_Shdr *shdr;
  {
    GElf_Shdr shdr_mem;
    GElf_Shdr *shdr;
  }
  
  
  }
  
  
-@@ -344,11 +357,6 @@ static const int valid_e_machine[] =
+@@ -337,11 +350,6 @@ static const int valid_e_machine[] =
    (sizeof (valid_e_machine) / sizeof (valid_e_machine[0]))
  
  
    (sizeof (valid_e_machine) / sizeof (valid_e_machine[0]))
  
  
  static void
  check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size)
  {
  static void
  check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size)
  {
-@@ -632,7 +640,8 @@ section [%2d] '%s': symbol table cannot 
+@@ -625,7 +633,8 @@ section [%2d] '%s': symbol table cannot
          }
        }
  
          }
        }
  
      ERROR (gettext ("\
  section [%2u] '%s': entry size is does not match ElfXX_Sym\n"),
           idx, section_name (ebl, idx));
      ERROR (gettext ("\
  section [%2u] '%s': entry size is does not match ElfXX_Sym\n"),
           idx, section_name (ebl, idx));
-@@ -670,7 +679,7 @@ section [%2d] '%s': XINDEX for zeroth en
+@@ -663,7 +672,7 @@ section [%2d] '%s': XINDEX for zeroth en
               xndxscnidx, section_name (ebl, xndxscnidx));
      }
  
               xndxscnidx, section_name (ebl, xndxscnidx));
      }
  
      {
        sym = gelf_getsymshndx (data, xndxdata, cnt, &sym_mem, &xndx);
        if (sym == NULL)
      {
        sym = gelf_getsymshndx (data, xndxdata, cnt, &sym_mem, &xndx);
        if (sym == NULL)
-@@ -690,7 +699,8 @@ section [%2d] '%s': symbol %zu: invalid 
+@@ -683,7 +692,8 @@ section [%2d] '%s': symbol %zu: invalid
        else
        {
          name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name);
        else
        {
          name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name);
        }
  
        if (sym->st_shndx == SHN_XINDEX)
        }
  
        if (sym->st_shndx == SHN_XINDEX)
-@@ -1038,9 +1048,11 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e
+@@ -1040,9 +1050,11 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e
      {
        GElf_Shdr rcshdr_mem;
        const GElf_Shdr *rcshdr = gelf_getshdr (scn, &rcshdr_mem);
      {
        GElf_Shdr rcshdr_mem;
        const GElf_Shdr *rcshdr = gelf_getshdr (scn, &rcshdr_mem);
        {
          /* Found the dynamic section.  Look through it.  */
          Elf_Data *d = elf_getdata (scn, NULL);
        {
          /* Found the dynamic section.  Look through it.  */
          Elf_Data *d = elf_getdata (scn, NULL);
-@@ -1050,7 +1062,9 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e
+@@ -1052,7 +1064,9 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e
            {
              GElf_Dyn dyn_mem;
              GElf_Dyn *dyn = gelf_getdyn (d, cnt, &dyn_mem);
            {
              GElf_Dyn dyn_mem;
              GElf_Dyn *dyn = gelf_getdyn (d, cnt, &dyn_mem);
  
              if (dyn->d_tag == DT_RELCOUNT)
                {
  
              if (dyn->d_tag == DT_RELCOUNT)
                {
-@@ -1064,7 +1078,9 @@ section [%2d] '%s': DT_RELCOUNT used for
+@@ -1066,7 +1080,9 @@ section [%2d] '%s': DT_RELCOUNT used for
                      /* Does the number specified number of relative
                         relocations exceed the total number of
                         relocations?  */
                      /* Does the number specified number of relative
                         relocations exceed the total number of
                         relocations?  */
                        ERROR (gettext ("\
  section [%2d] '%s': DT_RELCOUNT value %d too high for this section\n"),
                               idx, section_name (ebl, idx),
                        ERROR (gettext ("\
  section [%2d] '%s': DT_RELCOUNT value %d too high for this section\n"),
                               idx, section_name (ebl, idx),
-@@ -1224,7 +1240,8 @@ section [%2d] '%s': no relocations for m
+@@ -1226,7 +1242,8 @@ section [%2d] '%s': no relocations for m
        }
      }
  
        }
      }
  
      ERROR (gettext (reltype == ELF_T_RELA ? "\
  section [%2d] '%s': section entry size does not match ElfXX_Rela\n" : "\
  section [%2d] '%s': section entry size does not match ElfXX_Rel\n"),
      ERROR (gettext (reltype == ELF_T_RELA ? "\
  section [%2d] '%s': section entry size does not match ElfXX_Rela\n" : "\
  section [%2d] '%s': section entry size does not match ElfXX_Rel\n"),
-@@ -1447,7 +1464,8 @@ check_rela (Ebl *ebl, GElf_Ehdr *ehdr, G
+@@ -1449,7 +1466,8 @@ check_rela (Ebl *ebl, GElf_Ehdr *ehdr, G
    Elf_Data *symdata = elf_getdata (symscn, NULL);
    enum load_state state = state_undecided;
  
    Elf_Data *symdata = elf_getdata (symscn, NULL);
    enum load_state state = state_undecided;
  
      {
        GElf_Rela rela_mem;
        GElf_Rela *rela = gelf_getrela (data, cnt, &rela_mem);
      {
        GElf_Rela rela_mem;
        GElf_Rela *rela = gelf_getrela (data, cnt, &rela_mem);
-@@ -1497,7 +1515,8 @@ check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GE
+@@ -1499,7 +1517,8 @@ check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GE
    Elf_Data *symdata = elf_getdata (symscn, NULL);
    enum load_state state = state_undecided;
  
    Elf_Data *symdata = elf_getdata (symscn, NULL);
    enum load_state state = state_undecided;
  
      {
        GElf_Rel rel_mem;
        GElf_Rel *rel = gelf_getrel (data, cnt, &rel_mem);
      {
        GElf_Rel rel_mem;
        GElf_Rel *rel = gelf_getrel (data, cnt, &rel_mem);
-@@ -1600,7 +1619,8 @@ section [%2d] '%s': referenced as string
+@@ -1598,7 +1617,8 @@ section [%2d] '%s': referenced as string
           shdr->sh_link, section_name (ebl, shdr->sh_link),
           idx, section_name (ebl, idx));
  
           shdr->sh_link, section_name (ebl, shdr->sh_link),
           idx, section_name (ebl, idx));
  
      ERROR (gettext ("\
  section [%2d] '%s': section entry size does not match ElfXX_Dyn\n"),
           idx, section_name (ebl, idx));
      ERROR (gettext ("\
  section [%2d] '%s': section entry size does not match ElfXX_Dyn\n"),
           idx, section_name (ebl, idx));
-@@ -1610,7 +1630,7 @@ section [%2d] '%s': section entry size d
+@@ -1608,7 +1628,7 @@ section [%2d] '%s': section entry size d
           idx, section_name (ebl, idx));
  
    bool non_null_warned = false;
           idx, section_name (ebl, idx));
  
    bool non_null_warned = false;
      {
        GElf_Dyn dyn_mem;
        GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dyn_mem);
      {
        GElf_Dyn dyn_mem;
        GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dyn_mem);
-@@ -1891,6 +1911,8 @@ section [%2d] '%s': entry size does not 
+@@ -1880,6 +1900,8 @@ section [%2d] '%s': entry size does not
           idx, section_name (ebl, idx));
  
    if (symshdr != NULL
           idx, section_name (ebl, idx));
  
    if (symshdr != NULL
        && (shdr->sh_size / shdr->sh_entsize
          < symshdr->sh_size / symshdr->sh_entsize))
      ERROR (gettext ("\
        && (shdr->sh_size / shdr->sh_entsize
          < symshdr->sh_size / symshdr->sh_entsize))
      ERROR (gettext ("\
-@@ -1917,6 +1939,12 @@ section [%2d] '%s': extended section ind
+@@ -1906,6 +1928,12 @@ section [%2d] '%s': extended section ind
      }
  
    Elf_Data *data = elf_getdata (elf_getscn (ebl->elf, idx), NULL);
      }
  
    Elf_Data *data = elf_getdata (elf_getscn (ebl->elf, idx), NULL);
  
    if (*((Elf32_Word *) data->d_buf) != 0)
      ERROR (gettext ("symbol 0 should have zero extended section index\n"));
  
    if (*((Elf32_Word *) data->d_buf) != 0)
      ERROR (gettext ("symbol 0 should have zero extended section index\n"));
-@@ -1959,7 +1987,7 @@ section [%2d] '%s': hash table section i
+@@ -1948,7 +1976,7 @@ section [%2d] '%s': hash table section i
  
    size_t maxidx = nchain;
  
  
    size_t maxidx = nchain;
  
      {
        size_t symsize = symshdr->sh_size / symshdr->sh_entsize;
  
      {
        size_t symsize = symshdr->sh_size / symshdr->sh_entsize;
  
-@@ -1970,18 +1998,28 @@ section [%2d] '%s': hash table section i
+@@ -1959,18 +1987,28 @@ section [%2d] '%s': hash table section i
        maxidx = symsize;
      }
  
        maxidx = symsize;
      }
  
  }
  
  
  }
  
  
-@@ -2011,18 +2049,28 @@ section [%2d] '%s': hash table section i
+@@ -2000,18 +2038,28 @@ section [%2d] '%s': hash table section i
        maxidx = symsize;
      }
  
        maxidx = symsize;
      }
  
  }
  
  
  }
  
  
-@@ -2047,7 +2095,7 @@ section [%2d] '%s': bitmask size not pow
+@@ -2036,7 +2084,7 @@ section [%2d] '%s': bitmask size not pow
    if (shdr->sh_size < (4 + bitmask_words + nbuckets) * sizeof (Elf32_Word))
      {
        ERROR (gettext ("\
    if (shdr->sh_size < (4 + bitmask_words + nbuckets) * sizeof (Elf32_Word))
      {
        ERROR (gettext ("\
             idx, section_name (ebl, idx), (long int) shdr->sh_size,
             (long int) ((4 + bitmask_words + nbuckets) * sizeof (Elf32_Word)));
        return;
             idx, section_name (ebl, idx), (long int) shdr->sh_size,
             (long int) ((4 + bitmask_words + nbuckets) * sizeof (Elf32_Word)));
        return;
-@@ -2719,8 +2767,9 @@ section [%2d] '%s' refers in sh_link to 
+@@ -2708,8 +2756,9 @@ section [%2d] '%s' refers in sh_link to
  
    /* The number of elements in the version symbol table must be the
       same as the number of symbols.  */
  
    /* The number of elements in the version symbol table must be the
       same as the number of symbols.  */
           idx, section_name (ebl, idx),
 --- elfutils/src/readelf.c
 +++ elfutils/src/readelf.c
           idx, section_name (ebl, idx),
 --- elfutils/src/readelf.c
 +++ elfutils/src/readelf.c
-@@ -1178,6 +1178,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G
+@@ -1363,6 +1363,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G
    Elf32_Word *grpref = (Elf32_Word *) data->d_buf;
  
    GElf_Sym sym_mem;
    Elf32_Word *grpref = (Elf32_Word *) data->d_buf;
  
    GElf_Sym sym_mem;
    printf ((grpref[0] & GRP_COMDAT)
          ? ngettext ("\
  \nCOMDAT section group [%2zu] '%s' with signature '%s' contains %zu entry:\n",
    printf ((grpref[0] & GRP_COMDAT)
          ? ngettext ("\
  \nCOMDAT section group [%2zu] '%s' with signature '%s' contains %zu entry:\n",
-@@ -1190,8 +1192,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G
+@@ -1375,8 +1377,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G
                      data->d_size / sizeof (Elf32_Word) - 1),
          elf_ndxscn (scn),
          elf_strptr (ebl->elf, shstrndx, shdr->sh_name),
                      data->d_size / sizeof (Elf32_Word) - 1),
          elf_ndxscn (scn),
          elf_strptr (ebl->elf, shstrndx, shdr->sh_name),
          ?: gettext ("<INVALID SYMBOL>"),
          data->d_size / sizeof (Elf32_Word) - 1);
  
          ?: gettext ("<INVALID SYMBOL>"),
          data->d_size / sizeof (Elf32_Word) - 1);
  
-@@ -1342,7 +1344,8 @@ static void
+@@ -1527,10 +1529,12 @@ static void
  handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
  {
    int class = gelf_getclass (ebl->elf);
  handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
  {
    int class = gelf_getclass (ebl->elf);
    Elf_Data *data;
    size_t cnt;
    size_t shstrndx;
    Elf_Data *data;
    size_t cnt;
    size_t shstrndx;
-@@ -1357,6 +1360,11 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, 
++  size_t sh_entsize;
+   /* Get the data of the section.  */
+   data = elf_getdata (scn, NULL);
+@@ -1542,21 +1546,26 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn,
      error (EXIT_FAILURE, 0,
           gettext ("cannot get section header string table index"));
  
      error (EXIT_FAILURE, 0,
           gettext ("cannot get section header string table index"));
  
++  sh_entsize = gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT);
++
 +  glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem);
 +  if (glink == NULL)
 +    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
 +  glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem);
 +  if (glink == NULL)
 +    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
    printf (ngettext ("\
  \nDynamic segment contains %lu entry:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'\n",
                    "\
    printf (ngettext ("\
  \nDynamic segment contains %lu entry:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'\n",
                    "\
-@@ -1366,9 +1374,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, 
+ \nDynamic segment contains %lu entries:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'\n",
+-                  shdr->sh_size / shdr->sh_entsize),
+-        (unsigned long int) (shdr->sh_size / shdr->sh_entsize),
++                  shdr->sh_size / sh_entsize),
++        (unsigned long int) (shdr->sh_size / sh_entsize),
          class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
          shdr->sh_offset,
          (int) shdr->sh_link,
          class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
          shdr->sh_offset,
          (int) shdr->sh_link,
 +        elf_strptr (ebl->elf, shstrndx, glink->sh_name));
    fputs_unlocked (gettext ("  Type              Value\n"), stdout);
  
 +        elf_strptr (ebl->elf, shstrndx, glink->sh_name));
    fputs_unlocked (gettext ("  Type              Value\n"), stdout);
  
-   for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
-@@ -1951,6 +1957,13 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
+-  for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
++  for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
+     {
+       GElf_Dyn dynmem;
+       GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dynmem);
+@@ -1705,7 +1714,8 @@ static void
+ handle_relocs_rel (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr)
+ {
+   int class = gelf_getclass (ebl->elf);
+-  int nentries = shdr->sh_size / shdr->sh_entsize;
++  size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT);
++  int nentries = shdr->sh_size / sh_entsize;
+   /* Get the data of the section.  */
+   Elf_Data *data = elf_getdata (scn, NULL);
+@@ -1891,7 +1901,8 @@ static void
+ handle_relocs_rela (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr)
+ {
+   int class = gelf_getclass (ebl->elf);
+-  int nentries = shdr->sh_size / shdr->sh_entsize;
++  size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT);
++  int nentries = shdr->sh_size / sh_entsize;
+   /* Get the data of the section.  */
+   Elf_Data *data = elf_getdata (scn, NULL);
+@@ -2138,6 +2149,13 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
      error (EXIT_FAILURE, 0,
           gettext ("cannot get section header string table index"));
  
      error (EXIT_FAILURE, 0,
           gettext ("cannot get section header string table index"));
  
    /* Now we can compute the number of entries in the section.  */
    unsigned int nsyms = data->d_size / (class == ELFCLASS32
                                       ? sizeof (Elf32_Sym)
    /* Now we can compute the number of entries in the section.  */
    unsigned int nsyms = data->d_size / (class == ELFCLASS32
                                       ? sizeof (Elf32_Sym)
-@@ -1961,15 +1974,12 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
+@@ -2148,15 +2166,12 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
                    nsyms),
          (unsigned int) elf_ndxscn (scn),
          elf_strptr (ebl->elf, shstrndx, shdr->sh_name), nsyms);
                    nsyms),
          (unsigned int) elf_ndxscn (scn),
          elf_strptr (ebl->elf, shstrndx, shdr->sh_name), nsyms);
  
    fputs_unlocked (class == ELFCLASS32
                  ? gettext ("\
  
    fputs_unlocked (class == ELFCLASS32
                  ? gettext ("\
-@@ -2205,7 +2215,13 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn, 
+@@ -2392,7 +2407,13 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn,
      error (EXIT_FAILURE, 0,
           gettext ("cannot get section header string table index"));
  
      error (EXIT_FAILURE, 0,
           gettext ("cannot get section header string table index"));
  
    printf (ngettext ("\
  \nVersion needs section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'\n",
                    "\
    printf (ngettext ("\
  \nVersion needs section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'\n",
                    "\
-@@ -2216,9 +2232,7 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn, 
+@@ -2403,9 +2424,7 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn,
          class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
          shdr->sh_offset,
          (unsigned int) shdr->sh_link,
          class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
          shdr->sh_offset,
          (unsigned int) shdr->sh_link,
  
    unsigned int offset = 0;
    for (int cnt = shdr->sh_info; --cnt >= 0; )
  
    unsigned int offset = 0;
    for (int cnt = shdr->sh_info; --cnt >= 0; )
-@@ -2271,8 +2285,14 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G
+@@ -2458,8 +2477,14 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G
      error (EXIT_FAILURE, 0,
           gettext ("cannot get section header string table index"));
  
      error (EXIT_FAILURE, 0,
           gettext ("cannot get section header string table index"));
  
    printf (ngettext ("\
  \nVersion definition section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'\n",
                    "\
    printf (ngettext ("\
  \nVersion definition section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'\n",
                    "\
-@@ -2284,9 +2304,7 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G
+@@ -2471,9 +2496,7 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G
          class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
          shdr->sh_offset,
          (unsigned int) shdr->sh_link,
          class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
          shdr->sh_offset,
          (unsigned int) shdr->sh_link,
  
    unsigned int offset = 0;
    for (int cnt = shdr->sh_info; --cnt >= 0; )
  
    unsigned int offset = 0;
    for (int cnt = shdr->sh_info; --cnt >= 0; )
-@@ -2548,8 +2566,14 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G
+@@ -2735,25 +2758,30 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G
        filename = NULL;
      }
  
 +  GElf_Shdr glink_mem;
 +  GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
 +                                 &glink_mem);
        filename = NULL;
      }
  
 +  GElf_Shdr glink_mem;
 +  GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
 +                                 &glink_mem);
++  size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_HALF, 1, EV_CURRENT);
 +  if (glink == NULL)
 +    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
 +         elf_ndxscn (scn));
 +  if (glink == NULL)
 +    error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
 +         elf_ndxscn (scn));
    printf (ngettext ("\
  \nVersion symbols section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'",
                    "\
    printf (ngettext ("\
  \nVersion symbols section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'",
                    "\
-@@ -2561,9 +2585,7 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G
+ \nVersion symbols section [%2u] '%s' contains %d entries:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'",
+-                  shdr->sh_size / shdr->sh_entsize),
++                  shdr->sh_size / sh_entsize),
+         (unsigned int) elf_ndxscn (scn),
+         elf_strptr (ebl->elf, shstrndx, shdr->sh_name),
+-        (int) (shdr->sh_size / shdr->sh_entsize),
++        (int) (shdr->sh_size / sh_entsize),
          class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
          shdr->sh_offset,
          (unsigned int) shdr->sh_link,
          class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
          shdr->sh_offset,
          (unsigned int) shdr->sh_link,
 +        elf_strptr (ebl->elf, shstrndx, glink->sh_name));
  
    /* Now we can finally look at the actual contents of this section.  */
 +        elf_strptr (ebl->elf, shstrndx, glink->sh_name));
  
    /* Now we can finally look at the actual contents of this section.  */
-   for (unsigned int cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
-@@ -2615,7 +2637,17 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn,
+-  for (unsigned int cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
++  for (unsigned int cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
+     {
+       if (cnt % 2 == 0)
+       printf ("\n %4d:", cnt);
+@@ -2802,7 +2830,17 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn,
    for (Elf32_Word cnt = 0; cnt < nbucket; ++cnt)
      ++counts[lengths[cnt]];
  
    for (Elf32_Word cnt = 0; cnt < nbucket; ++cnt)
      ++counts[lengths[cnt]];
  
    printf (ngettext ("\
  \nHistogram for bucket list length in section [%2u] '%s' (total of %d bucket):\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'\n",
                    "\
    printf (ngettext ("\
  \nHistogram for bucket list length in section [%2u] '%s' (total of %d bucket):\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'\n",
                    "\
-@@ -2628,9 +2660,7 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn,
+@@ -2815,9 +2853,7 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn,
          shdr->sh_addr,
          shdr->sh_offset,
          (unsigned int) shdr->sh_link,
          shdr->sh_addr,
          shdr->sh_offset,
          (unsigned int) shdr->sh_link,
  
    if (extrastr != NULL)
      fputs (extrastr, stdout);
  
    if (extrastr != NULL)
      fputs (extrastr, stdout);
-@@ -4486,6 +4516,16 @@ print_debug_aranges_section (Dwfl_Module
+@@ -3077,7 +3113,8 @@ print_liblist (Ebl *ebl)
+       if (shdr != NULL && shdr->sh_type == SHT_GNU_LIBLIST)
+       {
+-        int nentries = shdr->sh_size / shdr->sh_entsize;
++        size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_LIB, 1, EV_CURRENT);
++        int nentries = shdr->sh_size / sh_entsize;
+         printf (ngettext ("\
+ \nLibrary list section [%2zu] '%s' at offset %#0" PRIx64 " contains %d entry:\n",
+                           "\
+@@ -4397,6 +4434,16 @@ print_decoded_aranges_section (Ebl *ebl,
        return;
      }
  
        return;
      }
  
                    "\
 --- elfutils/src/strip.c
 +++ elfutils/src/strip.c
                    "\
 --- elfutils/src/strip.c
 +++ elfutils/src/strip.c
-@@ -555,6 +555,11 @@ handle_elf (int fd, Elf *elf, const char
+@@ -565,6 +565,11 @@ handle_elf (int fd, Elf *elf, const char
        goto fail_close;
      }
  
        goto fail_close;
      }
  
    /* Storage for section information.  We leave room for two more
       entries since we unconditionally create a section header string
       table.  Maybe some weird tool created an ELF file without one.
    /* Storage for section information.  We leave room for two more
       entries since we unconditionally create a section header string
       table.  Maybe some weird tool created an ELF file without one.
-@@ -576,7 +581,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -586,7 +591,7 @@ handle_elf (int fd, Elf *elf, const char
      {
        /* This should always be true (i.e., there should not be any
         holes in the numbering).  */
      {
        /* This should always be true (i.e., there should not be any
         holes in the numbering).  */
  
        shdr_info[cnt].scn = scn;
  
  
        shdr_info[cnt].scn = scn;
  
-@@ -589,6 +594,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -599,6 +604,7 @@ handle_elf (int fd, Elf *elf, const char
                                        shdr_info[cnt].shdr.sh_name);
        if (shdr_info[cnt].name == NULL)
        {
                                        shdr_info[cnt].shdr.sh_name);
        if (shdr_info[cnt].name == NULL)
        {
          error (0, 0, gettext ("illformed file '%s'"), fname);
          goto fail_close;
        }
          error (0, 0, gettext ("illformed file '%s'"), fname);
          goto fail_close;
        }
-@@ -598,6 +604,8 @@ handle_elf (int fd, Elf *elf, const char
+@@ -608,6 +614,8 @@ handle_elf (int fd, Elf *elf, const char
  
        /* Remember the shdr.sh_link value.  */
        shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link;
  
        /* Remember the shdr.sh_link value.  */
        shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link;
  
        /* Sections in files other than relocatable object files which
         are not loaded can be freely moved by us.  In relocatable
  
        /* Sections in files other than relocatable object files which
         are not loaded can be freely moved by us.  In relocatable
-@@ -610,7 +618,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -620,7 +628,7 @@ handle_elf (int fd, Elf *elf, const char
         appropriate reference.  */
        if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX))
        {
         appropriate reference.  */
        if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX))
        {
          shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt;
        }
        else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP))
          shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt;
        }
        else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP))
-@@ -627,7 +635,12 @@ handle_elf (int fd, Elf *elf, const char
+@@ -637,7 +645,12 @@ handle_elf (int fd, Elf *elf, const char
          for (inner = 1;
               inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
               ++inner)
          for (inner = 1;
               inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
               ++inner)
  
          if (inner == 1 || (inner == 2 && (grpref[0] & GRP_COMDAT) == 0))
            /* If the section group contains only one element and this
  
          if (inner == 1 || (inner == 2 && (grpref[0] & GRP_COMDAT) == 0))
            /* If the section group contains only one element and this
-@@ -638,7 +651,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -648,7 +661,7 @@ handle_elf (int fd, Elf *elf, const char
        }
        else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym))
        {
        }
        else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym))
        {
          shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt;
        }
  
          shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt;
        }
  
-@@ -646,7 +659,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -656,7 +669,7 @@ handle_elf (int fd, Elf *elf, const char
         discarded right away.  */
        if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0)
        {
         discarded right away.  */
        if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0)
        {
  
          if (shdr_info[shdr_info[cnt].group_idx].idx == 0)
            {
  
          if (shdr_info[shdr_info[cnt].group_idx].idx == 0)
            {
-@@ -722,11 +735,15 @@ handle_elf (int fd, Elf *elf, const char
+@@ -732,10 +745,14 @@ handle_elf (int fd, Elf *elf, const char
            {
              /* If a relocation section is marked as being removed make
                 sure the section it is relocating is removed, too.  */
            {
              /* If a relocation section is marked as being removed make
                 sure the section it is relocating is removed, too.  */
 +            if (shdr_info[cnt].shdr.sh_type == SHT_REL
                   || shdr_info[cnt].shdr.sh_type == SHT_RELA)
 -                && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
 +            if (shdr_info[cnt].shdr.sh_type == SHT_REL
                   || shdr_info[cnt].shdr.sh_type == SHT_RELA)
 -                && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
+-              shdr_info[cnt].idx = 1;
 +              {
 +                if (shdr_info[cnt].shdr.sh_info >= shnum)
 +                  goto illformed;
 +                else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
 +              {
 +                if (shdr_info[cnt].shdr.sh_info >= shnum)
 +                  goto illformed;
 +                else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
-               shdr_info[cnt].idx = 1;
-           }
-+          }
++                  shdr_info[cnt].idx = 1;
++              }
  
  
-         if (shdr_info[cnt].idx == 1)
-           {
-@@ -753,7 +770,7 @@ handle_elf (int fd, Elf *elf, const char
+             /* If a group section is marked as being removed make
+                sure all the sections it contains are being removed, too.  */
+@@ -779,7 +796,7 @@ handle_elf (int fd, Elf *elf, const char
                  if (shdr_info[cnt].symtab_idx != 0
                      && shdr_info[shdr_info[cnt].symtab_idx].data == NULL)
                    {
                  if (shdr_info[cnt].symtab_idx != 0
                      && shdr_info[shdr_info[cnt].symtab_idx].data == NULL)
                    {
  
                      shdr_info[shdr_info[cnt].symtab_idx].data
                        = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
  
                      shdr_info[shdr_info[cnt].symtab_idx].data
                        = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
-@@ -793,6 +810,9 @@ handle_elf (int fd, Elf *elf, const char
+@@ -819,6 +836,9 @@ handle_elf (int fd, Elf *elf, const char
                      else if (scnidx == SHN_XINDEX)
                        scnidx = xndx;
  
                      else if (scnidx == SHN_XINDEX)
                        scnidx = xndx;
  
                      if (shdr_info[scnidx].idx == 0)
                        /* This symbol table has a real symbol in
                           a discarded section.  So preserve the
                      if (shdr_info[scnidx].idx == 0)
                        /* This symbol table has a real symbol in
                           a discarded section.  So preserve the
-@@ -823,12 +843,16 @@ handle_elf (int fd, Elf *elf, const char
+@@ -849,12 +869,16 @@ handle_elf (int fd, Elf *elf, const char
                }
  
              /* Handle references through sh_info.  */
                }
  
              /* Handle references through sh_info.  */
  
              /* Mark the section as investigated.  */
              shdr_info[cnt].idx = 2;
  
              /* Mark the section as investigated.  */
              shdr_info[cnt].idx = 2;
-@@ -967,7 +991,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -995,7 +1019,7 @@ handle_elf (int fd, Elf *elf, const char
          error (EXIT_FAILURE, 0, gettext ("while generating output file: %s"),
                 elf_errmsg (-1));
  
          error (EXIT_FAILURE, 0, gettext ("while generating output file: %s"),
                 elf_errmsg (-1));
  
  
        /* Add this name to the section header string table.  */
        shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
  
        /* Add this name to the section header string table.  */
        shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
-@@ -1004,7 +1028,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1032,7 +1056,7 @@ handle_elf (int fd, Elf *elf, const char
        error (EXIT_FAILURE, 0,
               gettext ("while create section header section: %s"),
               elf_errmsg (-1));
        error (EXIT_FAILURE, 0,
               gettext ("while create section header section: %s"),
               elf_errmsg (-1));
  
        shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn);
        if (shdr_info[cnt].data == NULL)
  
        shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn);
        if (shdr_info[cnt].data == NULL)
-@@ -1060,7 +1084,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1089,7 +1113,7 @@ handle_elf (int fd, Elf *elf, const char
      error (EXIT_FAILURE, 0,
           gettext ("while create section header section: %s"),
           elf_errmsg (-1));
      error (EXIT_FAILURE, 0,
           gettext ("while create section header section: %s"),
           elf_errmsg (-1));
  
    /* Finalize the string table and fill in the correct indices in the
       section headers.  */
  
    /* Finalize the string table and fill in the correct indices in the
       section headers.  */
-@@ -1150,20 +1174,20 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1179,20 +1203,20 @@ handle_elf (int fd, Elf *elf, const char
                    shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
                                             NULL);
  
                    shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
                                             NULL);
  
                            >= shdr_info[cnt].data->d_size / elsize);
                  }
  
                            >= shdr_info[cnt].data->d_size / elsize);
                  }
  
-@@ -1218,7 +1242,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1247,7 +1271,7 @@ handle_elf (int fd, Elf *elf, const char
                      sec = shdr_info[sym->st_shndx].idx;
                    else
                      {
                      sec = shdr_info[sym->st_shndx].idx;
                    else
                      {
  
                        sec = shdr_info[xshndx].idx;
                      }
  
                        sec = shdr_info[xshndx].idx;
                      }
-@@ -1239,7 +1263,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1268,7 +1292,7 @@ handle_elf (int fd, Elf *elf, const char
                            nxshndx = sec;
                          }
  
                            nxshndx = sec;
                          }
  
  
                        if ((inner != destidx || nshndx != sym->st_shndx
                             || (shndxdata != NULL && nxshndx != xshndx))
  
                        if ((inner != destidx || nshndx != sym->st_shndx
                             || (shndxdata != NULL && nxshndx != xshndx))
-@@ -1263,7 +1287,7 @@ handle_elf (int fd, Elf *elf, const char
-                            || shdr_info[cnt].debug_data == NULL)
-                     /* This is a section symbol for a section which has
-                        been removed.  */
--                    assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION);
-+                    elf_assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION);
+@@ -1295,9 +1319,11 @@ handle_elf (int fd, Elf *elf, const char
+                     {
+                       size_t sidx = (sym->st_shndx != SHN_XINDEX
+                                       ? sym->st_shndx : xshndx);
+-                      assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION
+-                              || (shdr_info[sidx].shdr.sh_type == SHT_GROUP
+-                                  && shdr_info[sidx].shdr.sh_info == inner));
++                      elf_assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION
++                                  || ((shdr_info[sidx].shdr.sh_type
++                                       == SHT_GROUP)
++                                      && (shdr_info[sidx].shdr.sh_info
++                                          == inner)));
+                     }
                  }
  
                  }
  
-               if (destidx != inner)
-@@ -1450,11 +1474,11 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1485,11 +1511,11 @@ handle_elf (int fd, Elf *elf, const char
                  {
                    GElf_Sym sym_mem;
                    GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
                  {
                    GElf_Sym sym_mem;
                    GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
                    size_t hidx = elf_hash (name) % nbucket;
  
                    if (bucket[hidx] == 0)
                    size_t hidx = elf_hash (name) % nbucket;
  
                    if (bucket[hidx] == 0)
-@@ -1473,7 +1497,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1508,8 +1534,8 @@ handle_elf (int fd, Elf *elf, const char
            else
              {
                /* Alpha and S390 64-bit use 64-bit SHT_HASH entries.  */
 -              assert (shdr_info[cnt].shdr.sh_entsize
            else
              {
                /* Alpha and S390 64-bit use 64-bit SHT_HASH entries.  */
 -              assert (shdr_info[cnt].shdr.sh_entsize
+-                      == sizeof (Elf64_Xword));
 +              elf_assert (shdr_info[cnt].shdr.sh_entsize
 +              elf_assert (shdr_info[cnt].shdr.sh_entsize
-                       == sizeof (Elf64_Xword));
++                            == sizeof (Elf64_Xword));
  
                Elf64_Xword *bucket = (Elf64_Xword *) hashd->d_buf;
  
                Elf64_Xword *bucket = (Elf64_Xword *) hashd->d_buf;
-@@ -1504,11 +1528,11 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1539,11 +1565,11 @@ handle_elf (int fd, Elf *elf, const char
                  {
                    GElf_Sym sym_mem;
                    GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
                  {
                    GElf_Sym sym_mem;
                    GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
This page took 0.111802 seconds and 4 git commands to generate.