libdw/ChangeLog           |   24 ++++++++++++++++++++++++
 libdw/dwarf_begin_elf.c   |   12 ++++++------
 libdw/dwarf_child.c       |    6 +++---
 libdw/dwarf_end.c         |   15 ++++++---------
 libdw/dwarf_formref_die.c |    2 +-
 libdw/dwarf_formstring.c  |    4 ++--
 libdw/dwarf_formudata.c   |    2 +-
 libdw/dwarf_getabbrev.c   |    6 +++---
 libdw/dwarf_getaranges.c  |   12 ++++++------
 libdw/dwarf_getattrs.c    |    4 ++--
 libdw/dwarf_getcfi.c      |    4 ++--
 libdw/dwarf_getmacros.c   |    2 +-
 libdw/dwarf_getpubnames.c |   20 ++++++++++++--------
 libdw/dwarf_getstring.c   |   12 +++++++-----
 libdw/dwarf_nextcu.c      |    8 ++++----
 libdw/dwarf_offdie.c      |    2 +-
 libdw/dwarf_ranges.c      |    2 +-
 libdw/libdwP.h            |   27 ++++++++++++++++++---------
 libdwfl/ChangeLog         |    4 ++++
 libdwfl/cu.c              |    3 ++-
 src/ChangeLog             |    6 ++++++
 src/readelf.c             |    4 ++--
 22 files changed, 114 insertions(+), 67 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 98b67f4..8a556ec 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,27 @@
+2012-03-20  Tom Tromey  <[email protected]>
+
+       * libdwP.h (struct Dwarf_Section): New.
+       (Dwarf_Section): New typedef.
+       (struct Dwarf) [sectiondata]: Change type.
+       [sectiondata_gzip_mask]: Remove.
+       (__libdw_checked_get_data, cu_data): Update.
+       * dwarf_ranges.c (dwarf_ranges): Update.
+       * dwarf_offdie.c (__libdw_offdie): Update.
+       * dwarf_nextcu.c (dwarf_next_unit): Update.
+       * dwarf_getstring.c (dwarf_getstring): Update.
+       * dwarf_getpubnames.c (get_offsets, dwarf_getpubnames): Update.
+       * dwarf_getmacros.c (dwarf_getmacros): Update.
+       * dwarf_getcfi.c (dwarf_getcfi): Update
+       * dwarf_getattrs.c (dwarf_getattrs): Update.
+       * dwarf_getaranges.c (dwarf_getaranges): Update.
+       * dwarf_getabbrev.c (__libdw_getabbrev): Update.
+       * dwarf_formudata.c (__libdw_formptr): Update.
+       * dwarf_formstring.c (dwarf_formstring): Update.
+       * dwarf_formref_die.c (dwarf_formref_die): Update.
+       * dwarf_end.c (__libdw_free_zdata): Rewrite.
+       * dwarf_child.c (__libdw_find_attr): Update.
+       * dwarf_begin_elf.c (check_section, valid_p): Update.
+
 2012-01-31  Mark Wielaard  <[email protected]>
 
        * dwarf_formudata.c (dwarf_formudata): Handle DW_FORM_sec_offset.
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index 9ec7d51..f7ae8ab 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -137,7 +137,7 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn 
*scn, bool inscngrp)
     if (strcmp (scnname, dwarf_scnnames[cnt]) == 0)
       {
        /* Found it.  Remember where the data is.  */
-       if (unlikely (result->sectiondata[cnt] != NULL))
+       if (unlikely (result->sectiondata[cnt].data != NULL))
          /* A section appears twice.  That's bad.  We ignore the section.  */
          break;
 
@@ -145,7 +145,7 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn 
*scn, bool inscngrp)
        Elf_Data *data = elf_getdata (scn, NULL);
        if (data != NULL && data->d_size != 0)
          /* Yep, there is actually data available.  */
-         result->sectiondata[cnt] = data;
+         result->sectiondata[cnt].data = data;
 
        break;
       }
