]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Post-merge nits for dusty old unwind branch.
authorRoland McGrath <roland@redhat.com>
Wed, 25 Mar 2009 23:59:43 +0000 (16:59 -0700)
committerRoland McGrath <roland@redhat.com>
Wed, 25 Mar 2009 23:59:43 +0000 (16:59 -0700)
libdw/cie.c
libdw/dwarf_frame_register.c
libdw/dwarf_getcfi.c
libdw/dwarf_getcfi_elf.c
libdw/encoded-value.h
libdw/fde.c
libdw/frame-cache.c
libdw/unwind.c
libdw/unwindP.h
libdwfl/Makefile.am

index 6f86037a6681815093b06e24aceb3d89358292cb..1b05dbaa1164cc56b574e610e7762cee6307c58f 100644 (file)
@@ -1,5 +1,5 @@
 /* CIE reading.
-   Copyright (C) 2006, 2007 Red Hat, Inc.
+   Copyright (C) 2006, 2007, 2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -111,7 +111,7 @@ intern_new_cie (Dwarf_CFI *cache, Dwarf_Off offset, const Dwarf_CIE *info)
          cie->lsda_encoding = *data++;
          if (!cie->sized_augmentation_data)
            cie->fde_augmentation_data_size
-             += encoded_value_size (&cache->data, cache->e_ident,
+             += encoded_value_size (cache->data, cache->e_ident,
                                     cie->lsda_encoding, NULL);
          continue;
 
@@ -121,7 +121,7 @@ intern_new_cie (Dwarf_CFI *cache, Dwarf_Off offset, const Dwarf_CIE *info)
 
        case 'P':               /* Skip personality routine.  */
          encoding = *data++;
