/* 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
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;
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;
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)
{
/* 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
? 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;
/* 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
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;
/* 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
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);
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);
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,
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)
{
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;
}
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);
/* 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
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
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;
/* 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
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)
{
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);
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)
/* 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
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);
}
/* 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
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));
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);
/* 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
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. */
/* 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. */
/* 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;
};
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 \