@@ -155,7 +155,7 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn 
*scn, bool inscngrp)
       {
        /* A compressed section.  */
 
-       if (unlikely (result->sectiondata[cnt] != NULL))
+       if (unlikely (result->sectiondata[cnt].data != NULL))
          /* A section appears twice.  That's bad.  We ignore the section.  */
          break;
 
@@ -211,8 +211,8 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn 
*scn, bool inscngrp)
              free (zdata);
            else
              {
-               result->sectiondata[cnt] = zdata;
-               result->sectiondata_gzip_mask |= 1U << cnt;
+               result->sectiondata[cnt].data = zdata;
+               result->sectiondata[cnt].gzipped = 1;
              }
          }
 
@@ -235,7 +235,7 @@ valid_p (Dwarf *result)
      necessary.  For now we require only .debug_info.  Hopefully this
      is correct.  */
   if (likely (result != NULL)
-      && unlikely (result->sectiondata[IDX_debug_info] == NULL))
+      && unlikely (result->sectiondata[IDX_debug_info].data == NULL))
     {
       __libdw_free_zdata (result);
       __libdw_seterrno (DWARF_E_NO_DWARF);
diff --git a/libdw/dwarf_child.c b/libdw/dwarf_child.c
index 0c2df00..2a4cf12 100644
--- a/libdw/dwarf_child.c
+++ b/libdw/dwarf_child.c
@@ -1,5 +1,5 @@
 /* Return child of current DIE.
-   Copyright (C) 2003-2011 Red Hat, Inc.
+   Copyright (C) 2003-2012 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <[email protected]>, 2003.
 
@@ -88,8 +88,8 @@ __libdw_find_attr (Dwarf_Die *die, unsigned int search_name,
 
   /* Search the name attribute.  */
   unsigned char *const endp
-    = ((unsigned char *) dbg->sectiondata[IDX_debug_abbrev]->d_buf
-       + dbg->sectiondata[IDX_debug_abbrev]->d_size);
+    = ((unsigned char *) dbg->sectiondata[IDX_debug_abbrev].data->d_buf
+       + dbg->sectiondata[IDX_debug_abbrev].data->d_size);
 
   const unsigned char *attrp = die->abbrev->attrp;
   while (1)
diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c
index 1e733ca..2636c69 100644
--- a/libdw/dwarf_end.c
+++ b/libdw/dwarf_end.c
@@ -1,5 +1,5 @@
 /* Release debugging handling context.
-   Copyright (C) 2002-2011 Red Hat, Inc.
+   Copyright (C) 2002-2012 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <[email protected]>, 2002.
 
@@ -83,15 +83,12 @@ void
 internal_function
 __libdw_free_zdata (Dwarf *dwarf)
 {
-  unsigned int gzip_mask = dwarf->sectiondata_gzip_mask;
-  while (gzip_mask != 0)
+  size_t i;
+
+  for (i = 0; i < IDX_last; ++i)
     {
-      int i = ffs (gzip_mask);
-      assert (i > 0);
-      --i;
-      assert (i < IDX_last);
-      free (dwarf->sectiondata[i]);
-      gzip_mask &= ~(1U << i);
+      if (dwarf->sectiondata[i].gzipped)
+       free (dwarf->sectiondata[i].data);
     }
 }
 #endif
diff --git a/libdw/dwarf_formref_die.c b/libdw/dwarf_formref_die.c
index 3ec770d..88dc065 100644
--- a/libdw/dwarf_formref_die.c
+++ b/libdw/dwarf_formref_die.c
@@ -105,7 +105,7 @@ dwarf_formref_die (attr, result)
          }
        while (cu->type_sig8 != sig);
 
-      data = cu->dbg->sectiondata[IDX_debug_types];
+      data = cu->dbg->sectiondata[IDX_debug_types].data;
       offset = cu->type_offset;
     }
   else
diff --git a/libdw/dwarf_formstring.c b/libdw/dwarf_formstring.c
index 1dee9b2..85dbae4 100644
--- a/libdw/dwarf_formstring.c
+++ b/libdw/dwarf_formstring.c
@@ -72,7 +72,7 @@ dwarf_formstring (attrp)
   Dwarf *dbg = attrp->cu->dbg;
 
   if (unlikely (attrp->form != DW_FORM_strp)
-      || dbg->sectiondata[IDX_debug_str] == NULL)
+      || dbg->sectiondata[IDX_debug_str].data == NULL)
     {
       __libdw_seterrno (DWARF_E_NO_STRING);
       return NULL;
@@ -83,6 +83,6 @@ dwarf_formstring (attrp)
                           attrp->cu->offset_size, &off, IDX_debug_str, 1))
     return NULL;
 
-  return (const char *) dbg->sectiondata[IDX_debug_str]->d_buf + off;
+  return (const char *) dbg->sectiondata[IDX_debug_str].data->d_buf + off;
 }
 INTDEF(dwarf_formstring)
diff --git a/libdw/dwarf_formudata.c b/libdw/dwarf_formudata.c
index 07efbe0..b3a7520 100644
--- a/libdw/dwarf_formudata.c
+++ b/libdw/dwarf_formudata.c
@@ -63,7 +63,7 @@ __libdw_formptr (Dwarf_Attribute *attr, int sec_index,
   if (attr == NULL)
     return NULL;
 
-  const Elf_Data *d = attr->cu->dbg->sectiondata[sec_index];
+  const Elf_Data *d = attr->cu->dbg->sectiondata[sec_index].data;
   if (unlikely (d == NULL))
     {
       __libdw_seterrno (err_nodata);
diff --git a/libdw/dwarf_getabbrev.c b/libdw/dwarf_getabbrev.c
index 07bf6df..7b632c0 100644
--- a/libdw/dwarf_getabbrev.c
+++ b/libdw/dwarf_getabbrev.c
@@ -67,17 +67,17 @@ __libdw_getabbrev (dbg, cu, offset, lengthp, result)
      Dwarf_Abbrev *result;
 {
   /* Don't fail if there is not .debug_abbrev section.  */
-  if (dbg->sectiondata[IDX_debug_abbrev] == NULL)
+  if (dbg->sectiondata[IDX_debug_abbrev].data == NULL)
     return NULL;
 
-  if (offset >= dbg->sectiondata[IDX_debug_abbrev]->d_size)
+  if (offset >= dbg->sectiondata[IDX_debug_abbrev].data->d_size)
     {
       __libdw_seterrno (DWARF_E_INVALID_OFFSET);
       return NULL;
     }
 
   const unsigned char *abbrevp
-    = (unsigned char *) dbg->sectiondata[IDX_debug_abbrev]->d_buf + offset;
+    = (unsigned char *) dbg->sectiondata[IDX_debug_abbrev].data->d_buf + 
offset;
 
   if (*abbrevp == '\0')
     /* We are past the last entry.  */
diff --git a/libdw/dwarf_getaranges.c b/libdw/dwarf_getaranges.c
index f18d63d..e8f377e 100644
--- a/libdw/dwarf_getaranges.c
+++ b/libdw/dwarf_getaranges.c
@@ -89,7 +89,7 @@ dwarf_getaranges (dbg, aranges, naranges)
       return 0;
     }
 