-         data += encoded_value_size (&cache->data, cache->e_ident,
+         data += encoded_value_size (cache->data, cache->e_ident,
                                      encoding, data);
          continue;
 
@@ -165,7 +165,7 @@ __libdw_find_cie (Dwarf_CFI *cache, Dwarf_Off offset)
   Dwarf_Off next_offset = offset;
   Dwarf_CFI_Entry entry;
   int result = INTUSE(dwarf_next_cfi) (cache->e_ident,
-                                      &cache->data, cache->eh_frame,
+                                      cache->data, cache->eh_frame,
                                       offset, &next_offset, &entry);
   if (result != 0 || entry.cie.CIE_id != CIE_ID)
     {
index c57c700077507cc808c785d22b0dd65cc00c4608..e1965e171e66b273327bbd9cf75252f7e7d3e510 100644 (file)
@@ -1,5 +1,5 @@
 /* Get register location expression for frame.
-   Copyright (C) 2006, 2007 Red Hat, Inc.
+   Copyright (C) 2006, 2007, 2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -124,7 +124,7 @@ dwarf_frame_register (fs, regno, ops_mem, ops, nops)
                                     ? 4 : 8);
 
        Dwarf_Block block;
-       const uint8_t *p = fs->cache->data.d_buf + reg->value;
+       const uint8_t *p = fs->cache->data->d_buf + reg->value;
        get_uleb128 (block.length, p);
        block.data = (void *) p;
 
index 16b5d17942130c364c009cb26ca4df97b09b4bd0..b9935504c991073442be54eb6e2ab7c989013ecc 100644 (file)
@@ -1,5 +1,5 @@
 /* Get CFI from DWARF file.
-   Copyright (C) 2006, 2007 Red Hat, Inc.
+   Copyright (C) 2006, 2007, 2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -68,14 +68,12 @@ dwarf_getcfi (dbg)
       Dwarf_CFI *cfi = libdw_typed_alloc (dbg, Dwarf_CFI);
 
       cfi->eh_frame = dbg->sectiondata[IDX_debug_frame] == NULL;
-      cfi->data = *dbg->sectiondata[cfi->eh_frame ? IDX_eh_frame
-                                   : IDX_debug_frame];
-      cfi->rawchunk = false;
+      cfi->data = dbg->sectiondata[cfi->eh_frame ? IDX_eh_frame
+                                  : IDX_debug_frame];
       cfi->elf = dbg->elf;
 
       cfi->search_table = NULL;
       cfi->search_table_vaddr = 0;
-      cfi->search_table_rawchunk = NULL;
       cfi->search_table_entries = 0;
       cfi->search_table_encoding = DW_EH_PE_omit;
 
index 94c46eaf21d64dc8a2e42e983b4beb664f2b56c6..16d0c6258ae33e03ff12ef82b7fb87196527ed88 100644 (file)
@@ -1,5 +1,5 @@
 /* Get CFI from ELF file's exception-handling info.
-   Copyright (C) 2006 Red Hat, Inc.
+   Copyright (C) 2006, 2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -110,12 +110,13 @@ parse_eh_frame_hdr (const uint8_t *hdr, size_t hdr_size, GElf_Addr hdr_vaddr,
     return (void *) -1l;
 
   /* Dummy used by read_encoded_value.  */
+  Elf_Data dummy_cfi_hdr_data = { .d_buf = (void *) hdr, .d_size = hdr_size };
   Dwarf_CFI dummy_cfi =
     {
       .e_ident = ehdr->e_ident,
       .datarel = hdr_vaddr,
       .frame_vaddr = hdr_vaddr,
-      .data = { .d_buf = (void *) hdr, .d_size = hdr_size }
+      .data = &dummy_cfi_hdr_data,
     };
 
   *eh_frame_vaddr = read_encoded_value (&dummy_cfi, eh_frame_ptr_encoding, &h);
@@ -143,11 +144,11 @@ getcfi_gnu_eh_frame (Elf *elf, const GElf_Ehdr *ehdr, const GElf_Phdr *phdr)
   if (unlikely (phdr->p_filesz < 4))
     goto invalid;
 
-  void *const hdr = gelf_rawchunk (elf, phdr->p_offset, phdr->p_filesz);
-  if (hdr == NULL)
+  Elf_Data *data = elf_getdata_rawchunk (elf, phdr->p_offset, phdr->p_filesz,
+                                        ELF_T_BYTE);
+  if (data == NULL)
     {
     invalid_hdr:
-      gelf_freechunk (elf, hdr);
     invalid:
       /* XXX might be read error or corrupt phdr */
       __libdw_seterrno (DWARF_E_INVALID_CFI);
@@ -157,7 +158,7 @@ getcfi_gnu_eh_frame (Elf *elf, const GElf_Ehdr *ehdr, const GElf_Phdr *phdr)
   Dwarf_Addr eh_frame_ptr;
   size_t search_table_entries;
   uint8_t search_table_encoding;
-  const uint8_t *search_table = parse_eh_frame_hdr (hdr, phdr->p_filesz,
+  const uint8_t *search_table = parse_eh_frame_hdr (data->d_buf, phdr->p_filesz,
                                                    phdr->p_vaddr, ehdr,
                                                    &eh_frame_ptr,
                                                    &search_table_entries,
@@ -176,25 +177,16 @@ getcfi_gnu_eh_frame (Elf *elf, const GElf_Ehdr *ehdr, const GElf_Phdr *phdr)
   if (elf_rawfile (elf, &filesize) != NULL)
     eh_frame_size = filesize - eh_frame_offset;
 
-  Elf_Data data = { .d_version = EV_CURRENT };
-  data.d_buf = gelf_rawchunk (elf, eh_frame_offset, eh_frame_size);
-  data.d_size = eh_frame_size;
-  if (data.d_buf == NULL)
+  data = elf_getdata_rawchunk (elf, eh_frame_offset, eh_frame_size, ELF_T_BYTE);
+  if (data == NULL)
     {
       __libdw_seterrno (DWARF_E_INVALID_ELF); /* XXX might be read error */
-      gelf_freechunk (elf, hdr);
       return NULL;
     }
   Dwarf_CFI *cfi = allocate_cfi (elf, eh_frame_ptr);
-  if (cfi == NULL)
-    {
-      gelf_freechunk (elf, hdr);
-      gelf_freechunk (elf, data.d_buf);
-    }
-  else
+  if (cfi != NULL)
     {
       cfi->data = data;
-      cfi->rawchunk = true;
 
       if (search_table != NULL)
        {
@@ -202,10 +194,7 @@ getcfi_gnu_eh_frame (Elf *elf, const GElf_Ehdr *ehdr, const GElf_Phdr *phdr)
          cfi->search_table_vaddr = phdr->p_vaddr;
          cfi->search_table_encoding = search_table_encoding;
          cfi->search_table_entries = search_table_entries;
-         cfi->search_table_rawchunk = hdr;
        }
-      else
-       gelf_freechunk (elf, hdr);
     }
   return cfi;
 }
@@ -244,7 +233,7 @@ getcfi_scn_eh_frame (Elf *elf, const GElf_Ehdr *ehdr,
   Dwarf_CFI *cfi = allocate_cfi (elf, shdr->sh_addr);
   if (cfi != NULL)
     {
-      cfi->data = *data;
+      cfi->data = data;
       if (hdr_scn != NULL)
        {
          Elf_Data *hdr_data = elf_rawdata (hdr_scn, NULL);
index d653dbc2e0bb751df52e18bf25782567c50c31de..a6cbd65f9fc635b3306ba8e92933b17c3cc4fbee 100644 (file)
@@ -1,5 +1,5 @@
 /* DW_EH_PE_* support for libdw unwinder.
-   Copyright (C) 2007 Red Hat, Inc.
+   Copyright (C) 2007, 2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -98,7 +98,7 @@ read_encoded_value (const Dwarf_CFI *cache,
     case DW_EH_PE_absptr:
       break;
     case DW_EH_PE_pcrel:
-      base = cache->frame_vaddr + (*p - (const uint8_t *) cache->data.d_buf);
+      base = cache->frame_vaddr + (*p - (const uint8_t *) cache->data->d_buf);
       break;
     case DW_EH_PE_textrel:
       // ia64: segrel
@@ -116,7 +116,7 @@ read_encoded_value (const Dwarf_CFI *cache,
        const size_t address_size
          = cache->e_ident[EI_CLASS] == ELFCLASS32 ? 4 : 8;
        size_t align = ((cache->frame_vaddr
-                        + (*p - (const uint8_t *) cache->data.d_buf))
+                        + (*p - (const uint8_t *) cache->data->d_buf))
                        & (address_size - 1));
        if (align != 0)
          *p += address_size - align;
index acfa39da29ad35900b9d10bcc8dd9acca97adfbe..12094e4d5ff5389a95e6da219b10b4dd116b0dfb 100644 (file)
@@ -1,5 +1,5 @@
 /* FDE reading.
-   Copyright (C) 2006, 2007 Red Hat, Inc.
+   Copyright (C) 2006, 2007, 2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -143,7 +143,7 @@ fde_by_offset (Dwarf_CFI *cache, Dwarf_Addr address, Dwarf_Off offset)
   Dwarf_CFI_Entry entry;
   Dwarf_Off next_offset;
   int result = INTUSE(dwarf_next_cfi) (cache->e_ident,
-                                      &cache->data, cache->eh_frame,
+                                      cache->data, cache->eh_frame,
                                       offset, &next_offset, &entry);
   if (result != 0)
     {
@@ -176,7 +176,7 @@ fde_by_offset (Dwarf_CFI *cache, Dwarf_Addr address, Dwarf_Off offset)
 static Dwarf_Off
 binary_search_fde (Dwarf_CFI *cache, Dwarf_Addr address)
 {
-  const size_t size = 2 * encoded_value_size (&cache->data, cache->e_ident,
+  const size_t size = 2 * encoded_value_size (cache->data, cache->e_ident,
                                              cache->search_table_encoding,
                                              NULL);
 
@@ -255,7 +255,7 @@ __libdw_find_fde (Dwarf_CFI *cache, Dwarf_Addr address)
       Dwarf_Off last_offset = cache->next_offset;
       Dwarf_CFI_Entry entry;
       int result = INTUSE(dwarf_next_cfi) (cache->e_ident,
-                                          &cache->data, cache->eh_frame,
+                                          cache->data, cache->eh_frame,
                                           last_offset, &cache->next_offset,
                                           &entry);
       if (result > 0)
index 2182ad3828b57d32b5542aa6c3ff73d3f3a4269b..784d014d5734d4124b0f95c437eca2a1a05fec64 100644 (file)
@@ -1,5 +1,5 @@
 /* Frame cache handling.
-   Copyright (C) 2006, 2007 Red Hat, Inc.
+   Copyright (C) 2006, 2007, 2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -84,7 +84,4 @@ __libdw_destroy_frame_cache (Dwarf_CFI *cache)
   tdestroy (cache->fde_tree, free_fde);
   tdestroy (cache->cie_tree, free_cie);
   tdestroy (cache->expr_tree, free_expr);
-
-  if (cache->rawchunk)
-    gelf_freechunk (cache->elf, cache->data.d_buf);
 }
index 1524fe00b3a42a4d34acadf5d6615666a72a014f..1328ba74fd29e77e03ec64add7451fe6537f92ea 100644 (file)
@@ -1,5 +1,5 @@
 /* CFI program execution.
-   Copyright (C) 2006, 2007 Red Hat, Inc.
+   Copyright (C) 2006, 2007, 2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -247,7 +247,7 @@ execute_cfi (Dwarf_CFI *cache,
 
        case DW_CFA_expression:
          get_uleb128 (regno, program);
-         offset = program - (const uint8_t *) cache->data.d_buf;
+         offset = program - (const uint8_t *) cache->data->d_buf;
          /* DW_FORM_block is a ULEB128 length followed by that many bytes.  */
          get_uleb128 (operand, program);
          cfi_assert (operand <= (Dwarf_Word) (end - program));
@@ -258,7 +258,7 @@ execute_cfi (Dwarf_CFI *cache,
        case DW_CFA_val_expression:
          get_uleb128 (regno, program);
          /* DW_FORM_block is a ULEB128 length followed by that many bytes.  */
-         offset = program - (const uint8_t *) cache->data.d_buf;
+         offset = program - (const uint8_t *) cache->data->d_buf;
          get_uleb128 (operand, program);
          cfi_assert (operand <= (Dwarf_Word) (end - program));
          register_rule (regno, val_expression, offset);
index 240388f7ff44a205748f923dd15af3f6fc5bb2de..893726c9951358f7e7aa1402096b5e7a1f6a036a 100644 (file)
@@ -1,5 +1,5 @@
 /* Internal definitions for libdw unwinder code.
-   Copyright (C) 2006, 2007 Red Hat, Inc.
+   Copyright (C) 2006, 2007, 2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -96,7 +96,7 @@ struct dwarf_fde
 struct Dwarf_CFI_s
 {
   /* Data of the .debug_frame or .eh_frame section.  */
-  Elf_Data data;
+  Elf_Data *data;
   const unsigned char *e_ident;        /* For EI_DATA and EI_CLASS.  */
 
   /* True if the file has a byte order different from the host.  */
@@ -105,8 +105,6 @@ struct Dwarf_CFI_s
   /* True if the section data is in .eh_frame format.  */
   bool eh_frame;
 
-  /* True if data.d_buf came from gelf_rawchunk.  */
-  bool rawchunk;
   Elf *elf;                    /* Originating ELF file.  */
 
   Dwarf_Addr frame_vaddr;  /* DW_EH_PE_pcrel, address of frame section.  */
@@ -135,7 +133,6 @@ struct Dwarf_CFI_s
   /* Binary search table in .eh_frame_hdr section.  */
   const uint8_t *search_table;
   Dwarf_Addr search_table_vaddr;
-  void *search_table_rawchunk;
   size_t search_table_entries;
   uint8_t search_table_encoding;
 };
index fe79914a271394a2742de811799b2f449ccf51b1..db59c4a3ce14f0b362782b7fe76a6485833544d0 100644 (file)
@@ -68,7 +68,7 @@ libdwfl_a_SOURCES = dwfl_begin.c dwfl_end.c dwfl_error.c dwfl_version.c \
                    dwfl_module_getsrc_file.c \
                    libdwfl_crc32.c libdwfl_crc32_file.c \
                    elf-from-memory.c \
-                   dwfl_module_getcfi.c dwfl_addrframe.c
+                   dwfl_module_getcfi.c dwfl_addrframe.c \
                    dwfl_module_getsym.c \
                    dwfl_module_addrname.c dwfl_module_addrsym.c \
                    dwfl_module_return_value_location.c \