xref: /titanic_44/usr/src/tools/ctf/dwarf/common/pro_opaque.h (revision 07dc1947c362e187fb955d283b692f8769dd5def)
149d3bc91SRichard Lowe /*
249d3bc91SRichard Lowe 
3*07dc1947SRichard Lowe   Copyright (C) 2000,2002,2004 Silicon Graphics, Inc.  All Rights Reserved.
4*07dc1947SRichard Lowe   Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
549d3bc91SRichard Lowe 
649d3bc91SRichard Lowe   This program is free software; you can redistribute it and/or modify it
749d3bc91SRichard Lowe   under the terms of version 2.1 of the GNU Lesser General Public License
849d3bc91SRichard Lowe   as published by the Free Software Foundation.
949d3bc91SRichard Lowe 
1049d3bc91SRichard Lowe   This program is distributed in the hope that it would be useful, but
1149d3bc91SRichard Lowe   WITHOUT ANY WARRANTY; without even the implied warranty of
1249d3bc91SRichard Lowe   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1349d3bc91SRichard Lowe 
1449d3bc91SRichard Lowe   Further, this software is distributed without any warranty that it is
1549d3bc91SRichard Lowe   free of the rightful claim of any third person regarding infringement
1649d3bc91SRichard Lowe   or the like.  Any license provided herein, whether implied or
1749d3bc91SRichard Lowe   otherwise, applies only to this software file.  Patent licenses, if
1849d3bc91SRichard Lowe   any, provided herein do not apply to combinations of this program with
1949d3bc91SRichard Lowe   other software, or any other product whatsoever.
2049d3bc91SRichard Lowe 
2149d3bc91SRichard Lowe   You should have received a copy of the GNU Lesser General Public
2249d3bc91SRichard Lowe   License along with this program; if not, write the Free Software
23*07dc1947SRichard Lowe   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
2449d3bc91SRichard Lowe   USA.
2549d3bc91SRichard Lowe 
26*07dc1947SRichard Lowe   Contact information:  Silicon Graphics, Inc., 1500 Crittenden Lane,
2749d3bc91SRichard Lowe   Mountain View, CA 94043, or:
2849d3bc91SRichard Lowe 
2949d3bc91SRichard Lowe   http://www.sgi.com
3049d3bc91SRichard Lowe 
3149d3bc91SRichard Lowe   For further information regarding this notice, see:
3249d3bc91SRichard Lowe 
3349d3bc91SRichard Lowe   http://oss.sgi.com/projects/GenInfo/NoticeExplan
3449d3bc91SRichard Lowe 
3549d3bc91SRichard Lowe */
3649d3bc91SRichard Lowe 
3749d3bc91SRichard Lowe 
3849d3bc91SRichard Lowe #include <stddef.h>
3949d3bc91SRichard Lowe 
4049d3bc91SRichard Lowe /*
4149d3bc91SRichard Lowe     Sgidefs included to define __uint32_t,
4249d3bc91SRichard Lowe     a guaranteed 4-byte quantity.
4349d3bc91SRichard Lowe */
4449d3bc91SRichard Lowe #include "libdwarfdefs.h"
4549d3bc91SRichard Lowe 
4649d3bc91SRichard Lowe #define true                    1
4749d3bc91SRichard Lowe #define false                   0
4849d3bc91SRichard Lowe 
4949d3bc91SRichard Lowe /* to identify a cie */
5049d3bc91SRichard Lowe #define DW_CIE_ID 		~(0x0)
5149d3bc91SRichard Lowe #define DW_CIE_VERSION		1
5249d3bc91SRichard Lowe 
5349d3bc91SRichard Lowe /*Dwarf_Word  is unsigned word usable for index, count in memory */
5449d3bc91SRichard Lowe /*Dwarf_Sword is   signed word usable for index, count in memory */
5549d3bc91SRichard Lowe /* The are 32 or 64 bits depending if 64 bit longs or not, which
5649d3bc91SRichard Lowe ** fits the  ILP32 and LP64 models
5749d3bc91SRichard Lowe ** These work equally well with ILP64.
5849d3bc91SRichard Lowe */
5949d3bc91SRichard Lowe 
6049d3bc91SRichard Lowe typedef unsigned long Dwarf_Word;
6149d3bc91SRichard Lowe typedef long Dwarf_Sword;
6249d3bc91SRichard Lowe 
6349d3bc91SRichard Lowe 
6449d3bc91SRichard Lowe typedef signed char Dwarf_Sbyte;
6549d3bc91SRichard Lowe typedef unsigned char Dwarf_Ubyte;
6649d3bc91SRichard Lowe typedef signed short Dwarf_Shalf;
6749d3bc91SRichard Lowe 
6849d3bc91SRichard Lowe /*
6949d3bc91SRichard Lowe 	On any change that makes libdwarf producer
7049d3bc91SRichard Lowe 	incompatible, increment this number.
7149d3bc91SRichard Lowe 	1->2->3 ...
7249d3bc91SRichard Lowe 
7349d3bc91SRichard Lowe */
7449d3bc91SRichard Lowe #define  PRO_VERSION_MAGIC 0xdead1
7549d3bc91SRichard Lowe 
7649d3bc91SRichard Lowe 
7749d3bc91SRichard Lowe /* these 2 are fixed sizes which must not vary with the
7849d3bc91SRichard Lowe ** ILP32/LP64 model. These two stay at 32 bit.
7949d3bc91SRichard Lowe */
8049d3bc91SRichard Lowe typedef __uint32_t Dwarf_ufixed;
8149d3bc91SRichard Lowe typedef __int32_t Dwarf_sfixed;
8249d3bc91SRichard Lowe 
8349d3bc91SRichard Lowe /*
8449d3bc91SRichard Lowe 	producer:
8549d3bc91SRichard Lowe 	This struct is used to hold information about all
8649d3bc91SRichard Lowe 	debug* sections. On creating a new section, section
8749d3bc91SRichard Lowe 	names and indices are added to this struct
8849d3bc91SRichard Lowe 	definition in pro_section.h
8949d3bc91SRichard Lowe */
9049d3bc91SRichard Lowe typedef struct Dwarf_P_Section_Data_s *Dwarf_P_Section_Data;
9149d3bc91SRichard Lowe 
9249d3bc91SRichard Lowe /*
9349d3bc91SRichard Lowe 	producer:
9449d3bc91SRichard Lowe 	This struct is used to hold entries in the include directories
9549d3bc91SRichard Lowe 	part of statement prologue. Definition in pro_line.h
9649d3bc91SRichard Lowe */
9749d3bc91SRichard Lowe typedef struct Dwarf_P_Inc_Dir_s *Dwarf_P_Inc_Dir;
9849d3bc91SRichard Lowe 
9949d3bc91SRichard Lowe /*
10049d3bc91SRichard Lowe 	producer:
10149d3bc91SRichard Lowe 	This struct holds file entries for the statement prologue.
10249d3bc91SRichard Lowe 	Defined in pro_line.h
10349d3bc91SRichard Lowe */
10449d3bc91SRichard Lowe typedef struct Dwarf_P_F_Entry_s *Dwarf_P_F_Entry;
10549d3bc91SRichard Lowe 
10649d3bc91SRichard Lowe /*
10749d3bc91SRichard Lowe 	producer:
10849d3bc91SRichard Lowe 	This struct holds information for each cie. Defn in pro_frame.h
10949d3bc91SRichard Lowe */
11049d3bc91SRichard Lowe typedef struct Dwarf_P_Cie_s *Dwarf_P_Cie;
11149d3bc91SRichard Lowe 
11249d3bc91SRichard Lowe /*
11349d3bc91SRichard Lowe 	producer:
11449d3bc91SRichard Lowe 	Struct to hold line number information, different from
11549d3bc91SRichard Lowe 	Dwarf_Line opaque type.
11649d3bc91SRichard Lowe */
11749d3bc91SRichard Lowe typedef struct Dwarf_P_Line_s *Dwarf_P_Line;
11849d3bc91SRichard Lowe 
11949d3bc91SRichard Lowe /*
12049d3bc91SRichard Lowe 	producer:
12149d3bc91SRichard Lowe 	Struct to hold information about address ranges.
12249d3bc91SRichard Lowe */
12349d3bc91SRichard Lowe typedef struct Dwarf_P_Simple_nameentry_s *Dwarf_P_Simple_nameentry;
12449d3bc91SRichard Lowe typedef struct Dwarf_P_Simple_name_header_s *Dwarf_P_Simple_name_header;
12549d3bc91SRichard Lowe typedef struct Dwarf_P_Arange_s *Dwarf_P_Arange;
12649d3bc91SRichard Lowe typedef struct Dwarf_P_Per_Reloc_Sect_s *Dwarf_P_Per_Reloc_Sect;
127*07dc1947SRichard Lowe typedef struct Dwarf_P_Per_Sect_String_Attrs_s *Dwarf_P_Per_Sect_String_Attrs;
12849d3bc91SRichard Lowe 
12949d3bc91SRichard Lowe /* Defined to get at the elf section numbers and section name
13049d3bc91SRichard Lowe    indices in symtab for the dwarf sections
13149d3bc91SRichard Lowe    Must match .rel.* names in _dwarf_rel_section_names
13249d3bc91SRichard Lowe    exactly.
13349d3bc91SRichard Lowe */
13449d3bc91SRichard Lowe #define         DEBUG_INFO      0
13549d3bc91SRichard Lowe #define         DEBUG_LINE      1
13649d3bc91SRichard Lowe #define         DEBUG_ABBREV    2
13749d3bc91SRichard Lowe #define         DEBUG_FRAME     3
13849d3bc91SRichard Lowe #define         DEBUG_ARANGES   4
13949d3bc91SRichard Lowe #define         DEBUG_PUBNAMES  5
14049d3bc91SRichard Lowe #define         DEBUG_STR       6
14149d3bc91SRichard Lowe #define         DEBUG_FUNCNAMES 7
14249d3bc91SRichard Lowe #define         DEBUG_TYPENAMES 8
14349d3bc91SRichard Lowe #define         DEBUG_VARNAMES  9
14449d3bc91SRichard Lowe #define         DEBUG_WEAKNAMES 10
14549d3bc91SRichard Lowe #define         DEBUG_MACINFO   11
14649d3bc91SRichard Lowe #define         DEBUG_LOC   12
14749d3bc91SRichard Lowe 
14849d3bc91SRichard Lowe     /* number of debug_* sections not including the relocations */
14949d3bc91SRichard Lowe #define         NUM_DEBUG_SECTIONS      DEBUG_LOC + 1
15049d3bc91SRichard Lowe 
15149d3bc91SRichard Lowe 
15249d3bc91SRichard Lowe struct Dwarf_P_Die_s {
15349d3bc91SRichard Lowe     Dwarf_Unsigned di_offset;	/* offset in debug info */
15449d3bc91SRichard Lowe     char *di_abbrev;		/* abbreviation */
15549d3bc91SRichard Lowe     Dwarf_Word di_abbrev_nbytes;	/* # of bytes in abbrev */
15649d3bc91SRichard Lowe     Dwarf_Tag di_tag;
15749d3bc91SRichard Lowe     Dwarf_P_Die di_parent;	/* parent of current die */
15849d3bc91SRichard Lowe     Dwarf_P_Die di_child;	/* first child */
159*07dc1947SRichard Lowe     /* The last child field makes linking up children an O(1) operation,
160*07dc1947SRichard Lowe        See pro_die.c. */
161*07dc1947SRichard Lowe     Dwarf_P_Die di_last_child;
16249d3bc91SRichard Lowe     Dwarf_P_Die di_left;	/* left sibling */
16349d3bc91SRichard Lowe     Dwarf_P_Die di_right;	/* right sibling */
16449d3bc91SRichard Lowe     Dwarf_P_Attribute di_attrs;	/* list of attributes */
16549d3bc91SRichard Lowe     Dwarf_P_Attribute di_last_attr;	/* last attribute */
16649d3bc91SRichard Lowe     int di_n_attr;		/* number of attributes */
167*07dc1947SRichard Lowe     Dwarf_P_Debug di_dbg;	/* For memory management */
168*07dc1947SRichard Lowe     Dwarf_Unsigned di_marker;   /* used to attach symbols to dies */
16949d3bc91SRichard Lowe };
17049d3bc91SRichard Lowe 
17149d3bc91SRichard Lowe 
17249d3bc91SRichard Lowe /* producer fields */
17349d3bc91SRichard Lowe struct Dwarf_P_Attribute_s {
17449d3bc91SRichard Lowe     Dwarf_Half ar_attribute;	/* Attribute Value. */
17549d3bc91SRichard Lowe     Dwarf_Half ar_attribute_form;	/* Attribute Form. */
17649d3bc91SRichard Lowe     Dwarf_P_Die ar_ref_die;	/* die pointer if form ref */
17749d3bc91SRichard Lowe     char *ar_data;		/* data, format given by form */
17849d3bc91SRichard Lowe     Dwarf_Unsigned ar_nbytes;	/* no. of bytes of data */
17949d3bc91SRichard Lowe     Dwarf_Unsigned ar_rel_symidx;	/* when attribute has a
18049d3bc91SRichard Lowe 					   relocatable value, holds
18149d3bc91SRichard Lowe 					   index of symbol in SYMTAB */
18249d3bc91SRichard Lowe     Dwarf_Ubyte ar_rel_type;	/* relocation type */
18349d3bc91SRichard Lowe     Dwarf_Word ar_rel_offset;	/* Offset of relocation within block */
18449d3bc91SRichard Lowe     char ar_reloc_len;		/* Number of bytes that relocation
18549d3bc91SRichard Lowe 				   applies to. 4 or 8. Unused and may
18649d3bc91SRichard Lowe 				   be 0 if if ar_rel_type is
18749d3bc91SRichard Lowe 				   R_MIPS_NONE */
18849d3bc91SRichard Lowe     Dwarf_P_Attribute ar_next;
18949d3bc91SRichard Lowe };
19049d3bc91SRichard Lowe 
19149d3bc91SRichard Lowe /* A block of .debug_macinfo data: this forms a series of blocks.
19249d3bc91SRichard Lowe ** Each macinfo input is compressed immediately and put into
19349d3bc91SRichard Lowe ** the current block if room, else a newblock allocated.
19449d3bc91SRichard Lowe ** The space allocation is such that the block and the macinfo
19549d3bc91SRichard Lowe ** data are one malloc block: free with a pointer to this and the
19649d3bc91SRichard Lowe ** mb_data is freed automatically.
19749d3bc91SRichard Lowe ** Like the struct hack, but legal ANSI C.
19849d3bc91SRichard Lowe */
19949d3bc91SRichard Lowe struct dw_macinfo_block_s {
20049d3bc91SRichard Lowe     struct dw_macinfo_block_s *mb_next;
20149d3bc91SRichard Lowe     unsigned long mb_avail_len;
20249d3bc91SRichard Lowe     unsigned long mb_used_len;
20349d3bc91SRichard Lowe     unsigned long mb_macinfo_data_space_len;
20449d3bc91SRichard Lowe     char *mb_data;		/* original malloc ptr. */
20549d3bc91SRichard Lowe };
20649d3bc91SRichard Lowe 
20749d3bc91SRichard Lowe /* dwarf_sn_kind is for the array of similarly-treated
20849d3bc91SRichard Lowe    name -> cu ties
20949d3bc91SRichard Lowe */
21049d3bc91SRichard Lowe enum dwarf_sn_kind { dwarf_snk_pubname, dwarf_snk_funcname,
21149d3bc91SRichard Lowe     dwarf_snk_weakname, dwarf_snk_typename,
21249d3bc91SRichard Lowe     dwarf_snk_varname,
21349d3bc91SRichard Lowe     dwarf_snk_entrycount	/* this one must be last */
21449d3bc91SRichard Lowe };
21549d3bc91SRichard Lowe 
21649d3bc91SRichard Lowe 
21749d3bc91SRichard Lowe 
21849d3bc91SRichard Lowe /* The calls to add a varname etc use a list of
21949d3bc91SRichard Lowe    these as the list.
22049d3bc91SRichard Lowe */
22149d3bc91SRichard Lowe struct Dwarf_P_Simple_nameentry_s {
22249d3bc91SRichard Lowe     Dwarf_P_Die sne_die;
22349d3bc91SRichard Lowe     char *sne_name;
22449d3bc91SRichard Lowe     int sne_name_len;
22549d3bc91SRichard Lowe     Dwarf_P_Simple_nameentry sne_next;
22649d3bc91SRichard Lowe };
22749d3bc91SRichard Lowe 
22849d3bc91SRichard Lowe /* An array of these, each of which heads a list
22949d3bc91SRichard Lowe    of Dwarf_P_Simple_nameentry
23049d3bc91SRichard Lowe */
23149d3bc91SRichard Lowe struct Dwarf_P_Simple_name_header_s {
23249d3bc91SRichard Lowe     Dwarf_P_Simple_nameentry sn_head;
23349d3bc91SRichard Lowe     Dwarf_P_Simple_nameentry sn_tail;
23449d3bc91SRichard Lowe     Dwarf_Signed sn_count;
23549d3bc91SRichard Lowe 
23649d3bc91SRichard Lowe     /* length that will be generated, not counting fixed header or
23749d3bc91SRichard Lowe        trailer */
23849d3bc91SRichard Lowe     Dwarf_Signed sn_net_len;
23949d3bc91SRichard Lowe };
240*07dc1947SRichard Lowe typedef int (*_dwarf_pro_reloc_name_func_ptr) (Dwarf_P_Debug dbg,
241*07dc1947SRichard Lowe     int sec_index,
242*07dc1947SRichard Lowe     Dwarf_Unsigned offset,/* r_offset */
24349d3bc91SRichard Lowe     Dwarf_Unsigned symidx,
24449d3bc91SRichard Lowe     enum Dwarf_Rel_Type type,
24549d3bc91SRichard Lowe     int reltarget_length);
24649d3bc91SRichard Lowe 
247*07dc1947SRichard Lowe typedef int (*_dwarf_pro_reloc_length_func_ptr) (Dwarf_P_Debug dbg,
248*07dc1947SRichard Lowe     int sec_index, Dwarf_Unsigned offset,/* r_offset */
249*07dc1947SRichard Lowe     Dwarf_Unsigned start_symidx,
250*07dc1947SRichard Lowe     Dwarf_Unsigned end_symidx,
251*07dc1947SRichard Lowe     enum Dwarf_Rel_Type type,
25249d3bc91SRichard Lowe     int reltarget_length);
25349d3bc91SRichard Lowe typedef int (*_dwarf_pro_transform_relocs_func_ptr) (Dwarf_P_Debug dbg,
25449d3bc91SRichard Lowe 						     Dwarf_Signed *
25549d3bc91SRichard Lowe 						     new_sec_count);
25649d3bc91SRichard Lowe 
25749d3bc91SRichard Lowe /*
25849d3bc91SRichard Lowe     Each slot in a block of slots could be:
25949d3bc91SRichard Lowe     a binary stream relocation entry (32 or 64bit relocation data)
26049d3bc91SRichard Lowe     a SYMBOLIC relocation entry.
26149d3bc91SRichard Lowe     During creation sometimes we create multiple chained blocks,
26249d3bc91SRichard Lowe     but sometimes we create a single long block.
26349d3bc91SRichard Lowe     Before returning reloc data to caller,
26449d3bc91SRichard Lowe     we switch to a single, long-enough,
26549d3bc91SRichard Lowe     block.
26649d3bc91SRichard Lowe 
26749d3bc91SRichard Lowe     We make counters here Dwarf_Unsigned so that we
26849d3bc91SRichard Lowe     get sufficient alignment. Since we use space after
26949d3bc91SRichard Lowe     the struct (at malloc time) for user data which
27049d3bc91SRichard Lowe     must have Dwarf_Unsigned alignment, this
27149d3bc91SRichard Lowe     struct must have that alignment too.
27249d3bc91SRichard Lowe */
27349d3bc91SRichard Lowe struct Dwarf_P_Relocation_Block_s {
27449d3bc91SRichard Lowe     Dwarf_Unsigned rb_slots_in_block;	/* slots in block, as created */
27549d3bc91SRichard Lowe     Dwarf_Unsigned rb_next_slot_to_use;	/* counter, start at 0. */
27649d3bc91SRichard Lowe     struct Dwarf_P_Relocation_Block_s *rb_next;
27749d3bc91SRichard Lowe     char *rb_where_to_add_next;	/* pointer to next slot (might be past
27849d3bc91SRichard Lowe 				   end, depending on
27949d3bc91SRichard Lowe 				   rb_next_slot_to_use) */
28049d3bc91SRichard Lowe     char *rb_data;		/* data area */
28149d3bc91SRichard Lowe };
28249d3bc91SRichard Lowe 
28349d3bc91SRichard Lowe /* One of these per potential relocation section
28449d3bc91SRichard Lowe    So one per actual dwarf section.
28549d3bc91SRichard Lowe    Left zeroed when not used (some sections have
28649d3bc91SRichard Lowe    no relocations).
28749d3bc91SRichard Lowe */
28849d3bc91SRichard Lowe struct Dwarf_P_Per_Reloc_Sect_s {
28949d3bc91SRichard Lowe     unsigned long pr_reloc_total_count;	/* total number of entries
29049d3bc91SRichard Lowe         across all blocks */
29149d3bc91SRichard Lowe 
29249d3bc91SRichard Lowe     unsigned long pr_slots_per_block_to_alloc;	/* at Block alloc, this
293*07dc1947SRichard Lowe         is the default number of slots to use */
29449d3bc91SRichard Lowe 
29549d3bc91SRichard Lowe     int pr_sect_num_of_reloc_sect;	/* sect number returned by
296*07dc1947SRichard Lowe         de_callback_func() or de_callback_func_b() call, this is the sect
297*07dc1947SRichard Lowe         number of the relocation section. */
29849d3bc91SRichard Lowe 
29949d3bc91SRichard Lowe     /* singly-linked list. add at and ('last') with count of blocks */
30049d3bc91SRichard Lowe     struct Dwarf_P_Relocation_Block_s *pr_first_block;
30149d3bc91SRichard Lowe     struct Dwarf_P_Relocation_Block_s *pr_last_block;
30249d3bc91SRichard Lowe     unsigned long pr_block_count;
30349d3bc91SRichard Lowe };
30449d3bc91SRichard Lowe 
30549d3bc91SRichard Lowe #define DEFAULT_SLOTS_PER_BLOCK 3
30649d3bc91SRichard Lowe 
307*07dc1947SRichard Lowe typedef struct memory_list_s {
308*07dc1947SRichard Lowe   struct memory_list_s *prev;
309*07dc1947SRichard Lowe   struct memory_list_s *next;
310*07dc1947SRichard Lowe } memory_list_t;
311*07dc1947SRichard Lowe 
312*07dc1947SRichard Lowe struct Dwarf_P_Per_Sect_String_Attrs_s {
313*07dc1947SRichard Lowe     int sect_sa_section_number;
314*07dc1947SRichard Lowe     unsigned sect_sa_n_alloc;
315*07dc1947SRichard Lowe     unsigned sect_sa_n_used;
316*07dc1947SRichard Lowe     Dwarf_P_String_Attr sect_sa_list;
317*07dc1947SRichard Lowe };
31849d3bc91SRichard Lowe 
31949d3bc91SRichard Lowe /* Fields used by producer */
32049d3bc91SRichard Lowe struct Dwarf_P_Debug_s {
32149d3bc91SRichard Lowe     /* used to catch dso passing dbg to another DSO with incompatible
32249d3bc91SRichard Lowe        version of libdwarf See PRO_VERSION_MAGIC */
32349d3bc91SRichard Lowe     int de_version_magic_number;
32449d3bc91SRichard Lowe 
32549d3bc91SRichard Lowe     Dwarf_Handler de_errhand;
32649d3bc91SRichard Lowe     Dwarf_Ptr de_errarg;
32749d3bc91SRichard Lowe 
328*07dc1947SRichard Lowe     /* Call back function, used to create .debug* sections. Provided
32949d3bc91SRichard Lowe        by user. Only of these used per dbg. */
330*07dc1947SRichard Lowe     Dwarf_Callback_Func de_callback_func;
331*07dc1947SRichard Lowe     Dwarf_Callback_Func_b de_callback_func_b;
33249d3bc91SRichard Lowe 
33349d3bc91SRichard Lowe     /* Flags from producer_init call */
33449d3bc91SRichard Lowe     Dwarf_Unsigned de_flags;
33549d3bc91SRichard Lowe 
33649d3bc91SRichard Lowe     /* This holds information on debug section stream output, including
33749d3bc91SRichard Lowe        the stream data */
33849d3bc91SRichard Lowe     Dwarf_P_Section_Data de_debug_sects;
33949d3bc91SRichard Lowe 
34049d3bc91SRichard Lowe     /* Pointer to the 'current active' section */
34149d3bc91SRichard Lowe     Dwarf_P_Section_Data de_current_active_section;
34249d3bc91SRichard Lowe 
34349d3bc91SRichard Lowe     /* Number of debug data streams globs. */
34449d3bc91SRichard Lowe     Dwarf_Word de_n_debug_sect;
34549d3bc91SRichard Lowe 
34649d3bc91SRichard Lowe     /* File entry information, null terminated singly-linked list */
34749d3bc91SRichard Lowe     Dwarf_P_F_Entry de_file_entries;
34849d3bc91SRichard Lowe     Dwarf_P_F_Entry de_last_file_entry;
34949d3bc91SRichard Lowe     Dwarf_Unsigned de_n_file_entries;
35049d3bc91SRichard Lowe 
35149d3bc91SRichard Lowe     /* Has the directories used to search for source files */
35249d3bc91SRichard Lowe     Dwarf_P_Inc_Dir de_inc_dirs;
35349d3bc91SRichard Lowe     Dwarf_P_Inc_Dir de_last_inc_dir;
35449d3bc91SRichard Lowe     Dwarf_Unsigned de_n_inc_dirs;
35549d3bc91SRichard Lowe 
35649d3bc91SRichard Lowe     /* Has all the line number info for the stmt program */
35749d3bc91SRichard Lowe     Dwarf_P_Line de_lines;
35849d3bc91SRichard Lowe     Dwarf_P_Line de_last_line;
35949d3bc91SRichard Lowe 
36049d3bc91SRichard Lowe     /* List of cie's for the debug unit */
36149d3bc91SRichard Lowe     Dwarf_P_Cie de_frame_cies;
36249d3bc91SRichard Lowe     Dwarf_P_Cie de_last_cie;
36349d3bc91SRichard Lowe     Dwarf_Unsigned de_n_cie;
36449d3bc91SRichard Lowe 
36549d3bc91SRichard Lowe     /* Singly-linked list of fde's for the debug unit */
36649d3bc91SRichard Lowe     Dwarf_P_Fde de_frame_fdes;
36749d3bc91SRichard Lowe     Dwarf_P_Fde de_last_fde;
36849d3bc91SRichard Lowe     Dwarf_Unsigned de_n_fde;
36949d3bc91SRichard Lowe 
37049d3bc91SRichard Lowe     /* First die, leads to all others */
37149d3bc91SRichard Lowe     Dwarf_P_Die de_dies;
37249d3bc91SRichard Lowe 
37349d3bc91SRichard Lowe     /* Pointer to list of strings */
37449d3bc91SRichard Lowe     char *de_strings;
37549d3bc91SRichard Lowe 
37649d3bc91SRichard Lowe     /* Pointer to chain of aranges */
37749d3bc91SRichard Lowe     Dwarf_P_Arange de_arange;
37849d3bc91SRichard Lowe     Dwarf_P_Arange de_last_arange;
37949d3bc91SRichard Lowe     Dwarf_Sword de_arange_count;
38049d3bc91SRichard Lowe 
38149d3bc91SRichard Lowe     /* macinfo controls. */
38249d3bc91SRichard Lowe     /* first points to beginning of the list during creation */
38349d3bc91SRichard Lowe     struct dw_macinfo_block_s *de_first_macinfo;
38449d3bc91SRichard Lowe 
38549d3bc91SRichard Lowe     /* current points to the current, unfilled, block */
38649d3bc91SRichard Lowe     struct dw_macinfo_block_s *de_current_macinfo;
38749d3bc91SRichard Lowe 
38849d3bc91SRichard Lowe     /* Pointer to the first section, to support reset_section_bytes */
38949d3bc91SRichard Lowe     Dwarf_P_Section_Data de_first_debug_sect;
39049d3bc91SRichard Lowe 
39149d3bc91SRichard Lowe     /* handles pubnames, weaknames, etc. See dwarf_sn_kind in
39249d3bc91SRichard Lowe        pro_opaque.h */
39349d3bc91SRichard Lowe     struct Dwarf_P_Simple_name_header_s
39449d3bc91SRichard Lowe       de_simple_name_headers[dwarf_snk_entrycount];
39549d3bc91SRichard Lowe 
39649d3bc91SRichard Lowe     /* relocation data. not all sections will actally have relocation
39749d3bc91SRichard Lowe        info, of course */
39849d3bc91SRichard Lowe     struct Dwarf_P_Per_Reloc_Sect_s de_reloc_sect[NUM_DEBUG_SECTIONS];
39949d3bc91SRichard Lowe     int de_reloc_next_to_return;	/* iterator on reloc sections
40049d3bc91SRichard Lowe 					   (SYMBOLIC output) */
40149d3bc91SRichard Lowe 
40249d3bc91SRichard Lowe     /* used in remembering sections */
403*07dc1947SRichard Lowe     int de_elf_sects[NUM_DEBUG_SECTIONS];  /* elf sect number of
404*07dc1947SRichard Lowe         the section itself, DEBUG_LINE for example */
40549d3bc91SRichard Lowe 
40649d3bc91SRichard Lowe     Dwarf_Unsigned de_sect_name_idx[NUM_DEBUG_SECTIONS]; /* section
407*07dc1947SRichard Lowe         name index or handle for the name of the symbol for
408*07dc1947SRichard Lowe         DEBUG_LINE for example */
40949d3bc91SRichard Lowe 
41049d3bc91SRichard Lowe     int de_offset_reloc;	/* offset reloc type, R_MIPS_32 for
41149d3bc91SRichard Lowe 				   example. Specific to the ABI being
41249d3bc91SRichard Lowe 				   produced. Relocates offset size
41349d3bc91SRichard Lowe 				   field */
41449d3bc91SRichard Lowe     int de_exc_reloc;		/* reloc type specific to exception
41549d3bc91SRichard Lowe 				   table relocs. */
41649d3bc91SRichard Lowe     int de_ptr_reloc;		/* standard reloc type, R_MIPS_32 for
41749d3bc91SRichard Lowe 				   example. Specific to the ABI being
41849d3bc91SRichard Lowe 				   produced. relocates pointer size
41949d3bc91SRichard Lowe 				   field */
42049d3bc91SRichard Lowe 
42149d3bc91SRichard Lowe     unsigned char de_offset_size;  /* section offset. Here to
42249d3bc91SRichard Lowe                                       avoid test of abi in macro
42349d3bc91SRichard Lowe                                       at run time MIPS -n32 4,
42449d3bc91SRichard Lowe                                       -64 8.  */
42549d3bc91SRichard Lowe 
42649d3bc91SRichard Lowe     unsigned char de_pointer_size;	/* size of pointer in target.
42749d3bc91SRichard Lowe 					   Here to avoid test of abi in
42849d3bc91SRichard Lowe 					   macro at run time MIPS -n32
42949d3bc91SRichard Lowe 					   4, -64 is 8.  */
43049d3bc91SRichard Lowe 
43149d3bc91SRichard Lowe     unsigned char de_is_64bit;	/* non-zero if is 64bit. Else 32 bit:
43249d3bc91SRichard Lowe 				   used for passing this info as a flag
43349d3bc91SRichard Lowe 				 */
43449d3bc91SRichard Lowe     unsigned char de_relocation_record_size;	/* reloc record size
43549d3bc91SRichard Lowe 						   varies by ABI and
43649d3bc91SRichard Lowe 						   relocation-output
43749d3bc91SRichard Lowe 						   method (stream or
43849d3bc91SRichard Lowe 						   symbolic) */
43949d3bc91SRichard Lowe 
44049d3bc91SRichard Lowe     unsigned char de_64bit_extension;	/* non-zero if creating 64 bit
44149d3bc91SRichard Lowe 					   offsets using dwarf2-99
44249d3bc91SRichard Lowe 					   extension proposal */
44349d3bc91SRichard Lowe 
44449d3bc91SRichard Lowe     int de_ar_data_attribute_form;	/* data8, data4 abi dependent */
44549d3bc91SRichard Lowe     int de_ar_ref_attr_form;	/* ref8 ref4 , abi dependent */
44649d3bc91SRichard Lowe 
44749d3bc91SRichard Lowe     /* simple name relocations */
44849d3bc91SRichard Lowe     _dwarf_pro_reloc_name_func_ptr de_reloc_name;
44949d3bc91SRichard Lowe 
45049d3bc91SRichard Lowe     /* relocations for a length, requiring a pair of symbols */
45149d3bc91SRichard Lowe     _dwarf_pro_reloc_length_func_ptr de_reloc_pair;
45249d3bc91SRichard Lowe 
45349d3bc91SRichard Lowe     _dwarf_pro_transform_relocs_func_ptr de_transform_relocs_to_disk;
45449d3bc91SRichard Lowe 
45549d3bc91SRichard Lowe     /* following used for macro buffers */
45649d3bc91SRichard Lowe     unsigned long de_compose_avail;
45749d3bc91SRichard Lowe     unsigned long de_compose_used_len;
45849d3bc91SRichard Lowe 
45949d3bc91SRichard Lowe     unsigned char de_same_endian;
46049d3bc91SRichard Lowe     void *(*de_copy_word) (void *, const void *, size_t);
46149d3bc91SRichard Lowe 
46249d3bc91SRichard Lowe     /* Add new fields at the END of this struct to preserve some hope
46349d3bc91SRichard Lowe        of sensible behavior on dbg passing between DSOs linked with
46449d3bc91SRichard Lowe        mismatched libdwarf producer versions. */
46549d3bc91SRichard Lowe 
466*07dc1947SRichard Lowe     Dwarf_P_Marker de_markers;  /* pointer to array of markers */
467*07dc1947SRichard Lowe     unsigned de_marker_n_alloc;
468*07dc1947SRichard Lowe     unsigned de_marker_n_used;
469*07dc1947SRichard Lowe     int de_sect_sa_next_to_return;  /* Iterator on sring attrib sects */
470*07dc1947SRichard Lowe     /* String attributes data of each section. */
471*07dc1947SRichard Lowe     struct Dwarf_P_Per_Sect_String_Attrs_s de_sect_string_attr[NUM_DEBUG_SECTIONS];
47249d3bc91SRichard Lowe };
47349d3bc91SRichard Lowe 
47449d3bc91SRichard Lowe #define CURRENT_VERSION_STAMP		2
47549d3bc91SRichard Lowe 
47649d3bc91SRichard Lowe Dwarf_Unsigned _dwarf_add_simple_name_entry(Dwarf_P_Debug dbg,
47749d3bc91SRichard Lowe 					    Dwarf_P_Die die,
47849d3bc91SRichard Lowe 					    char *entry_name,
47949d3bc91SRichard Lowe 					    enum dwarf_sn_kind
48049d3bc91SRichard Lowe 					    entrykind,
48149d3bc91SRichard Lowe 					    Dwarf_Error * error);
48249d3bc91SRichard Lowe 
48349d3bc91SRichard Lowe 
48449d3bc91SRichard Lowe #define DISTINGUISHED_VALUE 0xffffffff	/* 64bit extension flag */
485