-  if (dbg->sectiondata[IDX_debug_aranges] == NULL)
+  if (dbg->sectiondata[IDX_debug_aranges].data == NULL)
     {
       /* No such section.  */
       *aranges = NULL;
@@ -98,15 +98,15 @@ dwarf_getaranges (dbg, aranges, naranges)
       return 0;
     }
 
-  if (dbg->sectiondata[IDX_debug_aranges]->d_buf == NULL)
+  if (dbg->sectiondata[IDX_debug_aranges].data->d_buf == NULL)
     return -1;
 
   struct arangelist *arangelist = NULL;
   unsigned int narangelist = 0;
 
-  const unsigned char *readp = dbg->sectiondata[IDX_debug_aranges]->d_buf;
+  const unsigned char *readp = dbg->sectiondata[IDX_debug_aranges].data->d_buf;
   const unsigned char *readendp
-    = readp + dbg->sectiondata[IDX_debug_aranges]->d_size;
+    = readp + dbg->sectiondata[IDX_debug_aranges].data->d_size;
 
   while (readp < readendp)
     {
@@ -204,7 +204,7 @@ dwarf_getaranges (dbg, aranges, naranges)
          new_arange->arange.length = range_length;
 
          /* We store the actual CU DIE offset, not the CU header offset.  */
-         const char *cu_header = (dbg->sectiondata[IDX_debug_info]->d_buf
+         const char *cu_header = (dbg->sectiondata[IDX_debug_info].data->d_buf
                                   + offset);
          unsigned int offset_size;
          if (read_4ubyte_unaligned_noncvt (cu_header) == DWARF3_LENGTH_64_BIT)
@@ -221,7 +221,7 @@ dwarf_getaranges (dbg, aranges, naranges)
 
          /* Sanity-check the data.  */
          if (unlikely (new_arange->arange.offset
-                       >= dbg->sectiondata[IDX_debug_info]->d_size))
+                       >= dbg->sectiondata[IDX_debug_info].data->d_size))
            goto invalid;
        }
     }
