07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Copyright (C) 2000,2001,2004 Silicon Graphics, Inc. All Rights Reserved.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Portions Copyright 2008-2010 David Anderson, Inc. All rights reserved.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe This program is free software; you can redistribute it and/or modify it
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe under the terms of version 2.1 of the GNU Lesser General Public License
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe as published by the Free Software Foundation.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe This program is distributed in the hope that it would be useful, but
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe WITHOUT ANY WARRANTY; without even the implied warranty of
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe Further, this software is distributed without any warranty that it is
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe free of the rightful claim of any third person regarding infringement
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe or the like. Any license provided herein, whether implied or
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe otherwise, applies only to this software file. Patent licenses, if
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe any, provided herein do not apply to combinations of this program with
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe other software, or any other product whatsoever.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe You should have received a copy of the GNU Lesser General Public
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe License along with this program; if not, write the Free Software
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe Mountain View, CA 94043, or:
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe For further information regarding this notice, see:
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe http://oss.sgi.com/projects/GenInfo/NoticeExplan
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe/* Set r_info as defined by ELF generic ABI */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe#define Set_REL32_info(r,s,t) ((r).r_info = ELF32_R_INFO(s,t))
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe#define Set_REL64_info(r,s,t) ((r).r_info = ELF64_R_INFO(s,t))
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Return DW_DLV_ERROR on malloc error or reltarget_length error.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Return DW_DLV_OK otherwise
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /*ARGSUSED*/ int
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe_dwarf_pro_reloc_name_stream64(Dwarf_P_Debug dbg,
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe res = _dwarf_pro_reloc_get_a_slot(dbg, base_sec_index,
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe } else if (reltarget_length == dbg->de_pointer_size) {
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* We are in trouble: improper use of stream relocations.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Someone else will diagnose */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe Set_REL64_info(*elf64_reloc, symidx, rel_type);
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe#else /* !HAVE_ELF64_GETEHDR */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe#endif /* #if HAVE_ELF64_GETEHDR */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Return DW_DLV_ERROR on malloc error or reltarget_length error.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Return DW_DLV_OK otherwise
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe a binary reloc: 32bit ABI
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe_dwarf_pro_reloc_name_stream32(Dwarf_P_Debug dbg, int base_sec_index,
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe res = _dwarf_pro_reloc_get_a_slot(dbg, base_sec_index,
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe } else if (reltarget_length == dbg->de_pointer_size) {
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* We are in trouble: improper use of stream relocations.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Someone else will diagnose */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe Set_REL32_info(*elf32_reloc, (Dwarf_Word) symidx, rel_type);
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* get a slot, fill in the slot entry */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Return DW_DLV_OK.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Never can really do anything: lengths cannot
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe be represented as end-start in a stream.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /*ARGSUSED*/ int
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe_dwarf_pro_reloc_length_stream(Dwarf_P_Debug dbg,
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* get a slot, fill in the slot entry */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe Ensure each stream is a single buffer and
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe add that single buffer to the set of stream buffers.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe By creating a new buffer and copying if necessary.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe Free the input set of buffers if we consolidate.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe Return -1 on error (malloc failure)
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe Return DW_DLV_OK on success. Any other return indicates
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe malloc failed.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe unsigned long i = 0;
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe Dwarf_P_Per_Reloc_Sect p_reloc = &dbg->de_reloc_sect[0];
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe for (i = 0; i < NUM_DEBUG_SECTIONS; ++i, ++p_reloc) {
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe unsigned long ct = p_reloc->pr_reloc_total_count;
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe struct Dwarf_P_Relocation_Block_s *p_blk_last = 0;
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* Call de_callback_func or de_callback_func_b, getting
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe section number of reloc section. */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe dbg->de_callback_func_b(_dwarf_rel_section_names[i],
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* flags */ 0,
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* link to symtab, which we cannot
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* info == link to sec rels apply to
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe dbg->de_callback_func(_dwarf_rel_section_names[i],
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* flags */ 0,
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* link to symtab, which we cannot
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* info == link to sec rels apply to */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe _dwarf_p_error(dbg, error, DW_DLE_ELF_SECT_ERR);
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe prb->pr_sect_num_of_reloc_sect = rel_section_index;
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe GET_CHUNK(dbg, sec_index, data, total_size, &err);
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* following loop executes at least once. Effects the
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe consolidation to a single block or, if already a single
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe block, simply copies to the output buffer. And frees the
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe input block. The new block is in the de_debug_sects list. */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe _dwarf_p_dealloc(dbg, (Dwarf_Small *) p_blk_last);
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* ASSERT: sum of len copied == total_size */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe We have copied the input, now drop the pointers to it. For
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe debugging, leave the other data untouched. */