07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Copyright (C) 2000,2004 Silicon Graphics, 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 This function adds another type name to the
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe list of type names for the given Dwarf_P_Debug.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe It returns 0 on error, and 1 otherwise.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe _dwarf_add_simple_name_entry(dbg, die, type_name,
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe The following is the generic 'add a simple name entry'
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe for any of the simple name sections.
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe See enum dwarf_sn_kind in pro_opaque.h
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe name = _dwarf_p_get_alloc(dbg, strlen(entry_name) + 1);
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe hdr->sn_net_len += uword_size + nameentry->sne_name_len + 1;
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe _dwarf_transform_simplename_to_disk writes
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe ".rel.debug_pubnames",
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe ".rel.debug_funcnames", sgi extension
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe ".rel.debug_typenames", sgi extension
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe ".rel.debug_varnames", sgi extension
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe ".rel.debug_weaknames", sgi extension
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe section_index indexes one of those sections.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe entrykind is one of those 'kind's.
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe_dwarf_transform_simplename_to_disk(Dwarf_P_Debug dbg, enum dwarf_sn_kind entrykind, int section_index, /* in
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe de_elf_sects
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* Used to fill in 0. */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* Used to scan the section data buffers. */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe Dwarf_Unsigned adjusted_length; /* count excluding length field
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe int extension_size = dbg->de_64bit_extension ? 4 : 0;
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* ***** BEGIN CODE ***** */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe for (debug_sect = dbg->de_debug_sects; debug_sect != NULL;
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* We want the size of the .debug_info section for this CU
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe because the dwarf spec requires us to output it below so we
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe look for it specifically. */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe if (debug_sect->ds_elf_sect_no == dbg->de_elf_sects[DEBUG_INFO]) {
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* Size of the .debug_typenames (or similar) section header. */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe stream_bytes_count = extension_size + uword_size + /* Size of
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe sizeof(Dwarf_Half) + /* Size of version field. */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* add in the content size */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* Size of the last 0 offset. */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* Now we know how long the entire section is */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe GET_CHUNK(dbg, dbg->de_elf_sects[section_index],
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe stream_bytes, (unsigned long) stream_bytes_count, error);
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe (const void *) &x, sizeof(x), extension_size);
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* Write the adjusted length of .debug_*names section. */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe adjusted_length = stream_bytes_count - uword_size - extension_size;
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe (const void *) &adjusted_length,
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* Write the version as 2 bytes. */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe (const void *) &verstamp,
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* Write the offset of the compile-unit. */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe (const void *) &big_zero,
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* now create the relocation for the compile_unit offset */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* r_offset */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* debug_info section name symbol */
49d3bc91e27cd871b950d56c01398fa2f2e12ab4Richard Lowe /* Write the size of .debug_info section. */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe (const void *) &debug_info_size,
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe nameentry != NULL; nameentry = nameentry->sne_next) {
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* Copy offset of die from start of compile-unit. */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe /* Copy the type name. */
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe strcpy((char *) cur_stream_bytes_ptr, nameentry->sne_name);
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe cur_stream_bytes_ptr += nameentry->sne_name_len + 1;
07dc1947c362e187fb955d283b692f8769dd5defRichard Lowe (const void *) &big_zero,