diff --git a/libdw/dwarf_getattrs.c b/libdw/dwarf_getattrs.c
index 051dc25..f7b913e 100644
--- a/libdw/dwarf_getattrs.c
+++ b/libdw/dwarf_getattrs.c
@@ -92,8 +92,8 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) 
(Dwarf_Attribute *, void *),
     {
       /* Are we still in bounds?  */
       if (unlikely (attrp
-                   >= ((unsigned char *) 
dbg->sectiondata[IDX_debug_abbrev]->d_buf
-                       + dbg->sectiondata[IDX_debug_abbrev]->d_size)))
+                   >= ((unsigned char *) 
dbg->sectiondata[IDX_debug_abbrev].data->d_buf
+                       + dbg->sectiondata[IDX_debug_abbrev].data->d_size)))
        goto invalid_dwarf;
 
       /* Get attribute name and form.  */
diff --git a/libdw/dwarf_getcfi.c b/libdw/dwarf_getcfi.c
index c935631..f161b20 100644
--- a/libdw/dwarf_getcfi.c
+++ b/libdw/dwarf_getcfi.c
@@ -62,12 +62,12 @@ dwarf_getcfi (dbg)
   if (dbg == NULL)
     return NULL;
 
-  if (dbg->cfi == NULL && dbg->sectiondata[IDX_debug_frame] != NULL)
+  if (dbg->cfi == NULL && dbg->sectiondata[IDX_debug_frame].data != NULL)
     {
       Dwarf_CFI *cfi = libdw_typed_alloc (dbg, Dwarf_CFI);
 
       cfi->dbg = dbg;
-      cfi->data = (Elf_Data_Scn *) dbg->sectiondata[IDX_debug_frame];
+      cfi->data = (Elf_Data_Scn *) dbg->sectiondata[IDX_debug_frame].data;
 
       cfi->search_table = NULL;
       cfi->search_table_vaddr = 0;
diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c
index b9ec34b..21750ef 100644
--- a/libdw/dwarf_getmacros.c
+++ b/libdw/dwarf_getmacros.c
@@ -68,7 +68,7 @@ dwarf_getmacros (die, callback, arg, offset)
   if (die == NULL)
     return -1;
 
-  Elf_Data *d = die->cu->dbg->sectiondata[IDX_debug_macinfo];
+  Elf_Data *d = die->cu->dbg->sectiondata[IDX_debug_macinfo].data;
   if (unlikely (d == NULL) || unlikely (d->d_buf == NULL))
     {
       __libdw_seterrno (DWARF_E_NO_ENTRY);
diff --git a/libdw/dwarf_getpubnames.c b/libdw/dwarf_getpubnames.c
index 5560a75..c5fdfef 100644
--- a/libdw/dwarf_getpubnames.c
+++ b/libdw/dwarf_getpubnames.c
@@ -68,9 +68,11 @@ get_offsets (Dwarf *dbg)
   size_t cnt = 0;
   struct pubnames_s *mem = NULL;
   const size_t entsize = sizeof (struct pubnames_s);
-  unsigned char *const startp = dbg->sectiondata[IDX_debug_pubnames]->d_buf;
+  unsigned char *const startp
+    = dbg->sectiondata[IDX_debug_pubnames].data->d_buf;
   unsigned char *readp = startp;
-  unsigned char *endp = readp + dbg->sectiondata[IDX_debug_pubnames]->d_size;
+  unsigned char *endp
+    = readp + dbg->sectiondata[IDX_debug_pubnames].data->d_size;
 
   while (readp + 14 < endp)
     {
@@ -109,7 +111,8 @@ get_offsets (Dwarf *dbg)
       /* Now we know the offset of the first offset/name pair.  */
       mem[cnt].set_start = readp + 2 + 2 * len_bytes - startp;
       mem[cnt].address_len = len_bytes;
-      if (mem[cnt].set_start >= dbg->sectiondata[IDX_debug_pubnames]->d_size)
+      if (mem[cnt].set_start
+         >= dbg->sectiondata[IDX_debug_pubnames].data->d_size)
        /* Something wrong, the first entry is beyond the end of
           the section.  */
        break;
@@ -130,7 +133,7 @@ get_offsets (Dwarf *dbg)
 
       /* Determine the size of the CU header.  */
       unsigned char *infop
-       = ((unsigned char *) dbg->sectiondata[IDX_debug_info]->d_buf
+       = ((unsigned char *) dbg->sectiondata[IDX_debug_info].data->d_buf
           + mem[cnt].cu_offset);
       if (read_4ubyte_unaligned_noncvt (infop) == DWARF3_LENGTH_64_BIT)
        mem[cnt].cu_header_size = 23;
@@ -173,9 +176,9 @@ dwarf_getpubnames (dbg, callback, arg, offset)
     }
 
   /* Make sure it is a valid offset.  */
-  if (unlikely (dbg->sectiondata[IDX_debug_pubnames] == NULL
+  if (unlikely (dbg->sectiondata[IDX_debug_pubnames].data == NULL
                || ((size_t) offset
-                   >= dbg->sectiondata[IDX_debug_pubnames]->d_size)))
+                   >= dbg->sectiondata[IDX_debug_pubnames].data->d_size)))
     /* No (more) entry.  */
     return 0;
 
@@ -203,7 +206,7 @@ dwarf_getpubnames (dbg, callback, arg, offset)
     }
 
   unsigned char *startp
-    = (unsigned char *) dbg->sectiondata[IDX_debug_pubnames]->d_buf;
+    = (unsigned char *) dbg->sectiondata[IDX_debug_pubnames].data->d_buf;
   unsigned char *readp = startp + offset;
   while (1)
     {
@@ -243,7 +246,8 @@ dwarf_getpubnames (dbg, callback, arg, offset)
        /* This was the last set.  */
        break;
 
-      startp = (unsigned char *) dbg->sectiondata[IDX_debug_pubnames]->d_buf;
+      startp
+       = (unsigned char *) dbg->sectiondata[IDX_debug_pubnames].data->d_buf;
       readp = startp + dbg->pubnames_sets[cnt].set_start;
     }
 
diff --git a/libdw/dwarf_getstring.c b/libdw/dwarf_getstring.c
index d5e7abf..04e6295 100644
--- a/libdw/dwarf_getstring.c
+++ b/libdw/dwarf_getstring.c
@@ -65,18 +65,20 @@ dwarf_getstring (dbg, offset, lenp)
   if (dbg == NULL)
     return NULL;
 
-  if (dbg->sectiondata[IDX_debug_str] == NULL
-      || offset >= dbg->sectiondata[IDX_debug_str]->d_size)
+  if (dbg->sectiondata[IDX_debug_str].data == NULL
+      || offset >= dbg->sectiondata[IDX_debug_str].data->d_size)
     {
     no_string:
       __libdw_seterrno (DWARF_E_NO_STRING);
       return NULL;
     }
 
-  const char *result = ((const char *) dbg->sectiondata[IDX_debug_str]->d_buf
-                       + offset);
+  const char *result
+    = ((const char *) dbg->sectiondata[IDX_debug_str].data->d_buf
+       + offset);
   const char *endp = memchr (result, '\0',
-                            dbg->sectiondata[IDX_debug_str]->d_size - offset);
+                            dbg->sectiondata[IDX_debug_str].data->d_size
+                            - offset);
   if (endp == NULL)
     goto no_string;
 
