From: Roland McGrath Date: Fri, 3 Apr 2009 21:56:49 +0000 (-0700) Subject: Use Elf_Data_Scn section pointers instead of caching Elf pointer in Dwarf_CFI. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2432912ac3682d6803c16793dc1725c84ce8e9f5;p=thirdparty%2Felfutils.git Use Elf_Data_Scn section pointers instead of caching Elf pointer in Dwarf_CFI. --- diff --git a/libdw/cie.c b/libdw/cie.c index 1b05dbaa1..34e3ffec2 100644 --- a/libdw/cie.c +++ b/libdw/cie.c @@ -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) { diff --git a/libdw/dwarf_frame_register.c b/libdw/dwarf_frame_register.c index e1965e171..98efcc12e 100644 --- a/libdw/dwarf_frame_register.c +++ b/libdw/dwarf_frame_register.c @@ -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; diff --git a/libdw/dwarf_getcfi.c b/libdw/dwarf_getcfi.c index b9935504c..e6df97f0c 100644 --- a/libdw/dwarf_getcfi.c +++ b/libdw/dwarf_getcfi.c @@ -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; diff --git a/libdw/dwarf_getcfi_elf.c b/libdw/dwarf_getcfi_elf.c index 16d0c6258..8fc2a7256 100644 --- a/libdw/dwarf_getcfi_elf.c +++ b/libdw/dwarf_getcfi_elf.c @@ -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); diff --git a/libdw/encoded-value.h b/libdw/encoded-value.h index a6cbd65f9..b99859925 100644 --- a/libdw/encoded-value.h +++ b/libdw/encoded-value.h @@ -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; diff --git a/libdw/fde.c b/libdw/fde.c index 12094e4d5..b5a10fcec 100644 --- a/libdw/fde.c +++ b/libdw/fde.c @@ -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) diff --git a/libdw/unwind.c b/libdw/unwind.c index 2bb643982..aabc08025 100644 --- a/libdw/unwind.c +++ b/libdw/unwind.c @@ -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; } diff --git a/libdw/unwindP.h b/libdw/unwindP.h index 432dbc742..3ac503be3 100644 --- a/libdw/unwindP.h +++ b/libdw/unwindP.h @@ -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. */