From: Roland McGrath Date: Wed, 25 Mar 2009 23:59:43 +0000 (-0700) Subject: Post-merge nits for dusty old unwind branch. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d76c17c1aef0de212cfe39c4287f35545404fa8c;p=thirdparty%2Felfutils.git Post-merge nits for dusty old unwind branch. --- diff --git a/libdw/cie.c b/libdw/cie.c index 6f86037a6..1b05dbaa1 100644 --- a/libdw/cie.c +++ b/libdw/cie.c @@ -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) { diff --git a/libdw/dwarf_frame_register.c b/libdw/dwarf_frame_register.c index c57c70007..e1965e171 100644 --- a/libdw/dwarf_frame_register.c +++ b/libdw/dwarf_frame_register.c @@ -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; diff --git a/libdw/dwarf_getcfi.c b/libdw/dwarf_getcfi.c index 16b5d1794..b9935504c 100644 --- a/libdw/dwarf_getcfi.c +++ b/libdw/dwarf_getcfi.c @@ -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; diff --git a/libdw/dwarf_getcfi_elf.c b/libdw/dwarf_getcfi_elf.c index 94c46eaf2..16d0c6258 100644 --- a/libdw/dwarf_getcfi_elf.c +++ b/libdw/dwarf_getcfi_elf.c @@ -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); diff --git a/libdw/encoded-value.h b/libdw/encoded-value.h index d653dbc2e..a6cbd65f9 100644 --- a/libdw/encoded-value.h +++ b/libdw/encoded-value.h @@ -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; diff --git a/libdw/fde.c b/libdw/fde.c index acfa39da2..12094e4d5 100644 --- a/libdw/fde.c +++ b/libdw/fde.c @@ -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) diff --git a/libdw/frame-cache.c b/libdw/frame-cache.c index 2182ad382..784d014d5 100644 --- a/libdw/frame-cache.c +++ b/libdw/frame-cache.c @@ -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); } diff --git a/libdw/unwind.c b/libdw/unwind.c index 1524fe00b..1328ba74f 100644 --- a/libdw/unwind.c +++ b/libdw/unwind.c @@ -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); diff --git a/libdw/unwindP.h b/libdw/unwindP.h index 240388f7f..893726c99 100644 --- a/libdw/unwindP.h +++ b/libdw/unwindP.h @@ -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; }; diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am index fe79914a2..db59c4a3c 100644 --- a/libdwfl/Makefile.am +++ b/libdwfl/Makefile.am @@ -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 \