diff --git a/libdw/dwarf_nextcu.c b/libdw/dwarf_nextcu.c
index 2e8f4d7..66dd191 100644
--- a/libdw/dwarf_nextcu.c
+++ b/libdw/dwarf_nextcu.c
@@ -79,11 +79,11 @@ dwarf_next_unit (dwarf, off, next_off, header_sizep, 
versionp, abbrev_offsetp,
 
   /* If we reached the end before don't do anything.  */
   if (off == (Dwarf_Off) -1l
-      || unlikely (dwarf->sectiondata[sec_idx] == NULL)
+      || unlikely (dwarf->sectiondata[sec_idx].data == NULL)
       /* Make sure there is enough space in the .debug_info section
         for at least the initial word.  We cannot test the rest since
         we don't know yet whether this is a 64-bit object or not.  */
-      || unlikely (off + 4 >= dwarf->sectiondata[sec_idx]->d_size))
+      || unlikely (off + 4 >= dwarf->sectiondata[sec_idx].data->d_size))
     {
       *next_off = (Dwarf_Off) -1l;
       return 1;
@@ -91,7 +91,7 @@ dwarf_next_unit (dwarf, off, next_off, header_sizep, 
versionp, abbrev_offsetp,
 
   /* This points into the .debug_info section to the beginning of the
      CU entry.  */
-  const unsigned char *data = dwarf->sectiondata[sec_idx]->d_buf;
+  const unsigned char *data = dwarf->sectiondata[sec_idx].data->d_buf;
   const unsigned char *bytes = data + off;
 
   /* The format of the CU header is described in dwarf2p1 7.5.1:
@@ -136,7 +136,7 @@ dwarf_next_unit (dwarf, off, next_off, header_sizep, 
versionp, abbrev_offsetp,
 
   /* Now we know how large the header is.  */
   if (unlikely (DIE_OFFSET_FROM_CU_OFFSET (off, offset_size, debug_types)
-               >= dwarf->sectiondata[sec_idx]->d_size))
+               >= dwarf->sectiondata[sec_idx].data->d_size))
     {
       *next_off = -1;
       return 1;
diff --git a/libdw/dwarf_offdie.c b/libdw/dwarf_offdie.c
index 4c650cf..90ada60 100644
--- a/libdw/dwarf_offdie.c
+++ b/libdw/dwarf_offdie.c
@@ -65,7 +65,7 @@ __libdw_offdie (Dwarf *dbg, Dwarf_Off offset, Dwarf_Die 
*result,
     return NULL;
 
   Elf_Data *const data = dbg->sectiondata[debug_types ? IDX_debug_types
-                                         : IDX_debug_info];
+                                         : IDX_debug_info].data;
   if (offset >= data->d_size)
     {
       __libdw_seterrno (DWARF_E_INVALID_DWARF);
diff --git a/libdw/dwarf_ranges.c b/libdw/dwarf_ranges.c
index 50fb6ba..035f4c4 100644
--- a/libdw/dwarf_ranges.c
+++ b/libdw/dwarf_ranges.c
@@ -123,7 +123,7 @@ dwarf_ranges (Dwarf_Die *die, ptrdiff_t offset, Dwarf_Addr 
*basep,
 
   /* We have to look for a noncontiguous range.  */
 
-  const Elf_Data *d = die->cu->dbg->sectiondata[IDX_debug_ranges];
+  const Elf_Data *d = die->cu->dbg->sectiondata[IDX_debug_ranges].data;
   if (d == NULL && offset != 0)
     {
       __libdw_seterrno (DWARF_E_NO_DEBUG_RANGES);
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index b84bf02..1505512 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -1,5 +1,5 @@
 /* Internal definitions for libdwarf.
-   Copyright (C) 2002-2011 Red Hat, Inc.
+   Copyright (C) 2002-2012 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <[email protected]>, 2002.
 
@@ -141,6 +141,20 @@ enum
 
 #include "dwarf_sig8_hash.h"
 
+/* This represents a single DWARF section.  */
+struct Dwarf_Section
+{
+  /* The section data.  */
+  Elf_Data *data;
+
+#if USE_ZLIB
+  /* True if the section data is malloc'd decompressed data.  */
+  unsigned int gzipped : 1;
+#endif
+};
+
+typedef struct Dwarf_Section Dwarf_Section;
+
 /* This is the structure representing the debugging state.  */
 struct Dwarf
 {
@@ -148,12 +162,7 @@ struct Dwarf
   Elf *elf;
 
   /* The section data.  */
-  Elf_Data *sectiondata[IDX_last];
-
-#if USE_ZLIB
-  /* The 1 << N bit is set if sectiondata[N] is malloc'd decompressed data.  */
-  unsigned int sectiondata_gzip_mask:IDX_last;
-#endif
+  struct Dwarf_Section sectiondata[IDX_last];
 
   /* True if the file has a byte order different from the host.  */
   bool other_byte_order;
@@ -506,7 +515,7 @@ __libdw_relocate_offset (Dwarf *dbg __attribute__ 
((unused)),
 static inline Elf_Data *
 __libdw_checked_get_data (Dwarf *dbg, int sec_index)
 {
-  Elf_Data *data = dbg->sectiondata[sec_index];
+  Elf_Data *data = dbg->sectiondata[sec_index].data;
   if (unlikely (data == NULL)
       || unlikely (data->d_buf == NULL))
     {
@@ -618,7 +627,7 @@ cu_sec_idx (struct Dwarf_CU *cu)
 static inline Elf_Data *
 cu_data (struct Dwarf_CU *cu)
 {
-  return cu->dbg->sectiondata[cu_sec_idx (cu)];
+  return cu->dbg->sectiondata[cu_sec_idx (cu)].data;
 }
 
 /* Read up begin/end pair and increment read pointer.
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 87a0555..b25d87d 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2012-03-20  Tom Tromey  <[email protected]>
+
+       * cu.c (intern_cu): Update for change to sectiondata.
+
 2011-12-02  Roland McGrath  <[email protected]>
 
        * elf-from-memory.c (elf_from_remote_memory): Fix ELFCLASS64 case
diff --git a/libdwfl/cu.c b/libdwfl/cu.c
index 515aff3..353b915 100644
--- a/libdwfl/cu.c
+++ b/libdwfl/cu.c
@@ -197,7 +197,8 @@ intern_cu (Dwfl_Module *mod, Dwarf_Off cuoff, struct 
dwfl_cu **result)
 
   if (*found == &key || *found == NULL)
     {
-      if (unlikely (cuoff + 4 >= mod->dw->sectiondata[IDX_debug_info]->d_size))
+      if (unlikely (cuoff + 4
+                   >= mod->dw->sectiondata[IDX_debug_info].data->d_size))
        {
          /* This is the EOF marker.  Now we have interned all the CUs.
             One increment in MOD->lazycu counts not having hit EOF yet.  */
diff --git a/src/ChangeLog b/src/ChangeLog
index ff19b48..7f9a9d3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-20  Tom Tromey  <[email protected]>
+
+       * readelf.c (print_debug_abbrev_section): Update for change to
+       sectiondata.
+       (print_debug_str_section): Likewise.
+
 2012-01-31  Mark Wielaard  <[email protected]>
 
        * readelf.c (attr_callback): Don't special case DW_FORM_sec_offset.
diff --git a/src/readelf.c b/src/readelf.c
index 8876688..bea90b7 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -4572,7 +4572,7 @@ print_debug_abbrev_section (Dwfl_Module *dwflmod 
__attribute__ ((unused)),
          (uint64_t) shdr->sh_offset);
 
   Dwarf_Off offset = 0;
-  while (offset < dbg->sectiondata[IDX_debug_abbrev]->d_size)
+  while (offset < dbg->sectiondata[IDX_debug_abbrev].data->d_size)
     {
       printf (gettext ("\nAbbreviation section at offset %" PRIu64 ":\n"),
              offset);
@@ -6781,7 +6781,7 @@ print_debug_str_section (Dwfl_Module *dwflmod 
__attribute__ ((unused)),
                         Ebl *ebl, GElf_Ehdr *ehdr,
                         Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
 {
-  const size_t sh_size = dbg->sectiondata[IDX_debug_str]->d_size;
+  const size_t sh_size = dbg->sectiondata[IDX_debug_str].data->d_size;
 
   /* Compute floor(log16(shdr->sh_size)).  */
   GElf_Addr tmp = sh_size;
-- 
1.7.7.6

_______________________________________________
elfutils-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/elfutils-devel

Reply via email to