xref: /netbsd-src/external/gpl3/gdb/dist/include/elf/dwarf.h (revision 02f41505626a9ceb584d30d0789203495760ac88)
198b9484cSchristos /* Declarations and definitions of codes relating to the DWARF symbolic
298b9484cSchristos    debugging information format.
398b9484cSchristos 
498b9484cSchristos    Written by Ron Guilmette (rfg@netcom.com)
598b9484cSchristos 
6*02f41505Schristos    Copyright (C) 1992-2024 Free Software Foundation, Inc.
798b9484cSchristos 
898b9484cSchristos    This file is part of both GCC and the BFD library.
998b9484cSchristos 
1098b9484cSchristos    This program is free software; you can redistribute it and/or modify
1198b9484cSchristos    it under the terms of the GNU General Public License as published by
1298b9484cSchristos    the Free Software Foundation; either version 3 of the License, or
1398b9484cSchristos    (at your option) any later version.
1498b9484cSchristos 
1598b9484cSchristos    This program is distributed in the hope that it will be useful,
1698b9484cSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1798b9484cSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1898b9484cSchristos    GNU General Public License for more details.
1998b9484cSchristos 
2098b9484cSchristos    You should have received a copy of the GNU General Public License
2198b9484cSchristos    along with GCC; see the file COPYING3.  If not, write to the Free
2298b9484cSchristos    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
2398b9484cSchristos    02110-1301, USA.  */
2498b9484cSchristos 
2598b9484cSchristos /* This file is derived from the DWARF specification (a public document)
2698b9484cSchristos    Revision 1.0.1 (April 8, 1992) developed by the UNIX International
2798b9484cSchristos    Programming Languages Special Interest Group (UI/PLSIG) and distributed
2898b9484cSchristos    by UNIX International.  Copies of this specification are available from
2998b9484cSchristos    UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054.  */
3098b9484cSchristos 
3198b9484cSchristos #ifndef _ELF_DWARF_H
3298b9484cSchristos #define _ELF_DWARF_H
3398b9484cSchristos 
3498b9484cSchristos /* Tag names and codes.  */
3598b9484cSchristos 
3698b9484cSchristos enum dwarf_tag {
3798b9484cSchristos     TAG_padding			= 0x0000,
3898b9484cSchristos     TAG_array_type		= 0x0001,
3998b9484cSchristos     TAG_class_type		= 0x0002,
4098b9484cSchristos     TAG_entry_point		= 0x0003,
4198b9484cSchristos     TAG_enumeration_type	= 0x0004,
4298b9484cSchristos     TAG_formal_parameter	= 0x0005,
4398b9484cSchristos     TAG_global_subroutine	= 0x0006,
4498b9484cSchristos     TAG_global_variable		= 0x0007,
4598b9484cSchristos     				/* 0x0008 -- reserved */
4698b9484cSchristos 				/* 0x0009 -- reserved */
4798b9484cSchristos     TAG_label			= 0x000a,
4898b9484cSchristos     TAG_lexical_block		= 0x000b,
4998b9484cSchristos     TAG_local_variable		= 0x000c,
5098b9484cSchristos     TAG_member			= 0x000d,
5198b9484cSchristos 				/* 0x000e -- reserved */
5298b9484cSchristos     TAG_pointer_type		= 0x000f,
5398b9484cSchristos     TAG_reference_type		= 0x0010,
5498b9484cSchristos     TAG_compile_unit		= 0x0011,
5598b9484cSchristos     TAG_string_type		= 0x0012,
5698b9484cSchristos     TAG_structure_type		= 0x0013,
5798b9484cSchristos     TAG_subroutine		= 0x0014,
5898b9484cSchristos     TAG_subroutine_type		= 0x0015,
5998b9484cSchristos     TAG_typedef			= 0x0016,
6098b9484cSchristos     TAG_union_type		= 0x0017,
6198b9484cSchristos     TAG_unspecified_parameters	= 0x0018,
6298b9484cSchristos     TAG_variant			= 0x0019,
6398b9484cSchristos     TAG_common_block		= 0x001a,
6498b9484cSchristos     TAG_common_inclusion	= 0x001b,
6598b9484cSchristos     TAG_inheritance		= 0x001c,
6698b9484cSchristos     TAG_inlined_subroutine	= 0x001d,
6798b9484cSchristos     TAG_module			= 0x001e,
6898b9484cSchristos     TAG_ptr_to_member_type	= 0x001f,
6998b9484cSchristos     TAG_set_type		= 0x0020,
7098b9484cSchristos     TAG_subrange_type		= 0x0021,
7198b9484cSchristos     TAG_with_stmt		= 0x0022,
7298b9484cSchristos 
7398b9484cSchristos     /* GNU extensions */
7498b9484cSchristos 
7598b9484cSchristos     TAG_format_label		= 0x8000,  /* for FORTRAN 77 and Fortran 90 */
7698b9484cSchristos     TAG_namelist		= 0x8001,  /* For Fortran 90 */
7798b9484cSchristos     TAG_function_template	= 0x8002,  /* for C++ */
7898b9484cSchristos     TAG_class_template		= 0x8003   /* for C++ */
7998b9484cSchristos };
8098b9484cSchristos 
8198b9484cSchristos #define TAG_lo_user	0x8000  /* implementation-defined range start */
8298b9484cSchristos #define TAG_hi_user	0xffff  /* implementation-defined range end */
8398b9484cSchristos #define TAG_source_file TAG_compile_unit  /* for backward compatibility */
8498b9484cSchristos 
8598b9484cSchristos /* Form names and codes.  */
8698b9484cSchristos 
8798b9484cSchristos enum dwarf_form {
8898b9484cSchristos     FORM_ADDR	= 0x1,
8998b9484cSchristos     FORM_REF	= 0x2,
9098b9484cSchristos     FORM_BLOCK2	= 0x3,
9198b9484cSchristos     FORM_BLOCK4	= 0x4,
9298b9484cSchristos     FORM_DATA2	= 0x5,
9398b9484cSchristos     FORM_DATA4	= 0x6,
9498b9484cSchristos     FORM_DATA8	= 0x7,
9598b9484cSchristos     FORM_STRING	= 0x8
9698b9484cSchristos };
9798b9484cSchristos 
9898b9484cSchristos /* Attribute names and codes.  */
9998b9484cSchristos 
10098b9484cSchristos enum dwarf_attribute {
10198b9484cSchristos     AT_sibling			= (0x0010|FORM_REF),
10298b9484cSchristos     AT_location			= (0x0020|FORM_BLOCK2),
10398b9484cSchristos     AT_name			= (0x0030|FORM_STRING),
10498b9484cSchristos     AT_fund_type		= (0x0050|FORM_DATA2),
10598b9484cSchristos     AT_mod_fund_type		= (0x0060|FORM_BLOCK2),
10698b9484cSchristos     AT_user_def_type		= (0x0070|FORM_REF),
10798b9484cSchristos     AT_mod_u_d_type		= (0x0080|FORM_BLOCK2),
10898b9484cSchristos     AT_ordering			= (0x0090|FORM_DATA2),
10998b9484cSchristos     AT_subscr_data		= (0x00a0|FORM_BLOCK2),
11098b9484cSchristos     AT_byte_size		= (0x00b0|FORM_DATA4),
11198b9484cSchristos     AT_bit_offset		= (0x00c0|FORM_DATA2),
11298b9484cSchristos     AT_bit_size			= (0x00d0|FORM_DATA4),
11398b9484cSchristos 				/* (0x00e0|FORM_xxxx) -- reserved */
11498b9484cSchristos     AT_element_list		= (0x00f0|FORM_BLOCK4),
11598b9484cSchristos     AT_stmt_list		= (0x0100|FORM_DATA4),
11698b9484cSchristos     AT_low_pc			= (0x0110|FORM_ADDR),
11798b9484cSchristos     AT_high_pc			= (0x0120|FORM_ADDR),
11898b9484cSchristos     AT_language			= (0x0130|FORM_DATA4),
11998b9484cSchristos     AT_member			= (0x0140|FORM_REF),
12098b9484cSchristos     AT_discr			= (0x0150|FORM_REF),
12198b9484cSchristos     AT_discr_value		= (0x0160|FORM_BLOCK2),
12298b9484cSchristos 				/* (0x0170|FORM_xxxx) -- reserved */
12398b9484cSchristos 				/* (0x0180|FORM_xxxx) -- reserved */
12498b9484cSchristos     AT_string_length		= (0x0190|FORM_BLOCK2),
12598b9484cSchristos     AT_common_reference		= (0x01a0|FORM_REF),
12698b9484cSchristos     AT_comp_dir			= (0x01b0|FORM_STRING),
12798b9484cSchristos         AT_const_value_string	= (0x01c0|FORM_STRING),
12898b9484cSchristos         AT_const_value_data2	= (0x01c0|FORM_DATA2),
12998b9484cSchristos         AT_const_value_data4	= (0x01c0|FORM_DATA4),
13098b9484cSchristos         AT_const_value_data8	= (0x01c0|FORM_DATA8),
13198b9484cSchristos         AT_const_value_block2	= (0x01c0|FORM_BLOCK2),
13298b9484cSchristos         AT_const_value_block4	= (0x01c0|FORM_BLOCK4),
13398b9484cSchristos     AT_containing_type		= (0x01d0|FORM_REF),
13498b9484cSchristos         AT_default_value_addr	= (0x01e0|FORM_ADDR),
13598b9484cSchristos         AT_default_value_data2	= (0x01e0|FORM_DATA2),
13698b9484cSchristos         AT_default_value_data4	= (0x01e0|FORM_DATA4),
13798b9484cSchristos         AT_default_value_data8	= (0x01e0|FORM_DATA8),
13898b9484cSchristos         AT_default_value_string	= (0x01e0|FORM_STRING),
13998b9484cSchristos     AT_friends			= (0x01f0|FORM_BLOCK2),
14098b9484cSchristos     AT_inline			= (0x0200|FORM_STRING),
14198b9484cSchristos     AT_is_optional		= (0x0210|FORM_STRING),
14298b9484cSchristos         AT_lower_bound_ref	= (0x0220|FORM_REF),
14398b9484cSchristos         AT_lower_bound_data2	= (0x0220|FORM_DATA2),
14498b9484cSchristos         AT_lower_bound_data4	= (0x0220|FORM_DATA4),
14598b9484cSchristos         AT_lower_bound_data8	= (0x0220|FORM_DATA8),
14698b9484cSchristos     AT_private			= (0x0240|FORM_STRING),
14798b9484cSchristos     AT_producer			= (0x0250|FORM_STRING),
14898b9484cSchristos     AT_program			= (0x0230|FORM_STRING),
14998b9484cSchristos     AT_protected		= (0x0260|FORM_STRING),
15098b9484cSchristos     AT_prototyped		= (0x0270|FORM_STRING),
15198b9484cSchristos     AT_public			= (0x0280|FORM_STRING),
15298b9484cSchristos     AT_pure_virtual		= (0x0290|FORM_STRING),
15398b9484cSchristos     AT_return_addr		= (0x02a0|FORM_BLOCK2),
15498b9484cSchristos     AT_abstract_origin		= (0x02b0|FORM_REF),
15598b9484cSchristos     AT_start_scope		= (0x02c0|FORM_DATA4),
15698b9484cSchristos     AT_stride_size		= (0x02e0|FORM_DATA4),
15798b9484cSchristos         AT_upper_bound_ref	= (0x02f0|FORM_REF),
15898b9484cSchristos         AT_upper_bound_data2	= (0x02f0|FORM_DATA2),
15998b9484cSchristos         AT_upper_bound_data4	= (0x02f0|FORM_DATA4),
16098b9484cSchristos         AT_upper_bound_data8	= (0x02f0|FORM_DATA8),
16198b9484cSchristos     AT_virtual			= (0x0300|FORM_STRING),
16298b9484cSchristos 
16398b9484cSchristos     /* GNU extensions.  */
16498b9484cSchristos 
16598b9484cSchristos     AT_sf_names			= (0x8000|FORM_DATA4),
16698b9484cSchristos     AT_src_info			= (0x8010|FORM_DATA4),
16798b9484cSchristos     AT_mac_info			= (0x8020|FORM_DATA4),
16898b9484cSchristos     AT_src_coords		= (0x8030|FORM_DATA4),
16998b9484cSchristos     AT_body_begin		= (0x8040|FORM_ADDR),
17098b9484cSchristos     AT_body_end			= (0x8050|FORM_ADDR)
17198b9484cSchristos };
17298b9484cSchristos 
17398b9484cSchristos #define AT_lo_user	0x2000	/* implementation-defined range start */
17498b9484cSchristos #define AT_hi_user	0x3ff0	/* implementation-defined range end */
17598b9484cSchristos 
17698b9484cSchristos /* Location atom names and codes.  */
17798b9484cSchristos 
17898b9484cSchristos enum dwarf_location_atom {
17998b9484cSchristos     OP_REG	= 0x01,
18098b9484cSchristos     OP_BASEREG	= 0x02,
18198b9484cSchristos     OP_ADDR	= 0x03,
18298b9484cSchristos     OP_CONST	= 0x04,
18398b9484cSchristos     OP_DEREF2	= 0x05,
18498b9484cSchristos     OP_DEREF4	= 0x06,
18598b9484cSchristos     OP_ADD	= 0x07,
18698b9484cSchristos 
18798b9484cSchristos     /* GNU extensions.  */
18898b9484cSchristos 
18998b9484cSchristos     OP_MULT	= 0x80
19098b9484cSchristos };
19198b9484cSchristos 
19298b9484cSchristos #define OP_LO_USER	0x80  /* implementation-defined range start */
19398b9484cSchristos #define OP_HI_USER	0xff  /* implementation-defined range end */
19498b9484cSchristos 
19598b9484cSchristos /* Fundamental type names and codes.  */
19698b9484cSchristos 
19798b9484cSchristos enum dwarf_fundamental_type {
19898b9484cSchristos     FT_char		= 0x0001,
19998b9484cSchristos     FT_signed_char	= 0x0002,
20098b9484cSchristos     FT_unsigned_char	= 0x0003,
20198b9484cSchristos     FT_short		= 0x0004,
20298b9484cSchristos     FT_signed_short	= 0x0005,
20398b9484cSchristos     FT_unsigned_short	= 0x0006,
20498b9484cSchristos     FT_integer		= 0x0007,
20598b9484cSchristos     FT_signed_integer	= 0x0008,
20698b9484cSchristos     FT_unsigned_integer	= 0x0009,
20798b9484cSchristos     FT_long		= 0x000a,
20898b9484cSchristos     FT_signed_long	= 0x000b,
20998b9484cSchristos     FT_unsigned_long	= 0x000c,
21098b9484cSchristos     FT_pointer		= 0x000d,  /* an alias for (void *) */
21198b9484cSchristos     FT_float		= 0x000e,
21298b9484cSchristos     FT_dbl_prec_float	= 0x000f,
21398b9484cSchristos     FT_ext_prec_float	= 0x0010,  /* breaks "classic" svr4 SDB */
21498b9484cSchristos     FT_complex		= 0x0011,  /* breaks "classic" svr4 SDB */
21598b9484cSchristos     FT_dbl_prec_complex	= 0x0012,  /* breaks "classic" svr4 SDB */
21698b9484cSchristos 			/* 0x0013 -- reserved */
21798b9484cSchristos     FT_void		= 0x0014,
21898b9484cSchristos     FT_boolean		= 0x0015,  /* breaks "classic" svr4 SDB */
21998b9484cSchristos     FT_ext_prec_complex	= 0x0016,  /* breaks "classic" svr4 SDB */
22098b9484cSchristos     FT_label		= 0x0017,
22198b9484cSchristos 
22298b9484cSchristos     /* GNU extensions
22398b9484cSchristos        The low order byte must indicate the size (in bytes) for the type.
22498b9484cSchristos        All of these types will probably break "classic" svr4 SDB.  */
22598b9484cSchristos 
22698b9484cSchristos     FT_long_long	= 0x8008,
22798b9484cSchristos     FT_signed_long_long	= 0x8108,
22898b9484cSchristos     FT_unsigned_long_long = 0x8208,
22998b9484cSchristos 
23098b9484cSchristos     FT_int8		= 0x9001,
23198b9484cSchristos     FT_signed_int8	= 0x9101,
23298b9484cSchristos     FT_unsigned_int8	= 0x9201,
23398b9484cSchristos     FT_int16		= 0x9302,
23498b9484cSchristos     FT_signed_int16	= 0x9402,
23598b9484cSchristos     FT_unsigned_int16	= 0x9502,
23698b9484cSchristos     FT_int32		= 0x9604,
23798b9484cSchristos     FT_signed_int32	= 0x9704,
23898b9484cSchristos     FT_unsigned_int32	= 0x9804,
23998b9484cSchristos     FT_int64		= 0x9908,
24098b9484cSchristos     FT_signed_int64	= 0x9a08,
24198b9484cSchristos     FT_unsigned_int64	= 0x9b08,
24298b9484cSchristos     FT_int128		= 0x9c10,
24398b9484cSchristos     FT_signed_int128	= 0x9d10,
24498b9484cSchristos     FT_unsigned_int128	= 0x9e10,
24598b9484cSchristos 
24698b9484cSchristos     FT_real32		= 0xa004,
24798b9484cSchristos     FT_real64		= 0xa108,
24898b9484cSchristos     FT_real96		= 0xa20c,
24998b9484cSchristos     FT_real128		= 0xa310
25098b9484cSchristos };
25198b9484cSchristos 
25298b9484cSchristos #define FT_lo_user	0x8000  /* implementation-defined range start */
25398b9484cSchristos #define FT_hi_user	0xffff  /* implementation defined range end */
25498b9484cSchristos 
25598b9484cSchristos /* Type modifier names and codes.  */
25698b9484cSchristos 
25798b9484cSchristos enum dwarf_type_modifier {
25898b9484cSchristos     MOD_pointer_to	= 0x01,
25998b9484cSchristos     MOD_reference_to	= 0x02,
26098b9484cSchristos     MOD_const		= 0x03,
26198b9484cSchristos     MOD_volatile	= 0x04
26298b9484cSchristos };
26398b9484cSchristos 
26498b9484cSchristos #define MOD_lo_user	0x80  /* implementation-defined range start */
26598b9484cSchristos #define MOD_hi_user	0xff  /* implementation-defined range end */
26698b9484cSchristos 
26798b9484cSchristos /* Array ordering names and codes.  */
26898b9484cSchristos 
26998b9484cSchristos enum dwarf_array_dim_ordering {
27098b9484cSchristos     ORD_row_major	= 0,
27198b9484cSchristos     ORD_col_major	= 1
27298b9484cSchristos };
27398b9484cSchristos 
27498b9484cSchristos /* Array subscript format names and codes.  */
27598b9484cSchristos 
27698b9484cSchristos enum dwarf_subscr_data_formats {
27798b9484cSchristos     FMT_FT_C_C	= 0x0,
27898b9484cSchristos     FMT_FT_C_X	= 0x1,
27998b9484cSchristos     FMT_FT_X_C	= 0x2,
28098b9484cSchristos     FMT_FT_X_X	= 0x3,
28198b9484cSchristos     FMT_UT_C_C	= 0x4,
28298b9484cSchristos     FMT_UT_C_X	= 0x5,
28398b9484cSchristos     FMT_UT_X_C	= 0x6,
28498b9484cSchristos     FMT_UT_X_X	= 0x7,
28598b9484cSchristos     FMT_ET	= 0x8
28698b9484cSchristos };
28798b9484cSchristos 
28898b9484cSchristos /* Derived from above for ease of use.  */
28998b9484cSchristos 
29098b9484cSchristos #define FMT_CODE(_FUNDAMENTAL_TYPE_P, _LB_CONST_P, _UB_CONST_P) \
29198b9484cSchristos  (((_FUNDAMENTAL_TYPE_P) ? 0 : 4)	\
29298b9484cSchristos   | ((_LB_CONST_P) ? 0 : 2)		\
29398b9484cSchristos   | ((_UB_CONST_P) ? 0 : 1))
29498b9484cSchristos 
29598b9484cSchristos /* Source language names and codes.  */
29698b9484cSchristos 
29798b9484cSchristos enum dwarf_source_language {
29898b9484cSchristos     LANG_C89		= 0x00000001,
29998b9484cSchristos     LANG_C		= 0x00000002,
30098b9484cSchristos     LANG_ADA83		= 0x00000003,
30198b9484cSchristos     LANG_C_PLUS_PLUS	= 0x00000004,
30298b9484cSchristos     LANG_COBOL74	= 0x00000005,
30398b9484cSchristos     LANG_COBOL85	= 0x00000006,
30498b9484cSchristos     LANG_FORTRAN77	= 0x00000007,
30598b9484cSchristos     LANG_FORTRAN90	= 0x00000008,
30698b9484cSchristos     LANG_PASCAL83	= 0x00000009,
30798b9484cSchristos     LANG_MODULA2	= 0x0000000a,
30898b9484cSchristos     LANG_JAVA		= 0x0000000b
30998b9484cSchristos };
31098b9484cSchristos 
31198b9484cSchristos #define LANG_lo_user	0x00008000  /* implementation-defined range start */
31298b9484cSchristos #define LANG_hi_user	0x0000ffff  /* implementation-defined range end */
31398b9484cSchristos 
31498b9484cSchristos /* Names and codes for GNU "macinfo" extension.  */
31598b9484cSchristos 
31698b9484cSchristos enum dwarf_macinfo_record_type {
31798b9484cSchristos     MACINFO_start	= 's',
31898b9484cSchristos     MACINFO_resume	= 'r',
31998b9484cSchristos     MACINFO_define	= 'd',
32098b9484cSchristos     MACINFO_undef	= 'u'
32198b9484cSchristos };
32298b9484cSchristos 
32398b9484cSchristos #endif /* _ELF_DWARF_H */
324