]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Use Elf_Data_Scn section pointers instead of caching Elf pointer in Dwarf_CFI.
authorRoland McGrath <roland@redhat.com>
Fri, 3 Apr 2009 21:56:49 +0000 (14:56 -0700)
committerRoland McGrath <roland@redhat.com>
Fri, 3 Apr 2009 21:56:49 +0000 (14:56 -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/unwind.c
libdw/unwindP.h

index 1b05dbaa1164cc56b574e610e7762cee6307c58f..34e3ffec2e39d0733c7741e7d89466c9578825dc 100644 (file)
@@ -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->d, 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->d, 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->d, cache->eh_frame,
                                       offset, &next_offset, &entry);
   if (result != 0 || entry.cie.CIE_id != CIE_ID)
     {
index e1965e171e66b273327bbd9cf75252f7e7d3e510..98efcc12e22d40ebf20de0991fd093969790470e 100644 (file)
@@ -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.d_buf + reg->value;
        get_uleb128 (block.length, p);
        block.data = (void *) p;
 
index b9935504c991073442be54eb6e2ab7c989013ecc..e6df97f0c8e60f659d53860dd031d915fefe6da3 100644 (file)
@@ -68,9 +68,8 @@ 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->elf = dbg->elf;
+      cfi->data = (Elf_Data_Scn *) dbg->sectiondata[cfi->eh_frame ? IDX_eh_frame
+                                                   : IDX_debug_frame];
 
       cfi->search_table = NULL;
       cfi->search_table_vaddr = 0;
index 16d0c6258ae33e03ff12ef82b7fb87196527ed88..8fc2a7256f9110175b153bad976de958fa273d16 100644 (file)
@@ -71,7 +71,6 @@ allocate_cfi (Elf *elf, GElf_Addr vaddr)
       return NULL;
     }
 
-  cfi->elf = elf;
   cfi->e_ident = (unsigned char *) elf_getident (elf, NULL);
   if (cfi->e_ident == NULL)
     {
@@ -110,7 +109,10 @@ 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 };
+  Elf_Data_Scn dummy_cfi_hdr_data =
+    {
+      .d = { .d_buf = (void *) hdr, .d_size = hdr_size }
+    };
   Dwarf_CFI dummy_cfi =
     {
       .e_ident = ehdr->e_ident,
@@ -186,7 +188,7 @@ getcfi_gnu_eh_frame (Elf *elf, const GElf_Ehdr *ehdr, const GElf_Phdr *phdr)
   Dwarf_CFI *cfi = allocate_cfi (elf, eh_frame_ptr);
   if (cfi != NULL)
     {
-      cfi->data = data;
+      cfi->data = (Elf_Data_Scn *) data;
 
       if (search_table != NULL)
        {
@@ -233,7 +235,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 = (Elf_Data_Scn *) data;
       if (hdr_scn != NULL)
        {
          Elf_Data *hdr_data = elf_rawdata (hdr_scn, NULL);
index a6cbd65f9fc635b3306ba8e92933b17c3cc4fbee..b9985992578fd31b5ae6c1504b3d348fb04eb290 100644 (file)
@@ -89,8 +89,7 @@ encoded_value_size (const Elf_Data *data, const unsigned char e_ident[],
 }
 
 static Dwarf_Addr __attribute__ ((unused))
-read_encoded_value (const Dwarf_CFI *cache,
-                   uint8_t encoding, const uint8_t **p)
+read_encoded_value (const Dwarf_CFI *cache, uint8_t encoding, const uint8_t **p)
 {
   Dwarf_Addr base = 0;
   switch (encoding & 0x70)
@@ -98,7 +97,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.d_buf);
       break;
     case DW_EH_PE_textrel:
       // ia64: segrel
@@ -116,7 +115,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.d_buf))
                        & (address_size - 1));
        if (align != 0)
          *p += address_size - align;
index 12094e4d5ff5389a95e6da219b10b4dd116b0dfb..b5a10fcecca7f27fe08df3cf5f1415151ee49343 100644 (file)
@@ -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->d, cache->eh_frame,
                                       offset, &next_offset, &entry);
   if (result != 0)
     {
@@ -176,11 +176,10 @@ 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->d, cache->e_ident,
                                              cache->search_table_encoding,
                                              NULL);
 
-
   /* Dummy used by read_encoded_value.  */
   Dwarf_CFI dummy_cfi =
     {
@@ -255,7 +254,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->d, cache->eh_frame,
                                           last_offset, &cache->next_offset,
                                           &entry);
       if (result > 0)
index 2bb64398274dea87c55a685fca1dd6f446fb7f99..aabc0802543ef3b70d860fe51d24f8a2202d9771 100644 (file)
@@ -260,7 +260,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.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));
@@ -271,7 +271,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.d_buf;
          get_uleb128 (operand, program);
          cfi_assert (operand <= (Dwarf_Word) (end - program));
          program += operand;
@@ -417,7 +417,7 @@ cie_cache_initial_state (Dwarf_CFI *cache, struct dwarf_cie *cie)
   /* Make sure we have a backend handle cached.  */
   if (unlikely (cache->ebl == NULL))
     {
-      cache->ebl = ebl_openbackend (cache->elf);
+      cache->ebl = ebl_openbackend (cache->data->s->elf);
       if (unlikely (cache->ebl == NULL))
        cache->ebl = (void *) -1l;
     }
index 432dbc742354c7038cc74541e1b1269f085af5a5..3ac503be39ac982704fe6d2df0ea82fa8dc5751c 100644 (file)
@@ -51,6 +51,7 @@
 #define _UNWINDP_H 1
 
 #include "libdwP.h"
+#include "libelfP.h"
 #include "unwind.h"            /* XXX */
 struct ebl;
 
@@ -96,7 +97,7 @@ struct dwarf_fde
 struct Dwarf_CFI_s
 {
   /* Data of the .debug_frame or .eh_frame section.  */
-  Elf_Data *data;
+  Elf_Data_Scn *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 +106,6 @@ struct Dwarf_CFI_s
   /* True if the section data is in .eh_frame format.  */
   bool eh_frame;
 
-  Elf *elf;                    /* Originating ELF file.  */
-
   Dwarf_Addr frame_vaddr;  /* DW_EH_PE_pcrel, address of frame section.  */
   Dwarf_Addr textrel;          /* DW_EH_PE_textrel base address.  */
   Dwarf_Addr datarel;          /* DW_EH_PE_datarel base address.  */