summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2018-04-30 15:34:48 +1000
committerChris Johns <chrisj@rtems.org>2018-04-30 15:40:40 +1000
commit4bb3996f2c42611deef3f9b99a2c34d318b85bee (patch)
treec65cc92b347cf1c0e4d5f243a8ecf3e7e5dd79d6
parentrtemstoolkit: Update elftoolchain to the latest code. (diff)
downloadrtems-tools-4bb3996f2c42611deef3f9b99a2c34d318b85bee.tar.bz2
rtemstoolkit: Add libdwarf from elftoolchain.
The code is taken from: https://svn.code.sf.net/p/elftoolchain/code/trunk Update #3417
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/Makefile337
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/Version.map239
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/_libdwarf.h666
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf.3751
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf.h634
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_abbrev.c136
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_comp_dir.399
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_const_value_string.3126
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_dataref.3122
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_flag.3115
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_location_expr.3120
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_name.399
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_producer.399
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_ref_address.3117
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_reference.3117
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_signed_const.3131
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_string.3114
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_targ_address.3137
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_arange.3151
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_die_to_debug.395
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_directory_decl.397
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_expr_addr.3111
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_expr_gen.3118
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_fde_inst.3113
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_file_decl.3122
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_frame_cie.3124
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_frame_fde.3201
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_funcname.3103
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_line_entry.3164
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_pubname.3103
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_typename.3103
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_varname.3103
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_add_weakname.3103
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_arange.c171
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_attr.3120
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_attr.c312
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_attrlist.3146
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_attroffset.386
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_attrval.c222
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_attrval_signed.3225
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_child.3278
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_cu.c161
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_dealloc.3203
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_dealloc.c117
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_def_macro.3129
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_die.c413
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_die_abbrev_code.355
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_die_link.3118
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_diename.390
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_dieoffset.3206
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_dump.c1446
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_end_macro_file.390
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_errmsg.367
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_errmsg.c90
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_errno.358
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3182
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_expr_current_offset.384
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_expr_into_block.394
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_fde_cfa_offset.399
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_find_macro_value_start.368
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_finish.3140
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_finish.c61
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_form.c480
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_formaddr.397
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_formblock.3109
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_formexprloc.3109
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_formflag.397
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_formref.3136
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_formsig8.396
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_formstring.3101
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_formudata.3122
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_frame.c603
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_funcs.m436
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_AT_name.3259
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev.3179
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_children_flag.3100
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_code.386
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_entry.3159
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_tag.386
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_address_size.382
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_arange.3121
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_arange_info.3135
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_aranges.3148
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_index.386
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_info.3150
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_of_fde.388
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cu_die_offset.3103
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_die_infotypes_flag.373
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_elf.3103
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_at_pc.3125
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3156
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs3.3183
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_cfa_reg3.3171
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3156
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg3.3214
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_instr_bytes.3113
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_list.3218
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_n.3111
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_range.3149
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_form_class.387
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_funcs.3215
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_globals.3211
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_loclist_entry.3156
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_macro_details.3192
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_pubtypes.3243
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_ranges.3258
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_relocation_info.3228
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_relocation_info_count.3116
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_section_bytes.3157
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_section_max_offsets.3116
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_str.3149
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_types.3232
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_vars.3210
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_get_weaks.3215
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_hasattr.392
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_hasform.3127
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_highpc.3193
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_init.3178
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_init.c163
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_lineno.3202
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_lineno.c294
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_lne_end_sequence.3100
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_lne_set_address.3105
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist.3230
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist.c302
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist_from_expr.3201
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_macinfo.c88
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_nametbl.m4159
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_new_die.3164
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_new_expr.3135
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_new_fde.387
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_next_cu_header.3288
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_next_types_section.3134
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_object_init.3227
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_arange.c73
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_attr.c384
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_die.c110
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_expr.c223
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_finish.c45
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_frame.c195
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_funcs.m436
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_init.c122
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_lineno.c187
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_macinfo.c142
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_nametbl.m470
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_pubnames.m436
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_reloc.c114
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_sections.c81
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_types.m436
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_vars.m436
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_weaks.m436
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_producer_init.3297
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_producer_set_isa.398
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pubnames.m436
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_pubtypes.m436
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_ranges.c87
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_reloc.c40
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_reset_section_bytes.369
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_sections.c111
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_set_frame_cfa_value.3140
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_set_reloc_application.382
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_seterrarg.3102
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_seterror.c63
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_srcfiles.3105
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_srclines.3163
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_start_macro_file.3106
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_str.c62
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_tag.377
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_transform_to_disk_form.399
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_types.m436
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_undef_macro.3119
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_vars.m436
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_vendor_ext.3110
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_weaks.m436
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/dwarf_whatattr.379
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf.c35
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf.h841
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_abbrev.c266
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_arange.c260
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_attr.c459
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_die.c457
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_elf_access.c164
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_elf_init.c390
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_error.c58
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_frame.c1608
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_info.c383
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_init.c315
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_lineno.c777
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_loc.c701
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_loclist.c165
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_macinfo.c254
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_nametbl.c253
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_ranges.c152
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_reloc.c493
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_rw.c574
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_sections.c280
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/libdwarf_str.c159
-rw-r--r--rtemstoolkit/elftoolchain/libdwarf/os.NetBSD.mk2
-rw-r--r--rtemstoolkit/wscript78
199 files changed, 36534 insertions, 0 deletions
diff --git a/rtemstoolkit/elftoolchain/libdwarf/Makefile b/rtemstoolkit/elftoolchain/libdwarf/Makefile
new file mode 100644
index 0000000..4cd3cb7
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/Makefile
@@ -0,0 +1,337 @@
+# $Id: Makefile 3594 2018-04-11 18:26:50Z jkoshy $
+
+TOP= ..
+
+LIB= dwarf
+
+SRCS= \
+ dwarf_abbrev.c \
+ dwarf_arange.c \
+ dwarf_attr.c \
+ dwarf_attrval.c \
+ dwarf_cu.c \
+ dwarf_dealloc.c \
+ dwarf_die.c \
+ dwarf_dump.c \
+ dwarf_errmsg.c \
+ dwarf_finish.c \
+ dwarf_form.c \
+ dwarf_frame.c \
+ dwarf_funcs.c \
+ dwarf_init.c \
+ dwarf_lineno.c \
+ dwarf_loclist.c \
+ dwarf_macinfo.c \
+ dwarf_pro_arange.c \
+ dwarf_pro_attr.c \
+ dwarf_pro_die.c \
+ dwarf_pro_expr.c \
+ dwarf_pro_finish.c \
+ dwarf_pro_frame.c \
+ dwarf_pro_funcs.c \
+ dwarf_pro_init.c \
+ dwarf_pro_lineno.c \
+ dwarf_pro_macinfo.c \
+ dwarf_pro_pubnames.c \
+ dwarf_pro_reloc.c \
+ dwarf_pro_sections.c \
+ dwarf_pro_types.c \
+ dwarf_pro_vars.c \
+ dwarf_pro_weaks.c \
+ dwarf_pubnames.c \
+ dwarf_pubtypes.c \
+ dwarf_ranges.c \
+ dwarf_reloc.c \
+ dwarf_sections.c \
+ dwarf_seterror.c \
+ dwarf_str.c \
+ dwarf_types.c \
+ dwarf_vars.c \
+ dwarf_weaks.c \
+ libdwarf.c \
+ libdwarf_abbrev.c \
+ libdwarf_arange.c \
+ libdwarf_attr.c \
+ libdwarf_die.c \
+ libdwarf_error.c \
+ libdwarf_elf_access.c \
+ libdwarf_elf_init.c \
+ libdwarf_frame.c \
+ libdwarf_info.c \
+ libdwarf_init.c \
+ libdwarf_lineno.c \
+ libdwarf_loc.c \
+ libdwarf_loclist.c \
+ libdwarf_macinfo.c \
+ libdwarf_nametbl.c \
+ libdwarf_ranges.c \
+ libdwarf_reloc.c \
+ libdwarf_rw.c \
+ libdwarf_sections.c \
+ libdwarf_str.c
+
+INCS= dwarf.h libdwarf.h
+INCSDIR= /usr/include
+
+GENSRCS= dwarf_pubnames.c dwarf_pubtypes.c dwarf_weaks.c \
+ dwarf_funcs.c dwarf_vars.c dwarf_types.c \
+ dwarf_pro_pubnames.c dwarf_pro_weaks.c \
+ dwarf_pro_funcs.c dwarf_pro_types.c \
+ dwarf_pro_vars.c
+CLEANFILES= ${GENSRCS}
+
+SHLIB_MAJOR= 3
+
+WARNS?= 6
+
+LDADD+= -lelf
+
+MAN= dwarf.3 \
+ dwarf_add_arange.3 \
+ dwarf_add_AT_comp_dir.3 \
+ dwarf_add_AT_const_value_string.3 \
+ dwarf_add_AT_dataref.3 \
+ dwarf_add_AT_flag.3 \
+ dwarf_add_AT_location_expr.3 \
+ dwarf_add_AT_name.3 \
+ dwarf_add_AT_producer.3 \
+ dwarf_add_AT_ref_address.3 \
+ dwarf_add_AT_reference.3 \
+ dwarf_add_AT_signed_const.3 \
+ dwarf_add_AT_string.3 \
+ dwarf_add_AT_targ_address.3 \
+ dwarf_add_die_to_debug.3 \
+ dwarf_add_directory_decl.3 \
+ dwarf_add_expr_addr.3 \
+ dwarf_add_expr_gen.3 \
+ dwarf_add_fde_inst.3 \
+ dwarf_add_file_decl.3 \
+ dwarf_add_frame_cie.3 \
+ dwarf_add_frame_fde.3 \
+ dwarf_add_funcname.3 \
+ dwarf_add_line_entry.3 \
+ dwarf_add_pubname.3 \
+ dwarf_add_typename.3 \
+ dwarf_add_varname.3 \
+ dwarf_add_weakname.3 \
+ dwarf_attr.3 \
+ dwarf_attrlist.3 \
+ dwarf_attroffset.3 \
+ dwarf_attrval_signed.3 \
+ dwarf_child.3 \
+ dwarf_dealloc.3 \
+ dwarf_def_macro.3 \
+ dwarf_die_abbrev_code.3 \
+ dwarf_die_link.3 \
+ dwarf_diename.3 \
+ dwarf_dieoffset.3 \
+ dwarf_end_macro_file.3 \
+ dwarf_errmsg.3 \
+ dwarf_errno.3 \
+ dwarf_expand_frame_instructions.3 \
+ dwarf_expr_current_offset.3 \
+ dwarf_expr_into_block.3 \
+ dwarf_fde_cfa_offset.3 \
+ dwarf_find_macro_value_start.3 \
+ dwarf_finish.3 \
+ dwarf_formaddr.3 \
+ dwarf_formblock.3 \
+ dwarf_formexprloc.3 \
+ dwarf_formflag.3 \
+ dwarf_formref.3 \
+ dwarf_formsig8.3 \
+ dwarf_formstring.3 \
+ dwarf_formudata.3 \
+ dwarf_get_abbrev.3 \
+ dwarf_get_abbrev_children_flag.3 \
+ dwarf_get_abbrev_code.3 \
+ dwarf_get_abbrev_entry.3 \
+ dwarf_get_abbrev_tag.3 \
+ dwarf_get_address_size.3 \
+ dwarf_get_arange.3 \
+ dwarf_get_arange_info.3 \
+ dwarf_get_aranges.3 \
+ dwarf_get_AT_name.3 \
+ dwarf_get_cie_index.3 \
+ dwarf_get_cie_info.3 \
+ dwarf_get_cie_of_fde.3 \
+ dwarf_get_cu_die_offset.3 \
+ dwarf_get_die_infotypes_flag.3 \
+ dwarf_get_elf.3 \
+ dwarf_get_fde_at_pc.3 \
+ dwarf_get_fde_info_for_all_regs.3 \
+ dwarf_get_fde_info_for_all_regs3.3 \
+ dwarf_get_fde_info_for_cfa_reg3.3 \
+ dwarf_get_fde_info_for_reg.3 \
+ dwarf_get_fde_info_for_reg3.3 \
+ dwarf_get_fde_instr_bytes.3 \
+ dwarf_get_fde_list.3 \
+ dwarf_get_fde_n.3 \
+ dwarf_get_fde_range.3 \
+ dwarf_get_form_class.3 \
+ dwarf_get_funcs.3 \
+ dwarf_get_globals.3 \
+ dwarf_get_loclist_entry.3 \
+ dwarf_get_macro_details.3 \
+ dwarf_get_pubtypes.3 \
+ dwarf_get_ranges.3 \
+ dwarf_get_relocation_info.3 \
+ dwarf_get_relocation_info_count.3 \
+ dwarf_get_section_bytes.3 \
+ dwarf_get_section_max_offsets.3 \
+ dwarf_get_str.3 \
+ dwarf_get_types.3 \
+ dwarf_get_vars.3 \
+ dwarf_get_weaks.3 \
+ dwarf_hasattr.3 \
+ dwarf_hasform.3 \
+ dwarf_highpc.3 \
+ dwarf_init.3 \
+ dwarf_lineno.3 \
+ dwarf_lne_end_sequence.3 \
+ dwarf_lne_set_address.3 \
+ dwarf_loclist.3 \
+ dwarf_loclist_from_expr.3 \
+ dwarf_new_die.3 \
+ dwarf_new_expr.3 \
+ dwarf_new_fde.3 \
+ dwarf_next_cu_header.3 \
+ dwarf_next_types_section.3 \
+ dwarf_object_init.3 \
+ dwarf_producer_init.3 \
+ dwarf_producer_set_isa.3 \
+ dwarf_reset_section_bytes.3 \
+ dwarf_seterrarg.3 \
+ dwarf_set_frame_cfa_value.3 \
+ dwarf_set_reloc_application.3 \
+ dwarf_srcfiles.3 \
+ dwarf_srclines.3 \
+ dwarf_start_macro_file.3 \
+ dwarf_tag.3 \
+ dwarf_transform_to_disk_form.3 \
+ dwarf_undef_macro.3 \
+ dwarf_vendor_ext.3 \
+ dwarf_whatattr.3
+
+MLINKS+= \
+ dwarf_add_AT_const_value_string.3 dwarf_add_AT_const_value_signedint.3 \
+ dwarf_add_AT_const_value_string.3 dwarf_add_AT_const_value_unsignedint.3 \
+ dwarf_add_AT_signed_const.3 dwarf_add_AT_unsigned_const.3 \
+ dwarf_add_AT_targ_address.3 dwarf_add_AT_targ_address_b.3 \
+ dwarf_add_arange.3 dwarf_add_arange_b.3 \
+ dwarf_add_expr_addr.3 dwarf_add_expr_addr_b.3 \
+ dwarf_add_frame_fde.3 dwarf_add_frame_fde_b.3 \
+ dwarf_attrval_signed.3 dwarf_attrval_flag.3 \
+ dwarf_attrval_signed.3 dwarf_attrval_string.3 \
+ dwarf_attrval_signed.3 dwarf_attrval_unsigned.3 \
+ dwarf_child.3 dwarf_offdie.3 \
+ dwarf_child.3 dwarf_offdie_b.3 \
+ dwarf_child.3 dwarf_siblingof.3 \
+ dwarf_child.3 dwarf_siblingof_b.3 \
+ dwarf_dealloc.3 dwarf_fde_cie_list_dealloc.3 \
+ dwarf_dealloc.3 dwarf_funcs_dealloc.3 \
+ dwarf_dealloc.3 dwarf_globals_dealloc.3 \
+ dwarf_dealloc.3 dwarf_pubtypes_dealloc.3 \
+ dwarf_dealloc.3 dwarf_types_dealloc.3 \
+ dwarf_dealloc.3 dwarf_vars_dealloc.3 \
+ dwarf_dealloc.3 dwarf_weaks_dealloc.3 \
+ dwarf_dealloc.3 dwarf_ranges_dealloc.3 \
+ dwarf_dealloc.3 dwarf_srclines_dealloc.3 \
+ dwarf_init.3 dwarf_elf_init.3 \
+ dwarf_dieoffset.3 dwarf_die_CU_offset.3 \
+ dwarf_dieoffset.3 dwarf_die_CU_offset_range.3 \
+ dwarf_dieoffset.3 dwarf_get_cu_die_offset_given_cu_header_offset.3 \
+ dwarf_dieoffset.3 dwarf_get_cu_die_offset_given_cu_header_offset_b.3 \
+ dwarf_finish.3 dwarf_object_finish.3 \
+ dwarf_formref.3 dwarf_global_formref.3 \
+ dwarf_formudata.3 dwarf_formsdata.3 \
+ dwarf_get_AT_name.3 dwarf_get_ACCESS_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_ATE_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_CC_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_CFA_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_CHILDREN_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_DS_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_DSC_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_EH_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_END_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_FORM_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_ID_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_INL_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_LANG_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_LNE_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_LNS_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_MACINFO_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_OP_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_ORD_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_TAG_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_VIRTUALITY_name.3 \
+ dwarf_get_AT_name.3 dwarf_get_VIS_name.3 \
+ dwarf_get_cu_die_offset.3 dwarf_get_arange_cu_header_offset.3 \
+ dwarf_get_fde_list.3 dwarf_get_fde_list_eh.3 \
+ dwarf_get_funcs.3 dwarf_func_die_offset.3 \
+ dwarf_get_funcs.3 dwarf_func_cu_offset.3 \
+ dwarf_get_funcs.3 dwarf_func_name_offsets.3 \
+ dwarf_get_funcs.3 dwarf_funcname.3 \
+ dwarf_get_globals.3 dwarf_global_die_offset.3 \
+ dwarf_get_globals.3 dwarf_global_cu_offset.3 \
+ dwarf_get_globals.3 dwarf_global_name_offsets.3 \
+ dwarf_get_globals.3 dwarf_globname.3 \
+ dwarf_get_pubtypes.3 dwarf_pubtype_die_offset.3 \
+ dwarf_get_pubtypes.3 dwarf_pubtype_cu_offset.3 \
+ dwarf_get_pubtypes.3 dwarf_pubtype_name_offsets.3 \
+ dwarf_get_pubtypes.3 dwarf_pubtypename.3 \
+ dwarf_get_ranges.3 dwarf_get_ranges_a.3 \
+ dwarf_get_section_max_offsets.3 dwarf_get_section_max_offsets_b.3 \
+ dwarf_get_types.3 dwarf_type_die_offset.3 \
+ dwarf_get_types.3 dwarf_type_cu_offset.3 \
+ dwarf_get_types.3 dwarf_type_name_offsets.3 \
+ dwarf_get_types.3 dwarf_typename.3 \
+ dwarf_get_vars.3 dwarf_var_die_offset.3 \
+ dwarf_get_vars.3 dwarf_var_cu_offset.3 \
+ dwarf_get_vars.3 dwarf_var_name_offsets.3 \
+ dwarf_get_vars.3 dwarf_varname.3 \
+ dwarf_get_weaks.3 dwarf_weak_die_offset.3 \
+ dwarf_get_weaks.3 dwarf_weak_cu_offset.3 \
+ dwarf_get_weaks.3 dwarf_weak_name_offsets.3 \
+ dwarf_get_weaks.3 dwarf_weakname.3 \
+ dwarf_hasform.3 dwarf_whatform.3 \
+ dwarf_hasform.3 dwarf_whatform_direct.3 \
+ dwarf_highpc.3 dwarf_arrayorder.3 \
+ dwarf_highpc.3 dwarf_bitoffset.3 \
+ dwarf_highpc.3 dwarf_bitsize.3 \
+ dwarf_highpc.3 dwarf_bytesize.3 \
+ dwarf_highpc.3 dwarf_highpc_b.3 \
+ dwarf_highpc.3 dwarf_lowpc.3 \
+ dwarf_highpc.3 dwarf_srclang.3 \
+ dwarf_lineno.3 dwarf_lineaddr.3 \
+ dwarf_lineno.3 dwarf_linebeginstatement.3 \
+ dwarf_lineno.3 dwarf_lineblock.3 \
+ dwarf_lineno.3 dwarf_lineendsequence.3 \
+ dwarf_lineno.3 dwarf_lineoff.3 \
+ dwarf_lineno.3 dwarf_linesrc.3 \
+ dwarf_lineno.3 dwarf_line_srcfileno.3 \
+ dwarf_loclist.3 dwarf_loclist_n.3 \
+ dwarf_loclist_from_expr.3 dwarf_loclist_from_expr_a.3 \
+ dwarf_loclist_from_expr.3 dwarf_loclist_from_expr_b.3 \
+ dwarf_next_cu_header.3 dwarf_next_cu_header_b.3 \
+ dwarf_next_cu_header.3 dwarf_next_cu_header_c.3 \
+ dwarf_producer_init.3 dwarf_producer_init_b.3 \
+ dwarf_seterrarg.3 dwarf_seterrhand.3 \
+ dwarf_set_frame_cfa_value.3 dwarf_set_frame_rule_initial_value.3 \
+ dwarf_set_frame_cfa_value.3 dwarf_set_frame_rule_table_size.3 \
+ dwarf_set_frame_cfa_value.3 dwarf_set_frame_same_value.3 \
+ dwarf_set_frame_cfa_value.3 dwarf_set_frame_undefined_value.3
+
+dwarf_pubnames.c: dwarf_nametbl.m4 dwarf_pubnames.m4
+dwarf_pubtypes.c: dwarf_nametbl.m4 dwarf_pubtypes.m4
+dwarf_weaks.c: dwarf_nametbl.m4 dwarf_weaks.m4
+dwarf_funcs.c: dwarf_nametbl.m4 dwarf_funcs.m4
+dwarf_vars.c: dwarf_nametbl.m4 dwarf_vars.m4
+dwarf_types.c: dwarf_nametbl.m4 dwarf_types.m4
+dwarf_pro_pubnames.c: dwarf_pro_nametbl.m4 dwarf_pro_pubnames.m4
+dwarf_pro_weaks.c: dwarf_pro_nametbl.m4 dwarf_pro_weaks.m4
+dwarf_pro_funcs.c: dwarf_pro_nametbl.m4 dwarf_pro_funcs.m4
+dwarf_pro_types.c: dwarf_pro_nametbl.m4 dwarf_pro_types.m4
+dwarf_pro_vars.c: dwarf_pro_nametbl.m4 dwarf_pro_vars.m4
+
+.include "${TOP}/mk/elftoolchain.lib.mk"
diff --git a/rtemstoolkit/elftoolchain/libdwarf/Version.map b/rtemstoolkit/elftoolchain/libdwarf/Version.map
new file mode 100644
index 0000000..669f70e
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/Version.map
@@ -0,0 +1,239 @@
+/* $Id: Version.map 3085 2014-09-02 22:08:23Z kaiwang27 $ */
+
+R1.0 {
+global:
+ dwarf_add_AT_comp_dir;
+ dwarf_add_AT_const_value_signedint;
+ dwarf_add_AT_const_value_string;
+ dwarf_add_AT_const_value_unsignedint;
+ dwarf_add_AT_dataref;
+ dwarf_add_AT_flag;
+ dwarf_add_AT_location_expr;
+ dwarf_add_AT_name;
+ dwarf_add_AT_producer;
+ dwarf_add_AT_ref_address;
+ dwarf_add_AT_reference;
+ dwarf_add_AT_signed_const;
+ dwarf_add_AT_string;
+ dwarf_add_AT_targ_address;
+ dwarf_add_AT_targ_address_b;
+ dwarf_add_AT_unsigned_const;
+ dwarf_add_arange;
+ dwarf_add_arange_b;
+ dwarf_add_die_to_debug;
+ dwarf_add_directory_decl;
+ dwarf_add_expr_addr;
+ dwarf_add_expr_addr_b;
+ dwarf_add_expr_gen;
+ dwarf_add_fde_inst;
+ dwarf_add_file_decl;
+ dwarf_add_frame_cie;
+ dwarf_add_frame_fde;
+ dwarf_add_frame_fde_b;
+ dwarf_add_funcname;
+ dwarf_add_line_entry;
+ dwarf_add_pubname;
+ dwarf_add_typename;
+ dwarf_add_varname;
+ dwarf_add_weakname;
+ dwarf_arrayorder;
+ dwarf_attr;
+ dwarf_attrlist;
+ dwarf_attroffset;
+ dwarf_attrval_flag;
+ dwarf_attrval_signed;
+ dwarf_attrval_string;
+ dwarf_attrval_unsigned;
+ dwarf_bitoffset;
+ dwarf_bitsize;
+ dwarf_bytesize;
+ dwarf_child;
+ dwarf_dealloc;
+ dwarf_def_macro;
+ dwarf_die_CU_offset;
+ dwarf_die_CU_offset_range;
+ dwarf_die_abbrev_code;
+ dwarf_die_link;
+ dwarf_diename;
+ dwarf_dieoffset;
+ dwarf_elf_init;
+ dwarf_end_macro_file;
+ dwarf_errmsg_;
+ dwarf_expand_frame_instructions;
+ dwarf_expr_current_offset;
+ dwarf_expr_into_block;
+ dwarf_fde_cfa_offset;
+ dwarf_fde_cie_list_dealloc;
+ dwarf_find_macro_value_start;
+ dwarf_finish;
+ dwarf_formaddr;
+ dwarf_formblock;
+ dwarf_formexprloc;
+ dwarf_formflag;
+ dwarf_formref;
+ dwarf_formsdata;
+ dwarf_formsig8;
+ dwarf_formstring;
+ dwarf_formudata;
+ dwarf_func_cu_offset;
+ dwarf_func_die_offset;
+ dwarf_func_name_offsets;
+ dwarf_funcname;
+ dwarf_funcs_dealloc;
+ dwarf_get_ACCESS_name;
+ dwarf_get_ATE_name;
+ dwarf_get_AT_name;
+ dwarf_get_CC_name;
+ dwarf_get_CFA_name;
+ dwarf_get_CHILDREN_name;
+ dwarf_get_DSC_name;
+ dwarf_get_DS_name;
+ dwarf_get_EH_name;
+ dwarf_get_END_name;
+ dwarf_get_FORM_name;
+ dwarf_get_ID_name;
+ dwarf_get_INL_name;
+ dwarf_get_LANG_name;
+ dwarf_get_LNE_name;
+ dwarf_get_LNS_name;
+ dwarf_get_MACINFO_name;
+ dwarf_get_OP_name;
+ dwarf_get_ORD_name;
+ dwarf_get_TAG_name;
+ dwarf_get_VIRTUALITY_name;
+ dwarf_get_VIS_name;
+ dwarf_get_abbrev;
+ dwarf_get_abbrev_children_flag;
+ dwarf_get_abbrev_code;
+ dwarf_get_abbrev_entry;
+ dwarf_get_abbrev_tag;
+ dwarf_get_address_size;
+ dwarf_get_arange;
+ dwarf_get_arange_cu_header_offset;
+ dwarf_get_arange_info;
+ dwarf_get_aranges;
+ dwarf_get_cie_index;
+ dwarf_get_cie_info;
+ dwarf_get_cie_of_fde;
+ dwarf_get_cu_die_offset;
+ dwarf_get_cu_die_offset_given_cu_header_offset;
+ dwarf_get_cu_die_offset_given_cu_header_offset_b;
+ dwarf_get_die_infotypes_flag;
+ dwarf_get_elf;
+ dwarf_get_fde_at_pc;
+ dwarf_get_fde_info_for_all_regs3;
+ dwarf_get_fde_info_for_all_regs;
+ dwarf_get_fde_info_for_cfa_reg3;
+ dwarf_get_fde_info_for_reg3;
+ dwarf_get_fde_info_for_reg;
+ dwarf_get_fde_instr_bytes;
+ dwarf_get_fde_list;
+ dwarf_get_fde_list_eh;
+ dwarf_get_fde_n;
+ dwarf_get_fde_range;
+ dwarf_get_form_class;
+ dwarf_get_funcs;
+ dwarf_get_globals;
+ dwarf_get_loclist_entry;
+ dwarf_get_macro_details;
+ dwarf_get_pubtypes;
+ dwarf_get_ranges;
+ dwarf_get_ranges_a;
+ dwarf_get_relocation_info;
+ dwarf_get_relocation_info_count;
+ dwarf_get_section_bytes;
+ dwarf_get_section_max_offsets;
+ dwarf_get_section_max_offsets_b;
+ dwarf_get_str;
+ dwarf_get_types;
+ dwarf_get_vars;
+ dwarf_get_weaks;
+ dwarf_global_cu_offset;
+ dwarf_global_die_offset;
+ dwarf_global_formref;
+ dwarf_global_name_offsets;
+ dwarf_globals_dealloc;
+ dwarf_globname;
+ dwarf_hasattr;
+ dwarf_hasform;
+ dwarf_highpc;
+ dwarf_highpc_b;
+ dwarf_init;
+ dwarf_line_srcfileno;
+ dwarf_lineaddr;
+ dwarf_linebeginstatement;
+ dwarf_lineblock;
+ dwarf_lineendsequence;
+ dwarf_lineno;
+ dwarf_lineoff;
+ dwarf_linesrc;
+ dwarf_lne_end_sequence;
+ dwarf_lne_set_address;
+ dwarf_loclist;
+ dwarf_loclist_from_expr;
+ dwarf_loclist_from_expr_a;
+ dwarf_loclist_from_expr_b;
+ dwarf_loclist_n;
+ dwarf_lowpc;
+ dwarf_new_die;
+ dwarf_new_expr;
+ dwarf_new_fde;
+ dwarf_next_cu_header;
+ dwarf_next_cu_header_b;
+ dwarf_next_cu_header_c;
+ dwarf_next_types_section;
+ dwarf_object_finish;
+ dwarf_object_init;
+ dwarf_offdie;
+ dwarf_offdie_b;
+ dwarf_producer_finish;
+ dwarf_producer_init;
+ dwarf_producer_init_b;
+ dwarf_producer_set_isa;
+ dwarf_pubtype_cu_offset;
+ dwarf_pubtype_die_offset;
+ dwarf_pubtype_name_offsets;
+ dwarf_pubtypename;
+ dwarf_pubtypes_dealloc;
+ dwarf_ranges_dealloc;
+ dwarf_reset_section_bytes;
+ dwarf_set_frame_cfa_value;
+ dwarf_set_frame_rule_initial_value;
+ dwarf_set_frame_rule_table_size;
+ dwarf_set_frame_same_value;
+ dwarf_set_frame_undefined_value;
+ dwarf_set_reloc_application;
+ dwarf_seterrarg;
+ dwarf_seterrhand;
+ dwarf_siblingof;
+ dwarf_siblingof_b;
+ dwarf_srcfiles;
+ dwarf_srclang;
+ dwarf_srclines;
+ dwarf_srclines_dealloc;
+ dwarf_start_macro_file;
+ dwarf_tag;
+ dwarf_transform_to_disk_form;
+ dwarf_type_cu_offset;
+ dwarf_type_die_offset;
+ dwarf_type_name_offsets;
+ dwarf_typename;
+ dwarf_types_dealloc;
+ dwarf_undef_macro;
+ dwarf_var_cu_offset;
+ dwarf_var_die_offset;
+ dwarf_var_name_offsets;
+ dwarf_varname;
+ dwarf_vars_dealloc;
+ dwarf_vendor_ext;
+ dwarf_weak_cu_offset;
+ dwarf_weak_die_offset;
+ dwarf_weak_name_offsets;
+ dwarf_weakname;
+ dwarf_weaks_dealloc;
+ dwarf_whatattr;
+ dwarf_whatform;
+ dwarf_whatform_direct;
+local:
+ *;
+};
diff --git a/rtemstoolkit/elftoolchain/libdwarf/_libdwarf.h b/rtemstoolkit/elftoolchain/libdwarf/_libdwarf.h
new file mode 100644
index 0000000..6658d2d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/_libdwarf.h
@@ -0,0 +1,666 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2009-2014 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: _libdwarf.h 3298 2016-01-09 15:43:31Z jkoshy $
+ */
+
+#ifndef __LIBDWARF_H_
+#define __LIBDWARF_H_
+
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <assert.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gelf.h>
+#include "dwarf.h"
+#include "libdwarf.h"
+#include "uthash.h"
+
+#include "_elftc.h"
+
+#define DWARF_DIE_HASH_SIZE 8191
+
+struct _libdwarf_globals {
+ Dwarf_Handler errhand;
+ Dwarf_Ptr errarg;
+ int applyreloc;
+};
+
+extern struct _libdwarf_globals _libdwarf;
+
+#define _DWARF_SET_ERROR(_d, _e, _err, _elf_err) \
+ _dwarf_set_error(_d, _e, _err, _elf_err, __func__, __LINE__)
+#define DWARF_SET_ERROR(_d, _e, _err) \
+ _DWARF_SET_ERROR(_d, _e, _err, 0)
+#define DWARF_SET_ELF_ERROR(_d, _e) \
+ _DWARF_SET_ERROR(_d, _e, DW_DLE_ELF, elf_errno())
+
+/*
+ * Convenient macros for producer bytes stream generation.
+ */
+#define WRITE_VALUE(value, bytes) \
+ dbg->write_alloc(&ds->ds_data, &ds->ds_cap, &ds->ds_size, \
+ (value), (bytes), error)
+#define WRITE_ULEB128(value) \
+ _dwarf_write_uleb128_alloc(&ds->ds_data, &ds->ds_cap, \
+ &ds->ds_size, (value), error)
+#define WRITE_SLEB128(value) \
+ _dwarf_write_sleb128_alloc(&ds->ds_data, &ds->ds_cap, \
+ &ds->ds_size, (value), error)
+#define WRITE_STRING(string) \
+ _dwarf_write_string_alloc(&ds->ds_data, &ds->ds_cap, \
+ &ds->ds_size, (string), error)
+#define WRITE_BLOCK(blk, size) \
+ _dwarf_write_block_alloc(&ds->ds_data, &ds->ds_cap, \
+ &ds->ds_size, (blk), (size), error)
+#define WRITE_PADDING(byte, cnt) \
+ _dwarf_write_padding_alloc(&ds->ds_data, &ds->ds_cap, \
+ &ds->ds_size, (byte), (cnt), error)
+#define RCHECK(expr) \
+ do { \
+ ret = expr; \
+ if (ret != DW_DLE_NONE) \
+ goto gen_fail; \
+ } while(0)
+
+typedef struct _Dwarf_CU *Dwarf_CU;
+
+struct _Dwarf_AttrDef {
+ Dwarf_Half ad_attrib; /* DW_AT_XXX */
+ Dwarf_Half ad_form; /* DW_FORM_XXX */
+ uint64_t ad_offset; /* Offset in abbrev section. */
+ STAILQ_ENTRY(_Dwarf_AttrDef) ad_next; /* Next attribute define. */
+};
+
+struct _Dwarf_Attribute {
+ Dwarf_Die at_die; /* Ptr to containing DIE. */
+ Dwarf_Die at_refdie; /* Ptr to reference DIE. */
+ uint64_t at_offset; /* Offset in info section. */
+ Dwarf_Half at_attrib; /* DW_AT_XXX */
+ Dwarf_Half at_form; /* DW_FORM_XXX */
+ int at_indirect; /* Has indirect form. */
+ union {
+ uint64_t u64; /* Unsigned value. */
+ int64_t s64; /* Signed value. */
+ char *s; /* String. */
+ uint8_t *u8p; /* Block data. */
+ } u[2]; /* Value. */
+ Dwarf_Block at_block; /* Block. */
+ Dwarf_Locdesc *at_ld; /* at value is locdesc. */
+ Dwarf_P_Expr at_expr; /* at value is expr. */
+ uint64_t at_relsym; /* Relocation symbol index. */
+ const char *at_relsec; /* Rel. to dwarf section. */
+ STAILQ_ENTRY(_Dwarf_Attribute) at_next; /* Next attribute. */
+};
+
+struct _Dwarf_Abbrev {
+ uint64_t ab_entry; /* Abbrev entry. */
+ uint64_t ab_tag; /* Tag: DW_TAG_ */
+ uint8_t ab_children; /* DW_CHILDREN_no or DW_CHILDREN_yes */
+ uint64_t ab_offset; /* Offset in abbrev section. */
+ uint64_t ab_length; /* Length of this abbrev entry. */
+ uint64_t ab_atnum; /* Number of attribute defines. */
+ UT_hash_handle ab_hh; /* Uthash handle. */
+ STAILQ_HEAD(, _Dwarf_AttrDef) ab_attrdef; /* List of attribute defs. */
+};
+
+struct _Dwarf_Die {
+ Dwarf_Die die_parent; /* Parent DIE. */
+ Dwarf_Die die_child; /* First child DIE. */
+ Dwarf_Die die_left; /* Left sibling DIE. */
+ Dwarf_Die die_right; /* Right sibling DIE. */
+ uint64_t die_offset; /* DIE offset in section. */
+ uint64_t die_next_off; /* Next DIE offset in section. */
+ uint64_t die_abnum; /* Abbrev number. */
+ Dwarf_Abbrev die_ab; /* Abbrev pointer. */
+ Dwarf_Tag die_tag; /* DW_TAG_ */
+ Dwarf_Debug die_dbg; /* Dwarf_Debug pointer. */
+ Dwarf_CU die_cu; /* Compilation unit pointer. */
+ char *die_name; /* Ptr to the name string. */
+ Dwarf_Attribute *die_attrarray; /* Array of attributes. */
+ STAILQ_HEAD(, _Dwarf_Attribute) die_attr; /* List of attributes. */
+ STAILQ_ENTRY(_Dwarf_Die) die_pro_next; /* Next die in pro-die list. */
+};
+
+struct _Dwarf_P_Expr_Entry {
+ Dwarf_Loc ee_loc; /* Location expression. */
+ Dwarf_Unsigned ee_sym; /* Optional related reloc sym index. */
+ STAILQ_ENTRY(_Dwarf_P_Expr_Entry) ee_next; /* Next entry in list. */
+};
+
+struct _Dwarf_P_Expr {
+ Dwarf_Debug pe_dbg; /* Dwarf_Debug pointer. */
+ uint8_t *pe_block; /* Expression block data. */
+ int pe_invalid; /* Block data is up-to-date or not. */
+ Dwarf_Unsigned pe_length; /* Length of the block. */
+ STAILQ_HEAD(, _Dwarf_P_Expr_Entry) pe_eelist; /* List of entries. */
+ STAILQ_ENTRY(_Dwarf_P_Expr) pe_next; /* Next expr in list. */
+};
+
+struct _Dwarf_Line {
+ Dwarf_LineInfo ln_li; /* Ptr to line info. */
+ Dwarf_Addr ln_addr; /* Line address. */
+ Dwarf_Unsigned ln_symndx; /* Symbol index for relocation. */
+ Dwarf_Unsigned ln_fileno; /* File number. */
+ Dwarf_Unsigned ln_lineno; /* Line number. */
+ Dwarf_Signed ln_column; /* Column number. */
+ Dwarf_Bool ln_bblock; /* Basic block flag. */
+ Dwarf_Bool ln_stmt; /* Begin statement flag. */
+ Dwarf_Bool ln_endseq; /* End sequence flag. */
+ STAILQ_ENTRY(_Dwarf_Line) ln_next; /* Next line in list. */
+};
+
+struct _Dwarf_LineFile {
+ char *lf_fname; /* Filename. */
+ char *lf_fullpath; /* Full pathname of the file. */
+ Dwarf_Unsigned lf_dirndx; /* Dir index. */
+ Dwarf_Unsigned lf_mtime; /* Modification time. */
+ Dwarf_Unsigned lf_size; /* File size. */
+ STAILQ_ENTRY(_Dwarf_LineFile) lf_next; /* Next file in list. */
+};
+
+struct _Dwarf_LineInfo {
+ Dwarf_Unsigned li_length; /* Length of line info data. */
+ Dwarf_Half li_version; /* Version of line info. */
+ Dwarf_Unsigned li_hdrlen; /* Length of line info header. */
+ Dwarf_Small li_minlen; /* Minimum instrutction length. */
+ Dwarf_Small li_maxop; /* Maximum operations per inst. */
+ Dwarf_Small li_defstmt; /* Default value of is_stmt. */
+ int8_t li_lbase; /* Line base for special opcode. */
+ Dwarf_Small li_lrange; /* Line range for special opcode. */
+ Dwarf_Small li_opbase; /* Fisrt std opcode number. */
+ Dwarf_Small *li_oplen; /* Array of std opcode len. */
+ char **li_incdirs; /* Array of include dirs. */
+ Dwarf_Unsigned li_inclen; /* Length of inc dir array. */
+ char **li_lfnarray; /* Array of file names. */
+ Dwarf_Unsigned li_lflen; /* Length of filename array. */
+ STAILQ_HEAD(, _Dwarf_LineFile) li_lflist; /* List of files. */
+ Dwarf_Line *li_lnarray; /* Array of lines. */
+ Dwarf_Unsigned li_lnlen; /* Length of the line array. */
+ STAILQ_HEAD(, _Dwarf_Line) li_lnlist; /* List of lines. */
+};
+
+struct _Dwarf_NamePair {
+ Dwarf_NameTbl np_nt; /* Ptr to containing name table. */
+ Dwarf_Die np_die; /* Ptr to Ref. Die. */
+ Dwarf_Unsigned np_offset; /* Offset in CU. */
+ char *np_name; /* Object/Type name. */
+ STAILQ_ENTRY(_Dwarf_NamePair) np_next; /* Next pair in the list. */
+};
+
+struct _Dwarf_NameTbl {
+ Dwarf_Unsigned nt_length; /* Name lookup table length. */
+ Dwarf_Half nt_version; /* Name lookup table version. */
+ Dwarf_CU nt_cu; /* Ptr to Ref. CU. */
+ Dwarf_Off nt_cu_offset; /* Ref. CU offset in .debug_info */
+ Dwarf_Unsigned nt_cu_length; /* Ref. CU length. */
+ STAILQ_HEAD(, _Dwarf_NamePair) nt_nplist; /* List of offset+name pairs. */
+ STAILQ_ENTRY(_Dwarf_NameTbl) nt_next; /* Next name table in the list. */
+};
+
+struct _Dwarf_NameSec {
+ STAILQ_HEAD(, _Dwarf_NameTbl) ns_ntlist; /* List of name tables. */
+ Dwarf_NamePair *ns_array; /* Array of pairs of all tables. */
+ Dwarf_Unsigned ns_len; /* Length of the pair array. */
+};
+
+struct _Dwarf_Fde {
+ Dwarf_Debug fde_dbg; /* Ptr to containing dbg. */
+ Dwarf_Cie fde_cie; /* Ptr to associated CIE. */
+ Dwarf_FrameSec fde_fs; /* Ptr to containing .debug_frame. */
+ Dwarf_Ptr fde_addr; /* Ptr to start of the FDE. */
+ Dwarf_Unsigned fde_offset; /* Offset of the FDE. */
+ Dwarf_Unsigned fde_length; /* Length of the FDE. */
+ Dwarf_Unsigned fde_cieoff; /* Offset of associated CIE. */
+ Dwarf_Unsigned fde_initloc; /* Initial location. */
+ Dwarf_Unsigned fde_adrange; /* Address range. */
+ Dwarf_Unsigned fde_auglen; /* Augmentation length. */
+ uint8_t *fde_augdata; /* Augmentation data. */
+ uint8_t *fde_inst; /* Instructions. */
+ Dwarf_Unsigned fde_instlen; /* Length of instructions. */
+ Dwarf_Unsigned fde_instcap; /* Capacity of inst buffer. */
+ Dwarf_Unsigned fde_symndx; /* Symbol index for relocation. */
+ Dwarf_Unsigned fde_esymndx; /* End symbol index for relocation. */
+ Dwarf_Addr fde_eoff; /* Offset from the end symbol. */
+ STAILQ_ENTRY(_Dwarf_Fde) fde_next; /* Next FDE in list. */
+};
+
+struct _Dwarf_Cie {
+ Dwarf_Debug cie_dbg; /* Ptr to containing dbg. */
+ Dwarf_Unsigned cie_index; /* Index of the CIE. */
+ Dwarf_Unsigned cie_offset; /* Offset of the CIE. */
+ Dwarf_Unsigned cie_length; /* Length of the CIE. */
+ Dwarf_Half cie_version; /* CIE version. */
+ uint8_t *cie_augment; /* CIE augmentation (UTF-8). */
+ Dwarf_Unsigned cie_ehdata; /* Optional EH Data. */
+ uint8_t cie_addrsize; /* Address size. (DWARF4) */
+ uint8_t cie_segmentsize; /* Segment size. (DWARF4) */
+ Dwarf_Unsigned cie_caf; /* Code alignment factor. */
+ Dwarf_Signed cie_daf; /* Data alignment factor. */
+ Dwarf_Unsigned cie_ra; /* Return address register. */
+ Dwarf_Unsigned cie_auglen; /* Augmentation length. */
+ uint8_t *cie_augdata; /* Augmentation data; */
+ uint8_t cie_fde_encode; /* FDE PC start/range encode. */
+ Dwarf_Ptr cie_initinst; /* Initial instructions. */
+ Dwarf_Unsigned cie_instlen; /* Length of init instructions. */
+ STAILQ_ENTRY(_Dwarf_Cie) cie_next; /* Next CIE in list. */
+};
+
+struct _Dwarf_FrameSec {
+ STAILQ_HEAD(, _Dwarf_Cie) fs_cielist; /* List of CIE. */
+ STAILQ_HEAD(, _Dwarf_Fde) fs_fdelist; /* List of FDE. */
+ Dwarf_Cie *fs_ciearray; /* Array of CIE. */
+ Dwarf_Unsigned fs_cielen; /* Length of CIE array. */
+ Dwarf_Fde *fs_fdearray; /* Array of FDE.*/
+ Dwarf_Unsigned fs_fdelen; /* Length of FDE array. */
+};
+
+struct _Dwarf_Arange {
+ Dwarf_ArangeSet ar_as; /* Ptr to the set it belongs to. */
+ Dwarf_Unsigned ar_address; /* Start PC. */
+ Dwarf_Unsigned ar_range; /* PC range. */
+ Dwarf_Unsigned ar_symndx; /* First symbol index for reloc. */
+ Dwarf_Unsigned ar_esymndx; /* Second symbol index for reloc. */
+ Dwarf_Addr ar_eoff; /* Offset from second symbol. */
+ STAILQ_ENTRY(_Dwarf_Arange) ar_next; /* Next arange in list. */
+};
+
+struct _Dwarf_ArangeSet {
+ Dwarf_Unsigned as_length; /* Length of the arange set. */
+ Dwarf_Half as_version; /* Version of the arange set. */
+ Dwarf_Off as_cu_offset; /* Offset of associated CU. */
+ Dwarf_CU as_cu; /* Ptr to associated CU. */
+ Dwarf_Small as_addrsz; /* Target address size. */
+ Dwarf_Small as_segsz; /* Target segment size. */
+ STAILQ_HEAD (, _Dwarf_Arange) as_arlist; /* List of ae entries. */
+ STAILQ_ENTRY(_Dwarf_ArangeSet) as_next; /* Next set in list. */
+};
+
+struct _Dwarf_MacroSet {
+ Dwarf_Macro_Details *ms_mdlist; /* Array of macinfo entries. */
+ Dwarf_Unsigned ms_cnt; /* Length of the array. */
+ STAILQ_ENTRY(_Dwarf_MacroSet) ms_next; /* Next set in list. */
+};
+
+struct _Dwarf_Rangelist {
+ Dwarf_CU rl_cu; /* Ptr to associated CU. */
+ Dwarf_Unsigned rl_offset; /* Offset of the rangelist. */
+ Dwarf_Ranges *rl_rgarray; /* Array of ranges. */
+ Dwarf_Unsigned rl_rglen; /* Length of the ranges array. */
+ STAILQ_ENTRY(_Dwarf_Rangelist) rl_next; /* Next rangelist in list. */
+};
+
+struct _Dwarf_CU {
+ Dwarf_Debug cu_dbg; /* Ptr to containing dbg. */
+ Dwarf_Off cu_offset; /* Offset to the this CU. */
+ uint32_t cu_length; /* Length of CU data. */
+ uint16_t cu_length_size; /* Size in bytes of the length field. */
+ uint16_t cu_version; /* DWARF version. */
+ uint64_t cu_abbrev_offset; /* Offset into .debug_abbrev. */
+ uint64_t cu_abbrev_offset_cur; /* Current abbrev offset. */
+ int cu_abbrev_loaded; /* Abbrev table parsed. */
+ uint64_t cu_abbrev_cnt; /* Abbrev entry count. */
+ uint64_t cu_lineno_offset; /* Offset into .debug_lineno. */
+ uint8_t cu_pointer_size;/* Number of bytes in pointer. */
+ uint8_t cu_dwarf_size; /* CU section dwarf size. */
+ Dwarf_Sig8 cu_type_sig; /* Type unit's signature. */
+ uint64_t cu_type_offset; /* Type unit's type offset. */
+ Dwarf_Off cu_next_offset; /* Offset to the next CU. */
+ uint64_t cu_1st_offset; /* First DIE offset. */
+ int cu_pass2; /* Two pass DIE traverse. */
+ Dwarf_LineInfo cu_lineinfo; /* Ptr to Dwarf_LineInfo. */
+ Dwarf_Abbrev cu_abbrev_hash; /* Abbrev hash table. */
+ Dwarf_Bool cu_is_info; /* Compilation/type unit flag. */
+ STAILQ_ENTRY(_Dwarf_CU) cu_next; /* Next compilation unit. */
+};
+
+typedef struct _Dwarf_Section {
+ const char *ds_name; /* Section name. */
+ Dwarf_Small *ds_data; /* Section data. */
+ Dwarf_Unsigned ds_addr; /* Section virtual addr. */
+ Dwarf_Unsigned ds_size; /* Section size. */
+} Dwarf_Section;
+
+typedef struct _Dwarf_P_Section {
+ char *ds_name; /* Section name. */
+ Dwarf_Small *ds_data; /* Section data. */
+ Dwarf_Unsigned ds_size; /* Section size. */
+ Dwarf_Unsigned ds_cap; /* Section capacity. */
+ Dwarf_Unsigned ds_ndx; /* ELF section index. */
+ Dwarf_Unsigned ds_symndx; /* Section symbol index. (for reloc) */
+ STAILQ_ENTRY(_Dwarf_P_Section) ds_next; /* Next section in the list. */
+} *Dwarf_P_Section;
+
+typedef struct _Dwarf_Rel_Entry {
+ unsigned char dre_type; /* Reloc type. */
+ unsigned char dre_length; /* Reloc storage unit length. */
+ Dwarf_Unsigned dre_offset; /* Reloc storage unit offset. */
+ Dwarf_Unsigned dre_addend; /* Reloc addend. */
+ Dwarf_Unsigned dre_symndx; /* Reloc symbol index. */
+ const char *dre_secname; /* Refer to some debug section. */
+ STAILQ_ENTRY(_Dwarf_Rel_Entry) dre_next; /* Next reloc entry. */
+} *Dwarf_Rel_Entry;
+
+typedef struct _Dwarf_Rel_Section {
+ struct _Dwarf_P_Section *drs_ds; /* Ptr to actual reloc ELF section. */
+ struct _Dwarf_P_Section *drs_ref; /* Which debug section it refers. */
+ struct Dwarf_Relocation_Data_s *drs_drd; /* Reloc data array. */
+ STAILQ_HEAD(, _Dwarf_Rel_Entry) drs_dre; /* Reloc entry list. */
+ Dwarf_Unsigned drs_drecnt; /* Count of entries. */
+ Dwarf_Unsigned drs_size; /* Size of ELF section in bytes. */
+ int drs_addend; /* Elf_Rel or Elf_Rela */
+ STAILQ_ENTRY(_Dwarf_Rel_Section) drs_next; /* Next reloc section. */
+} *Dwarf_Rel_Section;
+
+typedef struct {
+ Elf_Data *ed_data;
+ void *ed_alloc;
+} Dwarf_Elf_Data;
+
+typedef struct {
+ Elf *eo_elf;
+ GElf_Ehdr eo_ehdr;
+ GElf_Shdr *eo_shdr;
+ Dwarf_Elf_Data *eo_data;
+ Dwarf_Unsigned eo_seccnt;
+ size_t eo_strndx;
+ Dwarf_Obj_Access_Methods eo_methods;
+} Dwarf_Elf_Object;
+
+struct _Dwarf_Debug {
+ Dwarf_Obj_Access_Interface *dbg_iface;
+ Dwarf_Section *dbg_section; /* Dwarf section list. */
+ Dwarf_Section *dbg_info_sec; /* Pointer to info section. */
+ Dwarf_Off dbg_info_off; /* Current info section offset. */
+ Dwarf_Section *dbg_types_sec; /* Pointer to type section. */
+ Dwarf_Off dbg_types_off; /* Current types section offset. */
+ Dwarf_Unsigned dbg_seccnt; /* Total number of dwarf sections. */
+ int dbg_mode; /* Access mode. */
+ int dbg_pointer_size; /* Object address size. */
+ int dbg_offset_size; /* DWARF offset size. */
+ int dbg_info_loaded; /* Flag indicating all CU loaded. */
+ int dbg_types_loaded; /* Flag indicating all TU loaded. */
+ Dwarf_Half dbg_machine; /* ELF machine architecture. */
+ Dwarf_Handler dbg_errhand; /* Error handler. */
+ Dwarf_Ptr dbg_errarg; /* Argument to the error handler. */
+ STAILQ_HEAD(, _Dwarf_CU) dbg_cu;/* List of compilation units. */
+ STAILQ_HEAD(, _Dwarf_CU) dbg_tu;/* List of type units. */
+ Dwarf_CU dbg_cu_current; /* Ptr to the current CU. */
+ Dwarf_CU dbg_tu_current; /* Ptr to the current TU. */
+ Dwarf_NameSec dbg_globals; /* Ptr to pubnames lookup section. */
+ Dwarf_NameSec dbg_pubtypes; /* Ptr to pubtypes lookup section. */
+ Dwarf_NameSec dbg_weaks; /* Ptr to weaknames lookup section. */
+ Dwarf_NameSec dbg_funcs; /* Ptr to static funcs lookup sect. */
+ Dwarf_NameSec dbg_vars; /* Ptr to static vars lookup sect. */
+ Dwarf_NameSec dbg_types; /* Ptr to types lookup section. */
+ Dwarf_FrameSec dbg_frame; /* Ptr to .debug_frame section. */
+ Dwarf_FrameSec dbg_eh_frame; /* Ptr to .eh_frame section. */
+ STAILQ_HEAD(, _Dwarf_ArangeSet) dbg_aslist; /* List of arange set. */
+ Dwarf_Arange *dbg_arange_array; /* Array of arange. */
+ Dwarf_Unsigned dbg_arange_cnt; /* Length of the arange array. */
+ char *dbg_strtab; /* Dwarf string table. */
+ Dwarf_Unsigned dbg_strtab_cap; /* Dwarf string table capacity. */
+ Dwarf_Unsigned dbg_strtab_size; /* Dwarf string table size. */
+ STAILQ_HEAD(, _Dwarf_MacroSet) dbg_mslist; /* List of macro set. */
+ STAILQ_HEAD(, _Dwarf_Rangelist) dbg_rllist; /* List of rangelist. */
+ uint64_t (*read)(uint8_t *, uint64_t *, int);
+ void (*write)(uint8_t *, uint64_t *, uint64_t, int);
+ int (*write_alloc)(uint8_t **, uint64_t *, uint64_t *,
+ uint64_t, int, Dwarf_Error *);
+ uint64_t (*decode)(uint8_t **, int);
+
+ Dwarf_Half dbg_frame_rule_table_size;
+ Dwarf_Half dbg_frame_rule_initial_value;
+ Dwarf_Half dbg_frame_cfa_value;
+ Dwarf_Half dbg_frame_same_value;
+ Dwarf_Half dbg_frame_undefined_value;
+
+ Dwarf_Regtable3 *dbg_internal_reg_table;
+
+ /*
+ * Fields used by libdwarf producer.
+ */
+
+ Dwarf_Unsigned dbgp_flags;
+ Dwarf_Unsigned dbgp_isa;
+ Dwarf_Callback_Func dbgp_func;
+ Dwarf_Callback_Func_b dbgp_func_b;
+ Dwarf_Die dbgp_root_die;
+ STAILQ_HEAD(, _Dwarf_Die) dbgp_dielist;
+ STAILQ_HEAD(, _Dwarf_P_Expr) dbgp_pelist;
+ Dwarf_LineInfo dbgp_lineinfo;
+ Dwarf_ArangeSet dbgp_as;
+ Dwarf_Macro_Details *dbgp_mdlist;
+ Dwarf_Unsigned dbgp_mdcnt;
+ STAILQ_HEAD(, _Dwarf_Cie) dbgp_cielist;
+ STAILQ_HEAD(, _Dwarf_Fde) dbgp_fdelist;
+ Dwarf_Unsigned dbgp_cielen;
+ Dwarf_Unsigned dbgp_fdelen;
+ Dwarf_NameTbl dbgp_pubs;
+ Dwarf_NameTbl dbgp_weaks;
+ Dwarf_NameTbl dbgp_funcs;
+ Dwarf_NameTbl dbgp_types;
+ Dwarf_NameTbl dbgp_vars;
+ STAILQ_HEAD(, _Dwarf_P_Section) dbgp_seclist;
+ Dwarf_Unsigned dbgp_seccnt;
+ Dwarf_P_Section dbgp_secpos;
+ Dwarf_P_Section dbgp_info;
+ STAILQ_HEAD(, _Dwarf_Rel_Section) dbgp_drslist;
+ Dwarf_Unsigned dbgp_drscnt;
+ Dwarf_Rel_Section dbgp_drspos;
+};
+
+/*
+ * Internal function prototypes.
+ */
+
+int _dwarf_abbrev_add(Dwarf_CU, uint64_t, uint64_t, uint8_t,
+ uint64_t, Dwarf_Abbrev *, Dwarf_Error *);
+void _dwarf_abbrev_cleanup(Dwarf_CU);
+int _dwarf_abbrev_find(Dwarf_CU, uint64_t, Dwarf_Abbrev *,
+ Dwarf_Error *);
+int _dwarf_abbrev_gen(Dwarf_P_Debug, Dwarf_Error *);
+int _dwarf_abbrev_parse(Dwarf_Debug, Dwarf_CU, Dwarf_Unsigned *,
+ Dwarf_Abbrev *, Dwarf_Error *);
+int _dwarf_add_AT_dataref(Dwarf_P_Debug, Dwarf_P_Die, Dwarf_Half,
+ Dwarf_Unsigned, Dwarf_Unsigned, const char *,
+ Dwarf_P_Attribute *, Dwarf_Error *);
+int _dwarf_add_string_attr(Dwarf_P_Die, Dwarf_P_Attribute *,
+ Dwarf_Half, char *, Dwarf_Error *);
+int _dwarf_alloc(Dwarf_Debug *, int, Dwarf_Error *);
+void _dwarf_arange_cleanup(Dwarf_Debug);
+int _dwarf_arange_gen(Dwarf_P_Debug, Dwarf_Error *);
+int _dwarf_arange_init(Dwarf_Debug, Dwarf_Error *);
+void _dwarf_arange_pro_cleanup(Dwarf_P_Debug);
+int _dwarf_attr_alloc(Dwarf_Die, Dwarf_Attribute *, Dwarf_Error *);
+Dwarf_Attribute _dwarf_attr_find(Dwarf_Die, Dwarf_Half);
+int _dwarf_attr_gen(Dwarf_P_Debug, Dwarf_P_Section, Dwarf_Rel_Section,
+ Dwarf_CU, Dwarf_Die, int, Dwarf_Error *);
+int _dwarf_attr_init(Dwarf_Debug, Dwarf_Section *, uint64_t *, int,
+ Dwarf_CU, Dwarf_Die, Dwarf_AttrDef, uint64_t, int,
+ Dwarf_Error *);
+int _dwarf_attrdef_add(Dwarf_Debug, Dwarf_Abbrev, uint64_t,
+ uint64_t, uint64_t, Dwarf_AttrDef *, Dwarf_Error *);
+uint64_t _dwarf_decode_lsb(uint8_t **, int);
+uint64_t _dwarf_decode_msb(uint8_t **, int);
+int64_t _dwarf_decode_sleb128(uint8_t **);
+uint64_t _dwarf_decode_uleb128(uint8_t **);
+void _dwarf_deinit(Dwarf_Debug);
+int _dwarf_die_alloc(Dwarf_Debug, Dwarf_Die *, Dwarf_Error *);
+int _dwarf_die_count_links(Dwarf_P_Die, Dwarf_P_Die,
+ Dwarf_P_Die, Dwarf_P_Die);
+Dwarf_Die _dwarf_die_find(Dwarf_Die, Dwarf_Unsigned);
+int _dwarf_die_gen(Dwarf_P_Debug, Dwarf_CU, Dwarf_Rel_Section,
+ Dwarf_Error *);
+void _dwarf_die_link(Dwarf_P_Die, Dwarf_P_Die, Dwarf_P_Die,
+ Dwarf_P_Die, Dwarf_P_Die);
+int _dwarf_die_parse(Dwarf_Debug, Dwarf_Section *, Dwarf_CU, int,
+ uint64_t, uint64_t, Dwarf_Die *, int, Dwarf_Error *);
+void _dwarf_die_pro_cleanup(Dwarf_P_Debug);
+void _dwarf_elf_deinit(Dwarf_Debug);
+int _dwarf_elf_init(Dwarf_Debug, Elf *, Dwarf_Error *);
+int _dwarf_elf_load_section(void *, Dwarf_Half, Dwarf_Small **,
+ int *);
+Dwarf_Endianness _dwarf_elf_get_byte_order(void *);
+Dwarf_Small _dwarf_elf_get_length_size(void *);
+Dwarf_Small _dwarf_elf_get_pointer_size(void *);
+Dwarf_Unsigned _dwarf_elf_get_section_count(void *);
+int _dwarf_elf_get_section_info(void *, Dwarf_Half,
+ Dwarf_Obj_Access_Section *, int *);
+void _dwarf_expr_cleanup(Dwarf_P_Debug);
+int _dwarf_expr_into_block(Dwarf_P_Expr, Dwarf_Error *);
+Dwarf_Section *_dwarf_find_next_types_section(Dwarf_Debug, Dwarf_Section *);
+Dwarf_Section *_dwarf_find_section(Dwarf_Debug, const char *);
+void _dwarf_frame_cleanup(Dwarf_Debug);
+int _dwarf_frame_fde_add_inst(Dwarf_P_Fde, Dwarf_Small,
+ Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Error *);
+int _dwarf_frame_gen(Dwarf_P_Debug, Dwarf_Error *);
+int _dwarf_frame_get_fop(Dwarf_Debug, uint8_t, uint8_t *,
+ Dwarf_Unsigned, Dwarf_Frame_Op **, Dwarf_Signed *,
+ Dwarf_Error *);
+int _dwarf_frame_get_internal_table(Dwarf_Fde, Dwarf_Addr,
+ Dwarf_Regtable3 **, Dwarf_Addr *, Dwarf_Error *);
+int _dwarf_frame_interal_table_init(Dwarf_Debug, Dwarf_Error *);
+void _dwarf_frame_params_init(Dwarf_Debug);
+void _dwarf_frame_pro_cleanup(Dwarf_P_Debug);
+int _dwarf_frame_regtable_copy(Dwarf_Debug, Dwarf_Regtable3 **,
+ Dwarf_Regtable3 *, Dwarf_Error *);
+int _dwarf_frame_section_load(Dwarf_Debug, Dwarf_Error *);
+int _dwarf_frame_section_load_eh(Dwarf_Debug, Dwarf_Error *);
+int _dwarf_generate_sections(Dwarf_P_Debug, Dwarf_Error *);
+Dwarf_Unsigned _dwarf_get_reloc_type(Dwarf_P_Debug, int);
+int _dwarf_get_reloc_size(Dwarf_Debug, Dwarf_Unsigned);
+void _dwarf_info_cleanup(Dwarf_Debug);
+int _dwarf_info_first_cu(Dwarf_Debug, Dwarf_Error *);
+int _dwarf_info_first_tu(Dwarf_Debug, Dwarf_Error *);
+int _dwarf_info_gen(Dwarf_P_Debug, Dwarf_Error *);
+int _dwarf_info_load(Dwarf_Debug, Dwarf_Bool, Dwarf_Bool,
+ Dwarf_Error *);
+int _dwarf_info_next_cu(Dwarf_Debug, Dwarf_Error *);
+int _dwarf_info_next_tu(Dwarf_Debug, Dwarf_Error *);
+void _dwarf_info_pro_cleanup(Dwarf_P_Debug);
+int _dwarf_init(Dwarf_Debug, Dwarf_Unsigned, Dwarf_Handler,
+ Dwarf_Ptr, Dwarf_Error *);
+int _dwarf_lineno_gen(Dwarf_P_Debug, Dwarf_Error *);
+int _dwarf_lineno_init(Dwarf_Die, uint64_t, Dwarf_Error *);
+void _dwarf_lineno_cleanup(Dwarf_LineInfo);
+void _dwarf_lineno_pro_cleanup(Dwarf_P_Debug);
+int _dwarf_loc_fill_locdesc(Dwarf_Debug, Dwarf_Locdesc *,
+ uint8_t *, uint64_t, uint8_t, uint8_t, uint8_t,
+ Dwarf_Error *);
+int _dwarf_loc_fill_locexpr(Dwarf_Debug, Dwarf_Locdesc **,
+ uint8_t *, uint64_t, uint8_t, uint8_t, uint8_t,
+ Dwarf_Error *);
+int _dwarf_loc_add(Dwarf_Die, Dwarf_Attribute, Dwarf_Error *);
+int _dwarf_loc_expr_add_atom(Dwarf_Debug, uint8_t *, uint8_t *,
+ Dwarf_Small, Dwarf_Unsigned, Dwarf_Unsigned, int *,
+ Dwarf_Error *);
+int _dwarf_loclist_find(Dwarf_Debug, Dwarf_CU, uint64_t,
+ Dwarf_Locdesc ***, Dwarf_Signed *, Dwarf_Unsigned *,
+ Dwarf_Error *);
+void _dwarf_macinfo_cleanup(Dwarf_Debug);
+int _dwarf_macinfo_gen(Dwarf_P_Debug, Dwarf_Error *);
+int _dwarf_macinfo_init(Dwarf_Debug, Dwarf_Error *);
+void _dwarf_macinfo_pro_cleanup(Dwarf_P_Debug);
+int _dwarf_nametbl_init(Dwarf_Debug, Dwarf_NameSec *,
+ Dwarf_Section *, Dwarf_Error *);
+void _dwarf_nametbl_cleanup(Dwarf_NameSec *);
+int _dwarf_nametbl_gen(Dwarf_P_Debug, const char *, Dwarf_NameTbl,
+ Dwarf_Error *);
+void _dwarf_nametbl_pro_cleanup(Dwarf_NameTbl *);
+int _dwarf_pro_callback(Dwarf_P_Debug, char *, int, Dwarf_Unsigned,
+ Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
+ Dwarf_Unsigned *, int *);
+Dwarf_P_Section _dwarf_pro_find_section(Dwarf_P_Debug, const char *);
+int _dwarf_ranges_add(Dwarf_Debug, Dwarf_CU, uint64_t,
+ Dwarf_Rangelist *, Dwarf_Error *);
+void _dwarf_ranges_cleanup(Dwarf_Debug);
+int _dwarf_ranges_find(Dwarf_Debug, uint64_t, Dwarf_Rangelist *);
+uint64_t _dwarf_read_lsb(uint8_t *, uint64_t *, int);
+uint64_t _dwarf_read_msb(uint8_t *, uint64_t *, int);
+int64_t _dwarf_read_sleb128(uint8_t *, uint64_t *);
+uint64_t _dwarf_read_uleb128(uint8_t *, uint64_t *);
+char *_dwarf_read_string(void *, Dwarf_Unsigned, uint64_t *);
+uint8_t *_dwarf_read_block(void *, uint64_t *, uint64_t);
+int _dwarf_reloc_section_finalize(Dwarf_P_Debug, Dwarf_Rel_Section,
+ Dwarf_Error *);
+int _dwarf_reloc_entry_add(Dwarf_P_Debug, Dwarf_Rel_Section,
+ Dwarf_P_Section, unsigned char, unsigned char,
+ Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
+ const char *, Dwarf_Error *);
+int _dwarf_reloc_entry_add_pair(Dwarf_P_Debug, Dwarf_Rel_Section,
+ Dwarf_P_Section, unsigned char, Dwarf_Unsigned,
+ Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
+ Dwarf_Unsigned, Dwarf_Error *);
+void _dwarf_reloc_cleanup(Dwarf_P_Debug);
+int _dwarf_reloc_gen(Dwarf_P_Debug, Dwarf_Error *);
+int _dwarf_reloc_section_gen(Dwarf_P_Debug, Dwarf_Rel_Section,
+ Dwarf_Error *);
+int _dwarf_reloc_section_init(Dwarf_P_Debug, Dwarf_Rel_Section *,
+ Dwarf_P_Section, Dwarf_Error *);
+void _dwarf_reloc_section_free(Dwarf_P_Debug, Dwarf_Rel_Section *);
+void _dwarf_section_cleanup(Dwarf_P_Debug);
+int _dwarf_section_callback(Dwarf_P_Debug, Dwarf_P_Section,
+ Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
+ Dwarf_Unsigned, Dwarf_Error *);
+void _dwarf_section_free(Dwarf_P_Debug, Dwarf_P_Section *);
+int _dwarf_section_init(Dwarf_P_Debug, Dwarf_P_Section *,
+ const char *, int, Dwarf_Error *);
+void _dwarf_set_error(Dwarf_Debug, Dwarf_Error *, int, int,
+ const char *, int);
+int _dwarf_strtab_add(Dwarf_Debug, char *, uint64_t *,
+ Dwarf_Error *);
+void _dwarf_strtab_cleanup(Dwarf_Debug);
+int _dwarf_strtab_gen(Dwarf_P_Debug, Dwarf_Error *);
+char *_dwarf_strtab_get_table(Dwarf_Debug);
+int _dwarf_strtab_init(Dwarf_Debug, Dwarf_Error *);
+void _dwarf_type_unit_cleanup(Dwarf_Debug);
+void _dwarf_write_block(void *, uint64_t *, uint8_t *, uint64_t);
+int _dwarf_write_block_alloc(uint8_t **, uint64_t *, uint64_t *,
+ uint8_t *, uint64_t, Dwarf_Error *);
+void _dwarf_write_lsb(uint8_t *, uint64_t *, uint64_t, int);
+int _dwarf_write_lsb_alloc(uint8_t **, uint64_t *, uint64_t *,
+ uint64_t, int, Dwarf_Error *);
+void _dwarf_write_msb(uint8_t *, uint64_t *, uint64_t, int);
+int _dwarf_write_msb_alloc(uint8_t **, uint64_t *, uint64_t *,
+ uint64_t, int, Dwarf_Error *);
+void _dwarf_write_padding(void *, uint64_t *, uint8_t, uint64_t);
+int _dwarf_write_padding_alloc(uint8_t **, uint64_t *, uint64_t *,
+ uint8_t, uint64_t, Dwarf_Error *);
+void _dwarf_write_string(void *, uint64_t *, char *);
+int _dwarf_write_string_alloc(uint8_t **, uint64_t *, uint64_t *,
+ char *, Dwarf_Error *);
+int _dwarf_write_sleb128(uint8_t *, uint8_t *, int64_t);
+int _dwarf_write_sleb128_alloc(uint8_t **, uint64_t *, uint64_t *,
+ int64_t, Dwarf_Error *);
+int _dwarf_write_uleb128(uint8_t *, uint8_t *, uint64_t);
+int _dwarf_write_uleb128_alloc(uint8_t **, uint64_t *, uint64_t *,
+ uint64_t, Dwarf_Error *);
+
+#endif /* !__LIBDWARF_H_ */
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf.3
new file mode 100644
index 0000000..863bee6
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf.3
@@ -0,0 +1,751 @@
+.\" Copyright (c) 2011 Joseph Koshy. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" This software is provided by Joseph Koshy ``as is'' and
+.\" any express or implied warranties, including, but not limited to, the
+.\" implied warranties of merchantability and fitness for a particular purpose
+.\" are disclaimed. in no event shall Joseph Koshy be liable
+.\" for any direct, indirect, incidental, special, exemplary, or consequential
+.\" damages (including, but not limited to, procurement of substitute goods
+.\" or services; loss of use, data, or profits; or business interruption)
+.\" however caused and on any theory of liability, whether in contract, strict
+.\" liability, or tort (including negligence or otherwise) arising in any way
+.\" out of the use of this software, even if advised of the possibility of
+.\" such damage.
+.\"
+.\" $Id: dwarf.3 3295 2016-01-08 22:08:10Z jkoshy $
+.\"
+.Dd December 21, 2014
+.Os
+.Dt DWARF 3
+.Sh NAME
+.Nm dwarf
+.Nd access debugging information in object files
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Sh DESCRIPTION
+.Pp
+The
+.Lb libdwarf
+provides functions that allow an application to read and write debugging
+information in object files.
+The format of debugging information accessible through this API
+is defined by the DWARF standard, see
+.Xr dwarf 4 .
+.Pp
+The
+.Xr DWARF 3
+API has two parts:
+.Bl -bullet
+.It
+A consumer API set allows applications to read existing debug information
+in a program object.
+The functions that comprise the DWARF consumer API are described in
+the section
+.Sx "DWARF Consumer API"
+below.
+.It
+A producer API set that allows applications to add debug information
+to a program object.
+The functions that comprise the DWARF producer API are described in
+the section
+.Sx "DWARF Producer API"
+below.
+.El
+.Pp
+Each function referenced below is further described in its own manual page.
+.Ss Namespace use
+The DWARF library uses the following prefixes:
+.Pp
+.Bl -tag -width ".Li Dwarf_*" -compact
+.It Li DWARF_*
+Used for error numbers and constants.
+.It Li DW_*
+Used for constants.
+.It Li Dwarf_*
+Used for types.
+.It Li dwarf_*
+Used for functions and macros that make up the API.
+.El
+.Ss Data Types
+The DWARF(3) API uses the following data types:
+.Pp
+.Bl -tag -width ".Vt Dwarf_Unsigned" -compact
+.It Vt Dwarf_Abbrev
+Describes DWARF abbreviations.
+.It Vt Dwarf_Addr
+A program address in the target object.
+.It Vt Dwarf_Arange
+Describes address ranges.
+.It Vt Dwarf_Attribute , Vt Dwarf_P_Attribute
+Describes attributes of debugging information entries.
+.It Vt Dwarf_Bool
+Used for boolean states.
+.It Vt Dwarf_Cie , Vt Dwarf_P_Cie
+Describes call information that is common to several frames.
+.It Vt Dwarf_Debug , Vt Dwarf_P_Debug
+An opaque type describing a debug context.
+.It Vt Dwarf_Die , Vt Dwarf_P_Die
+A debugging information entry.
+.It Vt Dwarf_Fde , Vt Dwarf_P_Fde
+A frame descriptor.
+.It Vt Dwarf_Func
+A descriptor representing a function.
+.It Vt Dwarf_Global
+A descriptor representing a global name.
+.It Vt Dwarf_Half
+A 16-bit wide unsigned numeric type.
+.It Vt Dwarf_Handler
+A pointer to an error handling function.
+.It Vt Dwarf_Line
+A descriptor for a source line.
+.It Vt Dwarf_Off
+An unsigned file offset.
+.It Vt Dwarf_P_Expr
+A descriptor for a location expression.
+.It Vt Dwarf_Ptr
+A virtual address used by an application.
+.It Vt Dwarf_Signed
+A 64-bit wide signed numeric type.
+.It Vt Dwarf_Small
+An 8-bit wide unsigned numeric type.
+.It Vt Dwarf_Type
+A descriptor representing a user-specified type.
+.It Vt Dwarf_Unsigned
+A 64-bit wide unsigned numeric type.
+.It Vt Dwarf_Var
+A descriptor representing a static variable.
+.It Vt Dwarf_Weak
+A descriptor representing a weak name.
+.El
+.Ss Error Handling
+.Pp
+Library functions that encounter an error will return with a value
+other than
+.Dv DW_DLV_OK .
+.Pp
+The
+.Lb libdwarf
+allows applications to specify three levels of error handling:
+.Bl -enum -compact
+.It
+Most library functions take a parameter of type
+.Vt Dwarf_Error
+that specifies a location to store an error descriptor in
+case of an error.
+If an error occurs during the execution on an API, and if this
+parameter is non-NULL, then an error descriptor is written to the
+location specified.
+.It
+Otherwise, if the error parameter was NULL, but if an error handler
+was defined for the debug context in use using
+.Xr dwarf_init 3
+or
+.Xr dwarf_seterrhand 3 ,
+then the library will invoke the specified error handler with an error
+descriptor as argument.
+.It
+Otherwise, if a library wide error handler was specified using
+.Xr dwarf_seterrhand 3 ,
+it is called.
+.El
+.Pp
+Error descriptors may be used with
+.Xr dwarf_errmsg 3
+or
+.Xr dwarf_errno 3 .
+.Sh The DWARF Consumer API
+The DWARF consumer API permits applications to read DWARF information in
+an object file.
+.Pp
+The major functional groups of functions in the consumer API are listed
+below.
+.Pp
+.Bl -tag -compact -width "CCCC"
+.It Abbreviations
+.Bl -tag -compact
+.It Fn dwarf_get_abbrev
+Retrieve abbreviation information at a given offset.
+.It Fn dwarf_get_abbrev_children_flag
+Check if an abbreviation has child elements.
+.It Fn dwarf_get_abbrev_code
+Retrieve the abbreviation code for an abbreviation entry descriptor.
+.It Fn dwarf_get_abbrev_entry
+Retrieve abbreviation information for an abbreviation entry
+descriptor.
+.It Fn dwarf_get_abbrev_tag
+Retrieve the tag for an abbreviation entry.
+.El
+.It Addresses
+.Bl -tag -compact
+.It Fn dwarf_get_address_size
+Return the number of bytes needed to represent an address.
+.It Fn dwarf_get_arange
+Search for an address range descriptor covering an address.
+.It Fn dwarf_get_arange_cu_header_offset
+Retrieve the offsets associated with an address range descriptor.
+.It Fn dwarf_get_arange_info
+Extract address range information from a descriptor.
+.It Fn dwarf_get_aranges
+Retrieve program address space mappings.
+.It Fn dwarf_get_cu_die_offset
+Retrieve the offset associated with a compilation unit for an address
+range descriptor.
+.It Fn dwarf_get_ranges , Fn dwarf_get_ranges_a
+Retrieve information about non-contiguous address ranges for
+a debugging information entry.
+.El
+.It Attributes
+.Bl -tag -compact
+.It Fn dwarf_arrayorder
+Retrieve the value of a
+.Dv DW_AT_ordering
+attribute.
+.It Fn dwarf_attr
+Retrieve an attribute descriptor.
+.It Fn dwarf_attrlist
+Retrieve attribute descriptors for a debugging information entry.
+.It Fn dwarf_attroffset
+Retrieve the section-relative offset of an attribute descriptor.
+.It Fn dwarf_attrval_flag
+Retrieve a
+.Dv DW_AT_FORM_flag
+value.
+.It Fn dwarf_attrval_signed
+Retrieve an attribute's value as a signed integral quantity.
+.It Fn dwarf_attrval_string
+Retrieve an attribute's value as a NUL-terminated string.
+.It Fn dwarf_attrval_unsigned
+Retrieve an attribute's value as an unsigned integral quantity.
+.It Fn dwarf_bitoffset ,
+Retrieve the value of a
+.Dv DW_AT_bit_offset
+attribute.
+.It Fn dwarf_bitsize ,
+Retrieve the value of a
+.Dv DW_AT_bit_size
+attribute.
+.It Fn dwarf_bytesize
+Retrieve the value of a
+.Dv DW_AT_byte_size
+attribute.
+.It Fn dwarf_formaddr
+Return the value of an
+.Dv ADDRESS Ns - Ns
+class attribute.
+.It Fn dwarf_formblock
+Return the value of a
+.Dv BLOCK Ns - Ns
+class attribute
+.It Fn dwarf_formexprloc
+Return information about a location expression.
+.It Fn dwarf_formflag
+Retrieve information about a
+.Dv BOOLEAN Ns - Ns
+class attribute.
+.It Fn dwarf_formref , Fn dwarf_global_formref
+Retrieve offsets for
+.Dv REFERENCE Ns - Ns
+class attributes.
+.It Fn dwarf_formsdata , Fn dwarf_formudata
+Retrieve the value of a
+.Dv CONSTANT Ns - Ns
+class attribute.
+.It Fn dwarf_formsig8
+Return the type signature for a DWARF type.
+.It Fn dwarf_formstring
+Retrieve information about a
+.Dv STRING Ns - Ns
+class attribute.
+.It Fn dwarf_get_form_class
+Retrieve the form class for an attribute.
+.It Fn dwarf_hasattr
+Check for the presence of an attribute.
+.It Fn dwarf_hasform
+Check if an attribute has the given form.
+.It Fn dwarf_whatattr
+Retrieve the attribute code for an attribute.
+.It Fn dwarf_whatform , Fn dwarf_whatform_direct
+Retrieve the form of an attribute.
+.El
+.It Call Information Entries and Frame Descriptor Entries
+.Bl -tag -compact
+.It Fn dwarf_get_cie_index
+Retrieve the index for a CIE descriptor.
+.It Fn dwarf_get_cie_info
+Retrieve information from a CIE descriptor.
+.It Fn dwarf_get_cie_of_fde
+Retrieve a CIE descriptor.
+.It Fn dwarf_get_fde_at_pc
+Retrieve an FDE descriptor for an address.
+.It Fn dwarf_get_fde_info_for_all_regs
+Retrieve register rule row.
+.It Fn dwarf_get_fde_info_for_all_regs3
+Retrieve register rule row (revised API).
+.It Fn dwarf_get_fde_info_for_cfa_reg3
+Retrieve a CFA register rule.
+.It Fn dwarf_get_fde_info_for_reg
+Retrieve a register rule.
+.It Fn dwarf_get_fde_info_for_reg3
+Retrieve a register rule (revised API).
+.It Fn dwarf_get_fde_instr_bytes
+Retrieve instructions from an FDE descriptor.
+.It Fn dwarf_get_fde_list , Fn dwarf_get_fde_list_eh
+Retrieve frame information.
+.It Fn dwarf_get_fde_n
+Retrieve an FDE descriptor.
+.It Fn dwarf_get_fde_range
+Retrieve range information from an FDE descriptor.
+.El
+.It Compilation Units
+.Bl -tag -compact
+.It Xo
+.Fn dwarf_get_cu_die_offset_given_cu_header_offset ,
+.Fn dwarf_get_cu_die_offset_given_cu_header_offset_b
+.Xc
+Retrieve the offset of the debugging information entry for a
+compilation or type unit.
+.It Xo
+.Fn dwarf_next_cu_header ,
+.Fn dwarf_next_cu_header_b ,
+.Fn dwarf_next_cu_header_c
+.Xc
+Step through compilation units in a debug context.
+.El
+.It Debugging Information Entries
+.Bl -tag -compact
+.It Fn dwarf_child
+Returns the child of a debugging information entry.
+.It Fn dwarf_die_abbrev_code
+Returns the abbreviation code for a debugging information entry.
+.It Fn dwarf_die_CU_offset , Fn dwarf_die_CU_offset_range
+Retrieve offsets and lengths for a compilation unit.
+.It Fn dwarf_diename
+Returns the
+.Dv DW_AT_name
+attribute for a debugging information entry.
+.It Fn dwarf_dieoffset
+Retrieves the offset for a debugging information entry.
+.It Fn dwarf_get_die_infotypes_flag
+Indicate the originating section for a debugging information entry.
+.It Fn dwarf_highpc , Fn dwarf_highpc_b
+Return the highest PC value for a debugging information entry.
+.It Fn dwarf_lowpc
+Return the lowest PC value for a debugging information entry.
+.It Fn dwarf_offdie , Fn dwarf_offdie_b
+Retrieve a debugging information entry given an offset.
+.It Fn dwarf_siblingof , Fn dwarf_siblingof_b
+Retrieve the sibling descriptor for a debugging information entry.
+.It Fn dwarf_srclang
+Retrieve the source language attribute for a debugging information
+entry.
+.It Fn dwarf_tag
+Retrieve the tag for a debugging information entry.
+.El
+.It Functions
+.Bl -tag -compact
+.It Fn dwarf_func_cu_offset
+Retrieves the offset for the compilation unit for a function.
+.It Fn dwarf_func_die_offset
+Retrieves the offset for the debugging information entry for a
+function.
+.It Fn dwarf_funcname
+Retrieves the name of a function.
+.It Fn dwarf_func_name_offsets
+Retrieve both the name and offsets for a function.
+.It Fn dwarf_get_funcs
+Retrieve information about static functions.
+.El
+.It Globals
+.Bl -tag -compact
+.It Fn dwarf_get_globals
+Retrieve a list of globals.
+.It Fn dwarf_global_cu_offset
+Return the offset for compilation unit for a global.
+.It Fn dwarf_global_die_offset
+Return the offset for the debugging information entry for a global.
+.It Fn dwarf_global_name_offsets
+Return the name and offsets for a global.
+.It Fn dwarf_globname
+Return the name for a global.
+.El
+.It Initialization and Finalization
+Functions
+.Fn dwarf_elf_init
+and
+.Fn dwarf_init
+may be used for initialization.
+The function
+.Fn dwarf_finish
+may be used to release resources.
+.Pp
+The functions
+.Fn dwarf_object_init
+and
+.Fn dwarf_object_finish
+allow an application to specify alternate low-level file access
+routines.
+.It Line Numbers
+.Bl -tag -compact
+.It Fn dwarf_lineaddr
+Retrieve the program address for a source line.
+.It Fn dwarf_linebeginstatement
+Check if a source line corresponds to the beginning of a statement.
+.It Fn dwarf_lineblock
+Check if a source line corresponds to the start of a basic block.
+.It Fn dwarf_lineendsequence
+Check if the source line corresponds to the end of a sequence of
+instructions.
+.It Fn dwarf_lineno
+Retrieve the line number for a line descriptor.
+.It Fn dwarf_lineoff
+Retrieve the column number for a line descriptor.
+.It Fn dwarf_linesrc
+Retrieve the source file for a line descriptor.
+.It Fn dwarf_line_srcfileno
+Retrieve the index of the source file for a line descriptor.
+.It Fn dwarf_srcfiles
+Retrieve source files for a compilation unit.
+.It Fn dwarf_srclines
+Return line number information for a compilation unit.
+.El
+.It Location Lists
+.Bl -tag -compact
+.It Fn dwarf_get_loclist_entry
+Retrieve a location list entry.
+.It Fn dwarf_loclist , Fn dwarf_loclist_n
+Retrieve location expressions.
+.It Xo
+.Fn dwarf_loclist_from_expr ,
+.Fn dwarf_loclist_from_expr_a ,
+.Fn dwarf_loclist_from_expr_b
+.Xc
+Translate a location expression into a location descriptor.
+.El
+.It Error Handling
+.Bl -tag -compact
+.It Fn dwarf_errmsg
+Retrieve a human-readable error message.
+.It Fn dwarf_errno
+Retrieve an error number from an error descriptor.
+.It Fn dwarf_seterrarg
+Set the argument passed to a callback error handler.
+.It Fn dwarf_seterrhand
+Set the callback handler to be called in case of an error.
+.El
+.It Frame Handling
+.Bl -tag -compact
+.It Fn dwarf_expand_frame_instructions
+Translate frame instruction bytes.
+.It Fn dwarf_set_frame_cfa_value
+Set the CFA parameter for the internal register rule table.
+.It Fn dwarf_set_frame_rule_initial_value
+Set the initial value of the register rules in the internal register
+rule table.
+.It Fn dwarf_set_frame_rule_table_size
+Set the maximum number of columns in the register rule table.
+.It Fn dwarf_set_frame_same_value
+Set the register number representing the
+.Dq "same value"
+rule.
+.It Fn dwarf_set_frame_undefined_value
+Set the register number representing the
+.Dq "undefined"
+rule.
+.El
+.It Macros
+.Bl -tag -compact
+.It Fn dwarf_find_macro_value_start
+Return the macro value part of a macro string.
+.It Fn dwarf_get_macro_details
+Retrieve macro information.
+.El
+.It Memory Management
+In the DWARF consumer API, the rules for memory management differ
+between functions.
+In some cases, the memory areas returned to the application by the
+library are freed by calling specific API functions.
+In others, the deallocation function
+.Fn dwarf_dealloc
+suffices.
+The individual manual pages for the API's functions document the
+specific memory management rules to be followed.
+.Pp
+The function
+.Fn dwarf_dealloc
+is used to mark memory arenas as unused.
+Additionally, the following functions release specific types of
+DWARF resources:
+.Fn dwarf_fde_cie_list_dealloc ,
+.Fn dwarf_funcs_dealloc ,
+.Fn dwarf_globals_dealloc ,
+.Fn dwarf_pubtypes_dealloc ,
+.Fn dwarf_ranges_dealloc ,
+.Fn dwarf_srclines_dealloc ,
+.Fn dwarf_types_dealloc ,
+.Fn dwarf_vars_dealloc ,
+and
+.Fn dwarf_weaks_dealloc .
+.It Symbol Constants
+The following functions may be used to return symbolic names
+for DWARF constants:
+.Fn dwarf_get_ACCESS_name ,
+.Fn dwarf_get_AT_name ,
+.Fn dwarf_get_ATE_name ,
+.Fn dwarf_get_CC_name ,
+.Fn dwarf_get_CFA_name ,
+.Fn dwarf_get_CHILDREN_name ,
+.Fn dwarf_get_DS_name ,
+.Fn dwarf_get_DSC_name ,
+.Fn dwarf_get_EH_name ,
+.Fn dwarf_get_END_name ,
+.Fn dwarf_get_FORM_name ,
+.Fn dwarf_get_ID_name ,
+.Fn dwarf_get_INL_name ,
+.Fn dwarf_get_LANG_name ,
+.Fn dwarf_get_LNE_name ,
+.Fn dwarf_get_LNS_name ,
+.Fn dwarf_get_MACINFO_name ,
+.Fn dwarf_get_OP_name ,
+.Fn dwarf_get_ORD_name ,
+.Fn dwarf_get_TAG_name ,
+.Fn dwarf_get_VIRTUALITY_name ,
+and
+.Fn dwarf_get_VIS_name .
+.It Types
+.Bl -tag -compact
+.It Fn dwarf_get_pubtypes , Fn dwarf_get_types
+Retrieve descriptors for user-defined types.
+.It Fn dwarf_next_types_section
+Step through
+.Dq \&.debug_types
+sections in a debug context.
+.It Fn dwarf_pubtype_cu_offset , Fn dwarf_type_cu_offset
+Return the offset for the compilation unit for a type.
+.It Fn dwarf_pubtype_die_offset , Fn dwarf_type_die_offset
+Return the offset for the debugging information entry for a type.
+.It Fn dwarf_pubtypename , Fn dwarf_typename
+Retrieve the name of a type.
+.It Fn dwarf_pubtype_name_offsets , Fn dwarf_type_name_offsets
+Retrieve the name and offsets for a type.
+.El
+.It Variables
+.Bl -tag -compact
+.It Fn dwarf_get_vars
+Retrieve descriptors for static variables.
+.It Fn dwarf_var_cu_offset
+Return the offset for the compilation unit for a variable.
+.It Fn dwarf_var_die_offset
+Return the offset for the debugging information entry for a variable.
+.It Fn dwarf_varname
+Retrieve the name of a variable.
+.It Fn dwarf_var_name_offsets
+Retrieve the name and offsets for a variable.
+.El
+.It Weak Symbols
+.Bl -tag -compact
+.It Fn dwarf_get_weaks
+Retrieve information about weak symbols.
+.It Fn dwarf_weak_cu_offset
+Return the offset for the compilation unit for a weak symbol.
+.It Fn dwarf_weak_die_offset
+Return the offset for the debugging information entry for a weak symbol.
+.It Fn dwarf_weakname
+Retrieve the name of a weak symbol.
+.It Fn dwarf_weak_name_offsets
+Retrieve the name and offsets for a weak symbol.
+.El
+.It Miscellaneous
+.Bl -tag -compact
+.It Fn dwarf_get_elf
+Retrieve the ELF descriptor for a debug context, see
+.Xr elf 3 .
+.It Fn dwarf_get_str
+Retrieve a NUL-terminated string from the DWARF string section.
+.It Fn dwarf_set_reloc_application
+Control whether relocations are to be handled by
+.Lb libdwarf .
+.El
+.El
+.Sh The DWARF Producer API
+The DWARF producer API permits applications to add DWARF information to
+an object file.
+.Pp
+The major functional groups of functions in the producer API are listed
+below.
+.Bl -tag -width "CCCC"
+.It Attribute Management
+The following functions are used to attach attributes to a debugging
+information entry:
+.Fn dwarf_add_AT_comp_dir ,
+.Fn dwarf_add_AT_const_value_signedint ,
+.Fn dwarf_add_AT_const_value_string ,
+.Fn dwarf_add_AT_const_value_unsignedint ,
+.Fn dwarf_add_AT_dataref ,
+.Fn dwarf_add_AT_flag ,
+.Fn dwarf_add_AT_location_expr ,
+.Fn dwarf_add_AT_name ,
+.Fn dwarf_add_AT_producer ,
+.Fn dwarf_add_AT_ref_address ,
+.Fn dwarf_add_AT_reference ,
+.Fn dwarf_add_AT_signed_const ,
+.Fn dwarf_add_AT_string ,
+.Fn dwarf_add_AT_targ_address ,
+.Fn dwarf_add_AT_targ_address_b
+and
+.Fn dwarf_add_AT_unsigned_const .
+.It Debugging Information Entry Management
+.Bl -tag -compact
+.It Fn dwarf_add_die_to_debug
+Set the root debugging information entry for a DWARF producer instance.
+.It Fn dwarf_die_link
+Links debugging information entries.
+.It Fn dwarf_new_die
+Allocate a new debugging information entry.
+.El
+.It Initialization and Finalization
+The functions
+.Fn dwarf_producer_init
+and
+.Fn dwarf_producer_init_b
+are used to initialize a producer instance.
+.Pp
+When done, applications release resources using the function
+.Fn dwarf_producer_finish .
+.It Relocations and Sections
+.Bl -tag -compact
+.It Fn dwarf_get_relocation_info
+Retrieve a relocation array from a producer instance.
+.It Fn dwarf_get_relocation_info_count
+Return the number of relocation arrays for a producer instance.
+.It Fn dwarf_get_section_bytes
+Retrieve the ELF byte stream for a section.
+.It Fn dwarf_reset_section_bytes
+Reset internal state for a producer instance.
+.It Fn dwarf_transform_to_disk_form
+Prepare byte streams for writing out.
+.El
+.It Macros
+.Bl -tag -compact
+.It Fn dwarf_def_macro
+Add a macro definition.
+.It Fn dwarf_end_macro_file , Fn dwarf_start_macro_file
+Record macro file related information.
+.It Fn dwarf_undef_macro
+Note the removal of a macro definition.
+.It Fn dwarf_vendor_ext
+Enables storing macro information as specified in the DWARF standard.
+.El
+.It Symbols, Expressions, Addresses and Offsets
+.Bl -tag -compact
+.It Fn dwarf_add_arange , Fn dwarf_add_arange_b
+Add address range information.
+.It Fn dwarf_add_directory_decl
+Add information about an include directory to a producer instance.
+.It Fn dwarf_add_fde_inst
+Add an operation to a frame descriptor entry.
+.It Fn dwarf_add_file_decl
+Add information about a source file to a producer instance.
+.It Fn dwarf_add_frame_cie
+Add call information to a frame descriptor.
+.It Fn dwarf_add_frame_fde , Fn dwarf_add_frame_fde_b
+Link a frame descriptor to a producer instance.
+.It Fn dwarf_add_funcname
+Add information about a function to a producer instance.
+.It Fn dwarf_add_line_entry
+Record mapping information between machine addresses and a source line.
+.It Fn dwarf_add_expr_addr , Fn dwarf_add_expr_addr_b
+Add a
+.Dv DW_OP_addr
+opcode to a location expression.
+.It Fn dwarf_add_expr_gen
+Add an operator to a location expression.
+.It Fn dwarf_add_pubname
+Add information about a global name to a producer instance.
+.It Fn dwarf_add_typename
+Add information about a type to a producer instance.
+.It Fn dwarf_add_varname
+Add information about a static variable to a producer instance.
+.It Fn dwarf_add_weakname
+Add information about a weak symbol to a producer instance.
+.It Fn dwarf_expr_current_offset
+Retrieve the current size of a location expression.
+.It Fn dwarf_expr_into_block
+Convert a location expression into a byte stream.
+.It Fn dwarf_fde_cfa_offset
+Append a
+.Dv DW_CFA_offset
+operation to a frame descriptor.
+.It Fn dwarf_lne_end_sequence , Fn dwarf_lne_set_address
+Note address ranges for source lines.
+.It Fn dwarf_new_expr
+Allocate a location expression descriptor.
+.It Fn dwarf_new_fde
+Allocate a frame descriptor.
+.El
+.It Miscellaneous
+The function
+.Fn dwarf_producer_set_isa
+sets the instruction set architecture for the producer instance.
+.El
+.Sh COMPATIBILITY
+This implementation is believed to be source compatible with the
+SGI/GNU DWARF(3) library, version 20110113.
+.Pp
+Known differences with the SGI/GNU library include:
+.Bl -bullet -compact
+.It
+The memory management scheme used differs, in a backward-compatible
+way.
+See
+.Sx Memory Management
+above, for coding guidelines for portable applications.
+.It
+There is provision for setting a library-wide error handler in
+addition to the per-debug context handlers supported by the SGI/GNU
+API, see the subsection
+.Sx Error Handling
+above.
+.El
+.Ss Extensions
+The following APIs are extensions specific to this implementation:
+.Bl -bullet -compact
+.It
+.Fn dwarf_attroffset
+.It
+.Fn dwarf_next_types_section
+.It
+.Fn dwarf_producer_set_isa
+.El
+.Sh SEE ALSO
+.Xr elf 3
+.Sh STANDARDS
+The DWARF standard is defined by
+.Rs
+.%T "The DWARF Debugging Information Format"
+.%V "Version 4"
+.%O "http://www.dwarfstd.org/"
+.Re
+.Sh HISTORY
+The DWARF(3) API originated at Silicon Graphics Inc.
+.Pp
+A BSD-licensed implementation of a subset of the API was written by
+.An John Birrell Aq Mt jb@FreeBSD.org
+for the FreeBSD project.
+The implementation was subsequently revised and completed by
+.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
+.Pp
+Manual pages for this implementation were written by
+.An Joseph Koshy Aq Mt jkoshy@users.sourceforge.net
+and
+.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf.h b/rtemstoolkit/elftoolchain/libdwarf/dwarf.h
new file mode 100644
index 0000000..6322568
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf.h
@@ -0,0 +1,634 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: dwarf.h 3494 2016-09-20 17:16:13Z emaste $
+ */
+
+#ifndef _DWARF_H_
+#define _DWARF_H_
+
+#define DW_TAG_array_type 0x01
+#define DW_TAG_class_type 0x02
+#define DW_TAG_entry_point 0x03
+#define DW_TAG_enumeration_type 0x04
+#define DW_TAG_formal_parameter 0x05
+#define DW_TAG_imported_declaration 0x08
+#define DW_TAG_label 0x0a
+#define DW_TAG_lexical_block 0x0b
+#define DW_TAG_member 0x0d
+#define DW_TAG_pointer_type 0x0f
+#define DW_TAG_reference_type 0x10
+#define DW_TAG_compile_unit 0x11
+#define DW_TAG_string_type 0x12
+#define DW_TAG_structure_type 0x13
+#define DW_TAG_subroutine_type 0x15
+#define DW_TAG_typedef 0x16
+#define DW_TAG_union_type 0x17
+#define DW_TAG_unspecified_parameters 0x18
+#define DW_TAG_variant 0x19
+#define DW_TAG_common_block 0x1a
+#define DW_TAG_common_inclusion 0x1b
+#define DW_TAG_inheritance 0x1c
+#define DW_TAG_inlined_subroutine 0x1d
+#define DW_TAG_module 0x1e
+#define DW_TAG_ptr_to_member_type 0x1f
+#define DW_TAG_set_type 0x20
+#define DW_TAG_subrange_type 0x21
+#define DW_TAG_with_stmt 0x22
+#define DW_TAG_access_declaration 0x23
+#define DW_TAG_base_type 0x24
+#define DW_TAG_catch_block 0x25
+#define DW_TAG_const_type 0x26
+#define DW_TAG_constant 0x27
+#define DW_TAG_enumerator 0x28
+#define DW_TAG_friend 0x2a
+#define DW_TAG_namelist 0x2b
+#define DW_TAG_namelist_item 0x2c
+#define DW_TAG_packed_type 0x2d
+#define DW_TAG_subprogram 0x2e
+#define DW_TAG_template_type_parameter 0x2f
+#define DW_TAG_template_type_param 0x2f
+#define DW_TAG_template_value_parameter 0x30
+#define DW_TAG_template_value_param 0x30
+#define DW_TAG_thrown_type 0x31
+#define DW_TAG_try_block 0x32
+#define DW_TAG_variant_part 0x33
+#define DW_TAG_variable 0x34
+#define DW_TAG_volatile_type 0x35
+#define DW_TAG_dwarf_procedure 0x36
+#define DW_TAG_restrict_type 0x37
+#define DW_TAG_interface_type 0x38
+#define DW_TAG_namespace 0x39
+#define DW_TAG_imported_module 0x3a
+#define DW_TAG_unspecified_type 0x3b
+#define DW_TAG_partial_unit 0x3c
+#define DW_TAG_imported_unit 0x3d
+#define DW_TAG_condition 0x3f
+#define DW_TAG_shared_type 0x40
+#define DW_TAG_type_unit 0x41
+#define DW_TAG_rvalue_reference_type 0x42
+#define DW_TAG_template_alias 0x43
+#define DW_TAG_lo_user 0x4080
+#define DW_TAG_hi_user 0xffff
+
+/* GNU extensions. */
+#define DW_TAG_format_label 0x4101
+#define DW_TAG_function_template 0x4102
+#define DW_TAG_class_template 0x4103
+#define DW_TAG_GNU_BINCL 0x4104
+#define DW_TAG_GNU_EINCL 0x4105
+#define DW_TAG_GNU_template_template_parameter 0x4106
+#define DW_TAG_GNU_template_template_param 0x4106
+#define DW_TAG_GNU_template_parameter_pack 0x4107
+#define DW_TAG_GNU_formal_parameter_pack 0x4108
+#define DW_TAG_GNU_call_site 0x4109
+#define DW_TAG_GNU_call_site_parameter 0x410a
+
+#define DW_CHILDREN_no 0x00
+#define DW_CHILDREN_yes 0x01
+
+#define DW_AT_sibling 0x01
+#define DW_AT_location 0x02
+#define DW_AT_name 0x03
+#define DW_AT_ordering 0x09
+#define DW_AT_subscr_data 0x0a
+#define DW_AT_byte_size 0x0b
+#define DW_AT_bit_offset 0x0c
+#define DW_AT_bit_size 0x0d
+#define DW_AT_element_list 0x0f
+#define DW_AT_stmt_list 0x10
+#define DW_AT_low_pc 0x11
+#define DW_AT_high_pc 0x12
+#define DW_AT_language 0x13
+#define DW_AT_member 0x14
+#define DW_AT_discr 0x15
+#define DW_AT_discr_value 0x16
+#define DW_AT_visibility 0x17
+#define DW_AT_import 0x18
+#define DW_AT_string_length 0x19
+#define DW_AT_common_reference 0x1a
+#define DW_AT_comp_dir 0x1b
+#define DW_AT_const_value 0x1c
+#define DW_AT_containing_type 0x1d
+#define DW_AT_default_value 0x1e
+#define DW_AT_inline 0x20
+#define DW_AT_is_optional 0x21
+#define DW_AT_lower_bound 0x22
+#define DW_AT_producer 0x25
+#define DW_AT_prototyped 0x27
+#define DW_AT_return_addr 0x2a
+#define DW_AT_start_scope 0x2c
+#define DW_AT_bit_stride 0x2e
+#define DW_AT_stride_size 0x2e
+#define DW_AT_upper_bound 0x2f
+#define DW_AT_abstract_origin 0x31
+#define DW_AT_accessibility 0x32
+#define DW_AT_address_class 0x33
+#define DW_AT_artificial 0x34
+#define DW_AT_base_types 0x35
+#define DW_AT_calling_convention 0x36
+#define DW_AT_count 0x37
+#define DW_AT_data_member_location 0x38
+#define DW_AT_decl_column 0x39
+#define DW_AT_decl_file 0x3a
+#define DW_AT_decl_line 0x3b
+#define DW_AT_declaration 0x3c
+#define DW_AT_discr_list 0x3d
+#define DW_AT_encoding 0x3e
+#define DW_AT_external 0x3f
+#define DW_AT_frame_base 0x40
+#define DW_AT_friend 0x41
+#define DW_AT_identifier_case 0x42
+#define DW_AT_macro_info 0x43
+#define DW_AT_namelist_item 0x44
+#define DW_AT_priority 0x45
+#define DW_AT_segment 0x46
+#define DW_AT_specification 0x47
+#define DW_AT_static_link 0x48
+#define DW_AT_type 0x49
+#define DW_AT_use_location 0x4a
+#define DW_AT_variable_parameter 0x4b
+#define DW_AT_virtuality 0x4c
+#define DW_AT_vtable_elem_location 0x4d
+#define DW_AT_allocated 0x4e
+#define DW_AT_associated 0x4f
+#define DW_AT_data_location 0x50
+#define DW_AT_byte_stride 0x51
+#define DW_AT_entry_pc 0x52
+#define DW_AT_use_UTF8 0x53
+#define DW_AT_extension 0x54
+#define DW_AT_ranges 0x55
+#define DW_AT_trampoline 0x56
+#define DW_AT_call_column 0x57
+#define DW_AT_call_file 0x58
+#define DW_AT_call_line 0x59
+#define DW_AT_description 0x5a
+#define DW_AT_binary_scale 0x5b
+#define DW_AT_decimal_scale 0x5c
+#define DW_AT_small 0x5d
+#define DW_AT_decimal_sign 0x5e
+#define DW_AT_digit_count 0x5f
+#define DW_AT_picture_string 0x60
+#define DW_AT_mutable 0x61
+#define DW_AT_threads_scaled 0x62
+#define DW_AT_explicit 0x63
+#define DW_AT_object_pointer 0x64
+#define DW_AT_endianity 0x65
+#define DW_AT_elemental 0x66
+#define DW_AT_pure 0x67
+#define DW_AT_recursive 0x68
+#define DW_AT_signature 0x69
+#define DW_AT_main_subprogram 0x6a
+#define DW_AT_data_bit_offset 0x6b
+#define DW_AT_const_expr 0x6c
+#define DW_AT_enum_class 0x6d
+#define DW_AT_linkage_name 0x6e
+#define DW_AT_lo_user 0x2000
+#define DW_AT_hi_user 0x3fff
+
+/* SGI/MIPS extensions. */
+#define DW_AT_MIPS_fde 0x2001
+#define DW_AT_MIPS_loop_begin 0x2002
+#define DW_AT_MIPS_tail_loop_begin 0x2003
+#define DW_AT_MIPS_epilog_begin 0x2004
+#define DW_AT_MIPS_loop_unroll_factor 0x2005
+#define DW_AT_MIPS_software_pipeline_depth 0x2006
+#define DW_AT_MIPS_linkage_name 0x2007
+#define DW_AT_MIPS_stride 0x2008
+#define DW_AT_MIPS_abstract_name 0x2009
+#define DW_AT_MIPS_clone_origin 0x200a
+#define DW_AT_MIPS_has_inlines 0x200b
+#define DW_AT_MIPS_stride_byte 0x200c
+#define DW_AT_MIPS_stride_elem 0x200d
+#define DW_AT_MIPS_ptr_dopetype 0x200e
+#define DW_AT_MIPS_allocatable_dopetype 0x200f
+#define DW_AT_MIPS_assumed_shape_dopetype 0x2010
+#define DW_AT_MIPS_assumed_size 0x2011
+
+/* GNU extensions. */
+#define DW_AT_sf_names 0x2101
+#define DW_AT_src_info 0x2102
+#define DW_AT_mac_info 0x2103
+#define DW_AT_src_coords 0x2104
+#define DW_AT_body_begin 0x2105
+#define DW_AT_body_end 0x2106
+#define DW_AT_GNU_vector 0x2107
+#define DW_AT_GNU_guarded_by 0x2108
+#define DW_AT_GNU_pt_guarded_by 0x2109
+#define DW_AT_GNU_guarded 0x210a
+#define DW_AT_GNU_pt_guarded 0x210b
+#define DW_AT_GNU_locks_excluded 0x210c
+#define DW_AT_GNU_exclusive_locks_required 0x210d
+#define DW_AT_GNU_shared_locks_required 0x210e
+#define DW_AT_GNU_odr_signature 0x210f
+#define DW_AT_GNU_template_name 0x2110
+#define DW_AT_GNU_call_site_value 0x2111
+#define DW_AT_GNU_call_site_data_value 0x2112
+#define DW_AT_GNU_call_site_target 0x2113
+#define DW_AT_GNU_call_site_target_clobbered 0x2114
+#define DW_AT_GNU_tail_call 0x2115
+#define DW_AT_GNU_all_tail_call_sites 0x2116
+#define DW_AT_GNU_all_call_sites 0x2117
+#define DW_AT_GNU_all_source_call_sites 0x2118
+
+/* Apple extensions. */
+#define DW_AT_APPLE_optimized 0x3fe1
+#define DW_AT_APPLE_flags 0x3fe2
+#define DW_AT_APPLE_isa 0x3fe3
+#define DW_AT_APPLE_block 0x3fe4
+#define DW_AT_APPLE_major_runtime_vers 0x3fe5
+#define DW_AT_APPLE_runtime_class 0x3fe6
+#define DW_AT_APPLE_omit_frame_ptr 0x3fe7
+#define DW_AT_APPLE_property_name 0x3fe8
+#define DW_AT_APPLE_property_getter 0x3fe9
+#define DW_AT_APPLE_property_setter 0x3fea
+#define DW_AT_APPLE_property_attribute 0x3feb
+#define DW_AT_APPLE_objc_complete_type 0x3fec
+#define DW_AT_APPLE_property 0x3fed
+
+#define DW_FORM_addr 0x01
+#define DW_FORM_block2 0x03
+#define DW_FORM_block4 0x04
+#define DW_FORM_data2 0x05
+#define DW_FORM_data4 0x06
+#define DW_FORM_data8 0x07
+#define DW_FORM_string 0x08
+#define DW_FORM_block 0x09
+#define DW_FORM_block1 0x0a
+#define DW_FORM_data1 0x0b
+#define DW_FORM_flag 0x0c
+#define DW_FORM_sdata 0x0d
+#define DW_FORM_strp 0x0e
+#define DW_FORM_udata 0x0f
+#define DW_FORM_ref_addr 0x10
+#define DW_FORM_ref1 0x11
+#define DW_FORM_ref2 0x12
+#define DW_FORM_ref4 0x13
+#define DW_FORM_ref8 0x14
+#define DW_FORM_ref_udata 0x15
+#define DW_FORM_indirect 0x16
+#define DW_FORM_sec_offset 0x17
+#define DW_FORM_exprloc 0x18
+#define DW_FORM_flag_present 0x19
+#define DW_FORM_ref_sig8 0x20
+#define DW_FORM_GNU_ref_alt 0x1f20
+#define DW_FORM_GNU_strp_alt 0x1f21
+
+#define DW_OP_addr 0x03
+#define DW_OP_deref 0x06
+#define DW_OP_const1u 0x08
+#define DW_OP_const1s 0x09
+#define DW_OP_const2u 0x0a
+#define DW_OP_const2s 0x0b
+#define DW_OP_const4u 0x0c
+#define DW_OP_const4s 0x0d
+#define DW_OP_const8u 0x0e
+#define DW_OP_const8s 0x0f
+#define DW_OP_constu 0x10
+#define DW_OP_consts 0x11
+#define DW_OP_dup 0x12
+#define DW_OP_drop 0x13
+#define DW_OP_over 0x14
+#define DW_OP_pick 0x15
+#define DW_OP_swap 0x16
+#define DW_OP_rot 0x17
+#define DW_OP_xderef 0x18
+#define DW_OP_abs 0x19
+#define DW_OP_and 0x1a
+#define DW_OP_div 0x1b
+#define DW_OP_minus 0x1c
+#define DW_OP_mod 0x1d
+#define DW_OP_mul 0x1e
+#define DW_OP_neg 0x1f
+#define DW_OP_not 0x20
+#define DW_OP_or 0x21
+#define DW_OP_plus 0x22
+#define DW_OP_plus_uconst 0x23
+#define DW_OP_shl 0x24
+#define DW_OP_shr 0x25
+#define DW_OP_shra 0x26
+#define DW_OP_xor 0x27
+#define DW_OP_bra 0x28
+#define DW_OP_eq 0x29
+#define DW_OP_ge 0x2a
+#define DW_OP_gt 0x2b
+#define DW_OP_le 0x2c
+#define DW_OP_lt 0x2d
+#define DW_OP_ne 0x2e
+#define DW_OP_skip 0x2f
+#define DW_OP_lit0 0x30
+#define DW_OP_lit1 0x31
+#define DW_OP_lit2 0x32
+#define DW_OP_lit3 0x33
+#define DW_OP_lit4 0x34
+#define DW_OP_lit5 0x35
+#define DW_OP_lit6 0x36
+#define DW_OP_lit7 0x37
+#define DW_OP_lit8 0x38
+#define DW_OP_lit9 0x39
+#define DW_OP_lit10 0x3a
+#define DW_OP_lit11 0x3b
+#define DW_OP_lit12 0x3c
+#define DW_OP_lit13 0x3d
+#define DW_OP_lit14 0x3e
+#define DW_OP_lit15 0x3f
+#define DW_OP_lit16 0x40
+#define DW_OP_lit17 0x41
+#define DW_OP_lit18 0x42
+#define DW_OP_lit19 0x43
+#define DW_OP_lit20 0x44
+#define DW_OP_lit21 0x45
+#define DW_OP_lit22 0x46
+#define DW_OP_lit23 0x47
+#define DW_OP_lit24 0x48
+#define DW_OP_lit25 0x49
+#define DW_OP_lit26 0x4a
+#define DW_OP_lit27 0x4b
+#define DW_OP_lit28 0x4c
+#define DW_OP_lit29 0x4d
+#define DW_OP_lit30 0x4e
+#define DW_OP_lit31 0x4f
+#define DW_OP_reg0 0x50
+#define DW_OP_reg1 0x51
+#define DW_OP_reg2 0x52
+#define DW_OP_reg3 0x53
+#define DW_OP_reg4 0x54
+#define DW_OP_reg5 0x55
+#define DW_OP_reg6 0x56
+#define DW_OP_reg7 0x57
+#define DW_OP_reg8 0x58
+#define DW_OP_reg9 0x59
+#define DW_OP_reg10 0x5a
+#define DW_OP_reg11 0x5b
+#define DW_OP_reg12 0x5c
+#define DW_OP_reg13 0x5d
+#define DW_OP_reg14 0x5e
+#define DW_OP_reg15 0x5f
+#define DW_OP_reg16 0x60
+#define DW_OP_reg17 0x61
+#define DW_OP_reg18 0x62
+#define DW_OP_reg19 0x63
+#define DW_OP_reg20 0x64
+#define DW_OP_reg21 0x65
+#define DW_OP_reg22 0x66
+#define DW_OP_reg23 0x67
+#define DW_OP_reg24 0x68
+#define DW_OP_reg25 0x69
+#define DW_OP_reg26 0x6a
+#define DW_OP_reg27 0x6b
+#define DW_OP_reg28 0x6c
+#define DW_OP_reg29 0x6d
+#define DW_OP_reg30 0x6e
+#define DW_OP_reg31 0x6f
+#define DW_OP_breg0 0x70
+#define DW_OP_breg1 0x71
+#define DW_OP_breg2 0x72
+#define DW_OP_breg3 0x73
+#define DW_OP_breg4 0x74
+#define DW_OP_breg5 0x75
+#define DW_OP_breg6 0x76
+#define DW_OP_breg7 0x77
+#define DW_OP_breg8 0x78
+#define DW_OP_breg9 0x79
+#define DW_OP_breg10 0x7a
+#define DW_OP_breg11 0x7b
+#define DW_OP_breg12 0x7c
+#define DW_OP_breg13 0x7d
+#define DW_OP_breg14 0x7e
+#define DW_OP_breg15 0x7f
+#define DW_OP_breg16 0x80
+#define DW_OP_breg17 0x81
+#define DW_OP_breg18 0x82
+#define DW_OP_breg19 0x83
+#define DW_OP_breg20 0x84
+#define DW_OP_breg21 0x85
+#define DW_OP_breg22 0x86
+#define DW_OP_breg23 0x87
+#define DW_OP_breg24 0x88
+#define DW_OP_breg25 0x89
+#define DW_OP_breg26 0x8a
+#define DW_OP_breg27 0x8b
+#define DW_OP_breg28 0x8c
+#define DW_OP_breg29 0x8d
+#define DW_OP_breg30 0x8e
+#define DW_OP_breg31 0x8f
+#define DW_OP_regx 0x90
+#define DW_OP_fbreg 0x91
+#define DW_OP_bregx 0x92
+#define DW_OP_piece 0x93
+#define DW_OP_deref_size 0x94
+#define DW_OP_xderef_size 0x95
+#define DW_OP_nop 0x96
+#define DW_OP_push_object_address 0x97
+#define DW_OP_call2 0x98
+#define DW_OP_call4 0x99
+#define DW_OP_call_ref 0x9a
+#define DW_OP_form_tls_address 0x9b
+#define DW_OP_call_frame_cfa 0x9c
+#define DW_OP_bit_piece 0x9d
+#define DW_OP_implicit_value 0x9e
+#define DW_OP_stack_value 0x9f
+#define DW_OP_lo_user 0xe0
+#define DW_OP_hi_user 0xff
+
+/* GNU extensions. */
+#define DW_OP_GNU_push_tls_address 0xe0
+#define DW_OP_GNU_uninit 0xf0
+#define DW_OP_GNU_encoded_addr 0xf1
+#define DW_OP_GNU_implicit_pointer 0xf2
+#define DW_OP_GNU_entry_value 0xf3
+#define DW_OP_GNU_const_type 0xf4
+#define DW_OP_GNU_regval_type 0xf5
+#define DW_OP_GNU_deref_type 0xf6
+#define DW_OP_GNU_convert 0xf7
+#define DW_OP_GNU_reinterpret 0xf9
+#define DW_OP_GNU_parameter_ref 0xfa
+#define DW_OP_GNU_addr_index 0xfb
+#define DW_OP_GNU_const_index 0xfc
+
+#define DW_ATE_address 0x1
+#define DW_ATE_boolean 0x2
+#define DW_ATE_complex_float 0x3
+#define DW_ATE_float 0x4
+#define DW_ATE_signed 0x5
+#define DW_ATE_signed_char 0x6
+#define DW_ATE_unsigned 0x7
+#define DW_ATE_unsigned_char 0x8
+#define DW_ATE_imaginary_float 0x9
+#define DW_ATE_packed_decimal 0xa
+#define DW_ATE_numeric_string 0xb
+#define DW_ATE_edited 0xc
+#define DW_ATE_signed_fixed 0xd
+#define DW_ATE_unsigned_fixed 0xe
+#define DW_ATE_decimal_float 0xf
+#define DW_ATE_lo_user 0x80
+#define DW_ATE_hi_user 0xff
+
+#define DW_ACCESS_public 0x01
+#define DW_ACCESS_protected 0x02
+#define DW_ACCESS_private 0x03
+
+#define DW_END_default 0x00
+#define DW_END_big 0x01
+#define DW_END_little 0x02
+#define DW_END_lo_user 0x40
+#define DW_END_high_user 0xff
+
+#define DW_VIS_local 0x01
+#define DW_VIS_exported 0x02
+#define DW_VIS_qualified 0x03
+
+#define DW_VIRTUALITY_none 0x00
+#define DW_VIRTUALITY_virtual 0x01
+#define DW_VIRTUALITY_pure_virtual 0x02
+
+#define DW_LANG_C89 0x0001
+#define DW_LANG_C 0x0002
+#define DW_LANG_Ada83 0x0003
+#define DW_LANG_C_plus_plus 0x0004
+#define DW_LANG_Cobol74 0x0005
+#define DW_LANG_Cobol85 0x0006
+#define DW_LANG_Fortran77 0x0007
+#define DW_LANG_Fortran90 0x0008
+#define DW_LANG_Pascal83 0x0009
+#define DW_LANG_Modula2 0x000a
+#define DW_LANG_Java 0x000b
+#define DW_LANG_C99 0x000c
+#define DW_LANG_Ada95 0x000d
+#define DW_LANG_Fortran95 0x000e
+#define DW_LANG_PLI 0x000f
+#define DW_LANG_ObjC 0x0010
+#define DW_LANG_ObjC_plus_plus 0x0011
+#define DW_LANG_UPC 0x0012
+#define DW_LANG_D 0x0013
+#define DW_LANG_lo_user 0x8000
+#define DW_LANG_Mips_Assembler 0x8001
+#define DW_LANG_hi_user 0xffff
+
+#define DW_ID_case_sensitive 0x00
+#define DW_ID_up_case 0x01
+#define DW_ID_down_case 0x02
+#define DW_ID_case_insensitive 0x03
+
+#define DW_CC_normal 0x01
+#define DW_CC_program 0x02
+#define DW_CC_nocall 0x03
+#define DW_CC_lo_user 0x40
+#define DW_CC_hi_user 0xff
+
+#define DW_INL_not_inlined 0x00
+#define DW_INL_inlined 0x01
+#define DW_INL_declared_not_inlined 0x02
+#define DW_INL_declared_inlined 0x03
+
+#define DW_ORD_row_major 0x00
+#define DW_ORD_col_major 0x01
+
+#define DW_DS_unsigned 0x01
+#define DW_DS_leading_overpunch 0x02
+#define DW_DS_trailing_overpunch 0x03
+#define DW_DS_leading_separate 0x04
+#define DW_DS_trailing_separate 0x05
+
+#define DW_DSC_label 0x00
+#define DW_DSC_range 0x01
+
+#define DW_LNS_copy 0x01
+#define DW_LNS_advance_pc 0x02
+#define DW_LNS_advance_line 0x03
+#define DW_LNS_set_file 0x04
+#define DW_LNS_set_column 0x05
+#define DW_LNS_negate_stmt 0x06
+#define DW_LNS_set_basic_block 0x07
+#define DW_LNS_const_add_pc 0x08
+#define DW_LNS_fixed_advance_pc 0x09
+#define DW_LNS_set_prologue_end 0x0a
+#define DW_LNS_set_epilogue_begin 0x0b
+#define DW_LNS_set_isa 0x0c
+
+#define DW_LNE_end_sequence 0x01
+#define DW_LNE_set_address 0x02
+#define DW_LNE_define_file 0x03
+#define DW_LNE_lo_user 0x80
+#define DW_LNE_hi_user 0xff
+
+#define DW_MACINFO_define 0x01
+#define DW_MACINFO_undef 0x02
+#define DW_MACINFO_start_file 0x03
+#define DW_MACINFO_end_file 0x04
+#define DW_MACINFO_vendor_ext 0xff
+
+#define DW_CFA_advance_loc 0x40
+#define DW_CFA_offset 0x80
+#define DW_CFA_restore 0xc0
+#define DW_CFA_extended 0
+
+#define DW_CFA_nop 0x00
+#define DW_CFA_set_loc 0x01
+#define DW_CFA_advance_loc1 0x02
+#define DW_CFA_advance_loc2 0x03
+#define DW_CFA_advance_loc4 0x04
+#define DW_CFA_offset_extended 0x05
+#define DW_CFA_restore_extended 0x06
+#define DW_CFA_undefined 0x07
+#define DW_CFA_same_value 0x08
+#define DW_CFA_register 0x09
+#define DW_CFA_remember_state 0x0a
+#define DW_CFA_restore_state 0x0b
+#define DW_CFA_def_cfa 0x0c
+#define DW_CFA_def_cfa_register 0x0d
+#define DW_CFA_def_cfa_offset 0x0e
+#define DW_CFA_def_cfa_expression 0x0f
+#define DW_CFA_expression 0x10
+#define DW_CFA_offset_extended_sf 0x11
+#define DW_CFA_def_cfa_sf 0x12
+#define DW_CFA_def_cfa_offset_sf 0x13
+#define DW_CFA_val_offset 0x14
+#define DW_CFA_val_offset_sf 0x15
+#define DW_CFA_val_expression 0x16
+#define DW_CFA_lo_user 0x1c
+#define DW_CFA_high_user 0x3f
+
+/*
+ * LSB(Linux Standard Base) extension to DWARF2.
+ */
+
+#define DW_EH_PE_absptr 0x00
+#define DW_EH_PE_uleb128 0x01
+#define DW_EH_PE_udata2 0x02
+#define DW_EH_PE_udata4 0x03
+#define DW_EH_PE_udata8 0x04
+#define DW_EH_PE_sleb128 0x09
+#define DW_EH_PE_sdata2 0x0a
+#define DW_EH_PE_sdata4 0x0b
+#define DW_EH_PE_sdata8 0x0c
+#define DW_EH_PE_pcrel 0x10
+#define DW_EH_PE_textrel 0x20
+#define DW_EH_PE_datarel 0x30
+#define DW_EH_PE_funcrel 0x40
+#define DW_EH_PE_aligned 0x50
+#define DW_EH_PE_omit 0xff
+
+#endif /* !_DWARF_H_ */
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_abbrev.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_abbrev.c
new file mode 100644
index 0000000..448dc77
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_abbrev.c
@@ -0,0 +1,136 @@
+/*-
+ * Copyright (c) 2009,2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_abbrev.c 2072 2011-10-27 03:26:49Z jkoshy $");
+
+int
+dwarf_get_abbrev(Dwarf_Debug dbg, Dwarf_Unsigned offset,
+ Dwarf_Abbrev *return_abbrev, Dwarf_Unsigned *length,
+ Dwarf_Unsigned *attr_count, Dwarf_Error *error)
+{
+ Dwarf_Abbrev ab;
+ int ret;
+
+ if (dbg == NULL || return_abbrev == NULL || length == NULL ||
+ attr_count == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ ret = _dwarf_abbrev_parse(dbg, NULL, &offset, &ab, error);
+ if (ret != DW_DLE_NONE) {
+ if (ret == DW_DLE_NO_ENTRY) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ } else
+ return (DW_DLV_ERROR);
+ }
+
+ *return_abbrev = ab;
+ *length = ab->ab_length;
+ *attr_count = ab->ab_atnum;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_abbrev_tag(Dwarf_Abbrev abbrev, Dwarf_Half *return_tag,
+ Dwarf_Error *error)
+{
+
+ if (abbrev == NULL || return_tag == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *return_tag = (Dwarf_Half) abbrev->ab_tag;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_abbrev_code(Dwarf_Abbrev abbrev, Dwarf_Unsigned *return_code,
+ Dwarf_Error *error)
+{
+
+ if (abbrev == NULL || return_code == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *return_code = abbrev->ab_entry;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_abbrev_children_flag(Dwarf_Abbrev abbrev, Dwarf_Signed *return_flag,
+ Dwarf_Error *error)
+{
+
+ if (abbrev == NULL || return_flag == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *return_flag = (Dwarf_Signed) abbrev->ab_children;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_abbrev_entry(Dwarf_Abbrev abbrev, Dwarf_Signed ndx,
+ Dwarf_Half *attr_num, Dwarf_Signed *form, Dwarf_Off *offset,
+ Dwarf_Error *error)
+{
+ Dwarf_AttrDef ad;
+ int i;
+
+ if (abbrev == NULL || attr_num == NULL || form == NULL ||
+ offset == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (ndx < 0 || (uint64_t) ndx >= abbrev->ab_atnum) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ ad = STAILQ_FIRST(&abbrev->ab_attrdef);
+ for (i = 0; i < ndx && ad != NULL; i++)
+ ad = STAILQ_NEXT(ad, ad_next);
+
+ assert(ad != NULL);
+
+ *attr_num = ad->ad_attrib;
+ *form = ad->ad_form;
+ *offset = ad->ad_offset;
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_comp_dir.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_comp_dir.3
new file mode 100644
index 0000000..875e13d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_comp_dir.3
@@ -0,0 +1,99 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_comp_dir.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_ADD_AT_COMP_DIR 3
+.Sh NAME
+.Nm dwarf_add_AT_comp_dir
+.Nd create and attach a DW_AT_comp_dir attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_comp_dir
+.Fa "Dwarf_P_Die die"
+.Fa "char *dir"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_AT_comp_dir
+creates a
+.Dv DW_AT_comp_dir
+attribute descriptor and attaches it to the debugging information
+entry referenced by argument
+.Ar die .
+The created attribute will have DWARF form
+.Dv DW_FORM_strp .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Argument
+.Ar dir
+should point to a NUL-terminated string which will become the value of
+the created attribute.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_AT_comp_dir
+returns the created attribute descriptor.
+In case of an error, function
+.Fn dwarf_add_AT_comp_dir
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_AT_comp_dir
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar die
+or
+.Ar dir
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_const_value_string 3 ,
+.Xr dwarf_add_AT_name 3 ,
+.Xr dwarf_add_AT_producer 3 ,
+.Xr dwarf_add_AT_string 3 ,
+.Xr dwarf_new_die 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_const_value_string.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_const_value_string.3
new file mode 100644
index 0000000..d617748
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_const_value_string.3
@@ -0,0 +1,126 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_const_value_string.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_ADD_AT_CONST_VALUE_STRING 3
+.Sh NAME
+.Nm dwarf_add_AT_const_value_signedint ,
+.Nm dwarf_add_AT_const_value_string ,
+.Nm dwarf_add_AT_const_value_unsignedint
+.Nd create and attach a DW_AT_const_value attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_const_value_signedint
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Signed value"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_const_value_string
+.Fa "Dwarf_P_Die die"
+.Fa "char *str"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_const_value_unsignedint
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Unsigned value"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions create a
+.Dv DW_AT_const_value
+attribute descriptor and attach it to the debugging information entry
+referenced by argument
+.Ar die .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Function
+.Fn dwarf_add_AT_const_value_signedint
+creates a
+.Dv DW_AT_const_value
+attribute descriptor containing the signed value specified by argument
+.Ar value .
+The created attribute descriptor will have DWARF form
+.Dv DW_FORM_sdata .
+.Pp
+Function
+.Fn dwarf_add_AT_const_value_unsignedint
+creates a
+.Dv DW_AT_const_value
+attribute descriptor containing the unsigned value specified by
+argument
+.Ar value .
+The created attribute descriptor will have DWARF form
+.Dv DW_FORM_udata .
+.Pp
+Function
+.Fn dwarf_add_AT_const_value_string
+creates a
+.Dv DW_AT_const_value
+attribute descriptor containing the string pointed to by the
+NUL-terminated argument
+.Ar str .
+The created attribute descriptor will have DWARF form
+.Dv DW_FORM_strp .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used by these functions to store error
+information in case of an error.
+.Sh RETURN VALUES
+On success, these functions return the created attribute descriptor.
+In case of an error, these functions return
+.Dv DW_DLV_BADADDR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar die
+or
+.Ar str
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during execution.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_name 3 ,
+.Xr dwarf_add_AT_signed_const 3 ,
+.Xr dwarf_add_AT_string 3 ,
+.Xr dwarf_add_AT_unsigned_const 3 ,
+.Xr dwarf_new_die 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_dataref.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_dataref.3
new file mode 100644
index 0000000..29a09e0
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_dataref.3
@@ -0,0 +1,122 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_dataref.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_ADD_AT_DATAREF 3
+.Sh NAME
+.Nm dwarf_add_AT_dataref
+.Nd create an attribute descriptor for a relocatable address
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_P_Attribute"
+.Fo dwarf_add_AT_dataref
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Unsigned pc_value"
+.Fa "Dwarf_Unsigned sym_index"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_AT_dataref
+creates an attribute descriptor for a relocatable address and attaches
+it to the debugging information entry referenced by argument
+.Ar die .
+.Pp
+If flag
+.Dv DW_DLC_SIZE_64
+is set, the address value will be 8 bytes in size and of the DWARF form
+.Dv DW_FORM_data8 .
+Otherwise, the address value will be 4 bytes in size and of the DWARF form
+.Dv DW_FORM_data4 .
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Argument
+.Ar attr
+specifies the attribute code of the created attribute descriptor.
+.Pp
+Argument
+.Ar pc_value
+specifies the value of the relocatable address.
+.Pp
+Argument
+.Ar sym_index
+specifies the ELF symbol index of the symbol to be used for
+relocation.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_AT_dataref
+returns the created attribute descriptor.
+In case of an error, function
+.Fn dwarf_add_AT_dataref
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_AT_dataref
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar dbg
+or
+.Ar die
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_reference 3 ,
+.Xr dwarf_add_AT_ref_address 3 ,
+.Xr dwarf_add_AT_signed_const 3 ,
+.Xr dwarf_add_AT_unsigned_const 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_flag.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_flag.3
new file mode 100644
index 0000000..19b345e
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_flag.3
@@ -0,0 +1,115 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_flag.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_ADD_AT_FLAG 3
+.Sh NAME
+.Nm dwarf_add_AT_flag
+.Nd create and attach a flag attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_flag
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Small flag"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_AT_flag
+creates an attribute descriptor belonging to the
+.Sq flag
+class, and attaches it to the debugging information entry referenced
+by argument
+.Ar die .
+The created attribute descriptor will have DWARF form
+.Dv DW_FORM_flag .
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Argument
+.Ar attr
+should specify the attribute code for the new attribute descriptor.
+.Pp
+Argument
+.Ar flag
+should specify the value of the new attribute descriptor.
+A zero value is treated as
+.Sq false
+and a non-zero value as
+.Sq true .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_AT_flag
+returns the created attribute descriptor.
+In case of an error, function
+.Fn dwarf_add_AT_flag
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_AT_flag
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar dbg
+or
+.Ar die
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_signed_const 3 ,
+.Xr dwarf_add_AT_unsigned_const 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_location_expr.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_location_expr.3
new file mode 100644
index 0000000..3c93273
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_location_expr.3
@@ -0,0 +1,120 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_location_expr.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 5, 2011
+.Os
+.Dt DWARF_ADD_AT_LOCATION_EXPR 3
+.Sh NAME
+.Nm dwarf_add_AT_location_expr
+.Nd create an attribute descriptor for a location expression
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_P_Attribute"
+.Fo dwarf_add_AT_location_expr
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_P_Expr loc_expr"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_AT_location_expr
+creates an attribute descriptor for a location expression and attaches
+it to the debugging information entry referenced by argument
+.Ar die .
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Argument
+.Ar attr
+specifies the attribute code of the created attribute descriptor.
+.Pp
+Argument
+.Ar loc_expr
+should reference a location expression descriptor allocated using
+.Xr dwarf_new_expr 3 .
+.Pp
+The attribute created by function
+.Fn dwarf_add_AT_location_expr
+will have one of the DWARF forms
+.Dv DW_FORM_block ,
+.Dv DW_FORM_block1 ,
+.Dv DW_FORM_block2
+or
+.Dv DW_FORM_block4 ,
+depending on the size of the byte stream generated by the location
+expression descriptor referenced by argument
+.Ar loc_expr .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used by to store error information in case of
+an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_AT_location_expr
+returns the created attribute descriptor.
+In case of an error, function
+.Fn dwarf_add_AT_location_expr
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_AT_location_expr
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar die
+or
+.Ar loc_expr
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_new_expr 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_name.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_name.3
new file mode 100644
index 0000000..d5ee761
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_name.3
@@ -0,0 +1,99 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_name.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_ADD_AT_NAME 3
+.Sh NAME
+.Nm dwarf_add_AT_name
+.Nd create and attach a DW_AT_name attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_name
+.Fa "Dwarf_P_Die die"
+.Fa "char *name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_AT_name
+creates a
+.Dv DW_AT_name
+attribute descriptor and attaches it to the debugging information
+entry referenced by argument
+.Ar die .
+The created attribute will have DWARF form
+.Dv DW_FORM_strp .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Argument
+.Ar name
+should point to a NUL-terminated string which will become the value of
+the created attribute.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_AT_name
+returns the created attribute descriptor.
+In case of an error, function
+.Fn dwarf_add_AT_name
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_AT_name
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar die
+or
+.Ar name
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+this function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_comp_dir 3 ,
+.Xr dwarf_add_AT_const_value_string 3 ,
+.Xr dwarf_add_AT_producer 3 ,
+.Xr dwarf_add_AT_string 3 ,
+.Xr dwarf_new_die 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_producer.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_producer.3
new file mode 100644
index 0000000..ae0b088
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_producer.3
@@ -0,0 +1,99 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_producer.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_ADD_AT_PRODUCER 3
+.Sh NAME
+.Nm dwarf_add_AT_producer
+.Nd create and attach a DW_AT_producer attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_producer
+.Fa "Dwarf_P_Die die"
+.Fa "char *producer"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_AT_producer
+creates a
+.Dv DW_AT_producer
+attribute descriptor and attaches it to the debugging information
+entry referenced by argument
+.Ar die .
+The created attribute will have DWARF form
+.Dv DW_FORM_strp .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Argument
+.Ar producer
+should point to a NUL-terminated string which will become the value of
+the created attribute.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_AT_producer
+returns the created attribute descriptor.
+In case of an error, function
+.Fn dwarf_add_AT_producer
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_AT_producer
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar die
+or
+.Ar producer
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+the function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_comp_dir 3 ,
+.Xr dwarf_add_AT_const_value_string 3 ,
+.Xr dwarf_add_AT_name 3 ,
+.Xr dwarf_add_AT_string 3 ,
+.Xr dwarf_new_die 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_ref_address.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_ref_address.3
new file mode 100644
index 0000000..8b2efc8
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_ref_address.3
@@ -0,0 +1,117 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_ref_address.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 7, 2011
+.Os
+.Dt DWARF_ADD_AT_REF_ADDRESS 3
+.Sh NAME
+.Nm dwarf_add_AT_ref_address
+.Nd create a reference class attribute descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_P_Attribute"
+.Fo dwarf_add_AT_ref_address
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Unsigned pc_value"
+.Fa "Dwarf_Unsigned sym_index"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_AT_ref_address
+creates a
+.Sq reference
+class attribute descriptor containing a relocatable address value.
+The created attribute will use DWARF form
+.Dv DW_FORM_ref_addr .
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Argument
+.Ar attr
+specifies the attribute code of the created attribute.
+.Pp
+Argument
+.Ar pc_value
+contains a relocatable address which will become the value of the
+created attribute.
+.Pp
+Argument
+.Ar sym_index
+should specify the ELF symbol index of the symbol to be used when
+relocating the address value.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_AT_ref_address
+returns the created attribute descriptor.
+In case of an error, function
+.Fn dwarf_add_AT_ref_address
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_AT_ref_address
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar dbg
+or
+.Ar die
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during execution.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_dataref 3 ,
+.Xr dwarf_add_AT_reference 3 ,
+.Xr dwarf_add_AT_signed_const 3 ,
+.Xr dwarf_add_AT_unsigned_const 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_reference.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_reference.3
new file mode 100644
index 0000000..4f6d51a
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_reference.3
@@ -0,0 +1,117 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_reference.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_ADD_AT_REFERENCE 3
+.Sh NAME
+.Nm dwarf_add_AT_reference
+.Nd create and attach an attribute that references another DIE
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_P_Attribute"
+.Fo dwarf_add_AT_reference
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_P_Die ref_die"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_AT_reference
+creates an attribute descriptor that references another debugging
+information entry in the same compilation unit.
+The attribute will be of DWARF form
+.Dv DW_FORM_ref4
+or
+.Dv DW_FORM_ref8
+depending on the target address size, and will contain the
+section-relative offset of the referenced debugging information entry
+as its value.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Argument
+.Ar attr
+should specify the attribute code of the created attribute descriptor.
+.Pp
+Argument
+.Ar ref_die
+should hold the debugging information entry descriptor that
+the attribute should refer to.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_AT_reference
+returns the created attribute descriptor.
+In case of an error, function
+.Fn dwarf_add_AT_reference
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_AT_reference
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar die
+or
+.Ar ref_die
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+the function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_dataref 3 ,
+.Xr dwarf_add_AT_ref_address 3 ,
+.Xr dwarf_add_AT_signed_const 3 ,
+.Xr dwarf_add_AT_unsigned_const 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_signed_const.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_signed_const.3
new file mode 100644
index 0000000..df7900d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_signed_const.3
@@ -0,0 +1,131 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_signed_const.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_ADD_AT_SIGNED_CONST 3
+.Sh NAME
+.Nm dwarf_add_AT_signed_const ,
+.Nm dwarf_add_AT_unsigned_const
+.Nd create and attach constant class attributes
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_signed_const
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Signed value"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_unsigned_const
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Unsigned value"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions create attribute descriptors belonging to the
+.Sq constant
+class
+and attach them to the debugging information entry referenced by
+argument
+.Ar die .
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Argument
+.Ar attr
+specifies the attribute code of the created attribute descriptor.
+.Pp
+Function
+.Fn dwarf_add_AT_signed_const
+creates an attribute descriptor with the signed value specified in
+argument
+.Ar value .
+.Pp
+Function
+.Fn dwarf_add_AT_unsigned_const
+creates an attribute descriptor with the unsigned value specified in
+argument
+.Ar value .
+.Pp
+The attribute created by these function will have one of the
+DWARF forms
+.Dv DW_FORM_data1 ,
+.Dv DW_FORM_data2 ,
+.Dv DW_FORM_data4
+or
+.Dv DW_FORM_data8 ,
+depending on the size of the value specified in argument
+.Ar value .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used by these functions to store error
+information in case of an error.
+.Sh RETURN VALUES
+On success, these functions return the created attribute descriptor.
+In case of an error, these functions return
+.Dv DW_DLV_BADADDR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar dbg
+or
+.Ar die
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during execution.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_const_value_signedint 3 ,
+.Xr dwarf_add_AT_const_value_unsignedint 3 ,
+.Xr dwarf_add_AT_dataref 3 ,
+.Xr dwarf_add_AT_ref_address 3 ,
+.Xr dwarf_add_AT_targ_address_b 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_string.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_string.3
new file mode 100644
index 0000000..a05a19d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_string.3
@@ -0,0 +1,114 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_string.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_ADD_AT_STRING 3
+.Sh NAME
+.Nm dwarf_add_AT_string
+.Nd create and attach a string class attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_string
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "char *str"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_AT_string
+creates an attribute descriptor belonging to the
+.Sq string
+class and attaches it to the debugging information entry referenced by
+argument
+.Ar die .
+The created attribute descriptor will have DWARF form
+.Dv DW_FORM_strp .
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Argument
+.Ar attr
+should specify the attribute code for the created attribute
+descriptor.
+.Pp
+Argument
+.Ar str
+should hold a pointer to a NUL-terminated string which will become the
+value of the created attribute descriptor.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_AT_string
+returns the created attribute descriptor.
+In case of an error, function
+.Fn dwarf_add_AT_string
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_AT_string
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar die
+or
+.Ar str
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+the function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_const_value_string 3 ,
+.Xr dwarf_add_AT_name 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_targ_address.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_targ_address.3
new file mode 100644
index 0000000..ce803c8
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_AT_targ_address.3
@@ -0,0 +1,137 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_AT_targ_address.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_ADD_AT_TARG_ADDRESS 3
+.Sh NAME
+.Nm dwarf_add_AT_targ_address ,
+.Nm dwarf_add_AT_targ_address_b
+.Nd create and attach address class attributes
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_targ_address
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Unsigned pc_value"
+.Fa "Dwarf_Signed sym_index"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft Dwarf_P_Attribute
+.Fo dwarf_add_AT_targ_address_b
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Unsigned pc_value"
+.Fa "Dwarf_Unsigned sym_index"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_AT_targ_address_b
+creates an attribute descriptor belonging to the
+.Sq address
+class and attaches it to the debugging information entry referenced by
+argument
+.Ar die .
+.Pp
+The created attribute descriptor will have DWARF form
+.Dv DW_FORM_addr .
+If flag
+.Dv DW_DLC_SIZE_64
+is set on the producer instance, the attribute value will be 8 bytes
+in size.
+Otherwise the attribute value will be 4 bytes in size.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+should reference a debugging information entry allocated using
+.Xr dwarf_new_die 3 .
+.Pp
+Argument
+.Ar attr
+should specify the attribute code of the created attribute descriptor.
+.Pp
+Argument
+.Ar pc_value
+should hold a relocatable address value which will become the value of
+the created attribute descriptor.
+.Pp
+Argument
+.Ar sym_index
+should specify the ELF symbol index of the symbol to be used for
+relocating the address value.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Pp
+Function
+.Fn dwarf_add_AT_targ_address
+is deprecated.
+It is similar to function
+.Fn dwarf_add_AT_targ_address_b
+except that it cannot handle all possible symbol index values.
+.Sh RETURN VALUES
+On success, these functions return the created attribute descriptor.
+In case of an error, these functions return
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+These functions can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar dbg
+or
+.Ar die
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during execution.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_const_value_unsignedint 3 ,
+.Xr dwarf_add_AT_dataref 3 ,
+.Xr dwarf_add_AT_ref_address 3 ,
+.Xr dwarf_add_AT_signed_const 3 ,
+.Xr dwarf_add_AT_unsigned_const 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_arange.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_arange.3
new file mode 100644
index 0000000..90a088a
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_arange.3
@@ -0,0 +1,151 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_arange.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 18, 2011
+.Os
+.Dt DWARF_ADD_ARANGE 3
+.Sh NAME
+.Nm dwarf_add_arange ,
+.Nm dwarf_add_arange_b
+.Nd add address range information to a DWARF producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_arange
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Addr start"
+.Fa "Dwarf_Unsigned length"
+.Fa "Dwarf_Signed symbol_index"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_arange_b
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Addr start"
+.Fa "Dwarf_Unsigned length"
+.Fa "Dwarf_Unsigned symbol_index"
+.Fa "Dwarf_Unsigned end_symbol_index"
+.Fa "Dwarf_Addr offset_from_end_symbol"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_arange_b
+adds an address range entry to a producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar start
+specifies the relocatable start address of the address range.
+.Pp
+Argument
+.Ar length
+specifies the length of the address range.
+.Pp
+Argument
+.Ar symbol_index
+specifies the ELF symbol index of the first symbol to be used for
+relocation.
+.Pp
+Argument
+.Ar end_symbol_index
+specifies the ELF symbol index of the second symbol to be used for
+relocation.
+.Bl -bullet
+.It
+If argument
+.Ar end_symbol_index
+is not 0, the
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+flag should have been set on the DWARF producer instance.
+The address value specified by argument
+.Ar start
+will be treated as an offset value from the first symbol,
+and the argument
+.Ar offset_from_end_symbol
+should hold an offset value from the second symbol.
+Application code can retrieve the relocation entries for the
+symbol pair by calling function
+.Xr dwarf_get_relocation_info 3 .
+The relocation entry for the first symbol will have type
+.Dv dwarf_drt_first_of_length_pair
+and the relocation entry for the second symbol will have type
+.Dv dwarf_drt_second_of_length_pair .
+.It
+If argument
+.Ar end_symbol_index
+is 0, argument
+.Ar offset_from_end_symbol
+will be ignored and only one symbol is used for relocation.
+.El
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Pp
+Function
+.Fn dwarf_add_arange
+is deprecated.
+It is similar to function
+.Fn dwarf_add_arange_b
+except that it cannot handle all possible symbol index values
+and supports only one relocation symbol.
+.Sh RETURN VALUES
+On success, these functions return a non-zero value.
+In case of an error, these functions return 0 and set
+the argument
+.Ar err .
+.Sh ERRORS
+These functions can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar end_symbol_index
+was non-zero, but the flag
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+was not set on the producer instance.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_relocation_info 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_die_to_debug.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_die_to_debug.3
new file mode 100644
index 0000000..5ea4e3f
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_die_to_debug.3
@@ -0,0 +1,95 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_die_to_debug.3 2938 2013-04-27 05:09:17Z jkoshy $
+.\"
+.Dd August 21, 2011
+.Os
+.Dt DWARF_ADD_DIE_TO_DEBUG 3
+.Sh NAME
+.Nm dwarf_add_die_to_debug
+.Nd set the root debugging information entry
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_Unsigned
+.Fo dwarf_add_die_to_debug
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die first_die"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_die_to_debug
+sets the root debugging information entry of a DWARF producer
+instance.
+All debugging information entries linked to the root entry will also
+be added to the producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar first_die
+should hold the debugging information entry which will become
+the root DIE.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_die_to_debug
+returns
+.Dv DW_DLV_OK .
+In case of an error, function
+.Fn dwarf_add_die_to_debug
+returns
+.Dv DW_DLV_NOCOUNT
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_die_to_debug
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar dbg
+or
+.Ar first_die
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_die_link 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_directory_decl.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_directory_decl.3
new file mode 100644
index 0000000..df19707
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_directory_decl.3
@@ -0,0 +1,97 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_directory_decl.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 17, 2011
+.Os
+.Dt DWARF_ADD_DIRECTORY_DECL 3
+.Sh NAME
+.Nm dwarf_add_directory_decl
+.Nd add a directory name to a producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_directory_decl
+.Fa "Dwarf_P_Debug dbg"
+.Fa "char *name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_directory_decl
+adds a source directory name to a producer instance and returns the
+index value generated for the directory name.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar name
+should point a NUL-terminated string containing the name of
+the directory.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_directory_decl
+returns the index value generated for the directory.
+In case of an error, function
+.Fn dwarf_add_directory_decl
+returns
+.Dv DW_DLV_NOCOUNT
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_directory_decl
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar dbg
+or
+.Ar name
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_file_decl 3 ,
+.Xr dwarf_add_line_entry 3 ,
+.Xr dwarf_lne_end_sequence 3 ,
+.Xr dwarf_lne_set_address 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_expr_addr.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_expr_addr.3
new file mode 100644
index 0000000..4a19ee8
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_expr_addr.3
@@ -0,0 +1,111 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_expr_addr.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 9, 2011
+.Os
+.Dt DWARF_ADD_EXPR_ADDR 3
+.Sh NAME
+.Nm dwarf_add_expr_addr ,
+.Nm dwarf_add_expr_addr_b
+.Nd add a DW_OP_addr location expression
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_expr_addr
+.Fa "Dwarf_P_Expr expr"
+.Fa "Dwarf_Unsigned address"
+.Fa "Dwarf_Signed sym_index"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_expr_addr_b
+.Fa "Dwarf_P_Expr expr"
+.Fa "Dwarf_Unsigned address"
+.Fa "Dwarf_Unsigned sym_index"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_expr_addr_b
+adds a
+.Dv DW_OP_addr
+location expression to the location expression descriptor referenced
+by argument
+.Ar expr .
+.Pp
+Argument
+.Ar expr
+should reference a location expression descriptor allocated using
+the function
+.Xr dwarf_new_expr 3 .
+.Pp
+Argument
+.Ar address
+specifies the operand, a relocatable address value.
+.Pp
+Argument
+.Ar sym_index
+specifies the ELF symbol index of the symbol to be used for
+relocation.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Pp
+Function
+.Fn dwarf_add_expr_addr
+is deprecated.
+It is similar to function
+.Fn dwarf_add_expr_addr_b
+except that it cannot handle all possible symbol index values.
+.Sh RETURN VALUES
+On success, these functions return the size in bytes of the location
+expression byte stream generated.
+In case of an error, these functions return
+.Dv DW_DLV_NOCOUNT
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar expr
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+the function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_location_expr 3 ,
+.Xr dwarf_add_expr_gen 3 ,
+.Xr dwarf_expr_current_offset 3 ,
+.Xr dwarf_expr_into_block 3 ,
+.Xr dwarf_new_expr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_expr_gen.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_expr_gen.3
new file mode 100644
index 0000000..71f2977
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_expr_gen.3
@@ -0,0 +1,118 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_expr_gen.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 9, 2011
+.Os
+.Dt DWARF_ADD_EXPR_GEN 3
+.Sh NAME
+.Nm dwarf_add_expr_gen
+.Nd add an operator to a location expression descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_expr_gen
+.Fa "Dwarf_P_Expr expr"
+.Fa "Dwarf_Small opcode"
+.Fa "Dwarf_Unsigned val1"
+.Fa "Dwarf_Unsigned val2"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_expr_gen
+adds a location expression operator to the location expression
+descriptor referenced by argument
+.Ar expr .
+.Pp
+Argument
+.Ar expr
+should reference a location expression descriptor allocated using
+the function
+.Xr dwarf_new_expr 3 .
+.Pp
+Argument
+.Ar opcode
+specifies the operation code of the location expression operator.
+Valid values for this argument are those denoted by the
+.Dv DW_OP_ Ns *
+constants defined in
+.In libdwarf.h .
+.Pp
+To generate a
+.Dv DW_OP_addr
+operation, application code should instead use
+.Xr dwarf_add_expr_addr_b 3 .
+.Pp
+Argument
+.Ar val1
+specifies the first operand of the location expression operator.
+.Pp
+Argument
+.Ar val2
+specifies the second operand of the location expression operator.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_expr_gen
+returns the size in bytes of the location expression byte stream
+generated.
+In case of an error, function
+.Fn dwarf_add_expr_gen
+returns
+.Dv DW_DLV_NOCOUNT
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_expr_gen
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_LOC_EXPR_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar expr
+was NULL.
+.It Bq Er DW_DLE_LOC_EXPR_BAD
+The operation code specified in argument
+.Ar opcode
+was invalid.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+the function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_location_expr 3 ,
+.Xr dwarf_add_expr_addr 3 ,
+.Xr dwarf_add_expr_addr_b 3 ,
+.Xr dwarf_expr_current_offset 3 ,
+.Xr dwarf_expr_into_block 3 ,
+.Xr dwarf_new_expr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_fde_inst.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_fde_inst.3
new file mode 100644
index 0000000..d2d9157
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_fde_inst.3
@@ -0,0 +1,113 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_fde_inst.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 26, 2011
+.Os
+.Dt DWARF_ADD_FDE_INST 3
+.Sh NAME
+.Nm dwarf_add_fde_inst
+.Nd add a call frame instruction to a DWARF frame descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_P_Fde"
+.Fo dwarf_add_fde_inst
+.Fa "Dwarf_P_Fde fde"
+.Fa "Dwarf_Small op"
+.Fa "Dwarf_Unsigned val1"
+.Fa "Dwarf_Unsigned val2"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_fde_inst
+adds a call frame instruction to the DWARF frame descriptor
+referenced by argument
+.Ar fde .
+.Pp
+Argument
+.Ar fde
+should reference a frame descriptor allocated using
+.Xr dwarf_new_fde 3 .
+.Pp
+Argument
+.Ar op
+specifies the operator for the frame instruction.
+The DWARF standard defines the set of legal values for this argument.
+.Pp
+Argument
+.Ar val1
+specifies the first operand of the frame instruction.
+.Pp
+Argument
+.Ar val2
+specifies the second operand of the frame instruction.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_fde_inst
+returns the frame descriptor given in argument
+.Ar fde .
+In case of an error, function
+.Fn dwarf_add_fde_inst
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_fde_inst
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_FRAME_INSTR_EXEC_ERROR"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar fde
+was NULL.
+.It Bq Er DW_DLE_FRAME_INSTR_EXEC_ERROR
+The frame instruction operator specified in argument
+.Ar op
+was invalid.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_frame_fde 3 ,
+.Xr dwarf_add_frame_fde_b 3 ,
+.Xr dwarf_add_frame_cie 3 ,
+.Xr dwarf_fde_cfa_offset 3 ,
+.Xr dwarf_new_fde 3
+.Rs
+.%T "The DWARF Debugging Information Format"
+.%V "Version 4"
+.%O "http://www.dwarfstd.org/"
+.Re
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_file_decl.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_file_decl.3
new file mode 100644
index 0000000..c389484
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_file_decl.3
@@ -0,0 +1,122 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_file_decl.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 17, 2011
+.Os
+.Dt DWARF_ADD_FILE_DECL 3
+.Sh NAME
+.Nm dwarf_add_file_decl
+.Nd add a source file entry to a producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_file_decl
+.Fa "Dwarf_P_Debug dbg"
+.Fa "char *name"
+.Fa "Dwarf_Unsigned dirndx"
+.Fa "Dwarf_Unsigned mtime"
+.Fa "Dwarf_Unsigned size"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_file_decl
+adds a source file entry to a producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar name
+should point to a NUL-terminated string containing the name of
+the source file.
+.Pp
+If the file name in argument
+.Ar name
+is not a fully qualified pathname, argument
+.Ar dirndx
+should specify the index of the directory where the source file resides.
+Otherwise, argument
+.Ar dirndx
+should be 0.
+Valid directory indices are those returned by the function
+.Xr dwarf_add_directory_decl 3 .
+.Pp
+Argument
+.Ar mtime
+specifies the time when the file was last modified.
+.Pp
+Argument
+.Ar size
+specifies the size of the file in bytes.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_file_decl
+returns the index value generated for the source file.
+In case of an error, function
+.Fn dwarf_add_file_decl
+returns
+.Dv DW_DLV_NOCOUNT
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_file_decl
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either arguments
+.Ar dbg
+or
+.Ar name
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+The length of the NUL-teminated string pointed to by argument
+.Ar name
+was 0.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_directory_decl 3 ,
+.Xr dwarf_add_line_entry 3 ,
+.Xr dwarf_lne_end_sequence 3 ,
+.Xr dwarf_lne_set_address 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_frame_cie.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_frame_cie.3
new file mode 100644
index 0000000..1bc6db5
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_frame_cie.3
@@ -0,0 +1,124 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_frame_cie.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 26, 2011
+.Os
+.Dt DWARF_ADD_FRAME_CIE 3
+.Sh NAME
+.Nm dwarf_add_frame_cie
+.Nd add a call frame common information entry to a DWARF producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_frame_cie
+.Fa "Dwarf_P_Debug dbg"
+.Fa "char *augmenter"
+.Fa "Dwarf_Small caf"
+.Fa "Dwarf_Small daf"
+.Fa "Dwarf_Small ra"
+.Fa "Dwarf_Ptr initinst"
+.Fa "Dwarf_Unsigned initlen"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_frame_cie
+adds a DWARF call frame common information entry (CIE) to a producer
+instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar augmenter
+should point to a NUL-terminated augmentation string for the common
+information entry.
+.Pp
+Argument
+.Ar caf
+specifies the code alignment factor.
+.Pp
+Argument
+.Ar daf
+specifies the data alignment factor.
+.Pp
+Argument
+.Ar ra
+specifies the column number used for the return address register.
+.Pp
+Argument
+.Ar initinst
+should point to a byte stream containing the initial instructions
+for the common information entry.
+.Pp
+Argument
+.Ar initlen
+should hold the length in bytes of the byte stream pointed to by
+argument
+.Ar initinst .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_frame_cie
+returns the index value of the created common information entry.
+In case of an error, function
+.Fn dwarf_add_frame_cie
+returns
+.Dv DW_DLV_NOCOUNT
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_frame_cie
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_fde_inst 3 ,
+.Xr dwarf_add_frame_fde 3 ,
+.Xr dwarf_add_frame_fde_b 3 ,
+.Xr dwarf_fde_cfa_offset 3 ,
+.Xr dwarf_new_fde 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_frame_fde.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_frame_fde.3
new file mode 100644
index 0000000..3c1ee11
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_frame_fde.3
@@ -0,0 +1,201 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_frame_fde.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 26, 2011
+.Os
+.Dt DWARF_ADD_FRAME_FDE 3
+.Sh NAME
+.Nm dwarf_add_frame_fde
+.Nd add a call frame descriptor to a DWARF producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_frame_fde
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Fde fde"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Unsigned cie"
+.Fa "Dwarf_Addr virt_addr"
+.Fa "Dwarf_Unsigned code_len"
+.Fa "Dwarf_Unsigned symbol_index"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_frame_fde_b
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Fde fde"
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_Unsigned cie"
+.Fa "Dwarf_Addr virt_addr"
+.Fa "Dwarf_Unsigned code_len"
+.Fa "Dwarf_Unsigned symbol_index"
+.Fa "Dwarf_Unsigned end_symbol_index"
+.Fa "Dwarf_Addr offset_from_end_sym"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_frame_fde_b
+adds the call frame descriptor referenced by argument
+.Ar fde
+to a producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar fde
+should reference a frame descriptor allocated using
+.Xr dwarf_new_fde 3 .
+.Pp
+Argument
+.Ar die
+is ignored by this implementation of the
+.Lb libdwarf .
+.Pp
+Argument
+.Ar cie
+specifies the index of call frame common information entry for
+the frame descriptor.
+Valid indices are those returned by the function
+.Xr dwarf_add_frame_cie 3 .
+.Pp
+Argument
+.Ar symbol_index
+specifies the ELF symbol index of the first symbol to be used for
+relocation.
+.Pp
+The meaning of the arguments
+.Ar virt_addr ,
+.Ar code_len
+and
+.Ar offset_from_end_sym
+depend on the value of argument
+.Ar end_symbol_index :
+.Bl -bullet
+.It
+If the argument
+.Ar end_symbol_index
+is zero, the argument
+.Ar virt_addr
+specifies the relocatable address of the start of the function
+associated with the frame descriptor, the argument
+.Ar code_len
+specifies the size in bytes of the machine instructions for this
+function, the argument
+.Ar symbol_index
+specifies the ELF symbol to be used for relocating the address in
+argument
+.Ar virt_addr ,
+and the argument
+.Ar offset_from_end_symbol
+is ignored.
+.It
+If the argument
+.Ar end_symbol_index
+is non-zero, it specifies the ELF symbol index of the second symbol to
+be used for relocation.
+In this case, the argument
+.Ar virt_addr
+specifies an offset from the relocatable symbol specified by argument
+.Ar symbol_index ,
+the argument
+.Ar offset_from_end_symbol
+should specify an offset from the symbol named by the argument
+.Ar end_symbol_index ,
+and the argument
+.Ar code_len
+will be ignored.
+The
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+flag should also have been set on the DWARF producer instance.
+.Pp
+Application code can retrieve the relocation entries for the symbol
+pair by calling function
+.Xr dwarf_get_relocation_info 3 .
+The relocation entry for the first symbol will have type
+.Dv dwarf_drt_first_of_length_pair
+and the relocation entry for the second symbol will have type
+.Dv dwarf_drt_second_of_length_pair .
+.El
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Pp
+Function
+.Fn dwarf_add_frame_fde
+is similar to function
+.Fn dwarf_add_frame_fde_b
+except that it supports only one relocation symbol.
+.Sh RETURN VALUES
+On success, these functions return the index value for
+the added frame descriptor.
+In case of an error, these functions return
+.Dv DW_DLV_NOCOUNT
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg
+or
+.Ar fde
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+The frame descriptor referenced by argument
+.Ar fde
+did not belong to the producer instance referenced by argument
+.Ar dbg .
+.It Bq Er DW_DLE_ARGUMENT
+The common information entry index specified by argument
+.Ar cie
+was invalid.
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar end_symbol_index
+was non-zero, but the flag
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+was not set on the producer instance.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_fde_inst 3 ,
+.Xr dwarf_add_frame_cie 3 ,
+.Xr dwarf_fde_cfa_offset 3 ,
+.Xr dwarf_get_relocation_info 3 ,
+.Xr dwarf_new_fde 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_funcname.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_funcname.3
new file mode 100644
index 0000000..ebc358c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_funcname.3
@@ -0,0 +1,103 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_funcname.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 24, 2011
+.Os
+.Dt DWARF_ADD_FUNCNAME 3
+.Sh NAME
+.Nm dwarf_add_funcname
+.Nd add information about a static function to a DWARF producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_funcname
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "char *name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_funcname
+adds information about a static function to a DWARF producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+specifies the debugging information entry associated with the static
+function.
+.Pp
+Argument
+.Ar name
+should point to a NUL-terminated string containing the name
+of the static function.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_funcname
+returns a non-zero value.
+In case of an error, function
+.Fn dwarf_add_funcname
+returns 0 and sets
+the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_funcname
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar die
+or
+.Ar name
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_pubname 3 ,
+.Xr dwarf_add_typename 3 ,
+.Xr dwarf_add_varname 3 ,
+.Xr dwarf_add_weakname 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_line_entry.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_line_entry.3
new file mode 100644
index 0000000..16e8075
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_line_entry.3
@@ -0,0 +1,164 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_line_entry.3 3182 2015-04-10 16:08:10Z emaste $
+.\"
+.Dd June 30, 2013
+.Os
+.Dt DWARF_ADD_LINE_ENTRY 3
+.Sh NAME
+.Nm dwarf_add_line_entry
+.Nd add a line number information entry to a producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_line_entry
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Unsigned filendx"
+.Fa "Dwarf_Addr off"
+.Fa "Dwarf_Unsigned lineno"
+.Fa "Dwarf_Signed column"
+.Fa "Dwarf_Bool is_stmt"
+.Fa "Dwarf_Bool basic_block"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_line_entry
+adds a line number information entry to a DWARF producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar filendx
+specifies the index of the source file that contains the source line
+in question.
+Valid source file indices are those returned by the function
+.Xr dwarf_add_file_decl 3 .
+.Pp
+Argument
+.Ar off
+specifies a relocatable program address.
+The ELF symbol to be used
+for relocation is set by a prior call to the function
+.Xr dwarf_lne_set_address 3 .
+.Pp
+Argument
+.Ar lineno
+specifies the line number of the source line.
+.Pp
+Argument
+.Ar column
+specifies the column number within the source line.
+.Pp
+If the argument
+.Ar is_stmt
+is set to true, it indicates that the instruction at the address
+specified by argument
+.Ar off
+is a recommended breakpoint location, i.e., the first instruction in
+the instruction sequence generated by the source line.
+.Pp
+If the argument
+.Ar basic_block
+is set to true, it indicates that the instruction at the address
+specified by argument
+.Ar off
+is the first instruction of a basic block.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_line_entry
+returns
+.Dv DW_DLV_OK .
+In case of an error, function
+.Fn dwarf_add_line_entry
+returns
+.Dv DW_DLV_NOCOUNT
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_line_entry
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+The function
+.Xr dwarf_lne_set_address 3
+was not called before calling this function.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh EXAMPLE
+To add line number information to the producer instance, use:
+.Bd -literal -offset indent
+Dwarf_P_Debug dbg;
+Dwarf_Error de;
+Dwarf_Unsigned dir, filendx;
+
+/* ... assume dbg refers to a DWARF producer instance ... */
+
+dir = dwarf_add_directory_decl(dbg, "/home/foo", &de);
+if (dir == DW_DLV_NOCOUNT)
+ errx(EXIT_FAILURE, "dwarf_add_directory_decl failed: %s",
+ dwarf_errmsg(-1));
+
+filendx = dwarf_add_file_decl(dbg, "bar.c", dir, 0, 1234, &de);
+if (filendx == DW_DLV_NOCOUNT)
+ errx(EXIT_FAILURE, "dwarf_add_file_decl failed: %s",
+ dwarf_errmsg(-1));
+
+if (dwarf_lne_set_address(dbg, 0x4012b0, 12, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_lne_set_address failed: %s",
+ dwarf_errmsg(-1));
+
+if (dwarf_add_line_entry(dbg, filendx, 10, 258, 0, 1, 1, &de) !=
+ DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_add_line_entry failed: %s",
+ dwarf_errmsg(-1));
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_directory_decl 3 ,
+.Xr dwarf_add_file_decl 3 ,
+.Xr dwarf_lne_end_sequence 3 ,
+.Xr dwarf_lne_set_address 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_pubname.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_pubname.3
new file mode 100644
index 0000000..8839178
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_pubname.3
@@ -0,0 +1,103 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_pubname.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 24, 2011
+.Os
+.Dt DWARF_ADD_PUBNAME 3
+.Sh NAME
+.Nm dwarf_add_pubname
+.Nd add information about a global object to a DWARF producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_pubname
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "char *name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_pubname
+adds information about a global object to a DWARF producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+specifies the debugging information entry associated with the global
+object.
+.Pp
+Argument
+.Ar name
+should point to a NUL-terminated string containing the name
+of the global object.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_pubname
+returns a non-zero value.
+In case of an error, function
+.Fn dwarf_add_pubname
+returns 0 and sets
+the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_pubname
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar die
+or
+.Ar name
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_funcname 3 ,
+.Xr dwarf_add_typename 3 ,
+.Xr dwarf_add_varname 3 ,
+.Xr dwarf_add_weakname 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_typename.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_typename.3
new file mode 100644
index 0000000..22a2b06
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_typename.3
@@ -0,0 +1,103 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_typename.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 24, 2011
+.Os
+.Dt DWARF_ADD_TYPENAME 3
+.Sh NAME
+.Nm dwarf_add_typename
+.Nd add information about a user-defined type to a DWARF producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_typename
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "char *name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_typename
+adds information about a user-defined type to a DWARF producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+specifies the debugging information entry associated with the
+user-defined type.
+.Pp
+Argument
+.Ar name
+should point to a NUL-terminated string containing the name
+of the user-defined type.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_typename
+returns a non-zero value.
+In case of an error, function
+.Fn dwarf_add_typename
+returns 0 and sets
+the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_typename
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar die
+or
+.Ar name
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_funcname 3 ,
+.Xr dwarf_add_pubname 3 ,
+.Xr dwarf_add_varname 3 ,
+.Xr dwarf_add_weakname 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_varname.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_varname.3
new file mode 100644
index 0000000..efcb0d3
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_varname.3
@@ -0,0 +1,103 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_varname.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 24, 2011
+.Os
+.Dt DWARF_ADD_VARNAME 3
+.Sh NAME
+.Nm dwarf_add_varname
+.Nd add information about a static variable to a DWARF producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_varname
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "char *name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_varname
+adds information about a static variable to a DWARF producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+specifies the debugging information entry associated with the static
+variable.
+.Pp
+Argument
+.Ar name
+should point to a NUL-terminated string containing the name
+of the static variable.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_varname
+returns a non-zero value.
+In case of an error, function
+.Fn dwarf_add_varname
+returns 0 and sets
+the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_varname
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar die
+or
+.Ar name
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_funcname 3 ,
+.Xr dwarf_add_pubname 3 ,
+.Xr dwarf_add_typename 3 ,
+.Xr dwarf_add_weakname 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_weakname.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_weakname.3
new file mode 100644
index 0000000..ac1ecbd
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_add_weakname.3
@@ -0,0 +1,103 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_add_weakname.3 2072 2011-10-27 03:26:49Z jkoshy $
+.\"
+.Dd September 24, 2011
+.Os
+.Dt DWARF_ADD_WEAKNAME 3
+.Sh NAME
+.Nm dwarf_add_weakname
+.Nd add information about a weak object to a DWARF producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_add_weakname
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_P_Die die"
+.Fa "char *name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_add_weakname
+adds information about a weak object to a DWARF producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar die
+specifies the debugging information entry associated with the weak
+object.
+.Pp
+Argument
+.Ar name
+should point to a NUL-terminated string containing the name
+of the weak object.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_add_weakname
+returns a non-zero value.
+In case of an error, function
+.Fn dwarf_add_weakname
+returns 0 and sets
+the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_add_weakname
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar die
+or
+.Ar name
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_funcname 3 ,
+.Xr dwarf_add_pubname 3 ,
+.Xr dwarf_add_typename 3 ,
+.Xr dwarf_add_varname 3 ,
+.Xr dwarf_new_die 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_arange.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_arange.c
new file mode 100644
index 0000000..46b42cb
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_arange.c
@@ -0,0 +1,171 @@
+/*-
+ * Copyright (c) 2009,2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_arange.c 2072 2011-10-27 03:26:49Z jkoshy $");
+
+int
+dwarf_get_aranges(Dwarf_Debug dbg, Dwarf_Arange **arlist,
+ Dwarf_Signed *ret_arange_cnt, Dwarf_Error *error)
+{
+
+ if (dbg == NULL || arlist == NULL || ret_arange_cnt == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (dbg->dbg_arange_cnt == 0) {
+ if (_dwarf_arange_init(dbg, error) != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ if (dbg->dbg_arange_cnt == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+ }
+
+ assert(dbg->dbg_arange_array != NULL);
+
+ *arlist = dbg->dbg_arange_array;
+ *ret_arange_cnt = dbg->dbg_arange_cnt;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_arange(Dwarf_Arange *arlist, Dwarf_Unsigned arange_cnt,
+ Dwarf_Addr addr, Dwarf_Arange *ret_arange, Dwarf_Error *error)
+{
+ Dwarf_Arange ar;
+ Dwarf_Debug dbg;
+ int i;
+
+ if (arlist == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ dbg = (*arlist)->ar_as->as_cu->cu_dbg;
+
+ if (ret_arange == NULL || arange_cnt == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ for (i = 0; (Dwarf_Unsigned)i < arange_cnt; i++) {
+ ar = arlist[i];
+ if (addr >= ar->ar_address && addr < ar->ar_address +
+ ar->ar_range) {
+ *ret_arange = ar;
+ return (DW_DLV_OK);
+ }
+ }
+
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+
+ return (DW_DLV_NO_ENTRY);
+}
+
+int
+dwarf_get_cu_die_offset(Dwarf_Arange ar, Dwarf_Off *ret_offset,
+ Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ Dwarf_ArangeSet as;
+
+ if (ar == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ as = ar->ar_as;
+ assert(as != NULL);
+ cu = as->as_cu;
+ assert(cu != NULL);
+
+ if (ret_offset == NULL) {
+ DWARF_SET_ERROR(cu->cu_dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_offset = cu->cu_1st_offset;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_arange_cu_header_offset(Dwarf_Arange ar, Dwarf_Off *ret_offset,
+ Dwarf_Error *error)
+{
+ Dwarf_ArangeSet as;
+
+ if (ar == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ as = ar->ar_as;
+ assert(as != NULL);
+
+ if (ret_offset == NULL) {
+ DWARF_SET_ERROR(as->as_cu->cu_dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_offset = as->as_cu_offset;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_arange_info(Dwarf_Arange ar, Dwarf_Addr *start,
+ Dwarf_Unsigned *length, Dwarf_Off *cu_die_offset, Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ Dwarf_ArangeSet as;
+
+ if (ar == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ as = ar->ar_as;
+ assert(as != NULL);
+ cu = as->as_cu;
+ assert(cu != NULL);
+
+ if (start == NULL || length == NULL ||
+ cu_die_offset == NULL) {
+ DWARF_SET_ERROR(cu->cu_dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *start = ar->ar_address;
+ *length = ar->ar_range;
+ *cu_die_offset = cu->cu_1st_offset;
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_attr.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attr.3
new file mode 100644
index 0000000..9ba367b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attr.3
@@ -0,0 +1,120 @@
+.\" Copyright (c) 2010 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_attr.3 3093 2014-09-02 22:09:40Z kaiwang27 $
+.\"
+.Dd April 8, 2010
+.Os
+.Dt DWARF_ATTR 3
+.Sh NAME
+.Nm dwarf_attr
+.Nd retrieve an attribute descriptor associated with a DWARF debugging information entry
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_attr
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Attribute *atp"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_attr
+retrieves the attribute descriptor for an attribute associated
+with the DWARF debugging information entry descriptor in
+argument
+.Ar die .
+.Pp
+DWARF attribute descriptors are represented by value of the opaque
+type
+.Vt Dwarf_Attribute ,
+see
+.Xr dwarf 3 .
+.Pp
+Argument
+.Ar attr
+names the desired DWARF attribute.
+Legal values for argument
+.Ar attr
+are those denoted by the
+.Dv DW_AT_*
+constants in the DWARF specification.
+.Pp
+Argument
+.Ar atp
+points to a location into which the returned attribute descriptor
+will be written.
+The returned descriptor may then be passed to the form query functions in the
+.Xr dwarf 3
+API set to access the data associated with the attribute.
+.Pp
+If argument
+.Ar err
+is non-NULL, it will be used to return an error descriptor in case
+of an error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_attr
+returns
+.Dv DW_DLV_OK on success.
+.Pp
+If the debugging information entry descriptor denoted by argument
+.Ar die
+does not contain the named attribute, the function returns
+.Dv DW_DLV_NO_ENTRY
+and sets argument
+.Ar err .
+For other errors, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_attr
+can fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar die
+or
+.Ar atp
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+Argument
+.Ar die
+had no attribute corresponding to the value
+in argument
+.Ar attr .
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attrlist 3 ,
+.Xr dwarf_attroffset 3 ,
+.Xr dwarf_hasattr 3 ,
+.Xr dwarf_hasform 3 ,
+.Xr dwarf_whatattr 3 ,
+.Xr dwarf_whatform 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_attr.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attr.c
new file mode 100644
index 0000000..a081d7b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attr.c
@@ -0,0 +1,312 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_attr.c 3064 2014-06-06 19:35:55Z kaiwang27 $");
+
+int
+dwarf_attr(Dwarf_Die die, Dwarf_Half attr, Dwarf_Attribute *atp,
+ Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ Dwarf_Attribute at;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || atp == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((at = _dwarf_attr_find(die, attr)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *atp = at;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_attrlist(Dwarf_Die die, Dwarf_Attribute **attrbuf,
+ Dwarf_Signed *attrcount, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+ int i;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || attrbuf == NULL || attrcount == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (die->die_ab->ab_atnum == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *attrcount = die->die_ab->ab_atnum;
+
+ if (die->die_attrarray != NULL) {
+ *attrbuf = die->die_attrarray;
+ return (DW_DLV_OK);
+ }
+
+ if ((die->die_attrarray = malloc(*attrcount * sizeof(Dwarf_Attribute)))
+ == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_ERROR);
+ }
+
+ for (i = 0, at = STAILQ_FIRST(&die->die_attr);
+ i < *attrcount && at != NULL; i++, at = STAILQ_NEXT(at, at_next))
+ die->die_attrarray[i] = at;
+
+ *attrbuf = die->die_attrarray;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_hasattr(Dwarf_Die die, Dwarf_Half attr, Dwarf_Bool *ret_bool,
+ Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_bool == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_bool = (_dwarf_attr_find(die, attr) != NULL);
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_attroffset(Dwarf_Attribute at, Dwarf_Off *ret_off, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || ret_off == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_off = at->at_offset;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_lowpc(Dwarf_Die die, Dwarf_Addr *ret_lowpc, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_lowpc == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((at = _dwarf_attr_find(die, DW_AT_low_pc)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *ret_lowpc = at->u[0].u64;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_highpc(Dwarf_Die die, Dwarf_Addr *ret_highpc, Dwarf_Error *error)
+{
+
+ return (dwarf_highpc_b(die, ret_highpc, NULL, NULL, error));
+}
+
+int
+dwarf_highpc_b(Dwarf_Die die, Dwarf_Addr *ret_highpc, Dwarf_Half *ret_form,
+ enum Dwarf_Form_Class *ret_class, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+ Dwarf_CU cu;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_highpc == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((at = _dwarf_attr_find(die, DW_AT_high_pc)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *ret_highpc = at->u[0].u64;
+
+ if (ret_form != NULL) {
+ *ret_form = at->at_form;
+ }
+
+ if (ret_class != NULL) {
+ cu = die->die_cu;
+ *ret_class = dwarf_get_form_class(cu->cu_version,
+ DW_AT_high_pc, cu->cu_length_size == 4 ? 4 : 8,
+ at->at_form);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_bytesize(Dwarf_Die die, Dwarf_Unsigned *ret_size, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_size == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((at = _dwarf_attr_find(die, DW_AT_byte_size)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *ret_size = at->u[0].u64;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_bitsize(Dwarf_Die die, Dwarf_Unsigned *ret_size, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_size == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((at = _dwarf_attr_find(die, DW_AT_bit_size)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *ret_size = at->u[0].u64;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_bitoffset(Dwarf_Die die, Dwarf_Unsigned *ret_size, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_size == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((at = _dwarf_attr_find(die, DW_AT_bit_offset)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *ret_size = at->u[0].u64;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_srclang(Dwarf_Die die, Dwarf_Unsigned *ret_lang, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_lang == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((at = _dwarf_attr_find(die, DW_AT_language)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *ret_lang = at->u[0].u64;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_arrayorder(Dwarf_Die die, Dwarf_Unsigned *ret_order, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_order == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((at = _dwarf_attr_find(die, DW_AT_ordering)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *ret_order = at->u[0].u64;
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_attrlist.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attrlist.3
new file mode 100644
index 0000000..0cb918d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attrlist.3
@@ -0,0 +1,146 @@
+.\" Copyright (c) 2010 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_attrlist.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_ATTRLIST 3
+.Sh NAME
+.Nm dwarf_attrlist
+.Nd retrieve DWARF attribute descriptors
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_attrlist
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Attribute **attrbuf"
+.Fa "Dwarf_Signed *attrcount"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_attrlist
+retrieves the DWARF attribute descriptors associated with a
+debugging information entry descriptor in argument
+.Ar die .
+The descriptors are returned as an array of values of the opaque type
+.Vt Dwarf_Attribute .
+The data associated with each returned attribute descriptor may be
+queried using the form query functions in the
+.Xr dwarf 3
+API set.
+.Pp
+Argument
+.Ar attrbuf
+points to a location that will hold a pointer to the returned
+array of DWARF attribute descriptors.
+Argument
+.Ar attrcount
+points to a location that will hold the number of descriptors in
+the returned array.
+.Pp
+If argument
+.Ar err
+is non-NULL, it is used to return an error descriptor in case of an
+error.
+.Ss Memory Management
+In the current implementation, the memory allocated for each DWARF
+attribute descriptor and for the returned array of descriptors is
+managed by the library and the application does not need to explicitly
+free the returned pointers.
+However, for compatibility with other implementations of the
+.Xr dwarf 3
+API, the application is permitted to pass the pointers returned by to
+the
+.Fn dwarf_dealloc
+function.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_attrlist
+returns
+.Dv DW_DLV_OK on success.
+.Pp
+If the debugging information entry descriptor denoted by argument
+.Ar die
+does not contain any attribute, the function returns
+.Dv DW_DLV_NO_ENTRY
+and sets argument
+.Ar err .
+For other errors, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh EXAMPLES
+To retrieve the attribute list for a DWARF debugging information
+entry use:
+.Bd -literal -offset indent
+Dwarf_Die dw_die;
+Dwarf_Error dw_e;
+Dwarf_Unsigned dw_count;
+Dwarf_Attribute *dw_attributes;
+int error, i;
+
+\&... variable dw_die contains a reference to the DIE of interest ...
+
+/* Retrieve the attribute list from the DIE. */
+if ((error = dwarf_attrlist(dw_die, &dw_attributes, &dw_count,
+ &dw_e)) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_attrlist: %s", dwarf_errmsg(dw_e));
+
+/* Process the attribute list. */
+for (i = 0; i < dw_count; ++i) {
+ /* Use the returned pointers in dw_attributes[i] here. */
+}
+.Ed
+.Sh ERRORS
+Function
+.Fn dwarf_diename
+can fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Arguments
+.Ar die ,
+.Ar attrbuf ,
+or
+.Ar attrcount
+were NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+Argument
+.Ar die
+had no attributes.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_dealloc 3 ,
+.Xr dwarf_hasattr 3 ,
+.Xr dwarf_hasform 3 ,
+.Xr dwarf_whatattr 3 ,
+.Xr dwarf_whatform 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_attroffset.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attroffset.3
new file mode 100644
index 0000000..af24ceb
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attroffset.3
@@ -0,0 +1,86 @@
+.\" Copyright (c) 2014 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_attroffset.3 3115 2014-12-20 18:26:46Z jkoshy $
+.\"
+.Dd December 20, 2014
+.Os
+.Dt DWARF_ATTROFFSET 3
+.Sh NAME
+.Nm dwarf_attroffset
+.Nd retrieve the section-relative offset of an attribute descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_attroffset
+.Fa "Dwarf_Attribute at"
+.Fa "Dwarf_Off *ret_off"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_attroffset
+retrieves the section-relative offset of the attribute descriptor
+referenced by argument
+.Ar at .
+.Pp
+Argument
+.Ar ret_off
+should point to a location that is to hold the returned
+section-relative offset.
+If argument
+.Ar err
+is non-NULL, it is used to return an error descriptor in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_attroffset
+returns
+.Dv DW_DLV_OK .
+.Pp
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh COMPATIBILITY
+This function is an extension to the
+.Xr DWARF 3
+API.
+.Sh ERRORS
+The
+.Fn dwarf_attroffset
+function may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar at
+or
+.Ar ret_off
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_attrval.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attrval.c
new file mode 100644
index 0000000..9a2f791
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attrval.c
@@ -0,0 +1,222 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_attrval.c 3509 2016-12-29 03:58:41Z emaste $");
+
+int
+dwarf_attrval_flag(Dwarf_Die die, Dwarf_Half attr, Dwarf_Bool *valp, Dwarf_Error *err)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || valp == NULL) {
+ DWARF_SET_ERROR(dbg, err, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *valp = 0;
+
+ if ((at = _dwarf_attr_find(die, attr)) == NULL) {
+ DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ switch (at->at_form) {
+ case DW_FORM_flag:
+ case DW_FORM_flag_present:
+ *valp = (Dwarf_Bool) (!!at->u[0].u64);
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
+ return (DW_DLV_ERROR);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_attrval_string(Dwarf_Die die, Dwarf_Half attr, const char **strp, Dwarf_Error *err)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || strp == NULL) {
+ DWARF_SET_ERROR(dbg, err, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *strp = NULL;
+
+ if ((at = _dwarf_attr_find(die, attr)) == NULL) {
+ DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ switch (at->at_form) {
+ case DW_FORM_strp:
+ *strp = at->u[1].s;
+ break;
+ case DW_FORM_string:
+ *strp = at->u[0].s;
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
+ return (DW_DLV_ERROR);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_attrval_signed(Dwarf_Die die, Dwarf_Half attr, Dwarf_Signed *valp, Dwarf_Error *err)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || valp == NULL) {
+ DWARF_SET_ERROR(dbg, err, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *valp = 0;
+
+ if ((at = _dwarf_attr_find(die, attr)) == NULL) {
+ DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ switch (at->at_form) {
+ case DW_FORM_data1:
+ *valp = (int8_t) at->u[0].s64;
+ break;
+ case DW_FORM_data2:
+ *valp = (int16_t) at->u[0].s64;
+ break;
+ case DW_FORM_data4:
+ *valp = (int32_t) at->u[0].s64;
+ break;
+ case DW_FORM_data8:
+ case DW_FORM_sdata:
+ *valp = at->u[0].s64;
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
+ return (DW_DLV_ERROR);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_attrval_unsigned(Dwarf_Die die, Dwarf_Half attr, Dwarf_Unsigned *valp, Dwarf_Error *err)
+{
+ Dwarf_Attribute at;
+ Dwarf_Die die1;
+ Dwarf_Unsigned val;
+ Dwarf_Debug dbg;
+ int first;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || valp == NULL) {
+ DWARF_SET_ERROR(dbg, err, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *valp = 0;
+
+ die1 = NULL;
+ for (;;) {
+ if ((at = _dwarf_attr_find(die, attr)) != NULL ||
+ attr != DW_AT_type)
+ break;
+ if ((at = _dwarf_attr_find(die, DW_AT_abstract_origin)) ==
+ NULL &&
+ (at = _dwarf_attr_find(die, DW_AT_specification)) == NULL)
+ break;
+
+ switch (at->at_form) {
+ case DW_FORM_ref1:
+ case DW_FORM_ref2:
+ case DW_FORM_ref4:
+ case DW_FORM_ref8:
+ case DW_FORM_ref_udata:
+ val = at->u[0].u64;
+ first = (die1 == NULL);
+ die1 = _dwarf_die_find(die, val);
+ if (!first)
+ dwarf_dealloc(dbg, die, DW_DLA_DIE);
+ if (die1 == NULL) {
+ DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+ die = die1;
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
+ return (DW_DLV_ERROR);
+ }
+ }
+
+ if (at == NULL) {
+ DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ switch (at->at_form) {
+ case DW_FORM_addr:
+ case DW_FORM_data1:
+ case DW_FORM_data2:
+ case DW_FORM_data4:
+ case DW_FORM_data8:
+ case DW_FORM_udata:
+ case DW_FORM_ref1:
+ case DW_FORM_ref2:
+ case DW_FORM_ref4:
+ case DW_FORM_ref8:
+ case DW_FORM_ref_udata:
+ *valp = at->u[0].u64;
+ break;
+ default:
+ if (die1 != NULL)
+ dwarf_dealloc(dbg, die1, DW_DLA_DIE);
+ DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
+ return (DW_DLV_ERROR);
+ }
+
+ if (die1 != NULL)
+ dwarf_dealloc(dbg, die1, DW_DLA_DIE);
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_attrval_signed.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attrval_signed.3
new file mode 100644
index 0000000..c9416bc
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_attrval_signed.3
@@ -0,0 +1,225 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_attrval_signed.3 3509 2016-12-29 03:58:41Z emaste $
+.\"
+.Dd December 26, 2016
+.Os
+.Dt DWARF_ATTRVAL_SIGNED 3
+.Sh NAME
+.Nm dwarf_attrval_flag ,
+.Nm dwarf_attrval_signed ,
+.Nm dwarf_attrval_string ,
+.Nm dwarf_attrval_unsigned
+.Nd retrieve the value of an attribute within a DWARF debugging information entry
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_attrval_flag
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Bool *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_attrval_signed
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Signed *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_attrval_string
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "const char **ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_attrval_unsigned
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Unsigned *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions search the debugging information entry referenced
+by argument
+.Ar die
+for the attribute named by argument
+.Ar attr .
+If the named attribute is found, the functions set the location
+pointed to by argument
+.Ar ret
+to the value of the attribute.
+The argument
+.Ar err ,
+if non NULL,
+will be used to return an error descriptor in case of an error.
+.Pp
+Function
+.Fn dwarf_attrval_flag
+sets the location pointed to by argument
+.Ar ret
+to either 0 or 1. If the form of the attribute named by argument
+.Ar attr
+is
+.Dv DW_FORM_flag ,
+function
+.Fn dwarf_attrval_flag
+sets the location pointed to by argument
+.Ar ret
+to 1 if the attribute has a non-zero value, or to 0 otherwise.
+If the form of the attribute named by argument
+.Ar attr
+is
+.Dv DW_FORM_flag_present ,
+function
+.Fn dwarf_attrval_flag
+unconditionally sets the location pointed to by argument
+.Ar ret
+to 1.
+The form of the attribute must be one of
+.Dv DW_FORM_flag
+or
+.Dv DW_FORM_flag_present .
+.Pp
+Function
+.Fn dwarf_attrval_signed
+stores the value for the attribute named by argument
+.Ar attr ,
+into the location pointed to by argument
+.Ar ret .
+The attribute's value is treated as a signed integral quantity and is
+sign-extended as needed.
+The attribute named by the argument
+.Ar attr
+must belong to the
+.Dv CONSTANT
+class and must have one of the following forms:
+.Dv DW_FORM_data1 ,
+.Dv DW_FORM_data2 ,
+.Dv DW_FORM_data4 ,
+.Dv DW_FORM_data8
+or
+.Dv DW_FORM_sdata .
+.Pp
+Function
+.Fn dwarf_attrval_string
+sets the location pointed to by argument
+.Ar ret
+to a pointer to a NUL-terminated string that is the value of the
+attribute named by argument
+.Ar attr .
+The form of the attribute must be one of
+.Dv DW_FORM_string
+or
+.Dv DW_FORM_strp .
+.Pp
+Function
+.Fn dwarf_attrval_unsigned
+stores the value for the attribute named by argument
+.Ar attr
+into the location pointed to by argument
+.Ar ret .
+The attribute's value is treated as an unsigned integral quantity, and
+is zero-extended as needed.
+The named attribute must belong to one of the
+.Dv CONSTANT ,
+.Dv ADDRESS
+or
+.Dv REFERENCE
+classes and must have one of the following forms:
+.Dv DW_FORM_addr ,
+.Dv DW_FORM_data1 ,
+.Dv DW_FORM_data2 ,
+.Dv DW_FORM_data4 ,
+.Dv DW_FORM_data8 ,
+.Dv DW_FORM_udata ,
+.Dv DW_FORM_ref1 ,
+.Dv DW_FORM_ref2 ,
+.Dv DW_FORM_ref4 ,
+.Dv DW_FORM_ref8 ,
+or
+.Dv DW_FORM_ref_udata .
+.Pp
+If the attribute named by argument
+.Ar attr
+is
+.Dv DW_AT_type
+and is not present in the debugging information entry referenced by argument
+.Ar die ,
+and if a
+.Dv DW_AT_abstract_origin
+or
+.Dv DW_AT_specification
+attribute is present in the debugging information entry,
+function
+.Fn dwarf_attrval_unsigned
+will search for the named attribute in the debugging information entry
+referenced by the
+.Dv DW_AT_abstract_origin
+or
+.Dv DW_AT_specification
+attribute.
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+If the named attribute was not found in the specified debugging
+information entry descriptor these functions return
+.Dv DW_DLV_NO_ENTRY
+and set argument
+.Ar err .
+For other errors, these functions return
+.Dv DW_DLV_ERROR
+and set argument
+.Ar err .
+.Sh COMPATIBILITY
+These functions are extensions added by this implementation of the
+DWARF(3) API.
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Va die
+or
+.Va ret
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+Argument
+.Ar die
+did not contain an attribute corresponding to the value in argument
+.Ar attr .
+.It Bq Er DW_DLE_ATTR_FORM_BAD
+The attribute named by argument
+.Ar attr
+was not of a permitted form.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_hasattr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_child.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_child.3
new file mode 100644
index 0000000..1e32e58
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_child.3
@@ -0,0 +1,278 @@
+.\" Copyright (c) 2010,2014 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_child.3 3127 2014-12-21 19:09:19Z jkoshy $
+.\"
+.Dd December 21, 2014
+.Os
+.Dt DWARF_CHILD 3
+.Sh NAME
+.Nm dwarf_child ,
+.Nm dwarf_offdie ,
+.Nm dwarf_offdie_b ,
+.Nm dwarf_siblingof ,
+.Nm dwarf_siblingof_b
+.Nd retrieve DWARF Debugging Information Entry descriptors
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fn dwarf_child "Dwarf_Die die" "Dwarf_Die *ret_die" "Dwarf_Error *err"
+.Ft int
+.Fo dwarf_offdie
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Off offset"
+.Fa "Dwarf_Die *ret_die"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_offdie_b
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Off offset"
+.Fa "Dwarf_Bool is_info"
+.Fa "Dwarf_Die *ret_die"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_siblingof
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Die *ret_die"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_siblingof_b
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Die *ret_die"
+.Fa "Dwarf_Bool is_info"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions are used to retrieve and traverse DWARF
+Debugging Information Entry (DIE) descriptors associated with
+a compilation unit.
+These descriptors are arranged in the form of a tree, traversable
+using
+.Dq child
+and
+.Dq sibling
+links; see
+.Xr dwarf 3
+for more information.
+DWARF Debugging Information Entry descriptors are represented
+by the
+.Vt Dwarf_Die
+opaque type.
+.Pp
+Function
+.Fn dwarf_child
+retrieves the child of descriptor denoted by argument
+.Ar die ,
+and stores it in the location pointed to by argument
+.Ar ret_die .
+.Pp
+Function
+.Fn dwarf_siblingof
+retrieves the sibling of the descriptor denoted by argument
+.Ar die ,
+and stores it in the location pointed to by argument
+.Ar ret_die .
+If argument
+.Ar die
+is NULL, the first debugging information entry descriptor for the
+current compilation unit will be returned.
+This function and function
+.Fn dwarf_child
+may be used together to traverse the tree of debugging information
+entry descriptors for a compilation unit.
+.Pp
+Function
+.Fn dwarf_siblingof_b
+is identical to the function
+.Fn dwarf_siblingof
+except that it can retrieve the sibling descriptor from either the
+current compilation unit or type unit.
+If argument
+.Ar is_info
+is non-zero, the function behaves identically to function
+.Fn dwarf_siblingof .
+If argument
+.Ar is_info
+is zero, the descriptor referred by argument
+.Ar die
+should be associated with a debugging information entry in the
+type unit.
+The function will store the sibling of the descriptor in the location
+pointed to by argument
+.Ar ret_die .
+If argument
+.Ar is_info
+is zero and argument
+.Ar die
+is
+.Dv NULL ,
+the first debugging information entry descriptor for the
+current type unit will be returned.
+.Pp
+Function
+.Fn dwarf_offdie
+retrieves the debugging information entry descriptor at global offset
+.Ar offset
+in the
+.Dq .debug_info
+section of the object associated with argument
+.Ar dbg .
+The returned descriptor is written to the location pointed to by argument
+.Ar ret_die .
+.Pp
+Function
+.Fn dwarf_offdie_b
+is identical to the function
+.Fn dwarf_offdie
+except that it can retrieve the debugging information entry descriptor at
+global offset
+.Ar offset
+from either of the
+.Dq .debug_info
+and
+.Dq .debug_types
+sections of the object associated with argument
+.Ar dbg .
+If argument
+.Ar is_info
+is non-zero, the function will retrieve the debugging information
+entry from the
+.Dq .debug_info
+section, otherwise the function will retrieve the debugging
+information entry from the
+.Dq .debug_types
+section.
+The returned descriptor is written to the location pointed to by argument
+.Ar ret_die .
+.Ss Memory Management
+The memory area used for the
+.Vt Dwarf_Die
+descriptor returned in argument
+.Ar ret_die
+is allocated by the
+.Lb libdwarf .
+Application code should use function
+.Fn dwarf_dealloc
+with the allocation type
+.Dv DW_DLA_DIE
+to free the memory area when the
+.Vt Dwarf_Die
+descriptor is no longer needed.
+.Sh RETURN VALUES
+These functions return the following values:
+.Bl -tag -width ".Bq Er DW_DLV_NO_ENTRY"
+.It Bq Er DW_DLV_OK
+The call succeeded.
+.It Bq Er DW_DLV_ERROR
+The requested operation failed.
+Additional information about the error encountered will be recorded in
+argument
+.Ar err ,
+if it is not NULL.
+.It Bq Er DW_DLV_NO_ENTRY
+For functions
+.Fn dwarf_child ,
+.Fn dwarf_siblingof
+and
+.Fn dwarf_siblingof_b ,
+the descriptor denoted by argument
+.Ar die
+did not have a child or sibling.
+.Pp
+For functions
+.Fn dwarf_offdie
+and
+.Fn dwarf_offdie_b ,
+there was no debugging information entry at the offset specified by
+argument
+.Ar offset .
+.El
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_DIE_NO_CU_CONTEXT"
+.It Bq Er DW_DLE_ARGUMENT
+Arguments
+.Ar dbg ,
+.Ar die
+or
+.Ar ret_die
+were NULL.
+.It Bq Er DW_DLE_DIE_NO_CU_CONTEXT
+Argument
+.Ar dbg
+was not associated with a compilation unit.
+.It Bq Er DW_DLE_NO_ENTRY
+The descriptor denoted by argument
+.Ar die
+had no child or sibling, or there was no DWARF debugging information
+entry at the offset specified by argument
+.Va offset .
+.El
+.Sh EXAMPLES
+To retrieve the first DWARF Debugging Information Entry descriptor for
+the first compilation unit associated with a
+.Vt Dwarf_Debug
+instance, and to traverse all its children, use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Die die, die0;
+Dwarf_Error de;
+
+\&... allocate dbg using dwarf_init() etc ...
+
+if (dwarf_next_cu_header(dbg, NULL, NULL, NULL, NULL, NULL, &de) !=
+ DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_next_cu_header: %s",
+ dwarf_errmsg(de));
+
+/* Get the first DIE for the current compilation unit. */
+die = NULL;
+if (dwarf_siblingof(dbg, die, &die0, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_siblingof: %s", dwarf_errmsg(de));
+
+/* Get the first child of this DIE. */
+die = die0;
+if (dwarf_child(die, &die0, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_child: %s", dwarf_errmsg(de));
+
+/* Get the rest of children. */
+do {
+ die = die0;
+ if (dwarf_siblingof(dbg, die, &die0, &de) == DW_DLV_ERROR)
+ errx(EXIT_FAILURE, "dwarf_siblingof: %s",
+ dwarf_errmsg(de));
+} while (die0 != NULL);
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_errmsg 3 ,
+.Xr dwarf_get_die_infotypes_flag.3 ,
+.Xr dwarf_next_cu_header 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_cu.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_cu.c
new file mode 100644
index 0000000..d103488
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_cu.c
@@ -0,0 +1,161 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2014 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_cu.c 3041 2014-05-18 15:11:03Z kaiwang27 $");
+
+int
+dwarf_next_cu_header_c(Dwarf_Debug dbg, Dwarf_Bool is_info,
+ Dwarf_Unsigned *cu_length, Dwarf_Half *cu_version,
+ Dwarf_Off *cu_abbrev_offset, Dwarf_Half *cu_pointer_size,
+ Dwarf_Half *cu_offset_size, Dwarf_Half *cu_extension_size,
+ Dwarf_Sig8 *type_signature, Dwarf_Unsigned *type_offset,
+ Dwarf_Unsigned *cu_next_offset, Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ int ret;
+
+ if (dbg == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (is_info) {
+ if (dbg->dbg_cu_current == NULL)
+ ret = _dwarf_info_first_cu(dbg, error);
+ else
+ ret = _dwarf_info_next_cu(dbg, error);
+ } else {
+ if (dbg->dbg_tu_current == NULL)
+ ret = _dwarf_info_first_tu(dbg, error);
+ else
+ ret = _dwarf_info_next_tu(dbg, error);
+ }
+
+ if (ret == DW_DLE_NO_ENTRY) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ } else if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ if (is_info) {
+ if (dbg->dbg_cu_current == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+ cu = dbg->dbg_cu_current;
+ } else {
+ if (dbg->dbg_tu_current == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+ cu = dbg->dbg_tu_current;
+ }
+
+ if (cu_length)
+ *cu_length = cu->cu_length;
+ if (cu_version)
+ *cu_version = cu->cu_version;
+ if (cu_abbrev_offset)
+ *cu_abbrev_offset = (Dwarf_Off) cu->cu_abbrev_offset;
+ if (cu_pointer_size)
+ *cu_pointer_size = cu->cu_pointer_size;
+ if (cu_offset_size) {
+ if (cu->cu_length_size == 4)
+ *cu_offset_size = 4;
+ else
+ *cu_offset_size = 8;
+ }
+ if (cu_extension_size) {
+ if (cu->cu_length_size == 4)
+ *cu_extension_size = 0;
+ else
+ *cu_extension_size = 4;
+ }
+ if (cu_next_offset)
+ *cu_next_offset = cu->cu_next_offset;
+
+ if (!is_info) {
+ if (type_signature)
+ *type_signature = cu->cu_type_sig;
+ if (type_offset)
+ *type_offset = cu->cu_type_offset;
+ }
+
+ return (DW_DLV_OK);
+}
+
+
+int
+dwarf_next_cu_header_b(Dwarf_Debug dbg, Dwarf_Unsigned *cu_length,
+ Dwarf_Half *cu_version, Dwarf_Off *cu_abbrev_offset,
+ Dwarf_Half *cu_pointer_size, Dwarf_Half *cu_offset_size,
+ Dwarf_Half *cu_extension_size, Dwarf_Unsigned *cu_next_offset,
+ Dwarf_Error *error)
+{
+
+ return (dwarf_next_cu_header_c(dbg, 1, cu_length, cu_version,
+ cu_abbrev_offset, cu_pointer_size, cu_offset_size,
+ cu_extension_size, NULL, NULL, cu_next_offset, error));
+}
+
+int
+dwarf_next_cu_header(Dwarf_Debug dbg, Dwarf_Unsigned *cu_length,
+ Dwarf_Half *cu_version, Dwarf_Off *cu_abbrev_offset,
+ Dwarf_Half *cu_pointer_size, Dwarf_Unsigned *cu_next_offset,
+ Dwarf_Error *error)
+{
+
+ return (dwarf_next_cu_header_b(dbg, cu_length, cu_version,
+ cu_abbrev_offset, cu_pointer_size, NULL, NULL, cu_next_offset,
+ error));
+}
+
+int
+dwarf_next_types_section(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+
+ /* Free resource allocated for current .debug_types section. */
+ _dwarf_type_unit_cleanup(dbg);
+ dbg->dbg_types_loaded = 0;
+ dbg->dbg_types_off = 0;
+
+ /* Reset type unit pointer. */
+ dbg->dbg_tu_current = NULL;
+
+ /* Search for the next .debug_types section. */
+ dbg->dbg_types_sec = _dwarf_find_next_types_section(dbg,
+ dbg->dbg_types_sec);
+
+ if (dbg->dbg_types_sec == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_dealloc.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_dealloc.3
new file mode 100644
index 0000000..51d355b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_dealloc.3
@@ -0,0 +1,203 @@
+.\" Copyright (c) 2009-2011 Joseph Koshy. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" This software is provided by Joseph Koshy ``as is'' and
+.\" any express or implied warranties, including, but not limited to, the
+.\" implied warranties of merchantability and fitness for a particular purpose
+.\" are disclaimed. in no event shall Joseph Koshy be liable
+.\" for any direct, indirect, incidental, special, exemplary, or consequential
+.\" damages (including, but not limited to, procurement of substitute goods
+.\" or services; loss of use, data, or profits; or business interruption)
+.\" however caused and on any theory of liability, whether in contract, strict
+.\" liability, or tort (including negligence or otherwise) arising in any way
+.\" out of the use of this software, even if advised of the possibility of
+.\" such damage.
+.\"
+.\" $Id: dwarf_dealloc.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd July 23, 2011
+.Os
+.Dt DWARF_DEALLOC 3
+.Sh NAME
+.Nm dwarf_dealloc ,
+.Nm dwarf_fde_cie_list_dealloc ,
+.Nm dwarf_funcs_dealloc ,
+.Nm dwarf_globals_dealloc ,
+.Nm dwarf_pubtypes_dealloc ,
+.Nm dwarf_ranges_dealloc ,
+.Nm dwarf_srclines_dealloc ,
+.Nm dwarf_types_dealloc ,
+.Nm dwarf_vars_dealloc ,
+.Nm dwarf_weaks_dealloc
+.Nd release resources
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft void
+.Fo dwarf_dealloc
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Ptr ptr"
+.Fa "Dwarf_Unsigned type"
+.Fc
+.Fo dwarf_fde_cie_list_dealloc
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Cie *cie_list"
+.Fa "Dwarf_Signed cie_count"
+.Fa "Dwarf_Fde *fde_list"
+.Fa "Dwarf_Signed fde_count"
+.Fc
+.Ft void
+.Fo dwarf_funcs_dealloc
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Func *funcs"
+.Fa "Dwarf_Signed funccount"
+.Fc
+.Ft void
+.Fo dwarf_globals_dealloc
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Global *globals"
+.Fa "Dwarf_Signed globalcount"
+.Fc
+.Ft void
+.Fo dwarf_pubtypes_dealloc
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Type *pubtypes"
+.Fa "Dwarf_Signed pubtypecount"
+.Fc
+.Ft void
+.Fo dwarf_ranges_dealloc
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Ranges *ranges"
+.Fa "Dwarf_Signed rangecount"
+.Fc
+.Ft void
+.Fo dwarf_srclines_dealloc
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Line *lines"
+.Fa "Dwarf_Signed linecount"
+.Fc
+.Ft void
+.Fo dwarf_types_dealloc
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Type *types"
+.Fa "Dwarf_Signed typecount"
+.Fc
+.Ft void
+.Fo dwarf_vars_dealloc
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Var *vars"
+.Fa "Dwarf_Signed varcount"
+.Fc
+.Ft void
+.Fo dwarf_weaks_dealloc
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Weak *weaks"
+.Fa "Dwarf_Signed weakcount"
+.Fc
+.Sh DESCRIPTION
+The function
+.Fn dwarf_dealloc
+is used by applications to indicate that memory areas returned by
+.Lb libdwarf
+may be safely disposed off.
+Due to the way memory is managed in the current implementation, the
+use of
+.Fn dwarf_dealloc
+is only necessary for a small set of DWARF types.
+.Pp
+Argument
+.Ar dbg
+should reference a valid debugging context allocated using
+.Xr dwarf_init 3 .
+.Pp
+Argument
+.Ar ptr
+should point to an object or memory area obtained by a prior call
+to a DWARF(3) function.
+.Pp
+Argument
+.Ar type
+indicates the type of object being deallocated.
+The indicated type must match that of the object being passed in
+argument
+.Ar ptr .
+Valid values for the
+.Ar type
+argument are:
+.Bl -tag -width ".Dv DW_DLA_FRAME_BLOCK"
+.It Dv DW_DLA_ABBREV
+An object of type
+.Vt Dwarf_Abbrev ,
+as returned by a call to the function
+.Xr dwarf_get_abbrev 3 .
+.It Dv DW_DLA_DIE
+An object of type
+.Vt Dwarf_Die ,
+as returned by calls to the functions
+.Xr dwarf_child 3 ,
+.Xr dwarf_offdie 3
+or
+.Xr dwarf_siblingof 3 .
+.It Dv DW_DLA_FRAME_BLOCK
+An array of objects of type
+.Vt Dwarf_Frame_op ,
+as returned by a call to the function
+.Xr dwarf_expand_frame_instructions 3 .
+.El
+.Pp
+Calls to
+.Fn dwarf_dealloc
+with other values for argument
+.Ar type
+are no-ops in this implementation.
+.Pp
+The functions
+.Fn dwarf_fde_cie_list_dealloc ,
+.Fn dwarf_funcs_dealloc ,
+.Fn dwarf_globals_dealloc ,
+.Fn dwarf_pubtypes_dealloc ,
+.Fn dwarf_ranges_dealloc ,
+.Fn dwarf_srclines_dealloc ,
+.Fn dwarf_types_dealloc ,
+.Fn dwarf_vars_dealloc
+and
+.Fn dwarf_weaks_dealloc
+are provided for compatibility with other implementations of the
+DWARF(3) API.
+Due to the way memory is managed in the current implementation, these
+functions are effectively no-ops.
+.Pp
+See
+.Xr dwarf 3
+for more information about the memory management scheme in this
+implementation of the DWARF(3) API.
+.Sh RETURN VALUES
+Functions
+.Fn dwarf_dealloc ,
+.Fn dwarf_fde_cie_list_dealloc ,
+.Fn dwarf_funcs_dealloc ,
+.Fn dwarf_globals_dealloc ,
+.Fn dwarf_pubtypes_dealloc ,
+.Fn dwarf_ranges_dealloc ,
+.Fn dwarf_srclines_dealloc ,
+.Fn dwarf_types_dealloc ,
+.Fn dwarf_vars_dealloc
+and
+.Fn dwarf_weaks_dealloc
+have no return value.
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_child 3 ,
+.Xr dwarf_expand_frame_instructions 3 ,
+.Xr dwarf_get_abbrev 3 ,
+.Xr dwarf_offdie 3 ,
+.Xr dwarf_siblingof 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_dealloc.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_dealloc.c
new file mode 100644
index 0000000..eb7ed1c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_dealloc.c
@@ -0,0 +1,117 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_dealloc.c 2073 2011-10-27 03:30:47Z jkoshy $");
+
+void
+dwarf_dealloc(Dwarf_Debug dbg, Dwarf_Ptr p, Dwarf_Unsigned alloc_type)
+{
+ Dwarf_Abbrev ab;
+ Dwarf_AttrDef ad, tad;
+ Dwarf_Attribute at, tat;
+ Dwarf_Die die;
+
+ /*
+ * This libdwarf implementation does not use the SGI/libdwarf
+ * style of memory allocation. In most cases it does not copy
+ * things to return to the client, so the client does not need
+ * to remember to free them. The remaining cases are handled
+ * below.
+ */
+
+ (void) dbg;
+
+ if (alloc_type == DW_DLA_LIST || alloc_type == DW_DLA_FRAME_BLOCK ||
+ alloc_type == DW_DLA_LOC_BLOCK || alloc_type == DW_DLA_LOCDESC)
+ free(p);
+ else if (alloc_type == DW_DLA_ABBREV) {
+ ab = p;
+ STAILQ_FOREACH_SAFE(ad, &ab->ab_attrdef, ad_next, tad) {
+ STAILQ_REMOVE(&ab->ab_attrdef, ad, _Dwarf_AttrDef,
+ ad_next);
+ free(ad);
+ }
+ free(ab);
+ } else if (alloc_type == DW_DLA_DIE) {
+ die = p;
+ STAILQ_FOREACH_SAFE(at, &die->die_attr, at_next, tat) {
+ STAILQ_REMOVE(&die->die_attr, at,
+ _Dwarf_Attribute, at_next);
+ if (at->at_ld != NULL)
+ free(at->at_ld);
+ free(at);
+ }
+ if (die->die_attrarray)
+ free(die->die_attrarray);
+ free(die);
+ }
+}
+
+void
+dwarf_srclines_dealloc(Dwarf_Debug dbg, Dwarf_Line *linebuf,
+ Dwarf_Signed count)
+{
+ /*
+ * In this libdwarf implementation, line information remains
+ * associated with the DIE for a compilation unit for the
+ * lifetime of the DIE. The client does not need to free
+ * the memory returned by `dwarf_srclines()`.
+ */
+
+ (void) dbg; (void) linebuf; (void) count;
+}
+
+void
+dwarf_ranges_dealloc(Dwarf_Debug dbg, Dwarf_Ranges *ranges,
+ Dwarf_Signed range_count)
+{
+ /*
+ * In this libdwarf implementation, ranges information is
+ * kept by a STAILQ inside Dwarf_Debug object. The client
+ * does not need to free the memory returned by
+ * `dwarf_get_ranges()` or `dwarf_get_ranges_a()`.
+ */
+
+ (void) dbg; (void) ranges; (void) range_count;
+}
+
+void
+dwarf_fde_cie_list_dealloc(Dwarf_Debug dbg, Dwarf_Cie *cie_list,
+ Dwarf_Signed cie_count, Dwarf_Fde *fde_list, Dwarf_Signed fde_count)
+{
+ /*
+ * In this implementation, FDE and CIE information is managed
+ * as part of the Dwarf_Debug object. The client does not need
+ * to explicitly free these memory arenas.
+ */
+ (void) dbg;
+ (void) cie_list;
+ (void) cie_count;
+ (void) fde_list;
+ (void) fde_count;
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_def_macro.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_def_macro.3
new file mode 100644
index 0000000..daa090f
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_def_macro.3
@@ -0,0 +1,129 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_def_macro.3 3182 2015-04-10 16:08:10Z emaste $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_DEF_MACRO 3
+.Sh NAME
+.Nm dwarf_def_macro
+.Nd add a macro definition to a DWARF producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "int"
+.Fo dwarf_def_macro
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Unsigned lineno"
+.Fa "char *name"
+.Fa "char *value"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_def_macro
+adds a macro definition to a DWARF producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar lineno
+specifies the line number of the source line where the macro is
+defined.
+A line number of zero is used for macros that are defined
+before any source file is read.
+.Pp
+Argument
+.Ar name
+should point to a NUL-terminated string containing the name
+of the macro.
+For function-like macros this parameter should also include
+parentheses and parameter names if any.
+.Pp
+Argument
+.Ar value
+should point to a NUL-terminated string containing the value
+of the macro.
+If the macro does not have a value, argument
+.Ar value
+should be set to NULL.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_def_macro
+returns
+.Dv DW_DLV_OK .
+In case of an error, function
+.Fn dwarf_def_macro
+returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh EXAMPLE
+To record the fact that a macro named
+.Dv _STDIO_H_
+was defined at line 20 of the current macro file, use:
+.Bd -literal -offset indent
+Dwarf_P_Debug dbg;
+Dwarf_Error de;
+
+/* ... Assume 'dbg' refers to a DWARF producer instance... */
+if (dwarf_def_macro(dbg, 20, "_STDIO_H_", NULL, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_def_macro failed: %s",
+ dwarf_errmsg(-1));
+.Ed
+.Sh ERRORS
+Function
+.Fn dwarf_def_macro
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either arguments
+.Ar dbg
+or
+.Ar name
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_end_macro_file 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3 ,
+.Xr dwarf_start_macro_file 3 ,
+.Xr dwarf_undef_macro 3 ,
+.Xr dwarf_vendor_ext 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_die.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_die.c
new file mode 100644
index 0000000..de6351a
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_die.c
@@ -0,0 +1,413 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2009,2011,2014 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_die.c 3039 2014-05-18 15:10:56Z kaiwang27 $");
+
+int
+dwarf_child(Dwarf_Die die, Dwarf_Die *ret_die, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ Dwarf_Section *ds;
+ Dwarf_CU cu;
+ int ret;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (die->die_ab->ab_children == DW_CHILDREN_no)
+ return (DW_DLV_NO_ENTRY);
+
+ dbg = die->die_dbg;
+ cu = die->die_cu;
+ ds = cu->cu_is_info ? dbg->dbg_info_sec : dbg->dbg_types_sec;
+ ret = _dwarf_die_parse(die->die_dbg, ds, cu, cu->cu_dwarf_size,
+ die->die_next_off, cu->cu_next_offset, ret_die, 0, error);
+
+ if (ret == DW_DLE_NO_ENTRY) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ } else if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_siblingof_b(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Die *ret_die,
+ Dwarf_Bool is_info, Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ Dwarf_Attribute at;
+ Dwarf_Section *ds;
+ uint64_t offset;
+ int ret, search_sibling;
+
+ if (dbg == NULL || ret_die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ ds = is_info ? dbg->dbg_info_sec : dbg->dbg_types_sec;
+ cu = is_info ? dbg->dbg_cu_current : dbg->dbg_tu_current;
+
+ if (cu == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_DIE_NO_CU_CONTEXT);
+ return (DW_DLV_ERROR);
+ }
+
+ /* Application requests the first DIE in this CU. */
+ if (die == NULL)
+ return (dwarf_offdie_b(dbg, cu->cu_1st_offset, is_info,
+ ret_die, error));
+
+ /*
+ * Check if the `is_info' flag matches the debug section the
+ * DIE belongs to.
+ */
+ if (is_info != die->die_cu->cu_is_info) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ /*
+ * If the DIE doesn't have any children, its sibling sits next
+ * right to it.
+ */
+ search_sibling = 0;
+ if (die->die_ab->ab_children == DW_CHILDREN_no)
+ offset = die->die_next_off;
+ else {
+ /*
+ * Look for DW_AT_sibling attribute for the offset of
+ * its sibling.
+ */
+ if ((at = _dwarf_attr_find(die, DW_AT_sibling)) != NULL) {
+ if (at->at_form != DW_FORM_ref_addr)
+ offset = at->u[0].u64 + cu->cu_offset;
+ else
+ offset = at->u[0].u64;
+ } else {
+ offset = die->die_next_off;
+ search_sibling = 1;
+ }
+ }
+
+ ret = _dwarf_die_parse(die->die_dbg, ds, cu, cu->cu_dwarf_size, offset,
+ cu->cu_next_offset, ret_die, search_sibling, error);
+
+ if (ret == DW_DLE_NO_ENTRY) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ } else if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ return (DW_DLV_OK);
+}
+
+
+int
+dwarf_siblingof(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Die *ret_die,
+ Dwarf_Error *error)
+{
+
+ return (dwarf_siblingof_b(dbg, die, ret_die, 1, error));
+}
+
+static int
+_dwarf_search_die_within_cu(Dwarf_Debug dbg, Dwarf_Section *s, Dwarf_CU cu,
+ Dwarf_Off offset, Dwarf_Die *ret_die, Dwarf_Error *error)
+{
+
+ assert(dbg != NULL && cu != NULL && ret_die != NULL);
+
+ return (_dwarf_die_parse(dbg, s, cu, cu->cu_dwarf_size,
+ offset, cu->cu_next_offset, ret_die, 0, error));
+}
+
+int
+dwarf_offdie_b(Dwarf_Debug dbg, Dwarf_Off offset, Dwarf_Bool is_info,
+ Dwarf_Die *ret_die, Dwarf_Error *error)
+{
+ Dwarf_Section *ds;
+ Dwarf_CU cu;
+ int ret;
+
+ if (dbg == NULL || ret_die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ ds = is_info ? dbg->dbg_info_sec : dbg->dbg_types_sec;
+ cu = is_info ? dbg->dbg_cu_current : dbg->dbg_tu_current;
+
+ /* First search the current CU. */
+ if (cu != NULL) {
+ if (offset > cu->cu_offset && offset < cu->cu_next_offset) {
+ ret = _dwarf_search_die_within_cu(dbg, ds, cu, offset,
+ ret_die, error);
+ if (ret == DW_DLE_NO_ENTRY) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ } else if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ return (DW_DLV_OK);
+ }
+ }
+
+ /* Search other CUs. */
+ ret = _dwarf_info_load(dbg, 1, is_info, error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ if (is_info) {
+ STAILQ_FOREACH(cu, &dbg->dbg_cu, cu_next) {
+ if (offset < cu->cu_offset ||
+ offset > cu->cu_next_offset)
+ continue;
+ ret = _dwarf_search_die_within_cu(dbg, ds, cu, offset,
+ ret_die, error);
+ if (ret == DW_DLE_NO_ENTRY) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ } else if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ return (DW_DLV_OK);
+ }
+ } else {
+ STAILQ_FOREACH(cu, &dbg->dbg_tu, cu_next) {
+ if (offset < cu->cu_offset ||
+ offset > cu->cu_next_offset)
+ continue;
+ ret = _dwarf_search_die_within_cu(dbg, ds, cu, offset,
+ ret_die, error);
+ if (ret == DW_DLE_NO_ENTRY) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ } else if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ return (DW_DLV_OK);
+ }
+ }
+
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+}
+
+int
+dwarf_offdie(Dwarf_Debug dbg, Dwarf_Off offset, Dwarf_Die *ret_die,
+ Dwarf_Error *error)
+{
+
+ return (dwarf_offdie_b(dbg, offset, 1, ret_die, error));
+}
+
+int
+dwarf_tag(Dwarf_Die die, Dwarf_Half *tag, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || tag == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ assert(die->die_ab != NULL);
+
+ *tag = (Dwarf_Half) die->die_ab->ab_tag;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_dieoffset(Dwarf_Die die, Dwarf_Off *ret_offset, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_offset == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_offset = die->die_offset;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_die_CU_offset(Dwarf_Die die, Dwarf_Off *ret_offset, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ Dwarf_CU cu;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_offset == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ cu = die->die_cu;
+ assert(cu != NULL);
+
+ *ret_offset = die->die_offset - cu->cu_offset;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_die_CU_offset_range(Dwarf_Die die, Dwarf_Off *cu_offset,
+ Dwarf_Off *cu_length, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ Dwarf_CU cu;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || cu_offset == NULL || cu_length == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ cu = die->die_cu;
+ assert(cu != NULL);
+
+ *cu_offset = cu->cu_offset;
+ *cu_length = cu->cu_length + cu->cu_length_size;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_diename(Dwarf_Die die, char **ret_name, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || ret_name == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (die->die_name == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *ret_name = die->die_name;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_die_abbrev_code(Dwarf_Die die)
+{
+
+ assert(die != NULL);
+
+ return (die->die_abnum);
+}
+
+int
+dwarf_get_cu_die_offset_given_cu_header_offset_b(Dwarf_Debug dbg,
+ Dwarf_Off in_cu_header_offset, Dwarf_Bool is_info,
+ Dwarf_Off *out_cu_die_offset, Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+
+ if (dbg == NULL || out_cu_die_offset == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (is_info) {
+ STAILQ_FOREACH(cu, &dbg->dbg_cu, cu_next) {
+ if (cu->cu_offset == in_cu_header_offset) {
+ *out_cu_die_offset = cu->cu_1st_offset;
+ break;
+ }
+ }
+ } else {
+ STAILQ_FOREACH(cu, &dbg->dbg_tu, cu_next) {
+ if (cu->cu_offset == in_cu_header_offset) {
+ *out_cu_die_offset = cu->cu_1st_offset;
+ break;
+ }
+ }
+ }
+
+ if (cu == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_cu_die_offset_given_cu_header_offset(Dwarf_Debug dbg,
+ Dwarf_Off in_cu_header_offset, Dwarf_Off *out_cu_die_offset,
+ Dwarf_Error *error)
+{
+
+ return (dwarf_get_cu_die_offset_given_cu_header_offset_b(dbg,
+ in_cu_header_offset, 1, out_cu_die_offset, error));
+}
+
+int
+dwarf_get_address_size(Dwarf_Debug dbg, Dwarf_Half *addr_size,
+ Dwarf_Error *error)
+{
+
+ if (dbg == NULL || addr_size == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *addr_size = dbg->dbg_pointer_size;
+
+ return (DW_DLV_OK);
+}
+
+Dwarf_Bool
+dwarf_get_die_infotypes_flag(Dwarf_Die die)
+{
+
+ assert(die != NULL);
+
+ return (die->die_cu->cu_is_info);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_die_abbrev_code.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_die_abbrev_code.3
new file mode 100644
index 0000000..82caf3b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_die_abbrev_code.3
@@ -0,0 +1,55 @@
+.\" Copyright (c) 2010 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_die_abbrev_code.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd April 14, 2010
+.Os
+.Dt DWARF_DIE_ABBREV_CODE 3
+.Sh NAME
+.Nm dwarf_die_abbrev_code
+.Nd retrieve the abbreviation code for a DWARF debugging information entry
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fn dwarf_die_abbrev_code "Dwarf_Die die"
+.Sh DESCRIPTION
+Function
+.Fn dwarf_die_abbrev_code
+returns the abbreviation code for the debugging information entry descriptor
+referenced by argument
+.Ar die .
+Argument
+.Ar die
+should be a valid pointer to a value of type
+.Vt Dwarf_Die .
+.Sh RETURN VALUES
+The function returns an integral value.
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_diename 3 ,
+.Xr dwarf_dieoffset 3 ,
+.Xr dwarf_tag 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_die_link.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_die_link.3
new file mode 100644
index 0000000..89ddb5b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_die_link.3
@@ -0,0 +1,118 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_die_link.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_DIE_LINK 3
+.Sh NAME
+.Nm dwarf_die_link
+.Nd link a debugging information entry
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_P_Die
+.Fo dwarf_die_link
+.Fa "Dwarf_P_Die die"
+.Fa "Dwarf_P_Die parent"
+.Fa "Dwarf_P_Die child"
+.Fa "Dwarf_P_Die left"
+.Fa "Dwarf_P_Die right"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_die_link
+links debugging information entries together.
+.Pp
+Argument
+.Ar die
+should specify the debugging information entry to be updated.
+.Pp
+Argument
+.Ar parent
+specifies the new parent link for the debugging information entry.
+.Pp
+Argument
+.Ar child
+specifies the new first child link for the debugging information entry.
+.Pp
+Argument
+.Ar left
+specifies the new left sibling link for the debugging information entry.
+.Pp
+Argument
+.Ar right
+specifies the new right sibling link for the debugging information entry.
+.Pp
+Only one of arguments
+.Ar parent ,
+.Ar child ,
+.Ar left
+and
+.Ar right
+is allowed to be non-NULL.
+Existing links to parent, child, left or right debugging information
+entries, if any, will be unlinked before the specified link is
+established.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_die_link
+returns the debugging information entry provided in argument
+.Ar die .
+In case of an error, function
+.Fn dwarf_die_link
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+The function
+.Fn dwarf_die_link
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar die
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+More than one of the arguments
+.Ar parent ,
+.Ar child ,
+.Ar left
+and
+.Ar right
+were non-NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_die_to_debug 3 ,
+.Xr dwarf_new_die 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_diename.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_diename.3
new file mode 100644
index 0000000..d9404de
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_diename.3
@@ -0,0 +1,90 @@
+.\" Copyright (c) 2010 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_diename.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd March 31, 2010
+.Os
+.Dt DWARF_DIENAME 3
+.Sh NAME
+.Nm dwarf_diename
+.Nd retrieve the name associated with a debugging information entry
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fn dwarf_diename "Dwarf_Die die" "char **ret_name" "Dwarf_Error *err"
+.Sh DESCRIPTION
+Function
+.Fn dwarf_diename
+retrieves a pointer to the NUL-terminated string associated with the
+.Dv DW_AT_name
+attribute of the debugging information entry descriptor referenced by
+argument
+.Ar die .
+If the pointer was successfully retrieved, it is stored in the location
+pointed to by argument
+.Ar ret_name .
+.Sh RETURN VALUES
+Function
+.Fn dwarf_diename
+returns
+.Dv DW_DLV_OK on success.
+.Pp
+If the debugging information entry descriptor denoted by argument
+.Ar die
+does not contain a
+.Dv DW_AT_name
+attribute, the function returns
+.Dv DW_DLV_NO_ENTRY
+and sets argument
+.Ar err .
+For other errors, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_diename
+can fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar die
+or
+.Ar ret_name
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+Argument
+.Ar die
+had no
+.Dv DW_AT_name
+attribute.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_tag 3 ,
+.Xr dwarf_dieoffset 3 ,
+.Xr dwarf_die_abbrev_code 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_dieoffset.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_dieoffset.3
new file mode 100644
index 0000000..00b0e71
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_dieoffset.3
@@ -0,0 +1,206 @@
+.\" Copyright (c) 2010,2014 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_dieoffset.3 3129 2014-12-21 20:06:26Z jkoshy $
+.\"
+.Dd December 21, 2014
+.Os
+.Dt DWARF_DIEOFFSET 3
+.Sh NAME
+.Nm dwarf_die_CU_offset ,
+.Nm dwarf_die_CU_offset_range ,
+.Nm dwarf_dieoffset ,
+.Nm dwarf_get_cu_die_offset_given_cu_header_offset ,
+.Nm dwarf_get_cu_die_offset_given_cu_header_offset_b
+.Nd return offsets of DWARF debugging information entries
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_die_CU_offset
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Off *ret_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_die_CU_offset_range
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Off *cu_offset"
+.Fa "Dwarf_Off *cu_length"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_dieoffset
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Off *ret_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_get_cu_die_offset_given_cu_header_offset
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Off in_cu_header_offset"
+.Fa "Dwarf_Off *out_cu_die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_get_cu_die_offset_given_cu_header_offset_b
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Off in_cu_header_offset"
+.Fa "Dwarf_Bool is_info"
+.Fa "Dwarf_Off *out_cu_die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions are used to retrieve offsets for DWARF debugging
+information entries.
+.Pp
+Function
+.Fn dwarf_die_CU_offset
+returns the offset of the debugging information entry referenced by
+argument
+.Ar die
+relative to the start of its containing compilation unit.
+Argument
+.Ar ret_offset
+should point to the location that is to hold the returned offset.
+If argument
+.Ar err
+is non-NULL, it will be used to return an error descriptor in case of
+an error.
+.Pp
+Function
+.Fn dwarf_die_CU_offset_range
+returns the section-relative offset and length of the compilation unit
+containing the debugging information entry referenced by argument
+.Ar die .
+Argument
+.Ar cu_offset
+should point to a location that will hold the returned offset.
+Argument
+.Ar cu_length
+should point to a location that will hold the returned length of the
+compilation unit.
+If argument
+.Ar err
+is non-NULL, it will be used to return an error descriptor in case of
+an error.
+.Pp
+Function
+.Fn dwarf_dieoffset
+retrieves the section-relative offset of the debugging information
+entry referenced by argument
+.Ar die .
+Argument
+.Ar ret_offset
+should point to a location that is to hold the returned
+section-relative offset.
+If argument
+.Ar err
+is non-NULL, it will be used to return an error descriptor in case of
+an error.
+.Pp
+Function
+.Fn dwarf_get_cu_die_offset_given_cu_header_offset
+returns the offset for the first debugging information entry for a
+compilation unit, given an offset to the header of the compilation
+unit.
+Argument
+.Ar dbg
+should reference a valid debugging context allocated using
+.Xr dwarf_init 3 .
+Argument
+.Ar in_cu_header_offset
+contains the offset to the start of a compilation unit.
+Argument
+.Ar out_cu_die_offset
+points to a location that will hold the returned offset.
+If argument
+.Ar err
+is non-NULL, it will be used to return an error descriptor in case of
+an error.
+.Pp
+Function
+.Fn dwarf_get_cu_die_offset_given_cu_header_offset_b
+behaves identically to the function
+.Fn dwarf_get_cu_die_offset_given_cu_header_offset
+when the argument
+.Ar is_info
+is non-zero.
+When the argument
+.Ar is_info
+is zero, function
+.Fn dwarf_get_cu_die_offset_given_cu_header_offset_b
+returns the offset for the first debugging information entry for a
+type unit, given an offset to the header of the type unit in argument
+.Ar in_cu_header_offset .
+Argument
+.Ar out_cu_die_offset
+points to a location that will hold the returned offset.
+If the argument
+.Ar err
+is non-NULL, it will be used to return an error descriptor in case of
+an error.
+.Sh RETURN VALUES
+On success, these functions return
+.Dv DW_DLV_OK .
+In case of an error, these functions return
+.Dv DW_DLV_ERROR
+and set argument
+.Ar err .
+.Pp
+Function
+.Fn dwarf_get_cu_die_offset_given_cu_header_offset
+and
+.Fn dwarf_get_cu_die_offset_given_cu_header_offset_b
+returns
+.Dv DW_DLV_NO_ENTRY
+and sets argument
+.Ar err
+if there is no compilation or type unit located at the
+offset specified in argument
+.Ar in_cu_header_offset .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Va cu_length ,
+.Va cu_offset ,
+.Va dbg ,
+.Va die ,
+.Va out_cu_die_offset
+or
+.Va ret_offset
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+Argument
+.Ar in_cu_header_offset
+specified an unknown offset.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_next_cu_header 3 ,
+.Xr dwarf_offdie 3 ,
+.Xr dwarf_offdie_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_dump.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_dump.c
new file mode 100644
index 0000000..aa7ef1d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_dump.c
@@ -0,0 +1,1446 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_dump.c 3494 2016-09-20 17:16:13Z emaste $");
+
+int
+dwarf_get_ACCESS_name(unsigned access, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (access) {
+ case DW_ACCESS_public:
+ *s = "DW_ACCESS_public"; break;
+ case DW_ACCESS_protected:
+ *s = "DW_ACCESS_protected"; break;
+ case DW_ACCESS_private:
+ *s = "DW_ACCESS_private"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_AT_name(unsigned attr, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (attr) {
+ case DW_AT_abstract_origin:
+ *s = "DW_AT_abstract_origin"; break;
+ case DW_AT_accessibility:
+ *s = "DW_AT_accessibility"; break;
+ case DW_AT_address_class:
+ *s = "DW_AT_address_class"; break;
+ case DW_AT_artificial:
+ *s = "DW_AT_artificial"; break;
+ case DW_AT_allocated:
+ *s = "DW_AT_allocated"; break;
+ case DW_AT_associated:
+ *s = "DW_AT_associated"; break;
+ case DW_AT_base_types:
+ *s = "DW_AT_base_types"; break;
+ case DW_AT_binary_scale:
+ *s = "DW_AT_binary_scale"; break;
+ case DW_AT_bit_offset:
+ *s = "DW_AT_bit_offset"; break;
+ case DW_AT_bit_size:
+ *s = "DW_AT_bit_size"; break;
+ case DW_AT_bit_stride:
+ *s = "DW_AT_bit_stride"; break;
+ case DW_AT_byte_size:
+ *s = "DW_AT_byte_size"; break;
+ case DW_AT_byte_stride:
+ *s = "DW_AT_byte_stride"; break;
+ case DW_AT_calling_convention:
+ *s = "DW_AT_calling_convention"; break;
+ case DW_AT_common_reference:
+ *s = "DW_AT_common_reference"; break;
+ case DW_AT_comp_dir:
+ *s = "DW_AT_comp_dir"; break;
+ case DW_AT_const_expr:
+ *s = "DW_AT_const_expr"; break;
+ case DW_AT_const_value:
+ *s = "DW_AT_const_value"; break;
+ case DW_AT_containing_type:
+ *s = "DW_AT_containing_type"; break;
+ case DW_AT_count:
+ *s = "DW_AT_count"; break;
+ case DW_AT_call_column:
+ *s = "DW_AT_call_column"; break;
+ case DW_AT_call_file:
+ *s = "DW_AT_call_file"; break;
+ case DW_AT_call_line:
+ *s = "DW_AT_call_line"; break;
+ case DW_AT_data_bit_offset:
+ *s = "DW_AT_data_bit_offset"; break;
+ case DW_AT_data_location:
+ *s = "DW_AT_data_location"; break;
+ case DW_AT_data_member_location:
+ *s = "DW_AT_data_member_location"; break;
+ case DW_AT_decl_column:
+ *s = "DW_AT_decl_column"; break;
+ case DW_AT_decl_file:
+ *s = "DW_AT_decl_file"; break;
+ case DW_AT_decl_line:
+ *s = "DW_AT_decl_line"; break;
+ case DW_AT_declaration:
+ *s = "DW_AT_declaration"; break;
+ case DW_AT_default_value:
+ *s = "DW_AT_default_value"; break;
+ case DW_AT_decimal_scale:
+ *s = "DW_AT_decimal_scale"; break;
+ case DW_AT_decimal_sign:
+ *s = "DW_AT_decimal_sign"; break;
+ case DW_AT_description:
+ *s = "DW_AT_description"; break;
+ case DW_AT_digit_count:
+ *s = "DW_AT_digit_count"; break;
+ case DW_AT_discr:
+ *s = "DW_AT_discr"; break;
+ case DW_AT_discr_list:
+ *s = "DW_AT_discr_list"; break;
+ case DW_AT_discr_value:
+ *s = "DW_AT_discr_value"; break;
+ case DW_AT_element_list:
+ *s = "DW_AT_element_list"; break;
+ case DW_AT_encoding:
+ *s = "DW_AT_encoding"; break;
+ case DW_AT_enum_class:
+ *s = "DW_AT_enum_class"; break;
+ case DW_AT_external:
+ *s = "DW_AT_external"; break;
+ case DW_AT_entry_pc:
+ *s = "DW_AT_entry_pc"; break;
+ case DW_AT_extension:
+ *s = "DW_AT_extension"; break;
+ case DW_AT_explicit:
+ *s = "DW_AT_explicit"; break;
+ case DW_AT_endianity:
+ *s = "DW_AT_endianity"; break;
+ case DW_AT_elemental:
+ *s = "DW_AT_elemental"; break;
+ case DW_AT_frame_base:
+ *s = "DW_AT_frame_base"; break;
+ case DW_AT_friend:
+ *s = "DW_AT_friend"; break;
+ case DW_AT_high_pc:
+ *s = "DW_AT_high_pc"; break;
+ case DW_AT_hi_user:
+ *s = "DW_AT_hi_user"; break;
+ case DW_AT_identifier_case:
+ *s = "DW_AT_identifier_case"; break;
+ case DW_AT_import:
+ *s = "DW_AT_import"; break;
+ case DW_AT_inline:
+ *s = "DW_AT_inline"; break;
+ case DW_AT_is_optional:
+ *s = "DW_AT_is_optional"; break;
+ case DW_AT_language:
+ *s = "DW_AT_language"; break;
+ case DW_AT_linkage_name:
+ *s = "DW_AT_linkage_name"; break;
+ case DW_AT_lo_user:
+ *s = "DW_AT_lo_user"; break;
+ case DW_AT_location:
+ *s = "DW_AT_location"; break;
+ case DW_AT_low_pc:
+ *s = "DW_AT_low_pc"; break;
+ case DW_AT_lower_bound:
+ *s = "DW_AT_lower_bound"; break;
+ case DW_AT_macro_info:
+ *s = "DW_AT_macro_info"; break;
+ case DW_AT_main_subprogram:
+ *s = "DW_AT_main_subprogram"; break;
+ case DW_AT_mutable:
+ *s = "DW_AT_mutable"; break;
+ case DW_AT_member:
+ *s = "DW_AT_member"; break;
+ case DW_AT_name:
+ *s = "DW_AT_name"; break;
+ case DW_AT_namelist_item:
+ *s = "DW_AT_namelist_item"; break;
+ case DW_AT_ordering:
+ *s = "DW_AT_ordering"; break;
+ case DW_AT_object_pointer:
+ *s = "DW_AT_object_pointer"; break;
+ case DW_AT_priority:
+ *s = "DW_AT_priority"; break;
+ case DW_AT_producer:
+ *s = "DW_AT_producer"; break;
+ case DW_AT_prototyped:
+ *s = "DW_AT_prototyped"; break;
+ case DW_AT_picture_string:
+ *s = "DW_AT_picture_string"; break;
+ case DW_AT_pure:
+ *s = "DW_AT_pure"; break;
+ case DW_AT_return_addr:
+ *s = "DW_AT_return_addr"; break;
+ case DW_AT_ranges:
+ *s = "DW_AT_ranges"; break;
+ case DW_AT_recursive:
+ *s = "DW_AT_recursive"; break;
+ case DW_AT_segment:
+ *s = "DW_AT_segment"; break;
+ case DW_AT_sibling:
+ *s = "DW_AT_sibling"; break;
+ case DW_AT_signature:
+ *s = "DW_AT_signature"; break;
+ case DW_AT_specification:
+ *s = "DW_AT_specification"; break;
+ case DW_AT_start_scope:
+ *s = "DW_AT_start_scope"; break;
+ case DW_AT_static_link:
+ *s = "DW_AT_static_link"; break;
+ case DW_AT_stmt_list:
+ *s = "DW_AT_stmt_list"; break;
+ case DW_AT_string_length:
+ *s = "DW_AT_string_length"; break;
+ case DW_AT_subscr_data:
+ *s = "DW_AT_subscr_data"; break;
+ case DW_AT_small:
+ *s = "DW_AT_small"; break;
+ case DW_AT_type:
+ *s = "DW_AT_type"; break;
+ case DW_AT_trampoline:
+ *s = "DW_AT_trampoline"; break;
+ case DW_AT_threads_scaled:
+ *s = "DW_AT_threads_scaled"; break;
+ case DW_AT_upper_bound:
+ *s = "DW_AT_upper_bound"; break;
+ case DW_AT_use_location:
+ *s = "DW_AT_use_location"; break;
+ case DW_AT_use_UTF8:
+ *s = "DW_AT_use_UTF8"; break;
+ case DW_AT_variable_parameter:
+ *s = "DW_AT_variable_parameter"; break;
+ case DW_AT_virtuality:
+ *s = "DW_AT_virtuality"; break;
+ case DW_AT_visibility:
+ *s = "DW_AT_visibility"; break;
+ case DW_AT_vtable_elem_location:
+ *s = "DW_AT_vtable_elem_location"; break;
+ case DW_AT_sf_names:
+ *s = "DW_AT_sf_names"; break;
+ case DW_AT_src_info:
+ *s = "DW_AT_src_info"; break;
+ case DW_AT_mac_info:
+ *s = "DW_AT_mac_info"; break;
+ case DW_AT_src_coords:
+ *s = "DW_AT_src_coords"; break;
+ case DW_AT_body_begin:
+ *s = "DW_AT_body_begin"; break;
+ case DW_AT_body_end:
+ *s = "DW_AT_body_end"; break;
+ case DW_AT_MIPS_fde:
+ *s = "DW_AT_MIPS_fde"; break;
+ case DW_AT_MIPS_loop_begin:
+ *s = "DW_AT_MIPS_loop_begin"; break;
+ case DW_AT_MIPS_tail_loop_begin:
+ *s = "DW_AT_MIPS_tail_loop_begin"; break;
+ case DW_AT_MIPS_epilog_begin:
+ *s = "DW_AT_MIPS_epilog_begin"; break;
+ case DW_AT_MIPS_loop_unroll_factor:
+ *s = "DW_AT_MIPS_loop_unroll_factor"; break;
+ case DW_AT_MIPS_software_pipeline_depth:
+ *s = "DW_AT_MIPS_software_pipeline_depth"; break;
+ case DW_AT_MIPS_linkage_name:
+ *s = "DW_AT_MIPS_linkage_name"; break;
+ case DW_AT_MIPS_stride:
+ *s = "DW_AT_MIPS_stride"; break;
+ case DW_AT_MIPS_abstract_name:
+ *s = "DW_AT_MIPS_abstract_name"; break;
+ case DW_AT_MIPS_clone_origin:
+ *s = "DW_AT_MIPS_clone_origin"; break;
+ case DW_AT_MIPS_has_inlines:
+ *s = "DW_AT_MIPS_has_inlines"; break;
+ case DW_AT_MIPS_stride_byte:
+ *s = "DW_AT_MIPS_stride_byte"; break;
+ case DW_AT_MIPS_stride_elem:
+ *s = "DW_AT_MIPS_stride_elem"; break;
+ case DW_AT_MIPS_ptr_dopetype:
+ *s = "DW_AT_MIPS_ptr_dopetype"; break;
+ case DW_AT_MIPS_allocatable_dopetype:
+ *s = "DW_AT_MIPS_allocatable_dopetype"; break;
+ case DW_AT_MIPS_assumed_shape_dopetype:
+ *s = "DW_AT_MIPS_assumed_shape_dopetype"; break;
+ case DW_AT_MIPS_assumed_size:
+ *s = "DW_AT_MIPS_assumed_size"; break;
+ case DW_AT_GNU_vector:
+ *s = "DW_AT_GNU_vector"; break;
+ case DW_AT_GNU_guarded_by:
+ *s = "DW_AT_GNU_guarded_by"; break;
+ case DW_AT_GNU_pt_guarded_by:
+ *s = "DW_AT_GNU_pt_guarded_by"; break;
+ case DW_AT_GNU_guarded:
+ *s = "DW_AT_GNU_guarded"; break;
+ case DW_AT_GNU_pt_guarded:
+ *s = "DW_AT_GNU_pt_guarded"; break;
+ case DW_AT_GNU_locks_excluded:
+ *s = "DW_AT_GNU_locks_excluded"; break;
+ case DW_AT_GNU_exclusive_locks_required:
+ *s = "DW_AT_GNU_exclusive_locks_required"; break;
+ case DW_AT_GNU_shared_locks_required:
+ *s = "DW_AT_GNU_shared_locks_required"; break;
+ case DW_AT_GNU_odr_signature:
+ *s = "DW_AT_GNU_odr_signature"; break;
+ case DW_AT_GNU_template_name:
+ *s = "DW_AT_GNU_template_name"; break;
+ case DW_AT_GNU_call_site_value:
+ *s = "DW_AT_GNU_call_site_value"; break;
+ case DW_AT_GNU_call_site_data_value:
+ *s = "DW_AT_GNU_call_site_data_value"; break;
+ case DW_AT_GNU_call_site_target:
+ *s = "DW_AT_GNU_call_site_target"; break;
+ case DW_AT_GNU_call_site_target_clobbered:
+ *s = "DW_AT_GNU_call_site_target_clobbered"; break;
+ case DW_AT_GNU_tail_call:
+ *s = "DW_AT_GNU_tail_call"; break;
+ case DW_AT_GNU_all_tail_call_sites:
+ *s = "DW_AT_GNU_all_tail_call_sites"; break;
+ case DW_AT_GNU_all_call_sites:
+ *s = "DW_AT_GNU_all_call_sites"; break;
+ case DW_AT_GNU_all_source_call_sites:
+ *s = "DW_AT_GNU_all_source_call_sites"; break;
+ case DW_AT_APPLE_optimized:
+ *s = "DW_AT_APPLE_optimized"; break;
+ case DW_AT_APPLE_flags:
+ *s = "DW_AT_APPLE_flags"; break;
+ case DW_AT_APPLE_isa:
+ *s = "DW_AT_APPLE_isa"; break;
+ case DW_AT_APPLE_block:
+ *s = "DW_AT_APPLE_block"; break;
+ case DW_AT_APPLE_major_runtime_vers:
+ *s = "DW_AT_APPLE_major_runtime_vers"; break;
+ case DW_AT_APPLE_runtime_class:
+ *s = "DW_AT_APPLE_runtime_class"; break;
+ case DW_AT_APPLE_omit_frame_ptr:
+ *s = "DW_AT_APPLE_omit_frame_ptr"; break;
+ case DW_AT_APPLE_property_name:
+ *s = "DW_AT_APPLE_property_name"; break;
+ case DW_AT_APPLE_property_getter:
+ *s = "DW_AT_APPLE_property_getter"; break;
+ case DW_AT_APPLE_property_setter:
+ *s = "DW_AT_APPLE_property_setter"; break;
+ case DW_AT_APPLE_property_attribute:
+ *s = "DW_AT_APPLE_property_attribute"; break;
+ case DW_AT_APPLE_objc_complete_type:
+ *s = "DW_AT_APPLE_objc_complete_type"; break;
+ case DW_AT_APPLE_property:
+ *s = "DW_AT_APPLE_property"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_ATE_name(unsigned ate, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch(ate) {
+ case DW_ATE_address:
+ *s = "DW_ATE_address"; break;
+ case DW_ATE_boolean:
+ *s = "DW_ATE_boolean"; break;
+ case DW_ATE_complex_float:
+ *s = "DW_ATE_complex_float"; break;
+ case DW_ATE_float:
+ *s = "DW_ATE_float"; break;
+ case DW_ATE_signed:
+ *s = "DW_ATE_signed"; break;
+ case DW_ATE_signed_char:
+ *s = "DW_ATE_signed_char"; break;
+ case DW_ATE_unsigned:
+ *s = "DW_ATE_unsigned"; break;
+ case DW_ATE_unsigned_char:
+ *s = "DW_ATE_unsigned_char"; break;
+ case DW_ATE_imaginary_float:
+ *s = "DW_ATE_imaginary_float"; break;
+ case DW_ATE_packed_decimal:
+ *s = "DW_ATE_packed_decimal"; break;
+ case DW_ATE_numeric_string:
+ *s = "DW_ATE_numeric_string"; break;
+ case DW_ATE_edited:
+ *s = "DW_ATE_edited"; break;
+ case DW_ATE_signed_fixed:
+ *s = "DW_ATE_signed_fixed"; break;
+ case DW_ATE_unsigned_fixed:
+ *s = "DW_ATE_unsigned_fixed"; break;
+ case DW_ATE_decimal_float:
+ *s = "DW_ATE_decimal_float"; break;
+ case DW_ATE_lo_user:
+ *s = "DW_ATE_lo_user"; break;
+ case DW_ATE_hi_user:
+ *s = "DW_ATE_hi_user"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_CC_name(unsigned cc, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (cc) {
+ case DW_CC_normal:
+ *s = "DW_CC_normal"; break;
+ case DW_CC_program:
+ *s = "DW_CC_program"; break;
+ case DW_CC_nocall:
+ *s = "DW_CC_nocall"; break;
+ case DW_CC_lo_user:
+ *s = "DW_CC_lo_user"; break;
+ case DW_CC_hi_user:
+ *s = "DW_CC_hi_user"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_CFA_name(unsigned cfa, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (cfa) {
+ case DW_CFA_advance_loc:
+ *s = "DW_CFA_advance_loc"; break;
+ case DW_CFA_offset:
+ *s = "DW_CFA_offset"; break;
+ case DW_CFA_restore:
+ *s = "DW_CFA_restore"; break;
+ case DW_CFA_nop:
+ *s = "DW_CFA_nop"; break;
+ case DW_CFA_set_loc:
+ *s = "DW_CFA_set_loc"; break;
+ case DW_CFA_advance_loc1:
+ *s = "DW_CFA_advance_loc1"; break;
+ case DW_CFA_advance_loc2:
+ *s = "DW_CFA_advance_loc2"; break;
+ case DW_CFA_advance_loc4:
+ *s = "DW_CFA_advance_loc4"; break;
+ case DW_CFA_offset_extended:
+ *s = "DW_CFA_offset_extended"; break;
+ case DW_CFA_restore_extended:
+ *s = "DW_CFA_restore_extended"; break;
+ case DW_CFA_undefined:
+ *s = "DW_CFA_undefined"; break;
+ case DW_CFA_same_value:
+ *s = "DW_CFA_same_value"; break;
+ case DW_CFA_register:
+ *s = "DW_CFA_register"; break;
+ case DW_CFA_remember_state:
+ *s = "DW_CFA_remember_state"; break;
+ case DW_CFA_restore_state:
+ *s = "DW_CFA_restore_state"; break;
+ case DW_CFA_def_cfa:
+ *s = "DW_CFA_def_cfa"; break;
+ case DW_CFA_def_cfa_register:
+ *s = "DW_CFA_def_cfa_register"; break;
+ case DW_CFA_def_cfa_offset:
+ *s = "DW_CFA_def_cfa_offset"; break;
+ case DW_CFA_def_cfa_expression:
+ *s = "DW_CFA_def_cfa_expression"; break;
+ case DW_CFA_expression:
+ *s = "DW_CFA_expression"; break;
+ case DW_CFA_offset_extended_sf:
+ *s = "DW_CFA_offset_extended_sf"; break;
+ case DW_CFA_def_cfa_sf:
+ *s = "DW_CFA_def_cfa_sf"; break;
+ case DW_CFA_def_cfa_offset_sf:
+ *s = "DW_CFA_def_cfa_offset_sf"; break;
+ case DW_CFA_val_offset:
+ *s = "DW_CFA_val_offset"; break;
+ case DW_CFA_val_offset_sf:
+ *s = "DW_CFA_val_offset_sf"; break;
+ case DW_CFA_val_expression:
+ *s = "DW_CFA_val_expression"; break;
+ case DW_CFA_lo_user:
+ *s = "DW_CFA_lo_user"; break;
+ case DW_CFA_high_user:
+ *s = "DW_CFA_high_user"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_CHILDREN_name(unsigned children, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (children) {
+ case DW_CHILDREN_no:
+ *s = "DW_CHILDREN_no"; break;
+ case DW_CHILDREN_yes:
+ *s = "DW_CHILDREN_yes"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_FORM_name(unsigned form, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (form) {
+ case DW_FORM_addr:
+ *s = "DW_FORM_addr"; break;
+ case DW_FORM_block:
+ *s = "DW_FORM_block"; break;
+ case DW_FORM_block1:
+ *s = "DW_FORM_block1"; break;
+ case DW_FORM_block2:
+ *s = "DW_FORM_block2"; break;
+ case DW_FORM_block4:
+ *s = "DW_FORM_block4"; break;
+ case DW_FORM_data1:
+ *s = "DW_FORM_data1"; break;
+ case DW_FORM_data2:
+ *s = "DW_FORM_data2"; break;
+ case DW_FORM_data4:
+ *s = "DW_FORM_data4"; break;
+ case DW_FORM_data8:
+ *s = "DW_FORM_data8"; break;
+ case DW_FORM_exprloc:
+ *s = "DW_FORM_exprloc"; break;
+ case DW_FORM_flag:
+ *s = "DW_FORM_flag"; break;
+ case DW_FORM_flag_present:
+ *s = "DW_FORM_flag_present"; break;
+ case DW_FORM_indirect:
+ *s = "DW_FORM_indirect"; break;
+ case DW_FORM_ref1:
+ *s = "DW_FORM_ref1"; break;
+ case DW_FORM_ref2:
+ *s = "DW_FORM_ref2"; break;
+ case DW_FORM_ref4:
+ *s = "DW_FORM_ref4"; break;
+ case DW_FORM_ref8:
+ *s = "DW_FORM_ref8"; break;
+ case DW_FORM_ref_addr:
+ *s = "DW_FORM_ref_addr"; break;
+ case DW_FORM_ref_sig8:
+ *s = "DW_FORM_ref_sig8"; break;
+ case DW_FORM_ref_udata:
+ *s = "DW_FORM_ref_udata"; break;
+ case DW_FORM_sdata:
+ *s = "DW_FORM_sdata"; break;
+ case DW_FORM_sec_offset:
+ *s = "DW_FORM_sec_offset"; break;
+ case DW_FORM_string:
+ *s = "DW_FORM_string"; break;
+ case DW_FORM_strp:
+ *s = "DW_FORM_strp"; break;
+ case DW_FORM_udata:
+ *s = "DW_FORM_udata"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_DS_name(unsigned ds, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (ds) {
+ case DW_DS_unsigned:
+ *s = "DW_DS_unsigned"; break;
+ case DW_DS_leading_overpunch:
+ *s = "DW_DS_leading_overpunch"; break;
+ case DW_DS_trailing_overpunch:
+ *s = "DW_DS_trailing_overpunch"; break;
+ case DW_DS_leading_separate:
+ *s = "DW_DS_leading_separate"; break;
+ case DW_DS_trailing_separate:
+ *s = "DW_DS_trailing_separate";
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_DSC_name(unsigned dsc, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (dsc) {
+ case DW_DSC_label:
+ *s = "DW_DSC_label"; break;
+ case DW_DSC_range:
+ *s = "DW_DSC_range"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_EH_name(unsigned eh, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (eh) {
+ case DW_EH_PE_absptr:
+ *s = "DW_EH_PE_absptr"; break;
+ case DW_EH_PE_uleb128:
+ *s = "DW_EH_PE_uleb128"; break;
+ case DW_EH_PE_udata2:
+ *s = "DW_EH_PE_udata2"; break;
+ case DW_EH_PE_udata4:
+ *s = "DW_EH_PE_udata4"; break;
+ case DW_EH_PE_udata8:
+ *s = "DW_EH_PE_udata8"; break;
+ case DW_EH_PE_sleb128:
+ *s = "DW_EH_PE_sleb128"; break;
+ case DW_EH_PE_sdata2:
+ *s = "DW_EH_PE_sdata2"; break;
+ case DW_EH_PE_sdata4:
+ *s = "DW_EH_PE_sdata4"; break;
+ case DW_EH_PE_sdata8:
+ *s = "DW_EH_PE_sdata8"; break;
+ case DW_EH_PE_pcrel:
+ *s = "DW_EH_PE_pcrel"; break;
+ case DW_EH_PE_textrel:
+ *s = "DW_EH_PE_textrel"; break;
+ case DW_EH_PE_datarel:
+ *s = "DW_EH_PE_datarel"; break;
+ case DW_EH_PE_funcrel:
+ *s = "DW_EH_PE_funcrel"; break;
+ case DW_EH_PE_aligned:
+ *s = "DW_EH_PE_aligned"; break;
+ case DW_EH_PE_omit:
+ *s = "DW_EH_PE_omit"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_END_name(unsigned end, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (end) {
+ case DW_END_default:
+ *s = "DW_END_default"; break;
+ case DW_END_big:
+ *s = "DW_END_big"; break;
+ case DW_END_little:
+ *s = "DW_END_little"; break;
+ case DW_END_lo_user:
+ *s = "DW_END_lo_user"; break;
+ case DW_END_high_user:
+ *s = "DW_END_high_user"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_ID_name(unsigned id, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (id) {
+ case DW_ID_case_sensitive:
+ *s = "DW_ID_case_sensitive"; break;
+ case DW_ID_up_case:
+ *s = "DW_ID_up_case"; break;
+ case DW_ID_down_case:
+ *s = "DW_ID_down_case"; break;
+ case DW_ID_case_insensitive:
+ *s = "DW_ID_case_insensitive"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_INL_name(unsigned inl, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (inl) {
+ case DW_INL_not_inlined:
+ *s = "DW_INL_not_inlined"; break;
+ case DW_INL_inlined:
+ *s = "DW_INL_inlined"; break;
+ case DW_INL_declared_not_inlined:
+ *s = "DW_INL_declared_not_inlined"; break;
+ case DW_INL_declared_inlined:
+ *s = "DW_INL_declared_inlined"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_LANG_name(unsigned lang, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (lang) {
+ case DW_LANG_C89:
+ *s = "DW_LANG_C89"; break;
+ case DW_LANG_C:
+ *s = "DW_LANG_C"; break;
+ case DW_LANG_Ada83:
+ *s = "DW_LANG_Ada83"; break;
+ case DW_LANG_C_plus_plus:
+ *s = "DW_LANG_C_plus_plus"; break;
+ case DW_LANG_Cobol74:
+ *s = "DW_LANG_Cobol74"; break;
+ case DW_LANG_Cobol85:
+ *s = "DW_LANG_Cobol85"; break;
+ case DW_LANG_Fortran77:
+ *s = "DW_LANG_Fortran77"; break;
+ case DW_LANG_Fortran90:
+ *s = "DW_LANG_Fortran90"; break;
+ case DW_LANG_Pascal83:
+ *s = "DW_LANG_Pascal83"; break;
+ case DW_LANG_Modula2:
+ *s = "DW_LANG_Modula2"; break;
+ case DW_LANG_Java:
+ *s = "DW_LANG_Java"; break;
+ case DW_LANG_C99:
+ *s = "DW_LANG_C99"; break;
+ case DW_LANG_Ada95:
+ *s = "DW_LANG_Ada95"; break;
+ case DW_LANG_Fortran95:
+ *s = "DW_LANG_Fortran95"; break;
+ case DW_LANG_PLI:
+ *s = "DW_LANG_PLI"; break;
+ case DW_LANG_ObjC:
+ *s = "DW_LANG_ObjC"; break;
+ case DW_LANG_ObjC_plus_plus:
+ *s = "DW_LANG_ObjC_plus_plus"; break;
+ case DW_LANG_UPC:
+ *s = "DW_LANG_UPC"; break;
+ case DW_LANG_D:
+ *s = "DW_LANG_D"; break;
+ case DW_LANG_lo_user:
+ *s = "DW_LANG_lo_user"; break;
+ case DW_LANG_Mips_Assembler:
+ *s = "DW_LANG_Mips_Assembler"; break;
+ case DW_LANG_hi_user:
+ *s = "DW_LANG_hi_user"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_LNE_name(unsigned lne, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (lne) {
+ case DW_LNE_end_sequence:
+ *s = "DW_LNE_end_sequence"; break;
+ case DW_LNE_set_address:
+ *s = "DW_LNE_set_address"; break;
+ case DW_LNE_define_file:
+ *s = "DW_LNE_define_file"; break;
+ case DW_LNE_lo_user:
+ *s = "DW_LNE_lo_user"; break;
+ case DW_LNE_hi_user:
+ *s = "DW_LNE_hi_user"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_LNS_name(unsigned lns, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (lns) {
+ case DW_LNS_copy:
+ *s = "DW_LNS_copy"; break;
+ case DW_LNS_advance_pc:
+ *s = "DW_LNS_advance_pc"; break;
+ case DW_LNS_advance_line:
+ *s = "DW_LNS_advance_line"; break;
+ case DW_LNS_set_file:
+ *s = "DW_LNS_set_file"; break;
+ case DW_LNS_set_column:
+ *s = "DW_LNS_set_column"; break;
+ case DW_LNS_negate_stmt:
+ *s = "DW_LNS_negate_stmt"; break;
+ case DW_LNS_set_basic_block:
+ *s = "DW_LNS_set_basic_block"; break;
+ case DW_LNS_const_add_pc:
+ *s = "DW_LNS_const_add_pc"; break;
+ case DW_LNS_fixed_advance_pc:
+ *s = "DW_LNS_fixed_advance_pc"; break;
+ case DW_LNS_set_prologue_end:
+ *s = "DW_LNS_set_prologue_end"; break;
+ case DW_LNS_set_epilogue_begin:
+ *s = "DW_LNS_set_epilogue_begin"; break;
+ case DW_LNS_set_isa:
+ *s = "DW_LNS_set_isa"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_MACINFO_name(unsigned mi, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (mi) {
+ case DW_MACINFO_define:
+ *s = "DW_MACINFO_define"; break;
+ case DW_MACINFO_undef:
+ *s = "DW_MACINFO_undef"; break;
+ case DW_MACINFO_start_file:
+ *s = "DW_MACINFO_start_file"; break;
+ case DW_MACINFO_end_file:
+ *s = "DW_MACINFO_end_file"; break;
+ case DW_MACINFO_vendor_ext:
+ *s = "DW_MACINFO_vendor_ext"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_OP_name(unsigned op, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (op) {
+ case DW_OP_deref:
+ *s = "DW_OP_deref"; break;
+ case DW_OP_reg0:
+ *s = "DW_OP_reg0"; break;
+ case DW_OP_reg1:
+ *s = "DW_OP_reg1"; break;
+ case DW_OP_reg2:
+ *s = "DW_OP_reg2"; break;
+ case DW_OP_reg3:
+ *s = "DW_OP_reg3"; break;
+ case DW_OP_reg4:
+ *s = "DW_OP_reg4"; break;
+ case DW_OP_reg5:
+ *s = "DW_OP_reg5"; break;
+ case DW_OP_reg6:
+ *s = "DW_OP_reg6"; break;
+ case DW_OP_reg7:
+ *s = "DW_OP_reg7"; break;
+ case DW_OP_reg8:
+ *s = "DW_OP_reg8"; break;
+ case DW_OP_reg9:
+ *s = "DW_OP_reg9"; break;
+ case DW_OP_reg10:
+ *s = "DW_OP_reg10"; break;
+ case DW_OP_reg11:
+ *s = "DW_OP_reg11"; break;
+ case DW_OP_reg12:
+ *s = "DW_OP_reg12"; break;
+ case DW_OP_reg13:
+ *s = "DW_OP_reg13"; break;
+ case DW_OP_reg14:
+ *s = "DW_OP_reg14"; break;
+ case DW_OP_reg15:
+ *s = "DW_OP_reg15"; break;
+ case DW_OP_reg16:
+ *s = "DW_OP_reg16"; break;
+ case DW_OP_reg17:
+ *s = "DW_OP_reg17"; break;
+ case DW_OP_reg18:
+ *s = "DW_OP_reg18"; break;
+ case DW_OP_reg19:
+ *s = "DW_OP_reg19"; break;
+ case DW_OP_reg20:
+ *s = "DW_OP_reg20"; break;
+ case DW_OP_reg21:
+ *s = "DW_OP_reg21"; break;
+ case DW_OP_reg22:
+ *s = "DW_OP_reg22"; break;
+ case DW_OP_reg23:
+ *s = "DW_OP_reg23"; break;
+ case DW_OP_reg24:
+ *s = "DW_OP_reg24"; break;
+ case DW_OP_reg25:
+ *s = "DW_OP_reg25"; break;
+ case DW_OP_reg26:
+ *s = "DW_OP_reg26"; break;
+ case DW_OP_reg27:
+ *s = "DW_OP_reg27"; break;
+ case DW_OP_reg28:
+ *s = "DW_OP_reg28"; break;
+ case DW_OP_reg29:
+ *s = "DW_OP_reg29"; break;
+ case DW_OP_reg30:
+ *s = "DW_OP_reg30"; break;
+ case DW_OP_reg31:
+ *s = "DW_OP_reg31"; break;
+ case DW_OP_lit0:
+ *s = "DW_OP_lit0"; break;
+ case DW_OP_lit1:
+ *s = "DW_OP_lit1"; break;
+ case DW_OP_lit2:
+ *s = "DW_OP_lit2"; break;
+ case DW_OP_lit3:
+ *s = "DW_OP_lit3"; break;
+ case DW_OP_lit4:
+ *s = "DW_OP_lit4"; break;
+ case DW_OP_lit5:
+ *s = "DW_OP_lit5"; break;
+ case DW_OP_lit6:
+ *s = "DW_OP_lit6"; break;
+ case DW_OP_lit7:
+ *s = "DW_OP_lit7"; break;
+ case DW_OP_lit8:
+ *s = "DW_OP_lit8"; break;
+ case DW_OP_lit9:
+ *s = "DW_OP_lit9"; break;
+ case DW_OP_lit10:
+ *s = "DW_OP_lit10"; break;
+ case DW_OP_lit11:
+ *s = "DW_OP_lit11"; break;
+ case DW_OP_lit12:
+ *s = "DW_OP_lit12"; break;
+ case DW_OP_lit13:
+ *s = "DW_OP_lit13"; break;
+ case DW_OP_lit14:
+ *s = "DW_OP_lit14"; break;
+ case DW_OP_lit15:
+ *s = "DW_OP_lit15"; break;
+ case DW_OP_lit16:
+ *s = "DW_OP_lit16"; break;
+ case DW_OP_lit17:
+ *s = "DW_OP_lit17"; break;
+ case DW_OP_lit18:
+ *s = "DW_OP_lit18"; break;
+ case DW_OP_lit19:
+ *s = "DW_OP_lit19"; break;
+ case DW_OP_lit20:
+ *s = "DW_OP_lit20"; break;
+ case DW_OP_lit21:
+ *s = "DW_OP_lit21"; break;
+ case DW_OP_lit22:
+ *s = "DW_OP_lit22"; break;
+ case DW_OP_lit23:
+ *s = "DW_OP_lit23"; break;
+ case DW_OP_lit24:
+ *s = "DW_OP_lit24"; break;
+ case DW_OP_lit25:
+ *s = "DW_OP_lit25"; break;
+ case DW_OP_lit26:
+ *s = "DW_OP_lit26"; break;
+ case DW_OP_lit27:
+ *s = "DW_OP_lit27"; break;
+ case DW_OP_lit28:
+ *s = "DW_OP_lit28"; break;
+ case DW_OP_lit29:
+ *s = "DW_OP_lit29"; break;
+ case DW_OP_lit30:
+ *s = "DW_OP_lit30"; break;
+ case DW_OP_lit31:
+ *s = "DW_OP_lit31"; break;
+ case DW_OP_dup:
+ *s = "DW_OP_dup"; break;
+ case DW_OP_drop:
+ *s = "DW_OP_drop"; break;
+ case DW_OP_over:
+ *s = "DW_OP_over"; break;
+ case DW_OP_swap:
+ *s = "DW_OP_swap"; break;
+ case DW_OP_rot:
+ *s = "DW_OP_rot"; break;
+ case DW_OP_xderef:
+ *s = "DW_OP_xderef"; break;
+ case DW_OP_abs:
+ *s = "DW_OP_abs"; break;
+ case DW_OP_and:
+ *s = "DW_OP_and"; break;
+ case DW_OP_div:
+ *s = "DW_OP_div"; break;
+ case DW_OP_minus:
+ *s = "DW_OP_minus"; break;
+ case DW_OP_mod:
+ *s = "DW_OP_mod"; break;
+ case DW_OP_mul:
+ *s = "DW_OP_mul"; break;
+ case DW_OP_neg:
+ *s = "DW_OP_neg"; break;
+ case DW_OP_not:
+ *s = "DW_OP_not"; break;
+ case DW_OP_or:
+ *s = "DW_OP_or"; break;
+ case DW_OP_plus:
+ *s = "DW_OP_plus"; break;
+ case DW_OP_shl:
+ *s = "DW_OP_shl"; break;
+ case DW_OP_shr:
+ *s = "DW_OP_shr"; break;
+ case DW_OP_shra:
+ *s = "DW_OP_shra"; break;
+ case DW_OP_xor:
+ *s = "DW_OP_xor"; break;
+ case DW_OP_eq:
+ *s = "DW_OP_eq"; break;
+ case DW_OP_ge:
+ *s = "DW_OP_ge"; break;
+ case DW_OP_gt:
+ *s = "DW_OP_gt"; break;
+ case DW_OP_le:
+ *s = "DW_OP_le"; break;
+ case DW_OP_lt:
+ *s = "DW_OP_lt"; break;
+ case DW_OP_ne:
+ *s = "DW_OP_ne"; break;
+ case DW_OP_nop:
+ *s = "DW_OP_nop"; break;
+ case DW_OP_const1u:
+ *s = "DW_OP_const1u"; break;
+ case DW_OP_const1s:
+ *s = "DW_OP_const1s"; break;
+ case DW_OP_pick:
+ *s = "DW_OP_pick"; break;
+ case DW_OP_deref_size:
+ *s = "DW_OP_deref_size"; break;
+ case DW_OP_xderef_size:
+ *s = "DW_OP_xderef_size"; break;
+ case DW_OP_const2u:
+ *s = "DW_OP_const2u"; break;
+ case DW_OP_const2s:
+ *s = "DW_OP_const2s"; break;
+ case DW_OP_bra:
+ *s = "DW_OP_bra"; break;
+ case DW_OP_skip:
+ *s = "DW_OP_skip"; break;
+ case DW_OP_const4u:
+ *s = "DW_OP_const4u"; break;
+ case DW_OP_const4s:
+ *s = "DW_OP_const4s"; break;
+ case DW_OP_const8u:
+ *s = "DW_OP_const8u"; break;
+ case DW_OP_const8s:
+ *s = "DW_OP_const8s"; break;
+ case DW_OP_constu:
+ *s = "DW_OP_constu"; break;
+ case DW_OP_plus_uconst:
+ *s = "DW_OP_plus_uconst"; break;
+ case DW_OP_regx:
+ *s = "DW_OP_regx"; break;
+ case DW_OP_piece:
+ *s = "DW_OP_piece"; break;
+ case DW_OP_consts:
+ *s = "DW_OP_consts"; break;
+ case DW_OP_breg0:
+ *s = "DW_OP_breg0"; break;
+ case DW_OP_breg1:
+ *s = "DW_OP_breg1"; break;
+ case DW_OP_breg2:
+ *s = "DW_OP_breg2"; break;
+ case DW_OP_breg3:
+ *s = "DW_OP_breg3"; break;
+ case DW_OP_breg4:
+ *s = "DW_OP_breg4"; break;
+ case DW_OP_breg5:
+ *s = "DW_OP_breg5"; break;
+ case DW_OP_breg6:
+ *s = "DW_OP_breg6"; break;
+ case DW_OP_breg7:
+ *s = "DW_OP_breg7"; break;
+ case DW_OP_breg8:
+ *s = "DW_OP_breg8"; break;
+ case DW_OP_breg9:
+ *s = "DW_OP_breg9"; break;
+ case DW_OP_breg10:
+ *s = "DW_OP_breg10"; break;
+ case DW_OP_breg11:
+ *s = "DW_OP_breg11"; break;
+ case DW_OP_breg12:
+ *s = "DW_OP_breg12"; break;
+ case DW_OP_breg13:
+ *s = "DW_OP_breg13"; break;
+ case DW_OP_breg14:
+ *s = "DW_OP_breg14"; break;
+ case DW_OP_breg15:
+ *s = "DW_OP_breg15"; break;
+ case DW_OP_breg16:
+ *s = "DW_OP_breg16"; break;
+ case DW_OP_breg17:
+ *s = "DW_OP_breg17"; break;
+ case DW_OP_breg18:
+ *s = "DW_OP_breg18"; break;
+ case DW_OP_breg19:
+ *s = "DW_OP_breg19"; break;
+ case DW_OP_breg20:
+ *s = "DW_OP_breg20"; break;
+ case DW_OP_breg21:
+ *s = "DW_OP_breg21"; break;
+ case DW_OP_breg22:
+ *s = "DW_OP_breg22"; break;
+ case DW_OP_breg23:
+ *s = "DW_OP_breg23"; break;
+ case DW_OP_breg24:
+ *s = "DW_OP_breg24"; break;
+ case DW_OP_breg25:
+ *s = "DW_OP_breg25"; break;
+ case DW_OP_breg26:
+ *s = "DW_OP_breg26"; break;
+ case DW_OP_breg27:
+ *s = "DW_OP_breg27"; break;
+ case DW_OP_breg28:
+ *s = "DW_OP_breg28"; break;
+ case DW_OP_breg29:
+ *s = "DW_OP_breg29"; break;
+ case DW_OP_breg30:
+ *s = "DW_OP_breg30"; break;
+ case DW_OP_breg31:
+ *s = "DW_OP_breg31"; break;
+ case DW_OP_fbreg:
+ *s = "DW_OP_fbreg"; break;
+ case DW_OP_bregx:
+ *s = "DW_OP_bregx"; break;
+ case DW_OP_addr:
+ *s = "DW_OP_addr"; break;
+ case DW_OP_push_object_address:
+ *s = "DW_OP_push_object_address"; break;
+ case DW_OP_call2:
+ *s = "DW_OP_call2"; break;
+ case DW_OP_call4:
+ *s = "DW_OP_call4"; break;
+ case DW_OP_call_ref:
+ *s = "DW_OP_call_ref"; break;
+ case DW_OP_form_tls_address:
+ *s = "DW_OP_form_tls_address"; break;
+ case DW_OP_call_frame_cfa:
+ *s = "DW_OP_call_frame_cfa"; break;
+ case DW_OP_bit_piece:
+ *s = "DW_OP_bit_piece"; break;
+ case DW_OP_implicit_value:
+ *s = "DW_OP_implicit_value"; break;
+ case DW_OP_stack_value:
+ *s = "DW_OP_stack_value"; break;
+ case DW_OP_GNU_push_tls_address:
+ *s = "DW_OP_GNU_push_tls_address"; break;
+ case DW_OP_GNU_uninit:
+ *s = "DW_OP_GNU_uninit"; break;
+ case DW_OP_GNU_encoded_addr:
+ *s = "DW_OP_GNU_encoded_addr"; break;
+ case DW_OP_GNU_implicit_pointer:
+ *s = "DW_OP_GNU_implicit_pointer"; break;
+ case DW_OP_GNU_entry_value:
+ *s = "DW_OP_GNU_entry_value"; break;
+ case DW_OP_GNU_const_type:
+ *s = "DW_OP_GNU_const_type"; break;
+ case DW_OP_GNU_regval_type:
+ *s = "DW_OP_GNU_regval_type"; break;
+ case DW_OP_GNU_deref_type:
+ *s = "DW_OP_GNU_deref_type"; break;
+ case DW_OP_GNU_convert:
+ *s = "DW_OP_GNU_convert"; break;
+ case DW_OP_GNU_reinterpret:
+ *s = "DW_OP_GNU_reinterpret"; break;
+ case DW_OP_GNU_parameter_ref:
+ *s = "DW_OP_GNU_parameter_ref"; break;
+ case DW_OP_GNU_addr_index:
+ *s = "DW_OP_GNU_addr_index"; break;
+ case DW_OP_GNU_const_index:
+ *s = "DW_OP_GNU_const_index"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_ORD_name(unsigned ord, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (ord) {
+ case DW_ORD_row_major:
+ *s = "DW_ORD_row_major"; break;
+ case DW_ORD_col_major:
+ *s = "DW_ORD_col_major"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_TAG_name(unsigned tag, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (tag) {
+ case DW_TAG_access_declaration:
+ *s = "DW_TAG_access_declaration"; break;
+ case DW_TAG_array_type:
+ *s = "DW_TAG_array_type"; break;
+ case DW_TAG_base_type:
+ *s = "DW_TAG_base_type"; break;
+ case DW_TAG_catch_block:
+ *s = "DW_TAG_catch_block"; break;
+ case DW_TAG_class_type:
+ *s = "DW_TAG_class_type"; break;
+ case DW_TAG_common_block:
+ *s = "DW_TAG_common_block"; break;
+ case DW_TAG_common_inclusion:
+ *s = "DW_TAG_common_inclusion"; break;
+ case DW_TAG_compile_unit:
+ *s = "DW_TAG_compile_unit"; break;
+ case DW_TAG_condition:
+ *s = "DW_TAG_condition"; break;
+ case DW_TAG_const_type:
+ *s = "DW_TAG_const_type"; break;
+ case DW_TAG_constant:
+ *s = "DW_TAG_constant"; break;
+ case DW_TAG_dwarf_procedure:
+ *s = "DW_TAG_dwarf_procedure"; break;
+ case DW_TAG_entry_point:
+ *s = "DW_TAG_entry_point"; break;
+ case DW_TAG_enumeration_type:
+ *s = "DW_TAG_enumeration_type"; break;
+ case DW_TAG_enumerator:
+ *s = "DW_TAG_enumerator"; break;
+ case DW_TAG_formal_parameter:
+ *s = "DW_TAG_formal_parameter"; break;
+ case DW_TAG_friend:
+ *s = "DW_TAG_friend"; break;
+ case DW_TAG_imported_declaration:
+ *s = "DW_TAG_imported_declaration"; break;
+ case DW_TAG_imported_module:
+ *s = "DW_TAG_imported_module"; break;
+ case DW_TAG_imported_unit:
+ *s = "DW_TAG_imported_unit"; break;
+ case DW_TAG_inheritance:
+ *s = "DW_TAG_inheritance"; break;
+ case DW_TAG_inlined_subroutine:
+ *s = "DW_TAG_inlined_subroutine"; break;
+ case DW_TAG_interface_type:
+ *s = "DW_TAG_interface_type"; break;
+ case DW_TAG_label:
+ *s = "DW_TAG_label"; break;
+ case DW_TAG_lexical_block:
+ *s = "DW_TAG_lexical_block"; break;
+ case DW_TAG_member:
+ *s = "DW_TAG_member"; break;
+ case DW_TAG_module:
+ *s = "DW_TAG_module"; break;
+ case DW_TAG_namelist:
+ *s = "DW_TAG_namelist"; break;
+ case DW_TAG_namelist_item:
+ *s = "DW_TAG_namelist_item"; break;
+ case DW_TAG_namespace:
+ *s = "DW_TAG_namespace"; break;
+ case DW_TAG_packed_type:
+ *s = "DW_TAG_packed_type"; break;
+ case DW_TAG_partial_unit:
+ *s = "DW_TAG_partial_unit"; break;
+ case DW_TAG_pointer_type:
+ *s = "DW_TAG_pointer_type"; break;
+ case DW_TAG_ptr_to_member_type:
+ *s = "DW_TAG_ptr_to_member_type"; break;
+ case DW_TAG_reference_type:
+ *s = "DW_TAG_reference_type"; break;
+ case DW_TAG_restrict_type:
+ *s = "DW_TAG_restrict_type"; break;
+ case DW_TAG_rvalue_reference_type:
+ *s = "DW_TAG_rvalue_reference_type"; break;
+ case DW_TAG_set_type:
+ *s = "DW_TAG_set_type"; break;
+ case DW_TAG_shared_type:
+ *s = "DW_TAG_shared_type"; break;
+ case DW_TAG_string_type:
+ *s = "DW_TAG_string_type"; break;
+ case DW_TAG_structure_type:
+ *s = "DW_TAG_structure_type"; break;
+ case DW_TAG_subprogram:
+ *s = "DW_TAG_subprogram"; break;
+ case DW_TAG_subrange_type:
+ *s = "DW_TAG_subrange_type"; break;
+ case DW_TAG_subroutine_type:
+ *s = "DW_TAG_subroutine_type"; break;
+ case DW_TAG_template_alias:
+ *s = "DW_TAG_template_alias"; break;
+ case DW_TAG_template_type_parameter:
+ *s = "DW_TAG_template_type_parameter"; break;
+ case DW_TAG_template_value_parameter:
+ *s = "DW_TAG_template_value_parameter"; break;
+ case DW_TAG_thrown_type:
+ *s = "DW_TAG_thrown_type"; break;
+ case DW_TAG_try_block:
+ *s = "DW_TAG_try_block"; break;
+ case DW_TAG_type_unit:
+ *s = "DW_TAG_type_unit"; break;
+ case DW_TAG_typedef:
+ *s = "DW_TAG_typedef"; break;
+ case DW_TAG_union_type:
+ *s = "DW_TAG_union_type"; break;
+ case DW_TAG_unspecified_parameters:
+ *s = "DW_TAG_unspecified_parameters"; break;
+ case DW_TAG_unspecified_type:
+ *s = "DW_TAG_unspecified_type"; break;
+ case DW_TAG_variable:
+ *s = "DW_TAG_variable"; break;
+ case DW_TAG_variant:
+ *s = "DW_TAG_variant"; break;
+ case DW_TAG_variant_part:
+ *s = "DW_TAG_variant_part"; break;
+ case DW_TAG_volatile_type:
+ *s = "DW_TAG_volatile_type"; break;
+ case DW_TAG_with_stmt:
+ *s = "DW_TAG_with_stmt"; break;
+ case DW_TAG_format_label:
+ *s = "DW_TAG_format_label"; break;
+ case DW_TAG_function_template:
+ *s = "DW_TAG_function_template"; break;
+ case DW_TAG_class_template:
+ *s = "DW_TAG_class_template"; break;
+ case DW_TAG_GNU_BINCL:
+ *s = "DW_TAG_GNU_BINCL"; break;
+ case DW_TAG_GNU_EINCL:
+ *s = "DW_TAG_GNU_EINCL"; break;
+ case DW_TAG_GNU_template_template_param:
+ *s = "DW_TAG_GNU_template_template_param"; break;
+ case DW_TAG_GNU_template_parameter_pack:
+ *s = "DW_TAG_GNU_template_parameter_pack"; break;
+ case DW_TAG_GNU_formal_parameter_pack:
+ *s = "DW_TAG_GNU_formal_parameter_pack"; break;
+ case DW_TAG_GNU_call_site:
+ *s = "DW_TAG_GNU_call_site"; break;
+ case DW_TAG_GNU_call_site_parameter:
+ *s = "DW_TAG_GNU_call_site_parameter"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_VIRTUALITY_name(unsigned vir, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (vir) {
+ case DW_VIRTUALITY_none:
+ *s = "DW_VIRTUALITY_none"; break;
+ case DW_VIRTUALITY_virtual:
+ *s = "DW_VIRTUALITY_virtual"; break;
+ case DW_VIRTUALITY_pure_virtual:
+ *s = "DW_VIRTUALITY_pure_virtual"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_VIS_name(unsigned vis, const char **s)
+{
+
+ assert(s != NULL);
+
+ switch (vis) {
+ case DW_VIS_local:
+ *s = "DW_VIS_local"; break;
+ case DW_VIS_exported:
+ *s = "DW_VIS_exported"; break;
+ case DW_VIS_qualified:
+ *s = "DW_VIS_qualified"; break;
+ default:
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_end_macro_file.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_end_macro_file.3
new file mode 100644
index 0000000..a4de18c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_end_macro_file.3
@@ -0,0 +1,90 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_end_macro_file.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd September 25, 2011
+.Os
+.Dt DWARF_END_MACRO_FILE 3
+.Sh NAME
+.Nm dwarf_end_macro_file
+.Nd mark the end of the current source file inclusion
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "int"
+.Fo dwarf_end_macro_file
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Error *err"
+.Fa
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_end_macro_file
+marks the end of the current source file inclusion.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_end_macro_file
+returns
+.Dv DW_DLV_OK .
+In case of an error, function
+.Fn dwarf_end_macro_file
+returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_end_macro_file
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_def_macro 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3 ,
+.Xr dwarf_start_macro_file 3 ,
+.Xr dwarf_undef_macro 3 ,
+.Xr dwarf_vendor_ext 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_errmsg.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_errmsg.3
new file mode 100644
index 0000000..466c091
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_errmsg.3
@@ -0,0 +1,67 @@
+.\" Copyright (c) 2009 Joseph Koshy. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" This software is provided by Joseph Koshy ``as is'' and
+.\" any express or implied warranties, including, but not limited to, the
+.\" implied warranties of merchantability and fitness for a particular purpose
+.\" are disclaimed. in no event shall Joseph Koshy be liable
+.\" for any direct, indirect, incidental, special, exemplary, or consequential
+.\" damages (including, but not limited to, procurement of substitute goods
+.\" or services; loss of use, data, or profits; or business interruption)
+.\" however caused and on any theory of liability, whether in contract, strict
+.\" liability, or tort (including negligence or otherwise) arising in any way
+.\" out of the use of this software, even if advised of the possibility of
+.\" such damage.
+.\"
+.\" $Id: dwarf_errmsg.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd December 12, 2009
+.Os
+.Dt DWARF_ERRMSG 3
+.Sh NAME
+.Nm dwarf_errmsg
+.Nd retrieve a human-readable string corresponding to a
+.Vt Dwarf_Error
+instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "const char *"
+.Fn dwarf_errmsg "Dwarf_Error err"
+.Sh DESCRIPTION
+Function
+.Fn dwarf_errmsg
+returns a
+.Dv NUL Ns - Ns
+terminated string for the error denoted by
+argument
+.Ar err .
+.Pp
+Argument
+.Ar err
+should be a valid handle to a
+.Vt Dwarf_Error
+instance.
+.Sh Memory Management
+The returned pointer should not be freed using
+.Xr free 3
+or
+.Xr dwarf_dealloc 3 .
+.Sh RETURN VALUES
+Function
+.Fn dwarf_errmsg
+returns a pointer to a
+.Dv NUL Ns - Ns
+terminated string.
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_errno 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_errmsg.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_errmsg.c
new file mode 100644
index 0000000..e300893
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_errmsg.c
@@ -0,0 +1,90 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_errmsg.c 2975 2014-01-21 20:08:04Z kaiwang27 $");
+
+static const char *_libdwarf_errors[] = {
+#define DEFINE_ERROR(N,S) [DW_DLE_##N] = S
+ DEFINE_ERROR(NONE, "No Error"),
+ DEFINE_ERROR(ERROR, "An error"),
+ DEFINE_ERROR(NO_ENTRY, "No entry found"),
+ DEFINE_ERROR(ARGUMENT, "Invalid argument"),
+ DEFINE_ERROR(DEBUG_INFO_NULL, "Debug info NULL"),
+ DEFINE_ERROR(MEMORY, "Insufficient memory"),
+ DEFINE_ERROR(ELF, "ELF error"),
+ DEFINE_ERROR(CU_LENGTH_ERROR, "Invalid compilation unit data"),
+ DEFINE_ERROR(VERSION_STAMP_ERROR, "Unsupported version"),
+ DEFINE_ERROR(DEBUG_ABBREV_NULL, "Abbrev not found"),
+ DEFINE_ERROR(DIE_NO_CU_CONTEXT, "No current compilation unit"),
+ DEFINE_ERROR(LOC_EXPR_BAD, "Invalid location expression"),
+ DEFINE_ERROR(EXPR_LENGTH_BAD, "Invalid DWARF expression length"),
+ DEFINE_ERROR(DEBUG_LOC_SECTION_SHORT, "Loclist section too short"),
+ DEFINE_ERROR(ATTR_FORM_BAD, "Invalid attribute form"),
+ DEFINE_ERROR(DEBUG_LINE_LENGTH_BAD, "Line info section too short"),
+ DEFINE_ERROR(LINE_FILE_NUM_BAD, "Invalid file number."),
+ DEFINE_ERROR(DIR_INDEX_BAD, "Invalid dir index."),
+ DEFINE_ERROR(DEBUG_FRAME_LENGTH_BAD, "Frame section too short"),
+ DEFINE_ERROR(NO_CIE_FOR_FDE, "FDE without corresponding CIE"),
+ DEFINE_ERROR(FRAME_AUGMENTATION_UNKNOWN, "Unknown CIE augmentation"),
+ DEFINE_ERROR(FRAME_INSTR_EXEC_ERROR, "Frame instruction exec error"),
+ DEFINE_ERROR(FRAME_VERSION_BAD, "Unsupported frame section version"),
+ DEFINE_ERROR(FRAME_TABLE_COL_BAD, "Invalid table column value"),
+ DEFINE_ERROR(DF_REG_NUM_TOO_HIGH, "Register number too large"),
+ DEFINE_ERROR(PC_NOT_IN_FDE_RANGE, "PC requested not in the FDE range"),
+ DEFINE_ERROR(ARANGE_OFFSET_BAD, "Invalid address range offset"),
+ DEFINE_ERROR(DEBUG_MACRO_INCONSISTENT, "Invalid macinfo data"),
+ DEFINE_ERROR(ELF_SECT_ERR, "Application callback failed"),
+ DEFINE_ERROR(NUM, "Unknown DWARF error")
+#undef DEFINE_ERROR
+};
+
+const char *
+dwarf_errmsg_(Dwarf_Error *error)
+{
+ const char *p;
+
+ if (error == NULL)
+ return NULL;
+
+ if (error->err_error < 0 || error->err_error >= DW_DLE_NUM)
+ return _libdwarf_errors[DW_DLE_NUM];
+ else if (error->err_error == DW_DLE_NONE)
+ return _libdwarf_errors[DW_DLE_NONE];
+ else
+ p = _libdwarf_errors[error->err_error];
+
+ if (error->err_error == DW_DLE_ELF)
+ snprintf(error->err_msg, sizeof(error->err_msg),
+ "ELF error : %s [%s(%d)]", elf_errmsg(error->err_elferror),
+ error->err_func, error->err_line);
+ else
+ snprintf(error->err_msg, sizeof(error->err_msg),
+ "%s [%s(%d)]", p, error->err_func, error->err_line);
+
+ return (const char *) error->err_msg;
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_errno.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_errno.3
new file mode 100644
index 0000000..7e1a1eb
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_errno.3
@@ -0,0 +1,58 @@
+.\" Copyright (c) 2009,2010 Joseph Koshy. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" This software is provided by Joseph Koshy ``as is'' and
+.\" any express or implied warranties, including, but not limited to, the
+.\" implied warranties of merchantability and fitness for a particular purpose
+.\" are disclaimed. in no event shall Joseph Koshy be liable
+.\" for any direct, indirect, incidental, special, exemplary, or consequential
+.\" damages (including, but not limited to, procurement of substitute goods
+.\" or services; loss of use, data, or profits; or business interruption)
+.\" however caused and on any theory of liability, whether in contract, strict
+.\" liability, or tort (including negligence or otherwise) arising in any way
+.\" out of the use of this software, even if advised of the possibility of
+.\" such damage.
+.\"
+.\" $Id: dwarf_errno.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd March 25, 2010
+.Os
+.Dt DWARF_ERRNO 3
+.Sh NAME
+.Nm dwarf_errno
+.Nd retrieve the error number corresponding to a
+.Vt Dwarf_Error
+instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fn dwarf_errno "Dwarf_Error err"
+.Sh DESCRIPTION
+Function
+.Fn dwarf_errno
+returns the error number associated with a
+.Vt Dwarf_Error
+instance.
+.Pp
+Argument
+.Ar err
+should be a valid handle to a
+.Vt Dwarf_Error
+instance.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_errno
+returns an integral value.
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_errmsg 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3
new file mode 100644
index 0000000..7bcd105
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3
@@ -0,0 +1,182 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_expand_frame_instructions.3 3181 2015-04-10 13:22:51Z emaste $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_EXPAND_FRAME_INSTRUCTIONS 3
+.Sh NAME
+.Nm dwarf_expand_frame_instructions
+.Nd expand frame instructions
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_expand_frame_instructions
+.Fa "Dwarf_Cie cie"
+.Fa "Dwarf_Ptr instructions"
+.Fa "Dwarf_Unsigned len"
+.Fa "Dwarf_Frame_Op **ret_ops"
+.Fa "Dwarf_Signed *ret_opcnt"
+.Fa "Dwarf_Error *error"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_expand_frame_instructions
+translates DWARF frame instruction bytes into an array of
+.Vt Dwarf_Frame_Op
+descriptors.
+.Pp
+Argument
+.Ar cie
+should reference the CIE descriptor associated with the instructions
+to be translated.
+.Pp
+Arugment
+.Ar instructions
+should point to an array of frame instruction bytes, as
+returned by the functions
+.Xr dwarf_get_cie_info 3
+or
+.Xr dwarf_get_fde_instr_bytes 3 .
+.Pp
+Argument
+.Ar len
+should specify the number of the frame instruction bytes to be
+translated.
+.Pp
+Argument
+.Ar ret_ops
+should point to a location that will be set to a pointer to
+an array of translated
+.Vt Dwarf_Frame_Op
+descriptors.
+.Pp
+Argument
+.Ar ret_opcnt
+should point to a location that will hold the total number of the
+returned descriptors.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Ss Memory Management
+The memory area used for the descriptor array returned in argument
+.Ar ret_ops
+is allocated by
+.Lb libdwarf .
+Application code should use function
+.Xr dwarf_dealloc 3
+with type
+.Dv DW_DLA_FRAME_BLOCK
+to free the memory area when the descriptor array is no longer needed.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_expand_frame_instructions
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_expand_frame_instructions
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar cie ,
+.Ar instructions ,
+.Ar ret_ops
+or
+.Ar ret_opcnt
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar len
+was 0.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+this function.
+.It Bq Er DW_DLE_FRAME_INSTR_EXEC_ERROR
+An unknown instruction was found in the instruction bytes provided
+in argument
+.Ar instructions .
+.El
+.Sh EXAMPLE
+To retrieve and expand the frame instructions for a given FDE
+descriptor, use:
+.Bd -literal -offset indent
+Dwarf_Dbg dbg;
+Dwarf_Cie cie;
+Dwarf_Fde fde;
+Dwarf_Ptr fde_inst;
+Dwarf_Unsigned fde_instlen;
+Dwarf_Frame_Op *ops;
+Dwarf_Signed opcnt;
+Dwarf_Error de;
+
+/* ... assuming `dbg` references a valid DWARF debugging context,
+ `fde` references a valid FDE descriptor and `cie` holds the CIE
+ descriptor associated with the FDE descriptor ... */
+
+if (dwarf_get_fde_instr_bytes(fde, &fde_inst, &fde_instlen,
+ &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_get_fde_instr_bytes failed: %s",
+ dwarf_errmsg(de));
+
+if (dwarf_expand_frame_instructions(cie, fde_inst, fde_instlen,
+ &ops, &opcnt, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE,
+ "dwarf_expand_frame_instructions failed: %s",
+ dwarf_errmsg(de));
+
+for (i = 0; i < opcnt; i++) {
+ /* ... use ops[i] ... */
+}
+
+/* Free the memory area when no longer needed. */
+dwarf_dealloc(dbg, ops, DW_DLA_FRAME_BLOCK);
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_frame_instructions_dealloc 3 ,
+.Xr dwarf_get_cie_info 3 ,
+.Xr dwarf_get_cie_index 3 ,
+.Xr dwarf_get_cie_of_fde ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_info_for_all_regs 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_fde_instr_bytes 3 ,
+.Xr dwarf_get_fde_list 3 ,
+.Xr dwarf_get_fde_list_eh 3 ,
+.Xr dwarf_get_fde_n 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_expr_current_offset.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_expr_current_offset.3
new file mode 100644
index 0000000..f22294e
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_expr_current_offset.3
@@ -0,0 +1,84 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_expr_current_offset.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd September 13, 2011
+.Os
+.Dt DWARF_EXPR_CURRENT_OFFSET 3
+.Sh NAME
+.Nm dwarf_expr_current_offset
+.Nd retrieve the number of bytes in a location expression stream
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_expr_current_offset
+.Fa "Dwarf_P_Expr expr"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_expr_current_offset
+returns the size in bytes of the stream representation of a location
+expression.
+.Pp
+Argument
+.Ar expr
+should reference a location expression descriptor allocated using
+.Xr dwarf_new_expr 3 .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_expr_current_offset
+returns the size in bytes of the location descriptor's stream
+representation.
+In case of an error, function
+.Fn dwarf_expr_current_offset
+returns
+.Dv DW_DLV_NOCOUNT
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_expr_current_offset
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar expr
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_expr_addr 3 ,
+.Xr dwarf_add_expr_addr_b 3 ,
+.Xr dwarf_add_expr_gen 3 ,
+.Xr dwarf_expr_into_block 3 ,
+.Xr dwarf_new_expr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_expr_into_block.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_expr_into_block.3
new file mode 100644
index 0000000..69f1d9c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_expr_into_block.3
@@ -0,0 +1,94 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_expr_into_block.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd September 13, 2011
+.Os
+.Dt DWARF_EXPR_INTO_BLOCK 3
+.Sh NAME
+.Nm dwarf_expr_into_block
+.Nd retrieve the byte stream for a location expression
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Addr"
+.Fo dwarf_expr_into_block
+.Fa "Dwarf_P_Expr expr"
+.Fa "Dwarf_Unsigned *length"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_expr_into_block
+retrieves the byte stream representation of a location expression.
+.Pp
+Argument
+.Ar expr
+should reference a location expression descriptor allocated using
+.Xr dwarf_new_expr 3 .
+.Pp
+Argument
+.Ar length
+should point to a location which will hold the size in bytes of
+the retrieved byte stream.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_expr_into_block
+returns the address of the first byte of the generated byte stream.
+In case of an error, function
+.Fn dwarf_expr_into_block
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_expr_into_block
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar expr
+or
+.Ar length
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+the function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_location_expr 3 ,
+.Xr dwarf_add_expr_addr 3 ,
+.Xr dwarf_add_expr_addr_b 3 ,
+.Xr dwarf_add_expr_gen 3 ,
+.Xr dwarf_expr_current_offset 3 ,
+.Xr dwarf_new_expr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_fde_cfa_offset.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_fde_cfa_offset.3
new file mode 100644
index 0000000..8150e78
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_fde_cfa_offset.3
@@ -0,0 +1,99 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_fde_cfa_offset.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd September 26, 2011
+.Os
+.Dt DWARF_FDE_CFA_OFFSET 3
+.Sh NAME
+.Nm dwarf_fde_cfa_offset
+.Nd add a DW_CFA_offset frame instruction to a DWARF frame descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_P_Fde"
+.Fo dwarf_fde_cfa_offset
+.Fa "Dwarf_P_Fde fde"
+.Fa "Dwarf_Unsigned reg"
+.Fa "Dwarf_Signed offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_fde_cfa_offset
+appends a
+.Dv DW_CFA_offset
+frame instruction to the frame descriptor referenced by argument
+.Ar fde .
+.Pp
+Argument
+.Ar fde
+should reference a frame descriptor allocated using
+.Xr dwarf_new_fde 3 .
+.Pp
+Argument
+.Ar reg
+specifies the register operand for the frame instruction.
+.Pp
+Argument
+.Ar offset
+specifies the offset operand for the frame instruction.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_fde_cfa_offset
+returns the frame descriptor given in argument
+.Ar fde .
+In case of an error, function
+.Fn dwarf_fde_cfa_offset
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_fde_cfa_offset
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar fde
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_fde_inst 3 ,
+.Xr dwarf_add_frame_fde 3 ,
+.Xr dwarf_add_frame_fde_b 3 ,
+.Xr dwarf_add_frame_cie 3 ,
+.Xr dwarf_new_fde 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_find_macro_value_start.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_find_macro_value_start.3
new file mode 100644
index 0000000..ede0df9
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_find_macro_value_start.3
@@ -0,0 +1,68 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_find_macro_value_start.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd March 26, 2011
+.Os
+.Dt DWARF_FIND_MACRO_VALUE_START 3
+.Sh NAME
+.Nm dwarf_find_macro_value_start
+.Nd return the address of the first byte of a macro value
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft char *
+.Fo dwarf_find_macro_value_start
+.Fa "char *macro_string"
+.Fc
+.Sh DESCRIPTION
+Given a DWARF macro string, function
+.Fn dwarf_find_macro_value_start
+returns a pointer to the first byte of the macro value part of the
+macro string.
+.Pp
+Argument
+.Ar macro_string
+should be a NUL-terminated string conforming to the macro format
+defined in the DWARF standard; see
+.Xr dwarf 4 .
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_find_macro_value_start
+returns a pointer to the first byte of the macro value.
+If the macro value part was not found, function
+.Fn dwarf_find_macro_value_start
+returns a pointer to the NUL-byte terminating argument
+.Ar macro_string .
+.Pp
+Function
+.Fn dwarf_find_macro_value_start
+returns NULL if argument
+.Ar macro_string
+was NULL.
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_macro_details 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_finish.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_finish.3
new file mode 100644
index 0000000..a26bf9b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_finish.3
@@ -0,0 +1,140 @@
+.\" Copyright (c) 2009,2011 Joseph Koshy. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" This software is provided by Joseph Koshy ``as is'' and
+.\" any express or implied warranties, including, but not limited to, the
+.\" implied warranties of merchantability and fitness for a particular purpose
+.\" are disclaimed. in no event shall Joseph Koshy be liable
+.\" for any direct, indirect, incidental, special, exemplary, or consequential
+.\" damages (including, but not limited to, procurement of substitute goods
+.\" or services; loss of use, data, or profits; or business interruption)
+.\" however caused and on any theory of liability, whether in contract, strict
+.\" liability, or tort (including negligence or otherwise) arising in any way
+.\" out of the use of this software, even if advised of the possibility of
+.\" such damage.
+.\"
+.\" $Id: dwarf_finish.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_FINISH 3
+.Sh NAME
+.Nm dwarf_finish ,
+.Nm dwarf_object_finish
+.Nd free resources associated with a debug descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fn dwarf_finish "Dwarf_Debug dbg" "Dwarf_Error *err"
+.Ft int
+.Fn dwarf_object_finish "Dwarf_Debug dbg" "Dwarf_Error *err"
+.Sh DESCRIPTION
+The
+.Fn dwarf_finish
+and
+.Fn dwarf_object_finish
+functions are used to release the resources associated with a debug
+descriptor allocated by a prior call to
+.Xr dwarf_init 3
+and
+.Xr dwarf_object_init 3
+respectively.
+.Pp
+Argument
+.Ar dbg
+denotes a valid
+.Vt Dwarf_Debug
+instance.
+Argument
+.Ar err
+will be used to record error information in case of an error.
+.Pp
+After a call to
+.Fn dwarf_finish
+or
+.Fn dwarf_object_finish ,
+the argument
+.Ar dbg
+will be invalid and should not be used further.
+.Pp
+For
+.Vt Dwarf_Debug
+descriptors opened using
+.Xr dwarf_init 3 ,
+the application would need to explicitly release the
+.Vt Elf
+instance associated with the descriptor by first retrieving
+the instance using
+.Xr dwarf_get_elf 3
+and closing it using
+.Xr elf_end 3 .
+.Sh RETURN VALUES
+These functions return
+.Dv DW_DLV_OK
+if successful.
+In case of an error, the functions return
+.Dv DW_DLV_ERROR
+and record additional information in argument
+.Ar err .
+.Sh EXAMPLES
+To deallocate a
+.Vt Dwarf_Debug
+instance allocated using
+.Xr dwarf_elf_init 3
+use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Error de;
+
+if (dwarf_finish(dbg, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_finish: %s", dwarf_errmsg(de));
+.Ed
+.Pp
+To deallocate a
+.Vt Dwarf_Debug
+instance allocated using
+.Xr dwarf_object_init 3
+use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Error de;
+
+if (dwarf_object_finish(dbg, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_object_finish: %s",
+ dwarf_errmsg(de));
+.Ed
+.Pp
+To deallocate a
+.Vt Dwarf_Debug
+instance allocated using
+.Xr dwarf_init 3
+use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dward_Error de;
+Elf *e;
+
+if (dwarf_get_elf(dbg, &e, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_get_elf: %s", dwarf_errmsg(&de));
+
+if (dwarf_finish(dbg, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_finish: %s", dwarf_errmsg(de));
+
+(void) elf_end(e);
+.Ed
+.Sh SEE ALSO
+.Xr elf_end 3 ,
+.Xr dwarf_elf_init 3 ,
+.Xr dwarf_get_elf 3 ,
+.Xr dwarf_init 3 ,
+.Xr dwarf_object_init 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_finish.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_finish.c
new file mode 100644
index 0000000..b3bdc0b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_finish.c
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_finish.c 2073 2011-10-27 03:30:47Z jkoshy $");
+
+int
+dwarf_finish(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ (void) error; /* unused */
+
+ if (dbg == NULL)
+ return (DW_DLV_OK);
+
+ _dwarf_deinit(dbg);
+ _dwarf_elf_deinit(dbg);
+
+ free(dbg);
+
+ return (DW_DLV_OK);
+}
+
+
+int
+dwarf_object_finish(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ (void) error; /* unused */
+
+ if (dbg == NULL)
+ return (DW_DLV_OK);
+
+ _dwarf_deinit(dbg);
+
+ free(dbg);
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_form.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_form.c
new file mode 100644
index 0000000..a9a22cb
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_form.c
@@ -0,0 +1,480 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2009,2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_form.c 2073 2011-10-27 03:30:47Z jkoshy $");
+
+int
+dwarf_hasform(Dwarf_Attribute at, Dwarf_Half form, Dwarf_Bool *return_hasform,
+ Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_hasform == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *return_hasform = (at->at_form == form);
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_whatform(Dwarf_Attribute at, Dwarf_Half *return_form, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_form == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *return_form = at->at_form;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_whatform_direct(Dwarf_Attribute at, Dwarf_Half *return_form,
+ Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_form == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (at->at_indirect)
+ *return_form = DW_FORM_indirect;
+ else
+ *return_form = (Dwarf_Half) at->at_form;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_whatattr(Dwarf_Attribute at, Dwarf_Half *return_attr, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_attr == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *return_attr = (Dwarf_Half) at->at_attrib;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_formref(Dwarf_Attribute at, Dwarf_Off *return_offset, Dwarf_Error *error)
+{
+ int ret;
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_offset == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ switch (at->at_form) {
+ case DW_FORM_ref1:
+ case DW_FORM_ref2:
+ case DW_FORM_ref4:
+ case DW_FORM_ref8:
+ case DW_FORM_ref_udata:
+ *return_offset = (Dwarf_Off) at->u[0].u64;
+ ret = DW_DLV_OK;
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ ret = DW_DLV_ERROR;
+ }
+
+ return (ret);
+}
+
+int
+dwarf_global_formref(Dwarf_Attribute at, Dwarf_Off *return_offset,
+ Dwarf_Error *error)
+{
+ int ret;
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_offset == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ switch (at->at_form) {
+ case DW_FORM_ref_addr:
+ case DW_FORM_sec_offset:
+ *return_offset = (Dwarf_Off) at->u[0].u64;
+ ret = DW_DLV_OK;
+ break;
+ case DW_FORM_ref1:
+ case DW_FORM_ref2:
+ case DW_FORM_ref4:
+ case DW_FORM_ref8:
+ case DW_FORM_ref_udata:
+ *return_offset = (Dwarf_Off) at->u[0].u64 +
+ at->at_die->die_cu->cu_offset;
+ ret = DW_DLV_OK;
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ ret = DW_DLV_ERROR;
+ }
+
+ return (ret);
+}
+
+int
+dwarf_formaddr(Dwarf_Attribute at, Dwarf_Addr *return_addr, Dwarf_Error *error)
+{
+ int ret;
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_addr == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (at->at_form == DW_FORM_addr) {
+ *return_addr = at->u[0].u64;
+ ret = DW_DLV_OK;
+ } else {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ ret = DW_DLV_ERROR;
+ }
+
+ return (ret);
+}
+
+int
+dwarf_formflag(Dwarf_Attribute at, Dwarf_Bool *return_bool, Dwarf_Error *error)
+{
+ int ret;
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_bool == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (at->at_form == DW_FORM_flag ||
+ at->at_form == DW_FORM_flag_present) {
+ *return_bool = (Dwarf_Bool) (!!at->u[0].u64);
+ ret = DW_DLV_OK;
+ } else {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ ret = DW_DLV_ERROR;
+ }
+
+ return (ret);
+}
+
+int
+dwarf_formudata(Dwarf_Attribute at, Dwarf_Unsigned *return_uvalue,
+ Dwarf_Error *error)
+{
+ int ret;
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_uvalue == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ switch (at->at_form) {
+ case DW_FORM_data1:
+ case DW_FORM_data2:
+ case DW_FORM_data4:
+ case DW_FORM_data8:
+ case DW_FORM_udata:
+ *return_uvalue = at->u[0].u64;
+ ret = DW_DLV_OK;
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ ret = DW_DLV_ERROR;
+ }
+
+ return (ret);
+}
+
+int
+dwarf_formsdata(Dwarf_Attribute at, Dwarf_Signed *return_svalue,
+ Dwarf_Error *error)
+{
+ int ret;
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_svalue == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ switch (at->at_form) {
+ case DW_FORM_data1:
+ *return_svalue = (int8_t) at->u[0].s64;
+ ret = DW_DLV_OK;
+ break;
+ case DW_FORM_data2:
+ *return_svalue = (int16_t) at->u[0].s64;
+ ret = DW_DLV_OK;
+ break;
+ case DW_FORM_data4:
+ *return_svalue = (int32_t) at->u[0].s64;
+ ret = DW_DLV_OK;
+ break;
+ case DW_FORM_data8:
+ case DW_FORM_sdata:
+ *return_svalue = at->u[0].s64;
+ ret = DW_DLV_OK;
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ ret = DW_DLV_ERROR;
+ }
+
+ return (ret);
+}
+
+int
+dwarf_formblock(Dwarf_Attribute at, Dwarf_Block **return_block,
+ Dwarf_Error *error)
+{
+ int ret;
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_block == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ switch (at->at_form) {
+ case DW_FORM_block:
+ case DW_FORM_block1:
+ case DW_FORM_block2:
+ case DW_FORM_block4:
+ *return_block = &at->at_block;
+ ret = DW_DLV_OK;
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ ret = DW_DLV_ERROR;
+ }
+
+ return (ret);
+}
+
+int
+dwarf_formsig8(Dwarf_Attribute at, Dwarf_Sig8 *return_sig8, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_sig8 == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (at->at_form != DW_FORM_ref_sig8) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ return (DW_DLV_ERROR);
+ }
+
+ assert(at->u[0].u64 == 8);
+ memcpy(return_sig8->signature, at->u[1].u8p, at->u[0].u64);
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_formexprloc(Dwarf_Attribute at, Dwarf_Unsigned *return_exprlen,
+ Dwarf_Ptr *return_expr, Dwarf_Error *error)
+{
+
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_exprlen == NULL || return_expr == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (at->at_form != DW_FORM_exprloc) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ return (DW_DLV_ERROR);
+ }
+
+ *return_exprlen = at->u[0].u64;
+ *return_expr = (void *) at->u[1].u8p;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_formstring(Dwarf_Attribute at, char **return_string,
+ Dwarf_Error *error)
+{
+ int ret;
+ Dwarf_Debug dbg;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || return_string == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ switch (at->at_form) {
+ case DW_FORM_string:
+ *return_string = (char *) at->u[0].s;
+ ret = DW_DLV_OK;
+ break;
+ case DW_FORM_strp:
+ *return_string = (char *) at->u[1].s;
+ ret = DW_DLV_OK;
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ ret = DW_DLV_ERROR;
+ }
+
+ return (ret);
+}
+
+enum Dwarf_Form_Class
+dwarf_get_form_class(Dwarf_Half dwversion, Dwarf_Half attr,
+ Dwarf_Half offset_size, Dwarf_Half form)
+{
+
+ switch (form) {
+ case DW_FORM_addr:
+ return (DW_FORM_CLASS_ADDRESS);
+ case DW_FORM_block:
+ case DW_FORM_block1:
+ case DW_FORM_block2:
+ case DW_FORM_block4:
+ return (DW_FORM_CLASS_BLOCK);
+ case DW_FORM_string:
+ case DW_FORM_strp:
+ return (DW_FORM_CLASS_STRING);
+ case DW_FORM_flag:
+ case DW_FORM_flag_present:
+ return (DW_FORM_CLASS_FLAG);
+ case DW_FORM_ref_addr:
+ case DW_FORM_ref_sig8:
+ case DW_FORM_ref_udata:
+ case DW_FORM_ref1:
+ case DW_FORM_ref2:
+ case DW_FORM_ref4:
+ case DW_FORM_ref8:
+ return (DW_FORM_CLASS_REFERENCE);
+ case DW_FORM_exprloc:
+ return (DW_FORM_CLASS_EXPRLOC);
+ case DW_FORM_data1:
+ case DW_FORM_data2:
+ case DW_FORM_sdata:
+ case DW_FORM_udata:
+ return (DW_FORM_CLASS_CONSTANT);
+ case DW_FORM_data4:
+ case DW_FORM_data8:
+ if (dwversion > 3)
+ return (DW_FORM_CLASS_CONSTANT);
+ if (form == DW_FORM_data4 && offset_size != 4)
+ return (DW_FORM_CLASS_CONSTANT);
+ if (form == DW_FORM_data8 && offset_size != 8)
+ return (DW_FORM_CLASS_CONSTANT);
+ /* FALLTHROUGH */
+ case DW_FORM_sec_offset:
+ /*
+ * DW_FORM_data4 and DW_FORM_data8 can be used as
+ * offset/pointer before DWARF4. Newly added
+ * DWARF4 form DW_FORM_sec_offset intents to replace
+ * DW_FORM_data{4,8} for this purpose. Anyway, to
+ * determine the actual class for these forms, we need
+ * to also look at the attribute number.
+ */
+ switch (attr) {
+ case DW_AT_location:
+ case DW_AT_string_length:
+ case DW_AT_return_addr:
+ case DW_AT_data_member_location:
+ case DW_AT_frame_base:
+ case DW_AT_segment:
+ case DW_AT_static_link:
+ case DW_AT_use_location:
+ case DW_AT_vtable_elem_location:
+ return (DW_FORM_CLASS_LOCLISTPTR);
+ case DW_AT_stmt_list:
+ return (DW_FORM_CLASS_LINEPTR);
+ case DW_AT_start_scope:
+ case DW_AT_ranges:
+ return (DW_FORM_CLASS_RANGELISTPTR);
+ case DW_AT_macro_info:
+ return (DW_FORM_CLASS_MACPTR);
+ default:
+ if (form == DW_FORM_data4 || form == DW_FORM_data8)
+ return (DW_FORM_CLASS_CONSTANT);
+ else
+ return (DW_FORM_CLASS_UNKNOWN);
+ }
+ default:
+ return (DW_FORM_CLASS_UNKNOWN);
+ }
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_formaddr.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formaddr.3
new file mode 100644
index 0000000..6b8c70d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formaddr.3
@@ -0,0 +1,97 @@
+.\" Copyright (c) 2010 Joseph Koshy
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_formaddr.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd July 23, 2010
+.Os
+.Dt DWARF_FORMADDR 3
+.Sh NAME
+.Nm dwarf_formaddr
+.Nd return the value of an ADDRESS class attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_formaddr
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Addr *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_formaddr
+sets the location pointed to by argument
+.Ar ret
+to the address represented by the attribute referenced
+by argument
+.Ar attr .
+The form of argument
+.Ar attr
+must be
+.Dv DW_FORM_addr .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_formaddr
+returns
+.Dv DW_DLV_OK
+on success.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_formblock
+may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar attr
+or
+.Ar ret
+was NULL.
+.It Bq Er DW_DLE_ATTR_FORM_BAD
+The attribute referenced by argument
+.Ar attr
+was not of form
+.Dv DW_FORM_addr .
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_formblock 3 ,
+.Xr dwarf_formflag 3 ,
+.Xr dwarf_formref 3 ,
+.Xr dwarf_formsdata 3 ,
+.Xr dwarf_formsig8 3 ,
+.Xr dwarf_formstring 3 ,
+.Xr dwarf_formudata 3 ,
+.Xr dwarf_hasattr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_formblock.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formblock.3
new file mode 100644
index 0000000..1ffb6e6
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formblock.3
@@ -0,0 +1,109 @@
+.\" Copyright (c) 2010 Joseph Koshy
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_formblock.3 3182 2015-04-10 16:08:10Z emaste $
+.\"
+.Dd July 23, 2010
+.Os
+.Dt DWARF_FORMBLOCK 3
+.Sh NAME
+.Nm dwarf_formblock
+.Nd return the value of a BLOCK attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_formblock
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Block **ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_formblock
+sets the location pointed to by argument
+.Ar ret
+to a pointer to a
+.Vt Dwarf_Block
+structure containing the value of the attribute referenced
+by argument
+.Ar attr .
+The form of argument
+.Ar attr
+must be one of
+.Dv DW_FORM_block ,
+.Dv DW_FORM_block1 ,
+.Dv DW_FORM_block2
+or
+.Dv DW_FORM_block4 .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Ss Memory Management
+The memory area referenced by the returned pointer is managed by
+the DWARF(3) library.
+The application should not attempt to free this memory
+area.
+Portable code may indicate that the memory area is to be freed by
+using
+.Xr dwarf_dealloc 3 .
+.Sh RETURN VALUES
+Function
+.Fn dwarf_formblock
+returns
+.Dv DW_DLV_OK
+on success.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_formblock
+may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar attr
+or
+.Ar ret
+was NULL.
+.It Bq Er DW_DLE_ATTR_FORM_BAD
+The attribute referenced by argument
+.Ar attr
+was not of a permitted kind.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_formflag 3 ,
+.Xr dwarf_formref 3 ,
+.Xr dwarf_formsdata 3 ,
+.Xr dwarf_formsig8 3 ,
+.Xr dwarf_formstring 3 ,
+.Xr dwarf_formudata 3 ,
+.Xr dwarf_hasattr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_formexprloc.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formexprloc.3
new file mode 100644
index 0000000..231ba3a
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formexprloc.3
@@ -0,0 +1,109 @@
+.\" Copyright (c) 2010 Joseph Koshy
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_formexprloc.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd July 25, 2010
+.Os
+.Dt DWARF_FORMEXPRLOC 3
+.Sh NAME
+.Nm dwarf_formexprloc
+.Nd return information about a location expression
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_formexprloc
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Unsigned *retlen"
+.Fa "Dwarf_Ptr *retexpr"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_formexprloc
+allows an application to retrieve the length and the bytes of a
+DWARF location expression.
+.Pp
+Argument
+.Ar attr
+should reference a DWARF attribute of the form
+.Dv DW_FORM_exprloc .
+Argument
+.Ar retlen
+should point to a location that will be set to the length of the
+location expression.
+Argument
+.Ar retexpr
+should point to a location that will be set to a pointer to the
+content of the location expression itself.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Ss Memory Management
+The application should not attempt to free the memory
+area referenced by the pointer returned in argument
+.Ar retexpr .
+.Sh RETURN VALUES
+Function
+.Fn dwarf_formexprloc
+returns
+.Dv DW_DLV_OK
+on success.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_formexprloc
+may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+One of arguments
+.Ar attr ,
+.Ar retlen
+or
+.Ar retexpr
+was NULL.
+.It Bq Er DW_DLE_ATTR_FORM_BAD
+The attribute referenced by argument
+.Ar attr
+was not of form
+.Dv DW_FORM_exprloc .
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_formblock 3 ,
+.Xr dwarf_formflag 3 ,
+.Xr dwarf_formref 3 ,
+.Xr dwarf_formsdata 3 ,
+.Xr dwarf_formsig8 3 ,
+.Xr dwarf_formstring 3 ,
+.Xr dwarf_formudata 3 ,
+.Xr dwarf_hasattr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_formflag.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formflag.3
new file mode 100644
index 0000000..2e23b33
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formflag.3
@@ -0,0 +1,97 @@
+.\" Copyright (c) 2010 Joseph Koshy
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_formflag.3 3181 2015-04-10 13:22:51Z emaste $
+.\"
+.Dd June 21, 2010
+.Os
+.Dt DWARF_FORMFLAG 3
+.Sh NAME
+.Nm dwarf_formflag
+.Nd return the value of a BOOLEAN class attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_formflag
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Bool *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_formflag
+sets the location pointed to by argument
+.Ar ret
+to 1 if the attribute referenced by argument
+.Ar attr
+has a non-zero value, or 0 otherwise.
+The form of argument
+.Ar attr
+must be one of
+.Dv DW_FORM_flag
+or
+.Dv DW_FORM_flag_present .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_formflag
+returns
+.Dv DW_DLV_OK
+on success.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_formflag
+may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar attr
+or
+.Ar ret
+was NULL.
+.It Bq Er DW_DLE_ATTR_FORM_BAD
+The attribute referenced by argument
+.Ar attr
+was not of a permitted kind.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_formblock 3 ,
+.Xr dwarf_formref 3 ,
+.Xr dwarf_formsdata 3 ,
+.Xr dwarf_formsig8 3 ,
+.Xr dwarf_formstring 3 ,
+.Xr dwarf_formudata 3 ,
+.Xr dwarf_hasattr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_formref.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formref.3
new file mode 100644
index 0000000..abde30c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formref.3
@@ -0,0 +1,136 @@
+.\" Copyright (c) 2010 Joseph Koshy
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_formref.3 3181 2015-04-10 13:22:51Z emaste $
+.\"
+.Dd June 21, 2010
+.Os
+.Dt DWARF_FORMREF 3
+.Sh NAME
+.Nm dwarf_formref ,
+.Nm dwarf_global_formref
+.Nd retrieve offsets for REFERENCE class attributes
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_formref
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Off *retoffset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_global_formref
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Off *retoffset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions return the offsets associated with a DWARF attribute
+descriptor.
+.Pp
+Function
+.Fn dwarf_formref
+returns the compilation unit relative offset of the descriptor
+referenced by argument
+.Ar attr
+in the location pointed to by argument
+.Ar retoffset .
+Argument
+.Ar attr
+must be a reference that is local to a compilation unit.
+Permitted forms for argument
+.Ar attr
+are
+.Dv DW_FORM_ref1 ,
+.Dv DW_FORM_ref2 ,
+.Dv DW_FORM_ref4 ,
+.Dv DW_FORM_ref8
+and
+.Dv DW_FORM_ref_udata .
+.Pp
+Function
+.Fn dwarf_global_formref
+returns the section-relative offset of the descriptor referenced by
+argument
+.Ar attr
+in the location pointed to by argument
+.Ar retoffset .
+Argument
+.Ar attr
+should be a legal
+.Sy REFERENCE
+class form.
+Permitted forms for argument
+.Ar attr
+are:
+.Dv DW_FORM_ref_addr ,
+.Dv DW_FORM_ref_udata ,
+.Dv DW_FORM_ref1 ,
+.Dv DW_FORM_ref2 ,
+.Dv DW_FORM_ref4 ,
+.Dv DW_FORM_ref8
+and
+.Dv DW_FORM_sec_offset .
+The returned offset is relative to the start of the
+.Dq .debug_info
+ELF section.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Sh RETURN VALUES
+These functions return
+.Dv DW_DLV_OK
+on success.
+In case of an error, these functions return
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar attr
+or
+.Ar retoffset
+was NULL.
+.It Bq Er DW_DLE_ATTR_FORM_BAD
+The attribute referenced by argument
+.Ar attr
+was not of a permitted kind.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_formblock 3 ,
+.Xr dwarf_formflag 3 ,
+.Xr dwarf_formsdata 3 ,
+.Xr dwarf_formsig8 3 ,
+.Xr dwarf_formstring 3 ,
+.Xr dwarf_formudata 3 ,
+.Xr dwarf_hasattr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_formsig8.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formsig8.3
new file mode 100644
index 0000000..a76c110
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formsig8.3
@@ -0,0 +1,96 @@
+.\" Copyright (c) 2010 Joseph Koshy
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_formsig8.3 3181 2015-04-10 13:22:51Z emaste $
+.\"
+.Dd July 24, 2010
+.Os
+.Dt DWARF_FORMSIG8 3
+.Sh NAME
+.Nm dwarf_formsig8
+.Nd return the 64-bit type signature for a DWARF type
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_formsig8
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Sig8 *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_formsig8
+sets the location pointed to by argument
+.Ar ret
+to the 64-bit type signature that is the value of
+the attribute referenced by argument
+.Ar attr .
+The form of argument
+.Ar attr
+must be
+.Dv DW_FORM_ref_sig8 .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_formsig8
+returns
+.Dv DW_DLV_OK
+on success.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_formsig8
+may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar attr
+or
+.Ar ret
+was NULL.
+.It Bq Er DW_DLE_ATTR_FORM_BAD
+The attribute referenced by argument
+.Ar attr
+was not of a permitted kind.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_formflag 3 ,
+.Xr dwarf_formref 3 ,
+.Xr dwarf_formsdata 3 ,
+.Xr dwarf_formstring 3 ,
+.Xr dwarf_formudata 3 ,
+.Xr dwarf_hasattr 3
+.Sh HISTORY
+Type signatures were added in version 4 of the DWARF specification.
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_formstring.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formstring.3
new file mode 100644
index 0000000..63e83f6
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formstring.3
@@ -0,0 +1,101 @@
+.\" Copyright (c) 2010 Joseph Koshy
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_formstring.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd July 24, 2010
+.Os
+.Dt DWARF_FORMSTRING 3
+.Sh NAME
+.Nm dwarf_formstring
+.Nd return the value of a STRING class attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_formstring
+.Fa "Dwarf_Attribute attr"
+.Fa "char **ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_formstring
+sets the location pointed to by argument
+.Ar ret
+to a pointer to a NUL-terminated string containing
+the value of the attribute referenced by argument
+.Ar attr .
+The form of argument
+.Ar attr
+must be one of
+.Dv DW_FORM_string
+or
+.Dv DW_FORM_strp .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Ss Memory Management
+The memory area referenced by the returned pointer is managed by
+the DWARF(3) library.
+The application should not attempt to directly free this memory
+area.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_formstring
+returns
+.Dv DW_DLV_OK
+on success.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_formstring
+may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar attr
+or
+.Ar ret
+was NULL.
+.It Bq Er DW_DLE_ATTR_FORM_BAD
+The attribute referenced by argument
+.Ar attr
+was not of a permitted kind.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_formblock 3 ,
+.Xr dwarf_formref 3 ,
+.Xr dwarf_formsdata 3 ,
+.Xr dwarf_formsig8 3 ,
+.Xr dwarf_formudata 3 ,
+.Xr dwarf_hasattr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_formudata.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formudata.3
new file mode 100644
index 0000000..9ed154e
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_formudata.3
@@ -0,0 +1,122 @@
+.\" Copyright (c) 2010 Joseph Koshy
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_formudata.3 3181 2015-04-10 13:22:51Z emaste $
+.\"
+.Dd June 21, 2010
+.Os
+.Dt DWARF_FORMUDATA 3
+.Sh NAME
+.Nm dwarf_formudata ,
+.Nm dwarf_formsdata
+.Nd return the value of a CONSTANT class attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_formudata
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Unsigned *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_formsdata
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Signed *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions return the value associated with a DWARF attribute
+describing a constant.
+.Pp
+Function
+.Fn dwarf_formudata
+sets the location pointed to by argument
+.Ar ret
+to the value of the attribute referenced by argument
+.Ar attr ,
+treating the value as an unsigned quantity.
+Argument
+.Ar attr
+must have one of the following forms:
+.Dv DW_FORM_data1 ,
+.Dv DW_FORM_data2 ,
+.Dv DW_FORM_data4 ,
+.Dv DW_FORM_data8
+and
+.Dv DW_FORM_udata .
+.Pp
+Function
+.Fn dwarf_formsdata
+sets the location pointed to by argument
+.Ar ret
+to the value of the attribute referenced by argument
+.Ar attr ,
+appropriately sign extended.
+Argument
+.Ar attr
+must have one of the following forms:
+.Dv DW_FORM_data1 ,
+.Dv DW_FORM_data2 ,
+.Dv DW_FORM_data4 ,
+.Dv DW_FORM_data8
+and
+.Dv DW_FORM_sdata .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Sh RETURN VALUES
+These functions return
+.Dv DW_DLV_OK
+on success.
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar attr
+or
+.Ar ret
+was NULL.
+.It Bq Er DW_DLE_ATTR_FORM_BAD
+The attribute referenced by argument
+.Ar attr
+was not of a permitted kind.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_formblock 3 ,
+.Xr dwarf_formflag 3 ,
+.Xr dwarf_formref 3 ,
+.Xr dwarf_formsig8 3 ,
+.Xr dwarf_formstring 3 ,
+.Xr dwarf_hasattr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_frame.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_frame.c
new file mode 100644
index 0000000..442f232
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_frame.c
@@ -0,0 +1,603 @@
+/*-
+ * Copyright (c) 2009,2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_frame.c 3106 2014-12-19 16:00:58Z kaiwang27 $");
+
+int
+dwarf_get_fde_list(Dwarf_Debug dbg, Dwarf_Cie **cie_list,
+ Dwarf_Signed *cie_count, Dwarf_Fde **fde_list, Dwarf_Signed *fde_count,
+ Dwarf_Error *error)
+{
+
+ if (dbg == NULL || cie_list == NULL || cie_count == NULL ||
+ fde_list == NULL || fde_count == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (dbg->dbg_internal_reg_table == NULL) {
+ if (_dwarf_frame_interal_table_init(dbg, error) != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ }
+
+ if (dbg->dbg_frame == NULL) {
+ if (_dwarf_frame_section_load(dbg, error) != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ if (dbg->dbg_frame == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+ }
+
+ if (dbg->dbg_frame->fs_ciearray == NULL ||
+ dbg->dbg_frame->fs_fdearray == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *cie_list = dbg->dbg_frame->fs_ciearray;
+ *cie_count = dbg->dbg_frame->fs_cielen;
+ *fde_list = dbg->dbg_frame->fs_fdearray;
+ *fde_count = dbg->dbg_frame->fs_fdelen;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_fde_list_eh(Dwarf_Debug dbg, Dwarf_Cie **cie_list,
+ Dwarf_Signed *cie_count, Dwarf_Fde **fde_list, Dwarf_Signed *fde_count,
+ Dwarf_Error *error)
+{
+
+ if (dbg == NULL || cie_list == NULL || cie_count == NULL ||
+ fde_list == NULL || fde_count == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (dbg->dbg_internal_reg_table == NULL) {
+ if (_dwarf_frame_interal_table_init(dbg, error) != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ }
+
+ if (dbg->dbg_eh_frame == NULL) {
+ if (_dwarf_frame_section_load_eh(dbg, error) != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ if (dbg->dbg_eh_frame == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+ }
+
+ if (dbg->dbg_eh_frame->fs_ciearray == NULL ||
+ dbg->dbg_eh_frame->fs_fdearray == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *cie_list = dbg->dbg_eh_frame->fs_ciearray;
+ *cie_count = dbg->dbg_eh_frame->fs_cielen;
+ *fde_list = dbg->dbg_eh_frame->fs_fdearray;
+ *fde_count = dbg->dbg_eh_frame->fs_fdelen;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_fde_n(Dwarf_Fde *fdelist, Dwarf_Unsigned fde_index,
+ Dwarf_Fde *ret_fde, Dwarf_Error *error)
+{
+ Dwarf_FrameSec fs;
+ Dwarf_Debug dbg;
+
+ dbg = fdelist != NULL ? (*fdelist)->fde_dbg : NULL;
+
+ if (fdelist == NULL || ret_fde == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ fs = fdelist[0]->fde_fs;
+ assert(fs != NULL);
+
+ if (fde_index >= fs->fs_fdelen) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *ret_fde = fdelist[fde_index];
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_fde_at_pc(Dwarf_Fde *fdelist, Dwarf_Addr pc, Dwarf_Fde *ret_fde,
+ Dwarf_Addr *lopc, Dwarf_Addr *hipc, Dwarf_Error *error)
+{
+ Dwarf_FrameSec fs;
+ Dwarf_Debug dbg;
+ Dwarf_Fde fde;
+ int i;
+
+ dbg = fdelist != NULL ? (*fdelist)->fde_dbg : NULL;
+
+ if (fdelist == NULL || ret_fde == NULL || lopc == NULL ||
+ hipc == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ fs = fdelist[0]->fde_fs;
+ assert(fs != NULL);
+
+ for (i = 0; (Dwarf_Unsigned)i < fs->fs_fdelen; i++) {
+ fde = fdelist[i];
+ if (pc >= fde->fde_initloc && pc < fde->fde_initloc +
+ fde->fde_adrange) {
+ *ret_fde = fde;
+ *lopc = fde->fde_initloc;
+ *hipc = fde->fde_initloc + fde->fde_adrange - 1;
+ return (DW_DLV_OK);
+ }
+ }
+
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+}
+
+int
+dwarf_get_cie_of_fde(Dwarf_Fde fde, Dwarf_Cie *ret_cie, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = fde != NULL ? fde->fde_dbg : NULL;
+
+ if (fde == NULL || ret_cie == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_cie = fde->fde_cie;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_fde_range(Dwarf_Fde fde, Dwarf_Addr *low_pc, Dwarf_Unsigned *func_len,
+ Dwarf_Ptr *fde_bytes, Dwarf_Unsigned *fde_byte_len, Dwarf_Off *cie_offset,
+ Dwarf_Signed *cie_index, Dwarf_Off *fde_offset, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = fde != NULL ? fde->fde_dbg : NULL;
+
+ if (fde == NULL || low_pc == NULL || func_len == NULL ||
+ fde_bytes == NULL || fde_byte_len == NULL || cie_offset == NULL ||
+ cie_index == NULL || fde_offset == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *low_pc = fde->fde_initloc;
+ *func_len = fde->fde_adrange;
+ *fde_bytes = fde->fde_addr;
+ *fde_byte_len = fde->fde_length;
+ *cie_offset = fde->fde_cieoff;
+ *cie_index = fde->fde_cie->cie_index;
+ *fde_offset = fde->fde_offset;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_cie_info(Dwarf_Cie cie, Dwarf_Unsigned *bytes_in_cie,
+ Dwarf_Small *version, char **augmenter, Dwarf_Unsigned *caf,
+ Dwarf_Unsigned *daf, Dwarf_Half *ra, Dwarf_Ptr *initinst,
+ Dwarf_Unsigned *inst_len, Dwarf_Error *error)
+{
+
+ if (cie == NULL || bytes_in_cie == NULL || version == NULL ||
+ augmenter == NULL || caf == NULL || daf == NULL || ra == NULL ||
+ initinst == NULL || inst_len == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *bytes_in_cie = cie->cie_length;
+ *version = cie->cie_version;
+ *augmenter = (char *) cie->cie_augment;
+ *caf = cie->cie_caf;
+ *daf = cie->cie_daf;
+ *ra = cie->cie_ra;
+ *initinst = cie->cie_initinst;
+ *inst_len = cie->cie_instlen;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_cie_index(Dwarf_Cie cie, Dwarf_Signed *cie_index, Dwarf_Error *error)
+{
+
+ if (cie == NULL || cie_index == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *cie_index = cie->cie_index;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_fde_instr_bytes(Dwarf_Fde fde, Dwarf_Ptr *ret_inst,
+ Dwarf_Unsigned *ret_len, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = fde != NULL ? fde->fde_dbg : NULL;
+
+ if (fde == NULL || ret_inst == NULL || ret_len == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_inst = fde->fde_inst;
+ *ret_len = fde->fde_instlen;
+
+ return (DW_DLV_OK);
+}
+
+#define RL rt->rt3_rules[table_column]
+#define CFA rt->rt3_cfa_rule
+
+int
+dwarf_get_fde_info_for_reg(Dwarf_Fde fde, Dwarf_Half table_column,
+ Dwarf_Addr pc_requested, Dwarf_Signed *offset_relevant,
+ Dwarf_Signed *register_num, Dwarf_Signed *offset, Dwarf_Addr *row_pc,
+ Dwarf_Error *error)
+{
+ Dwarf_Regtable3 *rt;
+ Dwarf_Debug dbg;
+ Dwarf_Addr pc;
+ int ret;
+
+ dbg = fde != NULL ? fde->fde_dbg : NULL;
+
+ if (fde == NULL || offset_relevant == NULL || register_num == NULL ||
+ offset == NULL || row_pc == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (pc_requested < fde->fde_initloc ||
+ pc_requested >= fde->fde_initloc + fde->fde_adrange) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_PC_NOT_IN_FDE_RANGE);
+ return (DW_DLV_ERROR);
+ }
+
+ ret = _dwarf_frame_get_internal_table(fde, pc_requested, &rt, &pc,
+ error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ if (table_column == dbg->dbg_frame_cfa_value) {
+ /* Application ask for CFA. */
+ *offset_relevant = CFA.dw_offset_relevant;
+ *register_num = CFA.dw_regnum;
+ *offset = CFA.dw_offset_or_block_len;
+ } else {
+ /* Application ask for normal registers. */
+ if (table_column >= dbg->dbg_frame_rule_table_size ||
+ table_column >= DW_REG_TABLE_SIZE) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_FRAME_TABLE_COL_BAD);
+ return (DW_DLV_ERROR);
+ }
+
+ *offset_relevant = RL.dw_offset_relevant;
+ *register_num = RL.dw_regnum;
+ *offset = RL.dw_offset_or_block_len;
+ }
+
+ *row_pc = pc;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_fde_info_for_all_regs(Dwarf_Fde fde, Dwarf_Addr pc_requested,
+ Dwarf_Regtable *reg_table, Dwarf_Addr *row_pc, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ Dwarf_Regtable3 *rt;
+ Dwarf_Addr pc;
+ Dwarf_Half cfa;
+ int i, ret;
+
+ dbg = fde != NULL ? fde->fde_dbg : NULL;
+
+ if (fde == NULL || reg_table == NULL || row_pc == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ assert(dbg != NULL);
+
+ if (pc_requested < fde->fde_initloc ||
+ pc_requested >= fde->fde_initloc + fde->fde_adrange) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_PC_NOT_IN_FDE_RANGE);
+ return (DW_DLV_ERROR);
+ }
+
+ ret = _dwarf_frame_get_internal_table(fde, pc_requested, &rt, &pc,
+ error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ /*
+ * Copy the CFA rule to the column intended for holding the CFA,
+ * if it's within the range of regtable.
+ */
+ cfa = dbg->dbg_frame_cfa_value;
+ if (cfa < DW_REG_TABLE_SIZE) {
+ reg_table->rules[cfa].dw_offset_relevant =
+ CFA.dw_offset_relevant;
+ reg_table->rules[cfa].dw_regnum = CFA.dw_regnum;
+ reg_table->rules[cfa].dw_offset = CFA.dw_offset_or_block_len;
+ }
+
+ /*
+ * Copy other columns.
+ */
+ for (i = 0; i < DW_REG_TABLE_SIZE && i < dbg->dbg_frame_rule_table_size;
+ i++) {
+
+ /* Do not overwrite CFA column */
+ if (i == cfa)
+ continue;
+
+ reg_table->rules[i].dw_offset_relevant =
+ rt->rt3_rules[i].dw_offset_relevant;
+ reg_table->rules[i].dw_regnum = rt->rt3_rules[i].dw_regnum;
+ reg_table->rules[i].dw_offset =
+ rt->rt3_rules[i].dw_offset_or_block_len;
+ }
+
+ *row_pc = pc;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_fde_info_for_reg3(Dwarf_Fde fde, Dwarf_Half table_column,
+ Dwarf_Addr pc_requested, Dwarf_Small *value_type,
+ Dwarf_Signed *offset_relevant, Dwarf_Signed *register_num,
+ Dwarf_Signed *offset_or_block_len, Dwarf_Ptr *block_ptr,
+ Dwarf_Addr *row_pc, Dwarf_Error *error)
+{
+ Dwarf_Regtable3 *rt;
+ Dwarf_Debug dbg;
+ Dwarf_Addr pc;
+ int ret;
+
+ dbg = fde != NULL ? fde->fde_dbg : NULL;
+
+ if (fde == NULL || value_type == NULL || offset_relevant == NULL ||
+ register_num == NULL || offset_or_block_len == NULL ||
+ block_ptr == NULL || row_pc == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (pc_requested < fde->fde_initloc ||
+ pc_requested >= fde->fde_initloc + fde->fde_adrange) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_PC_NOT_IN_FDE_RANGE);
+ return (DW_DLV_ERROR);
+ }
+
+ ret = _dwarf_frame_get_internal_table(fde, pc_requested, &rt, &pc,
+ error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ if (table_column >= dbg->dbg_frame_rule_table_size) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_FRAME_TABLE_COL_BAD);
+ return (DW_DLV_ERROR);
+ }
+
+ *value_type = RL.dw_value_type;
+ *offset_relevant = RL.dw_offset_relevant;
+ *register_num = RL.dw_regnum;
+ *offset_or_block_len = RL.dw_offset_or_block_len;
+ *block_ptr = RL.dw_block_ptr;
+ *row_pc = pc;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_fde_info_for_cfa_reg3(Dwarf_Fde fde, Dwarf_Addr pc_requested,
+ Dwarf_Small *value_type, Dwarf_Signed *offset_relevant,
+ Dwarf_Signed *register_num, Dwarf_Signed *offset_or_block_len,
+ Dwarf_Ptr *block_ptr, Dwarf_Addr *row_pc, Dwarf_Error *error)
+{
+ Dwarf_Regtable3 *rt;
+ Dwarf_Debug dbg;
+ Dwarf_Addr pc;
+ int ret;
+
+ dbg = fde != NULL ? fde->fde_dbg : NULL;
+
+ if (fde == NULL || value_type == NULL || offset_relevant == NULL ||
+ register_num == NULL || offset_or_block_len == NULL ||
+ block_ptr == NULL || row_pc == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (pc_requested < fde->fde_initloc ||
+ pc_requested >= fde->fde_initloc + fde->fde_adrange) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_PC_NOT_IN_FDE_RANGE);
+ return (DW_DLV_ERROR);
+ }
+
+ ret = _dwarf_frame_get_internal_table(fde, pc_requested, &rt, &pc,
+ error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ *value_type = CFA.dw_value_type;
+ *offset_relevant = CFA.dw_offset_relevant;
+ *register_num = CFA.dw_regnum;
+ *offset_or_block_len = CFA.dw_offset_or_block_len;
+ *block_ptr = CFA.dw_block_ptr;
+ *row_pc = pc;
+
+ return (DW_DLV_OK);
+}
+
+#undef RL
+#undef CFA
+
+int
+dwarf_get_fde_info_for_all_regs3(Dwarf_Fde fde, Dwarf_Addr pc_requested,
+ Dwarf_Regtable3 *reg_table, Dwarf_Addr *row_pc, Dwarf_Error *error)
+{
+ Dwarf_Regtable3 *rt;
+ Dwarf_Debug dbg;
+ Dwarf_Addr pc;
+ int ret;
+
+ dbg = fde != NULL ? fde->fde_dbg : NULL;
+
+ if (fde == NULL || reg_table == NULL || reg_table->rt3_rules == NULL ||
+ row_pc == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ assert(dbg != NULL);
+
+ if (pc_requested < fde->fde_initloc ||
+ pc_requested >= fde->fde_initloc + fde->fde_adrange) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_PC_NOT_IN_FDE_RANGE);
+ return (DW_DLV_ERROR);
+ }
+
+ ret = _dwarf_frame_get_internal_table(fde, pc_requested, &rt, &pc,
+ error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ ret = _dwarf_frame_regtable_copy(dbg, &reg_table, rt, error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ *row_pc = pc;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_expand_frame_instructions(Dwarf_Cie cie, Dwarf_Ptr instruction,
+ Dwarf_Unsigned len, Dwarf_Frame_Op **ret_oplist, Dwarf_Signed *ret_opcnt,
+ Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ int ret;
+
+ dbg = cie != NULL ? cie->cie_dbg : NULL;
+
+ if (cie == NULL || instruction == NULL || len == 0 ||
+ ret_oplist == NULL || ret_opcnt == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ ret = _dwarf_frame_get_fop(dbg, cie->cie_addrsize, instruction, len,
+ ret_oplist, ret_opcnt, error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ return (DW_DLV_OK);
+}
+
+Dwarf_Half
+dwarf_set_frame_rule_table_size(Dwarf_Debug dbg, Dwarf_Half value)
+{
+ Dwarf_Half old_value;
+
+ old_value = dbg->dbg_frame_rule_table_size;
+ dbg->dbg_frame_rule_table_size = value;
+
+ return (old_value);
+}
+
+Dwarf_Half
+dwarf_set_frame_rule_initial_value(Dwarf_Debug dbg, Dwarf_Half value)
+{
+ Dwarf_Half old_value;
+
+ old_value = dbg->dbg_frame_rule_initial_value;
+ dbg->dbg_frame_rule_initial_value = value;
+
+ return (old_value);
+}
+
+Dwarf_Half
+dwarf_set_frame_cfa_value(Dwarf_Debug dbg, Dwarf_Half value)
+{
+ Dwarf_Half old_value;
+
+ old_value = dbg->dbg_frame_cfa_value;
+ dbg->dbg_frame_cfa_value = value;
+
+ return (old_value);
+}
+
+Dwarf_Half
+dwarf_set_frame_same_value(Dwarf_Debug dbg, Dwarf_Half value)
+{
+ Dwarf_Half old_value;
+
+ old_value = dbg->dbg_frame_same_value;
+ dbg->dbg_frame_same_value = value;
+
+ return (old_value);
+}
+
+Dwarf_Half
+dwarf_set_frame_undefined_value(Dwarf_Debug dbg, Dwarf_Half value)
+{
+ Dwarf_Half old_value;
+
+ old_value = dbg->dbg_frame_undefined_value;
+ dbg->dbg_frame_undefined_value = value;
+
+ return (old_value);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_funcs.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_funcs.m4
new file mode 100644
index 0000000..5960ee9
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_funcs.m4
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_funcs.m4 2073 2011-10-27 03:30:47Z jkoshy $");
+
+/* WARNING: GENERATED FROM __file__. */
+
+divert(-1)
+include(SRCDIR`/dwarf_nametbl.m4')
+divert(0)
+MAKE_NAMETBL_API(func,Func,func,static_func)
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_AT_name.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_AT_name.3
new file mode 100644
index 0000000..473adc3
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_AT_name.3
@@ -0,0 +1,259 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_AT_name.3 3142 2015-01-29 23:11:14Z jkoshy $
+.\"
+.Dd April 22, 2011
+.Os
+.Dt DWARF_GET_AT_NAME 3
+.Sh NAME
+.Nm dwarf_get_ACCESS_name ,
+.Nm dwarf_get_AT_name ,
+.Nm dwarf_get_ATE_name ,
+.Nm dwarf_get_CC_name ,
+.Nm dwarf_get_CFA_name ,
+.Nm dwarf_get_CHILDREN_name ,
+.Nm dwarf_get_DS_name ,
+.Nm dwarf_get_DSC_name ,
+.Nm dwarf_get_EH_name ,
+.Nm dwarf_get_END_name ,
+.Nm dwarf_get_FORM_name ,
+.Nm dwarf_get_ID_name ,
+.Nm dwarf_get_INL_name ,
+.Nm dwarf_get_LANG_name ,
+.Nm dwarf_get_LNE_name ,
+.Nm dwarf_get_LNS_name ,
+.Nm dwarf_get_MACINFO_name ,
+.Nm dwarf_get_OP_name ,
+.Nm dwarf_get_ORD_name ,
+.Nm dwarf_get_TAG_name ,
+.Nm dwarf_get_VIRTUALITY_name ,
+.Nm dwarf_get_VIS_name
+.Nd retrieve the symbolic names of DWARF constants
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_ACCESS_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_AT_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_ATE_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_CC_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_CFA_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_CHILDREN_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_DS_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_DSC_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_EH_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_END_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_FORM_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_ID_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_INL_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_LANG_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_LNE_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_LNS_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_MACINFO_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_OP_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_ORD_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_TAG_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_VIRTUALITY_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Ft int
+.Fo dwarf_get_VIS_name
+.Fa "unsigned val"
+.Fa "char **str"
+.Fc
+.Sh DESCRIPTION
+These functions return the symbolic name of a numeric DWARF constant.
+.Pp
+Argument
+.Ar val
+specifies the numeric value whose symbolic name is desired.
+.Pp
+Argument
+.Ar str
+should point to a location which will hold the returned
+NUL-terminated string containing the symbolic name of the
+specified value.
+.Pp
+The list of functions and the DWARF constants that they accept are:
+.Pp
+.Bl -tag -width ".Fn dwarf_get_VIRTUALITY_name" -compact
+.It Fn dwarf_get_ACCESS_name
+.Dv DW_ACCESS_*
+constants.
+.It Fn dwarf_get_AT_name
+.Dv DW_AT_*
+constants.
+.It Fn dwarf_get_ATE_name
+.Dv DW_ATE_*
+constants.
+.It Fn dwarf_get_CC_name
+.Dv DW_CC_*
+constants.
+.It Fn dwarf_get_CFA_name
+.Dv DW_CFA_*
+constants.
+.It Fn dwarf_get_CHILDREN_name
+.Dv DW_CHILDREN_*
+constants.
+.It Fn dwarf_get_DS_name
+.Dv DW_DS_*
+constants.
+.It Fn dwarf_get_DSC_name
+.Dv DW_DSC_*
+constants.
+.It Fn dwarf_get_EH_name
+.Dv DW_EH_PE_*
+constants.
+.It Fn dwarf_get_END_name
+.Dv DW_END_*
+constants.
+.It Fn dwarf_get_FORM_name
+.Dv DW_FORM_*
+constants.
+.It Fn dwarf_get_ID_name
+.Dv DW_ID_*
+constants.
+.It Fn dwarf_get_INL_name
+.Dv DW_INL_*
+constants.
+.It Fn dwarf_get_LANG_name
+.Dv DW_LANG_*
+constants.
+.It Fn dwarf_get_LNE_name
+.Dv DW_LNE_*
+constants.
+.It Fn dwarf_get_LNS_name
+.Dv DW_LNS_*
+constants.
+.It Fn dwarf_get_MACINFO_name
+.Dv DW_MACINFO_*
+constants.
+.It Fn dwarf_get_OP_name
+.Dv DW_OP_*
+constants.
+.It Fn dwarf_get_ORD_name
+.Dv DW_ORD_*
+constants.
+.It Fn dwarf_get_TAG_name
+.Dv DW_TAG_*
+constants.
+.It Fn dwarf_get_VIRTUALITY_name
+.Dv DW_VIRTUALITY_*
+constants.
+.It Fn dwarf_get_VIS_name
+.Dv DW_VIS_*
+constants.
+.El
+.Sh RETURN VALUES
+These functions return
+.Dv DW_DLV_OK on success.
+If the DWARF constant denoted by argument
+.Ar val
+is not recognized, these function return
+.Dv DW_DLV_NO_ENTRY .
+.Sh SEE ALSO
+.Xr dwarf 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev.3
new file mode 100644
index 0000000..afb5468
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev.3
@@ -0,0 +1,179 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_abbrev.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd March 27, 2011
+.Os
+.Dt DWARF_GET_ABBREV 3
+.Sh NAME
+.Nm dwarf_get_abbrev
+.Nd retrieve abbreviation information
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_abbrev
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Unsigned offset"
+.Fa "Dwarf_Abbrev *ret_abbrev"
+.Fa "Dwarf_Unsigned *length"
+.Fa "Dwarf_Unsigned *attr_count"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_abbrev
+retrieves information about an abbreviation from the DWARF abbreviations
+section,
+.Dq ".debug_abbrev" .
+Abbreviation information is returned using an opaque descriptor
+of type
+.Vt Dwarf_Abbrev .
+The returned
+.Vt Dwarf_Abbrev
+descriptor may then be passed to the other abbreviation related APIs
+in the DWARF(3) API to retrieve specific information about the
+abbreviation.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+.Pp
+Argument
+.Ar offset
+should be an offset, relative to the
+.Dq ".debug_abbrev"
+section, to the start of an abbreviation entry.
+.Pp
+Argument
+.Ar ret_abbrev
+should point to a location that will hold a pointer to the
+returned
+.Vt Dwarf_Abbrev
+descriptor.
+.Pp
+Argument
+.Ar length
+should point to a location that will hold the number of bytes used
+by the abbrevation in the DWARF
+.Dq ".debug_abbrev"
+section.
+.Pp
+Argument
+.Ar attr_count
+should point to a location that will hold the number of
+attributes in the abbrevation.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Ss Memory Management
+The memory area used for the
+.Vt Dwarf_Abbrev
+descriptor returned in argument
+.Ar ret_abbrev
+is allocated by the
+.Lb libdwarf .
+Application code should use function
+.Fn dwarf_dealloc
+with the allocation type
+.Dv DW_DLA_ABBREV
+to free the memory area when the
+.Vt Dwarf_Abbrev
+descriptor is no longer needed.
+.Ss Application Programming Notes
+The last abbreviation entry in a standard DWARF abbreviation section
+will have a special length value of 1.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_abbrev
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+It returns
+.Dv DW_DLV_NO_ENTRY
+if there is no abbreviation information at offset
+.Ar offset .
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_abbrev
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar ret_abbrev ,
+.Ar length
+or
+.Ar attr_count
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+There is no abbreviation information at offset
+.Ar offset .
+.El
+.Sh EXAMPLE
+To loop through all the abbreviation information associated with
+a DWARF debug context, use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Abbrev ab;
+Dwarf_Off aboff;
+Dwarf_Unsigned length, attr_count;
+Dwarf_Half tag;
+Dwarf_Error de;
+int ret;
+
+while ((ret = dwarf_next_cu_header(dbg, NULL, NULL, &aboff,
+ NULL, NULL, &de)) == DW_DLV_OK) {
+ while ((ret = dwarf_get_abbrev(re->dbg, aboff, &ab, &length,
+ &attr_count, &de)) == DW_DLV_OK) {
+ if (length == 1) /* Last entry. */
+ break;
+ aboff += length;
+ if (dwarf_get_abbrev_tag(ab, &tag, &de) != DW_DLV_OK) {
+ warnx("dwarf_get_abbrev_tag failed: %s",
+ dwarf_errmsg(de));
+ continue;
+ }
+ if (ret != DW_DLV_OK)
+ warnx("dwarf_get_abbrev: %s", dwarf_errmsg(de));
+}
+if (ret == DW_DLV_ERROR)
+ warnx("dwarf_next_cu_header: %s", dwarf_errmsg(de));
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_dealloc 3 ,
+.Xr dwarf_get_abbrev_tag 3 ,
+.Xr dwarf_get_abbrev_code 3 ,
+.Xr dwarf_get_abbrev_children_flag 3 ,
+.Xr dwarf_get_abbrev_entry 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_children_flag.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_children_flag.3
new file mode 100644
index 0000000..6f9ed84
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_children_flag.3
@@ -0,0 +1,100 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_abbrev_children_flag.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd March 14, 2011
+.Os
+.Dt DWARF_GET_ABBREV_CHILDREN_FLAG 3
+.Sh NAME
+.Nm dwarf_get_abbrev_children_flag
+.Nd return a flag indicating the presence of children
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_abbrev_children_flag
+.Fa "Dwarf_Abbrev abbrev"
+.Fa "Dwarf_Signed *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_abbrev_children_flag
+retrieves a flag indicating whether the DWARF debug information entry
+associated with a DWARF abbreviation descriptor has child entries.
+.Pp
+Argument
+.Ar abbrev
+should be a valid DWARF abbreviation descriptor, as returned by
+.Xr dwarf_get_abbrev 3 .
+.Pp
+Argument
+.Ar ret
+should point to a location which will hold the returned
+flag.
+The value returned will be one of the following:
+.Bl -tag -width ".Dv DW_CHILDREN_yes" -compact
+.It Dv DW_CHILDREN_yes
+The debugging information entry associated with the
+specified abbreviation descriptor has children.
+.It Dv DW_CHILDREN_no
+The debugging information entry associated with the
+specified abbreviation descriptor has no children.
+.El
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Pp
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_abbrev_children_flag
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_abbrev_children_flag
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar abbrev
+or
+.Ar ret
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_abbrev 3 ,
+.Xr dwarf_get_abbrev_code 3 ,
+.Xr dwarf_get_abbrev_tag 3 ,
+.Xr dwarf_get_abbrev_entry 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_code.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_code.3
new file mode 100644
index 0000000..18c3c29
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_code.3
@@ -0,0 +1,86 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_abbrev_code.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd March 13, 2011
+.Os
+.Dt DWARF_GET_ABBREV_CODE 3
+.Sh NAME
+.Nm dwarf_get_abbrev_code
+.Nd retrieve the abbreviation code for an abbreviation
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_abbrev_code
+.Fa "Dwarf_Abbrev abbrev"
+.Fa "Dwarf_Unsigned *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_abbrev_code
+retrieves the abbreviation code for the abbreviation entry descriptor
+referenced by argument
+.Ar abbrev .
+.Pp
+Argument
+.Ar ret
+should point to a location which will hold the returned
+abbreviation code.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_abbrev_code
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_abbrev_code
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar abbrev
+or
+.Ar ret
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_abbrev 3 ,
+.Xr dwarf_get_abbrev_tag 3 ,
+.Xr dwarf_get_abbrev_children_flag 3 ,
+.Xr dwarf_get_abbrev_entry 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_entry.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_entry.3
new file mode 100644
index 0000000..f9e084b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_entry.3
@@ -0,0 +1,159 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_abbrev_entry.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd April 02, 2011
+.Os
+.Dt DWARF_GET_ABBREV_ENTRY 3
+.Sh NAME
+.Nm dwarf_get_abbrev_entry
+.Nd retrieve attribute information from an abbreviation descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_abbrev_entry
+.Fa "Dwarf_Abbrev abbrev"
+.Fa "Dwarf_Signed ndx"
+.Fa "Dwarf_Half *code"
+.Fa "Dwarf_Signed *form"
+.Fa "Dwarf_Off *offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_abbrev_entry
+retrieves attribute information from a DWARF abbreviation descriptor.
+.Pp
+Argument
+.Ar abbrev
+should be a valid abbreviation descriptor, as returned by function
+.Xr dwarf_get_abbrev 3 .
+.Pp
+Argument
+.Ar ndx
+specifies the 0-based index of the attribute.
+The total count of the attributes contained in the abbreviation
+entry can be retrieved using the function
+.Xr dwarf_get_abbrev 3 .
+.Pp
+Argument
+.Ar code
+should point to a location which will hold a returned
+attribute code.
+.Pp
+Argument
+.Ar form
+should point to a location which will hold the returned
+form of the attribute.
+.Pp
+Argument
+.Ar offset
+should point to a location which will hold a returned offset, relative
+to the
+.Dq ".debug_abbrev"
+section, for the specified attribute.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_abbrev_entry
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+It returns
+.Dv DW_DLV_NO_ENTRY
+if the attribute index specified by argument
+.Ar ndx
+is out of range.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_abbrev_entry
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar abbrev ,
+.Ar code ,
+.Ar form
+or
+.Ar offset
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+The attribute index specified by argument
+.Ar ndx
+was out of range.
+.El
+.Sh EXAMPLE
+To loop through all the attribute entries contained in the
+abbreviation section, use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Abbrev ab;
+Dwarf_Off aboff, atoff;
+Dwarf_Signed form;
+Dwarf_Half attr;
+Dwarf_Unsigned length, attr_count;
+Dwarf_Error de;
+int i, ret;
+
+/* ...allocate 'dbg' using dwarf_init(3) ... */
+
+while ((ret = dwarf_next_cu_header(dbg, NULL, NULL, &aboff,
+ NULL, NULL, &de)) == DW_DLV_OK) {
+ while ((ret = dwarf_get_abbrev(dbg, aboff, &ab, &length,
+ &attr_count, &de)) == DW_DLV_OK) {
+ if (length == 1) /* Last entry. */
+ break;
+ aboff += length;
+ for (i = 0; (Dwarf_Unsigned) i < attr_count; i++) {
+ if (dwarf_get_abbrev_entry(ab, i,
+ &attr, &form, &atoff, &de) != DW_DLV_OK) {
+ warnx("dwarf_get_abbrev_entry failed:"
+ " %s", dwarf_errmsg(de));
+ continue;
+ }
+ /* .. use the retrieved information ... */
+ }
+ }
+
+ if (ret != DW_DLV_OK)
+ warnx("dwarf_get_abbrev: %s", dwarf_errmsg(de));
+}
+
+if (ret == DW_DLV_ERROR)
+ warnx("dwarf_next_cu_header: %s", dwarf_errmsg(de));
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_abbrev 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_tag.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_tag.3
new file mode 100644
index 0000000..c1fc37f
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev_tag.3
@@ -0,0 +1,86 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_abbrev_tag.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd March 13, 2011
+.Os
+.Dt DWARF_GET_ABBREV_TAG 3
+.Sh NAME
+.Nm dwarf_get_abbrev_tag
+.Nd retrieve the tag for an abbreviation
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_abbrev_tag
+.Fa "Dwarf_Abbrev abbrev"
+.Fa "Dwarf_Half *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_abbrev_tag
+retrieves the tag for the abbreviation entry descriptor referenced by
+argument
+.Ar abbrev .
+.Pp
+Argument
+.Ar ret
+should point to a location which will hold the returned
+abbreviation tag.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_abbrev_tag
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_abbrev_tag
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar abbrev
+or
+.Ar ret
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_abbrev 3 ,
+.Xr dwarf_get_abbrev_code 3 ,
+.Xr dwarf_get_abbrev_children_flag 3 ,
+.Xr dwarf_get_abbrev_entry 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_address_size.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_address_size.3
new file mode 100644
index 0000000..856b375
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_address_size.3
@@ -0,0 +1,82 @@
+.\" Copyright (c) 2010 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_address_size.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd April 14, 2010
+.Os
+.Dt DWARF_GET_ADDRESS_SIZE 3
+.Sh NAME
+.Nm dwarf_get_address_size
+.Nd return the number of bytes needed to represent an address
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_address_size
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Half *addr_size"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_address_size
+returns the size in bytes of a native address for a program object.
+.Pp
+Argument
+.Ar dbg
+should denote a DWARF debug context created from a program object using
+.Xr dwarf_init 3 .
+Argument
+.Ar addr_size
+should point to a location that will hold the returned size.
+Argument
+.Ar err ,
+if non-NULL, it will be used to return error information.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_tag
+returns
+.Dv DW_DLV_OK .
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_address_size
+can fail with the following error:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arguments
+.Ar dbg
+or
+.Ar addr_size
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_init 3 ,
+.Xr dwarf_finish 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_arange.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_arange.3
new file mode 100644
index 0000000..b169140
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_arange.3
@@ -0,0 +1,121 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_arange.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd April 16, 2011
+.Os
+.Dt DWARF_GET_ARANGE 3
+.Sh NAME
+.Nm dwarf_get_arange
+.Nd retrieve the address range descriptor for an address
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_arange
+.Fa "Dwarf_Arange *ar_list"
+.Fa "Dwarf_Unsigned ar_cnt"
+.Fa "Dwarf_Addr addr"
+.Fa "Dwarf_Arange *ret_ar"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_arange
+searches an array of
+.Vt Dwarf_Arange
+descriptors for one that covers a given address.
+.Pp
+Argument
+.Ar ar_list
+should point to an array of
+.Vt Dwarf_Arange
+descriptors.
+.Pp
+Argument
+.Ar ar_cnt
+specifies the number of
+.Vt Dwarf_Arange
+descriptors in the array pointed to by argument
+.Ar ar_list .
+.Pp
+Argument
+.Ar addr
+specifies the address being looked up.
+.Pp
+Argument
+.Ar ret_ar
+will be used to store the
+.Vt Dwarf_Arange
+descriptor that covers the given address.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_arange
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+It returns
+.Dv DW_DLV_NO_ENTRY
+if there is no
+.Vt Dwarf_Arange
+descriptor that covers the provided address.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_arange
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar ar_list
+or
+.Ar ret_ar
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+Value of argument
+.Ar ar_cnt
+equals to 0.
+.It Bq Er DW_DLE_NO_ENTRY
+A
+.Vt Dwarf_Arange
+descriptor that covers the given address
+was not found.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_aranges 3 ,
+.Xr dwarf_get_arange_cu_header_offset 3 ,
+.Xr dwarf_get_arange_info 3 ,
+.Xr dwarf_get_cu_die_offset 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_arange_info.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_arange_info.3
new file mode 100644
index 0000000..3878edd
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_arange_info.3
@@ -0,0 +1,135 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_arange_info.3 3142 2015-01-29 23:11:14Z jkoshy $
+.\"
+.Dd April 16, 2011
+.Os
+.Dt DWARF_GET_ARANGE_INFO 3
+.Sh NAME
+.Nm dwarf_get_arange_info
+.Nd extract address range information from a descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_arange_info
+.Fa "Dwarf_Arange ar"
+.Fa "Dwarf_Addr *start"
+.Fa "Dwarf_Unsigned *length"
+.Fa "Dwarf_Off *cu_die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_arange_info
+extracts address range information from a
+.Vt Dwarf_Arange
+descriptor.
+.Pp
+Argument
+.Ar ar
+should reference a valid
+.Vt Dwarf_Arange
+descriptor returned by function
+.Xr dwarf_get_aranges 3 .
+.Pp
+Argument
+.Ar start
+should point to a location which will hold the start value of the
+address range associated with the descriptor.
+.Pp
+Argument
+.Ar length
+should point to a location which will hold the length in bytes of the
+address range associated with the descriptor.
+.Pp
+Argument
+.Ar cu_die_offset
+should point to a location which will be set to an offset, relative to
+the
+.Dq ".debug_info"
+section, of the first debugging information entry in the compilation
+unit associated with argument
+.Ar ar .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_arange_info
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_arange_info
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar ar ,
+.Ar start ,
+.Ar length
+or
+.Ar cu_die_offset
+was NULL.
+.El
+.Sh EXAMPLE
+To loop through all the address lookup table entries, use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Addr start;
+Dwarf_Arange *aranges;
+Dwarf_Off die_off;
+Dwarf_Signed i, cnt;
+Dwarf_Unsigned length;
+Dwarf_Error de;
+
+if (dwarf_get_aranges(dbg, &aranges, &cnt, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_get_aranges: %s",
+ dwarf_errmsg(de));
+for (i = 0; i < cnt; i++) {
+ if (dwarf_get_arange_info(aranges[i], &start, &length,
+ &die_off, &de) != DW_DLV_OK) {
+ warnx("dwarf_get_arange_info: %s",
+ dwarf_errmsg(de));
+ continue;
+ }
+ /* Do something with the returned information. */
+}
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_arange 3 ,
+.Xr dwarf_get_aranges 3 ,
+.Xr dwarf_get_arange_cu_header_offset 3 ,
+.Xr dwarf_get_cu_die_offset 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_aranges.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_aranges.3
new file mode 100644
index 0000000..1444704
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_aranges.3
@@ -0,0 +1,148 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_aranges.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_GET_ARANGES 3
+.Sh NAME
+.Nm dwarf_get_aranges
+.Nd retrieve program address space mappings
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_aranges
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Arange **ar_list"
+.Fa "Dwarf_Signed *ar_cnt"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+The function
+.Fn dwarf_get_aranges
+retrieves address range information from the
+.Dq ".debug_aranges"
+DWARF section.
+Information about address ranges is returned using opaque descriptors
+of type
+.Vt Dwarf_Arange ,
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+.Pp
+Argument
+.Ar ar_list
+should point to a location which will be set to a pointer to an array
+of
+.Vt Dwarf_Arange
+descriptors.
+.Pp
+Argument
+.Ar ar_cnt
+should point to a location which will be set to the number of
+descriptors returned.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Ss Memory Management
+The memory area used for the array returned in argument
+.Ar ar_list
+is owned by
+.Lb libdwarf .
+Application code should not attempt to directly free this area.
+Portable applications should instead use
+.Xr dwarf_dealloc 3
+to indicate that the memory area may be freed.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_aranges
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+It returns
+.Dv DW_DLV_NO_ENTRY
+if there is no
+.Dq ".debug_aranges"
+section associated with the specified debugging context.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_aranges
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar ar_list
+or
+.Ar ar_cnt
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+The debugging context
+.Ar dbg
+did not contain a
+.Dq ".debug_aranges"
+string section.
+.El
+.Sh EXAMPLE
+To loop through all the address lookup table entries, use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Addr start;
+Dwarf_Arange *aranges;
+Dwarf_Off die_off;
+Dwarf_Signed i, cnt;
+Dwarf_Unsigned length;
+Dwarf_Error de;
+
+if (dwarf_get_aranges(dbg, &aranges, &cnt, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_get_aranges: %s",
+ dwarf_errmsg(de));
+
+for (i = 0; i < cnt; i++) {
+ if (dwarf_get_arange_info(aranges[i], &start, &length,
+ &die_off, &de) != DW_DLV_OK) {
+ warnx("dwarf_get_arange_info: %s",
+ dwarf_errmsg(de));
+ continue;
+ }
+ /* Do something with the returned information. */
+}
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_arange 3 ,
+.Xr dwarf_get_arange_cu_header_offset 3 ,
+.Xr dwarf_get_arange_info 3 ,
+.Xr dwarf_get_cu_die_offset 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_index.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_index.3
new file mode 100644
index 0000000..d6bc015
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_index.3
@@ -0,0 +1,86 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_cie_index.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd May 22, 2011
+.Os
+.Dt DWARF_GET_CIE_INDEX 3
+.Sh NAME
+.Nm dwarf_get_cie_index
+.Nd retrieve the index of a CIE descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_cie_index
+.Fa "Dwarf_Cie cie"
+.Fa "Dwarf_Signed *cie_index"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_cie_index
+retrieves the zero-based index of a given CIE descriptor in the array
+of CIE descriptors returned by the functions
+.Xr dwarf_get_fde_list 3
+and
+.Xr dwarf_get_fde_list_eh 3 .
+.Pp
+Argument
+.Ar cie
+should reference a valid DWARF CIE descriptor.
+.Pp
+Argument
+.Ar cie_index
+should point to a location that will hold the returned index.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_cie_index
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_cie_index
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arugments
+.Ar cie
+or
+.Ar cie_index
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_cie_info 3 ,
+.Xr dwarf_get_cie_of_fde 3 ,
+.Xr dwarf_get_fde_list 3 ,
+.Xr dwarf_get_fde_list_eh 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_info.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_info.3
new file mode 100644
index 0000000..f3710ca
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_info.3
@@ -0,0 +1,150 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_cie_info.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd May 29, 2011
+.Os
+.Dt DWARF_GET_CIE_INFO 3
+.Sh NAME
+.Nm dwarf_get_cie_info
+.Nd retrieve information associated with a CIE descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_cie_info
+.Fa "Dwarf_Cie cie"
+.Fa "Dwarf_Unsigned *cie_byte_len"
+.Fa "Dwarf_Small *version"
+.Fa "char **augmentation"
+.Fa "Dwarf_Unsigned *caf"
+.Fa "Dwarf_Unsigned *daf"
+.Fa "Dwarf_Half *ra"
+.Fa "Dwarf_Ptr *init_inst"
+.Fa "Dwarf_Unsigned *inst_len"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_cie_info
+retrieves the information associated with a given CIE descriptor.
+.Pp
+Argument
+.Ar cie
+should reference a valid DWARF CIE descriptor, such as would be
+returned by function
+.Xr dwarf_get_cie_of_fde 3 .
+.Pp
+Argument
+.Ar cie_byte_len
+should point to a location that will hold the length in bytes of
+the CIE descriptor itself.
+.Pp
+Argument
+.Ar version
+should point to a location that will hold the version number of
+the CIE descriptor.
+.Pp
+Arugment
+.Ar augmentation
+should point to a location that will be set to a pointer to a
+NUL-terminated string containing augmentation data encoded as UTF-8.
+.Pp
+Argument
+.Ar caf
+should point to a location that will hold the code alignment
+factor recorded in the CIE descriptor.
+.Pp
+Arugment
+.Ar daf
+should point to a location that will hold the data alignment
+factor recorded in the CIE descriptor.
+.Pp
+Argument
+.Ar ra
+should point to a location that will hold the return address
+recorded in the CIE descriptor.
+.Pp
+Argument
+.Ar init_inst
+should point to a location that will be set to a pointer to an array
+of bytes containing the initial instructions associated with the CIE
+descriptor.
+.Pp
+Argument
+.Ar inst_len
+should point to a location that will hold the length in bytes
+of the initial instructions returned in argument
+.Ar init_inst .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_cie_info
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_cie_info
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar cie ,
+.Ar cie_byte_len ,
+.Ar version ,
+.Ar augmentation ,
+.Ar caf ,
+.Ar daf ,
+.Ar ra ,
+.Ar init_inst
+or
+.Ar inst_len
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_cie_index 3 ,
+.Xr dwarf_get_cie_of_fde 3 ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_info_for_all_regs 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_fde_instr_bytes 3 ,
+.Xr dwarf_get_fde_list 3 ,
+.Xr dwarf_get_fde_list_eh 3 ,
+.Xr dwarf_get_fde_n 3 ,
+.Xr dwarf_get_fde_range 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_of_fde.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_of_fde.3
new file mode 100644
index 0000000..4fa5c5d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cie_of_fde.3
@@ -0,0 +1,88 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_cie_of_fde.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd May 22, 2011
+.Os
+.Dt DWARF_GET_CIE_OF_FDE 3
+.Sh NAME
+.Nm dwarf_get_cie_of_fde
+.Nd retrieve CIE descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_cie_of_fde
+.Fa "Dwarf_Fde fde"
+.Fa "Dwarf_Cie *ret_cie"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_cie_of_fde
+retrieves the CIE descriptor associated with a given FDE descriptor.
+.Pp
+Argument
+.Ar fde
+should reference a valid FDE descriptor.
+.Pp
+Argument
+.Ar ret_cie
+should point to a location that will hold the returned CIE
+descriptor.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_cie_of_fde
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_cie_of_fde
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of arugments
+.Ar fde
+or
+.Ar ret_cie
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_cie_info 3 ,
+.Xr dwarf_get_cie_index 3 ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_n 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cu_die_offset.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cu_die_offset.3
new file mode 100644
index 0000000..b71e431
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_cu_die_offset.3
@@ -0,0 +1,103 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_cu_die_offset.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd April 10, 2011
+.Os
+.Dt DWARF_GET_CU_DIE_OFFSET 3
+.Sh NAME
+.Nm dwarf_get_arange_cu_header_offset ,
+.Nm dwarf_get_cu_die_offset
+.Nd retrieve compilation unit offsets
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_arange_cu_header_offset
+.Fa "Dwarf_Arange ar"
+.Fa "Dwarf_Off *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_get_cu_die_offset
+.Fa "Dwarf_Arange ar"
+.Fa "Dwarf_Off *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions retrieve the offsets, relative to the
+.Dq ".debug_info"
+DWARF section, of the debugging information entries describing the
+compilation unit associated with a
+.Vt Dwarf_Arange
+descriptor.
+.Pp
+Function
+.Fn dwarf_get_arange_cu_header_offset
+retrieves the offset of the compilation unit header associated with
+argument
+.Ar ar ,
+and stores it in the location pointed to by argument
+.Ar ret .
+.Pp
+Function
+.Fn dwarf_get_cu_die_offset
+retrieves the offset of the debugging information entry for the
+compilation unit associated with argument
+.Ar ar ,
+and stores it in the location pointed to by argument
+.Ar ret .
+.Pp
+If argument
+.Ar err
+is not NULL, these functions will use it to store error information,
+in case of an error.
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar ar
+was not a valid
+.Vt Dwarf_Arange
+descriptor.
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar ret
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_arange 3 ,
+.Xr dwarf_get_arange_info 3 ,
+.Xr dwarf_get_aranges 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_die_infotypes_flag.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_die_infotypes_flag.3
new file mode 100644
index 0000000..4f5a19a
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_die_infotypes_flag.3
@@ -0,0 +1,73 @@
+.\" Copyright (c) 2014 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_die_infotypes_flag.3 3118 2014-12-20 20:30:06Z jkoshy $
+.\"
+.Dd December 20, 2014
+.Os
+.Dt DWARF_GET_DIE_INFOTYPES_FLAG 3
+.Sh NAME
+.Nm dwarf_get_die_infotypes_flag
+.Nd indicate the originating DWARF section for a DIE
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_Bool
+.Fo dwarf_get_die_infotypes_flag
+.Fa "Dwarf_Die die"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_die_infotypes_flag
+returns a flag indicating the originating DWARF section for the
+debugging information entry referenced by argument
+.Ar die .
+.Pp
+Argument
+.Ar die
+should reference a valid debugging information entry descriptor.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_die_infotypes_flag
+returns a non-zero value if argument
+.Ar die
+originates in the
+.Dq .debug_info
+section.
+.Pp
+It returns zero if argument
+.Ar die
+originates in the
+.Dq .debug_types
+section.
+.Sh ERRORS
+Function
+.Fn dwarf_get_die_infotypes_flag
+always succeeds.
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_next_cu_header_c 3 ,
+.Xr dwarf_offdie_b 3 ,
+.Xr dwarf_siblingof_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_elf.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_elf.3
new file mode 100644
index 0000000..c93a7ef
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_elf.3
@@ -0,0 +1,103 @@
+.\" Copyright (c) 2009 Joseph Koshy. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" This software is provided by Joseph Koshy ``as is'' and
+.\" any express or implied warranties, including, but not limited to, the
+.\" implied warranties of merchantability and fitness for a particular purpose
+.\" are disclaimed. in no event shall Joseph Koshy be liable
+.\" for any direct, indirect, incidental, special, exemplary, or consequential
+.\" damages (including, but not limited to, procurement of substitute goods
+.\" or services; loss of use, data, or profits; or business interruption)
+.\" however caused and on any theory of liability, whether in contract, strict
+.\" liability, or tort (including negligence or otherwise) arising in any way
+.\" out of the use of this software, even if advised of the possibility of
+.\" such damage.
+.\"
+.\" $Id: dwarf_get_elf.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_GET_ELF 3
+.Sh NAME
+.Nm dwarf_get_elf
+.Nd retrieve the
+.Vt Elf
+descriptor associated with a
+.Vt Dwarf_Debug
+instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_elf
+.Fa "Dwarf_Debug dbg"
+.Fa "Elf **elf"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_elf
+returns the
+.Vt Elf
+descriptor associated with a
+.Vt Dwarf_Debug
+instance.
+.Pp
+Argument
+.Ar dbg
+should be a handle to a valid
+.Vt Dwarf_Debug
+instance returned by a prior call to
+.Xr dwarf_init 3
+or
+.Xr dwarf_elf_init 3 .
+.Pp
+Argument
+.Ar elf
+points a location into which a handle to an
+.Vt Elf
+descriptor will be written.
+.Pp
+Argument
+.Ar err
+is used to record error information in case of failure.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_get_elf
+returns
+.Dv DW_DLV_OK .
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh EXAMPLES
+To retrieve the
+.Vt Elf
+instance associated with a
+.Vt Dwarf_Debug
+instance use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Error de;
+Elf *elf;
+
+\&... allocate dbg using dwarf_init() etc ...
+
+if (dwarf_get_elf(dbg, &elf, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_get_elf: %s", dwarf_errmsg(de));
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_errmsg 3 ,
+.Xr dwarf_init 3 ,
+.Xr dwarf_finish 3 ,
+.Xr elf 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_at_pc.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_at_pc.3
new file mode 100644
index 0000000..8aa36ec
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_at_pc.3
@@ -0,0 +1,125 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_fde_at_pc.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd May 22, 2011
+.Os
+.Dt DWARF_GET_FDE_AT_PC 3
+.Sh NAME
+.Nm dwarf_get_fde_at_pc
+.Nd retrieve the FDE descriptor for an address
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_fde_at_pc
+.Fa "Dwarf_Fde *fdelist"
+.Fa "Dwarf_Addr pc"
+.Fa "Dwarf_Fde *ret_fde"
+.Fa "Dwarf_Addr *lopc"
+.Fa "Dwarf_Addr *hipc"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_fde_at_pc
+searches the provided array of DWARF FDE descriptors for a descriptor
+covering a given program counter address.
+.Pp
+Argument
+.Ar fdelist
+should point to an array of FDE descriptors, as returned by the functions
+.Xr dwarf_get_fde_list 3
+or
+.Xr dwarf_get_fde_list_eh 3 .
+.Pp
+Argument
+.Ar pc
+should contain the program counter address being looked up.
+.Pp
+Argument
+.Ar ret_fde
+should point to a location that will hold the returned FDE descriptor.
+.Pp
+Argument
+.Ar lopc
+should point to a location that will be set to the lowest address
+covered by the returned FDE descriptor.
+.Pp
+Argument
+.Ar hipc
+should point to a location that will be set to the highest address
+covered by the returned FDE descriptor.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_fde_at_pc
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+It returns
+.Dv DW_DLV_NO_ENTRY
+if a FDE descriptor that covers the address specified by argument
+.Ar pc
+is not found.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_fde_at_pc
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Va fdelist ,
+.Va ret_fde ,
+.Va lopc ,
+or
+.Va hipc
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+These was no FDE descriptor covering the address specified by argument
+.Ar pc .
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_cie_of_fde 3 ,
+.Xr dwarf_get_fde_info_for_all_regs 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_fde_instr_bytes 3 ,
+.Xr dwarf_get_fde_list 3 ,
+.Xr dwarf_get_fde_list_eh 3 ,
+.Xr dwarf_get_fde_n 3 ,
+.Xr dwarf_get_fde_range 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3
new file mode 100644
index 0000000..f55d3d6
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3
@@ -0,0 +1,156 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_fde_info_for_all_regs.3 3182 2015-04-10 16:08:10Z emaste $
+.\"
+.Dd June 4, 2011
+.Os
+.Dt DWARF_GET_FDE_INFO_FOR_ALL_REGS 3
+.Sh NAME
+.Nm dwarf_get_fde_info_for_all_regs
+.Nd retrieve register rule row
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_fde_info_for_all_regs
+.Fa "Dwarf_Fde fde"
+.Fa "Dwarf_Addr pc"
+.Fa "Dwarf_Regtable *reg_table"
+.Fa "Dwarf_Addr *row_pc"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_fde_info_for_all_regs
+retrieves a row from the register rule table associated with the given
+FDE descriptor.
+.Pp
+Argument
+.Ar fde
+should reference a valid DWARF FDE descriptor.
+.Pp
+Argument
+.Ar pc
+should hold the program counter address to be used to locate the
+desired table row.
+.Pp
+Argument
+.Ar reg_table
+should point to a
+.Vt Dwarf_Regtable
+descriptor which will hold the returned table row of register rules.
+.Pp
+Argument
+.Ar row_pc
+should point to a location which will be set to the lowest program
+counter address associated with the table row.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Pp
+The
+.Vt Dwarf_Regtable
+descriptor is defined in the header file
+.In libdwarf.h :
+.Bd -literal -offset indent
+typedef struct {
+ struct {
+ Dwarf_Small dw_offset_relevant;
+ Dwarf_Half dw_regnum;
+ Dwarf_Addr dw_offset;
+ } rules[DW_REG_TABLE_SIZE];
+} Dwarf_Regtable;
+.Ed
+.Pp
+For each of the register rules returned,
+the
+.Va dw_offset_relevant
+field is set to 1 if the register rule has a offset value.
+The
+.Va dw_regnum
+field is set to the register number associated with the regsiter rule.
+The
+.Va dw_offset
+field is set to the offset value associated with the register rule.
+.Pp
+The number of register columns returned is either the constant
+value
+.Dv DW_REG_TABLE_SIZE as defined
+in the header file
+.In libdwarf.h ,
+or the value set by function
+.Xr dwarf_set_frame_rule_table_size 3 ,
+whichever is smaller.
+.Ss COMPATIBILITY
+Function
+.Fn dwarf_get_fde_info_for_all_regs
+is deprecated since it only supports DWARF2 frame sections.
+Applications should instead use function
+.Xr dwarf_get_fde_info_for_all_regs3 3
+which supports both DWARF2 and DWARF3 frame sections.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_fde_info_for_all_regs
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_fde_info_for_all_regs
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar fde ,
+.Ar reg_table
+or
+.Ar row_pc
+was NULL.
+.It Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE
+The program counter value provided in argument
+.Ar pc
+did not fall in the range covered by argument
+.Ar fde .
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_fde_n 3 ,
+.Xr dwarf_set_frame_cfa_value 3 ,
+.Xr dwarf_set_frame_rule_table_size 3 ,
+.Xr dwarf_set_frame_rule_initial_value 3 ,
+.Xr dwarf_set_frame_same_value 3 ,
+.Xr dwarf_set_frame_undefined_value 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs3.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs3.3
new file mode 100644
index 0000000..841d983
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs3.3
@@ -0,0 +1,183 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_fde_info_for_all_regs3.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd June 26, 2011
+.Os
+.Dt DWARF_GET_FDE_INFO_FOR_ALL_REGS3 3
+.Sh NAME
+.Nm dwarf_get_fde_info_for_all_regs3
+.Nd retrieve register rule row
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_fde_info_for_all_regs3
+.Fa "Dwarf_Fde fde"
+.Fa "Dwarf_Addr pc"
+.Fa "Dwarf_Regtable3 *reg_table"
+.Fa "Dwarf_Addr *row_pc"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_fde_info_for_all_regs3
+retrieves a row from the register rule table associated with the given
+FDE descriptor.
+.Pp
+Argument
+.Ar fde
+should reference a valid DWARF FDE descriptor.
+.Pp
+Argument
+.Ar pc
+should hold the program counter address to be used to locate the
+desired table row.
+.Pp
+Argument
+.Ar reg_table
+should point to a
+.Vt Dwarf_Regtable3
+descriptor which will hold the returned table row of register rules.
+The
+.Vt Dwarf_Regtable3
+descriptor is defined in the header file
+.In libdwarf.h :
+.Bd -literal -offset indent
+typedef struct {
+ Dwarf_Small dw_offset_relevant;
+ Dwarf_Small dw_value_type;
+ Dwarf_Half dw_regnum;
+ Dwarf_Unsigned dw_offset_or_block_len;
+ Dwarf_Ptr dw_block_ptr;
+} Dwarf_Regtable_Entry3;
+
+typedef struct {
+ Dwarf_Regtable_Entry3 rt3_cfa_rule;
+ Dwarf_Half rt3_reg_table_size;
+ Dwarf_Regtable_Entry3 *rt3_rules;
+} Dwarf_Regtable3;
+.Ed
+.Pp
+The
+.Va rt3_reg_table_size
+field specifies the maximum number of register rule columns to be
+returned, and should be set by the application before calling the
+function.
+The
+.Va rt3_rules
+field should point to a memory arena allocated by the application with
+space for at least
+.Vt rt3_reg_table_size
+descriptors of type
+.Vt Dwarf_Regtable_Entry3 .
+.Pp
+On a successful execution of this function, the
+.Va rt3_cfa_rule
+field will be set to the CFA register rule associated with the table
+row, and the
+.Va rt3_rules
+array will hold the returned register rules contained in the table row.
+.Pp
+For each register rule descriptor returned,
+the
+.Va dw_offset_relevant
+field will be set to 1 if the register rule has a offset value,
+the
+.Va dw_value_type
+field will be set to the type code of the register rule and the
+.Va dw_regnum
+field will be set to the register number associated with the register rule.
+If the register rule is of type
+.Dv DW_EXPR_OFFSET
+or
+.Dv DW_EXPR_VAL_OFFSET ,
+the
+.Va dw_offset_or_block_len
+field will be set to the offset value associated with the register rule.
+If the type is
+.Dv DW_EXPR_EXPRESSION
+or
+.Dv DW_EXPR_VAL_EXPRESSION ,
+the
+.Va dw_offset_or_block_len
+field will be set to the length in bytes of the DWARF expression block
+associated with the register rule.
+The
+.Va dw_block_ptr
+field will be set to a pointer to the content of the DWARF expression block
+associated with the register rule.
+.Pp
+Argument
+.Ar row_pc
+should point to a location which will be set to the lowest program
+counter address associated with the table row.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_fde_info_for_all_regs3
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_fde_info_for_all_regs3
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar fde ,
+.Ar reg_table
+or
+.Ar row_pc
+was NULL.
+.It Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE
+The program counter value provided in argument
+.Ar pc
+did not fall in the range covered by argument
+.Ar fde .
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_info_for_all_regs 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_fde_n 3 ,
+.Xr dwarf_set_frame_cfa_value 3 ,
+.Xr dwarf_set_frame_rule_table_size 3 ,
+.Xr dwarf_set_frame_rule_initial_value 3 ,
+.Xr dwarf_set_frame_same_value 3 ,
+.Xr dwarf_set_frame_undefined_value 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_cfa_reg3.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_cfa_reg3.3
new file mode 100644
index 0000000..f8271f0
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_cfa_reg3.3
@@ -0,0 +1,171 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_fde_info_for_cfa_reg3.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd June 12, 2011
+.Os
+.Dt DWARF_GET_FDE_INFO_FOR_CFA_REGS3 3
+.Sh NAME
+.Nm dwarf_get_fde_info_for_cfa_regs3
+.Nd retrieve a CFA register rule
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_fde_info_for_cfa_regs3
+.Fa "Dwarf_Fde fde"
+.Fa "Dwarf_Addr pc"
+.Fa "Dwarf_Small *type"
+.Fa "Dwarf_Signed *offset_relevant"
+.Fa "Dwarf_Signed *register_num"
+.Fa "Dwarf_Signed *offset_or_block_len"
+.Fa "Dwarf_Ptr *block_ptr"
+.Fa "Dwarf_Addr *row_pc"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_fde_info_for_cfa_reg3
+retrieves the CFA register rule for a given program counter address
+from the register rule table associated with an FDE descriptor.
+.Pp
+Argument
+.Ar fde
+should reference a valid DWARF FDE descriptor.
+.Pp
+Argument
+.Ar pc
+should hold the program counter address to be used to locate the
+desired register rule row.
+.Pp
+On successful execution,
+.Fn dwarf_get_fde_info_for_cfa_reg3
+stores information about the CFA register rule found into the locations
+pointed to by the arguments
+.Ar type ,
+.Ar offset_relevant ,
+.Ar register_num ,
+.Ar offset_or_block_len ,
+.Ar block_ptr
+and
+.Ar row_pc .
+.Pp
+Argument
+.Ar type
+should point to a location which will hold the type code of the
+register rule found.
+The returned value is one of the
+.Dv DW_EXPR_*
+contants defined in the header file
+.In libdwarf.h .
+.Pp
+If there is an offset value associated with the CFA register rule,
+the location pointed to by argument
+.Ar offset_relevant
+will be set to 1.
+.Pp
+Argument
+.Ar register_num
+should point to a location which will hold the register number associated
+with the CFA register rule.
+.Pp
+If the CFA register rule is of type
+.Dv DW_EXPR_OFFSET
+or
+.Dv DW_EXPR_VAL_OFFSET ,
+the location pointed to by argument
+.Ar offset_or_block_len
+will be set to the offset value associated with the register rule,
+or to 0 if the register rule does not have an offset value.
+If the type code is
+.Dv DW_EXPR_EXPRESSION
+or
+.Dv DW_EXPR_VAL_EXPRESSION ,
+the location pointed to by argument
+.Ar offset_or_block_len
+will be set to the length in bytes of the DWARF expression block
+associated with the register rule.
+.Pp
+Argument
+.Ar block_ptr
+should point to a location which will be set to a pointer to the
+content of the DWARF expression block associated with the CFA register
+rule.
+.Pp
+Argument
+.Ar row_pc
+should point to a location which will be set to the lowest program
+counter address associated with the register rule found.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_fde_info_for_cfa_reg3
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_fde_info_for_cfa_reg3
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar block_ptr ,
+.Ar fde ,
+.Ar offset_or_block_len ,
+.Ar offset_relevant ,
+.Ar register_num ,
+.Ar row_pc ,
+or
+.Ar type
+was NULL.
+.It Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE
+The program counter value provided in argument
+.Ar pc
+did not fall in the range covered by argument
+.Ar fde .
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_info_for_all_regs 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_reg 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_fde_n 3 ,
+.Xr dwarf_set_frame_cfa_value 3 ,
+.Xr dwarf_set_frame_rule_table_size 3 ,
+.Xr dwarf_set_frame_rule_initial_value 3 ,
+.Xr dwarf_set_frame_same_value 3 ,
+.Xr dwarf_set_frame_undefined_value 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3
new file mode 100644
index 0000000..fd05814
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3
@@ -0,0 +1,156 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_fde_info_for_reg.3 3181 2015-04-10 13:22:51Z emaste $
+.\"
+.Dd June 4, 2011
+.Os
+.Dt DWARF_GET_FDE_INFO_FOR_REG 3
+.Sh NAME
+.Nm dwarf_get_fde_info_for_reg
+.Nd retrieve register rule
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_fde_info_for_reg
+.Fa "Dwarf_Fde fde"
+.Fa "Dwarf_Half table_column"
+.Fa "Dwarf_Addr pc"
+.Fa "Dwarf_Signed *offset_relevant"
+.Fa "Dwarf_Signed *register_num"
+.Fa "Dwarf_Signed *offset"
+.Fa "Dwarf_Addr *row_pc"
+.Fa "Dwarf_Error *error"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_fde_info_for_reg
+retrieves a register rule from the register rule table associated with
+a given FDE descriptor, given a program counter address and rule
+column number.
+.Pp
+Argument
+.Ar fde
+should reference a valid DWARF FDE descriptor.
+.Pp
+Arugment
+.Ar table_column
+should hold the column number of the register rule desired.
+.Pp
+Argument
+.Ar pc
+should hold the program counter address to be used to locate the
+desired register rule row.
+.Pp
+On successful execution,
+.Fn dwarf_get_fde_info_for_reg
+stores information about the register rule found into the locations
+pointed to by the arguments
+.Ar offset_relevant ,
+.Ar register_num ,
+.Ar offset
+and
+.Ar row_pc .
+.Pp
+If there is an offset value associated with the register rule,
+the location pointed to by argument
+.Ar offset_relevant
+will be set to 1.
+.Pp
+Argument
+.Ar register_num
+should point to a location which will hold the register number associated
+with the register rule.
+.Pp
+Argument
+.Ar offset
+should point to a location which will be set to the offset value
+associated with the register rule, or to 0 if the register rule
+does not have an offset value.
+.Pp
+Argument
+.Ar row_pc
+should point to a location which will be set to the lowest program
+counter address associated with the register rule found.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Ss COMPATIBILITY
+Function
+.Fn dwarf_get_fde_info_for_reg
+is deprecated since it only supports DWARF2 frame sections.
+Applications should instead use function
+.Xr dwarf_get_fde_info_for_reg3 3
+which supports both DWARF2 and DWARF3 frame sections.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_fde_info_for_reg
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_fde_info_for_reg
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_FRAME_TABLE_COL_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar fde ,
+.Ar offset_relevant ,
+.Ar register_num ,
+.Ar offset
+or
+.Ar row_pc
+was NULL.
+.It Bq Er DW_DLE_FRAME_TABLE_COL_BAD
+The column number provided in argument
+.Ar table_column
+was too large.
+.It Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE
+The program counter value provided in argument
+.Ar pc
+did not fall in the range covered by argument
+.Ar fde .
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_info_for_all_regs 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_fde_n 3 ,
+.Xr dwarf_set_frame_cfa_value 3 ,
+.Xr dwarf_set_frame_rule_table_size 3 ,
+.Xr dwarf_set_frame_rule_initial_value 3 ,
+.Xr dwarf_set_frame_same_value 3 ,
+.Xr dwarf_set_frame_undefined_value 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg3.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg3.3
new file mode 100644
index 0000000..85c0f7f
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg3.3
@@ -0,0 +1,214 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_fde_info_for_reg3.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_GET_FDE_INFO_FOR_REG3 3
+.Sh NAME
+.Nm dwarf_get_fde_info_for_reg3
+.Nd retrieve register rule
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_fde_info_for_reg3
+.Fa "Dwarf_Fde fde"
+.Fa "Dwarf_Half table_column"
+.Fa "Dwarf_Addr pc"
+.Fa "Dwarf_Small *type"
+.Fa "Dwarf_Signed *offset_relevant"
+.Fa "Dwarf_Signed *register_num"
+.Fa "Dwarf_Signed *offset_or_block_len"
+.Fa "Dwarf_Ptr *block_ptr"
+.Fa "Dwarf_Addr *row_pc"
+.Fa "Dwarf_Error *error"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_fde_info_for_reg3
+retrieves a register rule from the register rule table associated with
+a given FDE descriptor, given a program counter address and rule
+column number.
+.Pp
+Argument
+.Ar fde
+should reference a valid DWARF FDE descriptor.
+.Pp
+Arugment
+.Ar table_column
+should hold the column number of the register rule desired.
+.Pp
+Argument
+.Ar pc
+should hold the program counter address to be used to locate the
+desired register rule row.
+.Pp
+On successful execution,
+.Fn dwarf_get_fde_info_for_reg3
+stores information about the register rule found into the locations
+pointed to by the arguments
+.Ar type ,
+.Ar offset_relevant ,
+.Ar register_num ,
+.Ar offset_or_block_len ,
+.Ar block_ptr
+and
+.Ar row_pc .
+.Pp
+Argument
+.Ar type
+should point to a location which will hold the type code of the
+register rule found.
+The returned value is one of the
+.Dv DW_EXPR_*
+contants defined in the header file
+.In libdwarf.h .
+.Pp
+If there is an offset value associated with the register rule,
+the location pointed to by argument
+.Ar offset_relevant
+will be set to 1.
+.Pp
+Argument
+.Ar register_num
+should point to a location which will hold the register number associated
+with the register rule.
+.Pp
+If the register rule is of type
+.Dv DW_EXPR_OFFSET
+or
+.Dv DW_EXPR_VAL_OFFSET ,
+the location pointed to by argument
+.Ar offset_or_block_len
+will be set to the offset value associated with the register rule,
+or to 0 if the register rule does not have an offset value.
+If the type code is
+.Dv DW_EXPR_EXPRESSION
+or
+.Dv DW_EXPR_VAL_EXPRESSION ,
+the location pointed to by argument
+.Ar offset_or_block_len
+will be set to the length in bytes of the DWARF expression block
+associated with the register rule.
+.Pp
+Argument
+.Ar block_ptr
+should point to a location which will be set to a pointer to the
+content of the DWARF expression block associated with the register
+rule.
+.Pp
+Argument
+.Ar row_pc
+should point to a location which will be set to the lowest program
+counter address associated with the register rule found.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_fde_info_for_reg3
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_fde_info_for_reg3
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_FRAME_TABLE_COL_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar block_ptr ,
+.Ar fde ,
+.Ar offset_or_block_len ,
+.Ar offset_relevant ,
+.Ar register_num ,
+.Ar row_pc ,
+or
+.Ar type
+was NULL.
+.It Bq Er DW_DLE_FRAME_TABLE_COL_BAD
+The column number provided in argument
+.Ar table_column
+was too large.
+.It Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE
+The program counter value provided in argument
+.Ar pc
+did not fall in the range covered by argument
+.Ar fde .
+.El
+.Sh EXAMPLE
+To retrieve the register rules at column 3 from a rule table
+associated with a FDE descriptor:
+.Bd -literal -offset indent
+Dwarf_Fde fde;
+Dwarf_Off fde_offset, cie_offset;
+Dwarf_Unsigned func_len, fde_length;
+Dwarf_Signed cie_index, offset_relevant, register_num;
+Dwarf_Signed offset_or_block_len;
+Dwarf_Addr low_pc, row_pc;
+Dwarf_Ptr fde_addr, block_ptr;
+Dwarf_Small type;
+Dwarf_Error de;
+
+/* ... assuming `fde` references a valid FDE descriptor... */
+if (dwarf_get_fde_range(fde, &low_pc, &func_len, &fde_addr,
+ &fde_length, &cie_offset, &cie_index, &fde_offset,
+ &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_get_fde_range failed: %s",
+ dwarf_errmsg(de));
+
+/* Iterate all the table rows. */
+for (pc = low_pc; pc < low_pc + func_len; pc++) {
+ if (dwarf_get_fde_info_for_reg3(fde, 3, pc, &type,
+ &offset_relevant, &register_num, &offset_or_block_len,
+ &block_ptr, &row_pc, &de) != DW_DLV_OK) {
+ warnx("dwarf_get_fde_info_for_reg3 failed: %s",
+ dwarf_errmsg(de));
+ continue;
+ }
+ /* ... use the retrieved register rule ... */
+}
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_info_for_all_regs 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg 3 ,
+.Xr dwarf_get_fde_n 3 ,
+.Xr dwarf_set_frame_cfa_value 3 ,
+.Xr dwarf_set_frame_rule_table_size 3 ,
+.Xr dwarf_set_frame_rule_initial_value 3 ,
+.Xr dwarf_set_frame_same_value 3 ,
+.Xr dwarf_set_frame_undefined_value 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_instr_bytes.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_instr_bytes.3
new file mode 100644
index 0000000..488d566
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_instr_bytes.3
@@ -0,0 +1,113 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_fde_instr_bytes.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd May 23, 2011
+.Os
+.Dt DWARF_GET_FDE_INSTR_BYTES 3
+.Sh NAME
+.Nm dwarf_get_fde_instr_bytes
+.Nd retrieve instructions from FDE descritpor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_fde_instr_bytes
+.Fa "Dwarf_Fde fde"
+.Fa "Dwarf_Ptr *ret_inst"
+.Fa "Dwarf_Unsigned *ret_len"
+.Fa "Dwarf_Error *error"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_fde_instr_bytes
+retrieves instruction bytes from a given FDE descriptor.
+.Pp
+Argument
+.Ar fde
+should reference a valid DWARF FDE descriptor.
+.Pp
+Argument
+.Ar ret_inst
+should point to a location that will be set to a pointer
+to an array of bytes containing the instructions of the
+FDE descriptor.
+.Pp
+Argument
+.Ar ret_len
+should point to a location that will hold the length in
+bytes of the instructions returned in argument
+.Ar ret_inst .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Pp
+Applications can use the function
+.Xr dwarf_expand_frame_instructions 3
+to parse and expand the returned instruction bytes into an array of
+.Vt Dwarf_Frame_Op
+descriptors.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_fde_instr_bytes
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_fde_instr_bytes
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar fde ,
+.Ar ret_inst
+or
+.Ar ret_len
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_expand_frame_instructions 3 ,
+.Xr dwarf_get_cie_info 3 ,
+.Xr dwarf_get_cie_index 3 ,
+.Xr dwarf_get_cie_of_fde ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_info_for_all_regs 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_fde_list 3 ,
+.Xr dwarf_get_fde_list_eh 3 ,
+.Xr dwarf_get_fde_n 3 ,
+.Xr dwarf_get_fde_range 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_list.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_list.3
new file mode 100644
index 0000000..7164ae6
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_list.3
@@ -0,0 +1,218 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_fde_list.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_GET_FDE_LIST 3
+.Sh NAME
+.Nm dwarf_get_fde_list
+.Nd retrieve frame information
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_fde_list
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Cie **cie_list"
+.Fa "Dwarf_Signed *cie_count"
+.Fa "Dwarf_Fde **fde_list"
+.Fa "Dwarf_Signed *fde_count"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_get_fde_list_eh
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Cie **cie_list"
+.Fa "Dwarf_Signed *cie_count"
+.Fa "Dwarf_Fde **fde_list"
+.Fa "Dwarf_Signed *fde_count"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions retrieve frame related information for the specified
+DWARF debug context.
+.Pp
+Function
+.Fn dwarf_get_fde_list
+retrieves frame information from the DWARF section named
+.Dq ".debug_frame" .
+For objects containing GNU style C++ exception handling
+information, the function
+.Fn dwarf_get_fde_list_eh
+retrieves frame information from the section named
+.Dq ".eh_frame" .
+.Pp
+Frame information is returned using opaque descriptors
+of type
+.Vt Dwarf_Cie
+and
+.Vt Dwarf_Fde .
+Applications need to use the other frame related functions in the
+DWARF(3) API set to retrieve the information contained in these
+descriptors.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+.Pp
+Argument
+.Ar cie_list
+should point to a location that will be set to a pointer to an array
+of
+.Vt Dwarf_Cie
+descriptors.
+.Pp
+Argument
+.Ar cie_count
+should point to a location that will be set to the number of
+.Vt Dwarf_Cie
+descriptors returned.
+.Pp
+Argument
+.Ar fde_list
+should point to a location that will be set to a pointer to an array
+of
+.Vt Dwarf_Fde
+descriptors.
+.Pp
+Argument
+.Ar fde_count
+should point to a location that will be set to the number of
+.Vt Dwarf_Fde
+descriptors returned.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Ss Memory Management
+The memory areas used for the arrays returned in arguments
+.Ar cie_list
+and
+.Ar fde_list
+are owned by the
+.Lb libdwarf .
+Application code should not attempt to directly free these areas.
+Portable applications should instead use the
+.Xr dwarf_fde_cie_list_dealloc 3
+function to indicate that these memory areas may be freed.
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+They return
+.Dv DW_DLV_NO_ENTRY
+if there is no frame information associated with the given DWARF
+debug context.
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Va dbg ,
+.Va cie_list ,
+.Va cie_count ,
+.Va fde_list
+or
+.Va fde_count
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+There is no frame information associated with the giving DWARF debug
+context.
+.El
+.Sh EXAMPLE
+To obtain frame information from the
+.Dq ".debug_frame"
+section, use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Cie *cie_list, cie;
+Dwarf_Fde *fde_list, fde;
+Dwarf_Off fde_offset, cie_offset;
+Dwarf_Unsigned func_len, fde_length, fde_instlen;
+Dwarf_Signed cie_count, fde_count, cie_index;
+Dwarf_Addr low_pc;
+Dwarf_Ptr fde_addr, fde_inst, cie_inst;
+Dwarf_Error de;
+int i;
+
+if (dwarf_get_fde_list(dbg, &cie_list, &cie_count,
+ &fde_list, &fde_count, &de) != DW_DLV_OK) {
+ errx(EXIT_FAILURE, "dwarf_get_fde_list failed: %s",
+ dwarf_errmsg(de));
+}
+
+for (i = 0; i < fde_count; i++) {
+ if (dwarf_get_fde_n(fde_list, i, &fde, &de) != DW_DLV_OK) {
+ warnx("dwarf_get_fde_n failed: %s",
+ dwarf_errmsg(de));
+ continue;
+ }
+ if (dwarf_get_cie_of_fde(fde, &cie, &de) != DW_DLV_OK) {
+ warnx("dwarf_get_fde_n failed: %s",
+ dwarf_errmsg(de));
+ continue;
+ }
+ if (dwarf_get_fde_range(fde, &low_pc, &func_len, &fde_addr,
+ &fde_length, &cie_offset, &cie_index, &fde_offset,
+ &de) != DW_DLV_OK) {
+ warnx("dwarf_get_fde_range failed: %s",
+ dwarf_errmsg(de));
+ continue;
+ }
+ if (dwarf_get_fde_instr_bytes(fde, &fde_inst, &fde_instlen,
+ &de) != DW_DLV_OK) {
+ warnx("dwarf_get_fde_instr_bytes failed: %s",
+ dwarf_errmsg(de));
+ continue;
+ }
+
+ /* ... Use the retrieved frame information ... */
+}
+
+/* Indicate that the returned arrays may be freed. */
+dwarf_fde_cie_list_dealloc(dbg, cie_list, cie_count, fde_list,
+ fde_count);
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_cie_index 3 ,
+.Xr dwarf_get_cie_of_fde 3 ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_instr_bytes 3 ,
+.Xr dwarf_get_fde_n 3 ,
+.Xr dwarf_get_fde_range 3 ,
+.Xr dwarf_fde_cie_list_dealloc 3 ,
+.Xr dwarf_set_frame_cfa_value 3 ,
+.Xr dwarf_set_frame_rule_table_size 3 ,
+.Xr dwarf_set_frame_rule_initial_value 3 ,
+.Xr dwarf_set_frame_same_value 3 ,
+.Xr dwarf_set_frame_undefined_value 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_n.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_n.3
new file mode 100644
index 0000000..dbb6c27
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_n.3
@@ -0,0 +1,111 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_fde_n.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd May 14, 2011
+.Os
+.Dt DWARF_GET_FDE_N 3
+.Sh NAME
+.Nm dwarf_get_fde_n
+.Nd retrieve FDE descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_fde_n
+.Fa "Dwarf_Fde *fdelist"
+.Fa "Dwarf_Unsigned fde_index"
+.Fa "Dwarf_Fde *ret_fde"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_fde_n
+retrieves an FDE descriptor from an array of FDE descriptors.
+.Pp
+Argument
+.Ar fdelist
+should point to an array of FDE descriptors, as returned by the functions
+.Xr dwarf_get_fde_list 3
+or
+.Xr dwarf_get_fde_list_eh 3 .
+.Pp
+Argument
+.Ar fde_index
+specifies the 0-based index of the desired FDE descriptor.
+.Pp
+Argument
+.Ar ret_fde
+should point to a location that will hold the returned FDE descriptor.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_fde_n
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+It returns
+.Dv DW_DLV_NO_ENTRY
+if the FDE descriptor index specified by argument
+.Ar fde_index
+is out of range.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_fde_n
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Ar fdelist
+or
+.Ar ret_fde
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+The FDE descriptor index specified by argument
+.Ar fde_index
+was out of range.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_cie_of_fde 3 ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_info_for_all_regs 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_fde_instr_bytes 3 ,
+.Xr dwarf_get_fde_list 3 ,
+.Xr dwarf_get_fde_list_eh 3 ,
+.Xr dwarf_get_fde_range 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_range.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_range.3
new file mode 100644
index 0000000..1ea708c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_fde_range.3
@@ -0,0 +1,149 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_fde_range.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd May 22, 2011
+.Os
+.Dt DWARF_GET_FDE_RANGE 3
+.Sh NAME
+.Nm dwarf_get_fde_range
+.Nd retrieve range information from an FDE descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_fde_range
+.Fa "Dwarf_Fde fde"
+.Fa "Dwarf_Addr *low_pc"
+.Fa "Dwarf_Unsigned *func_len"
+.Fa "Dwarf_Ptr *fde_bytes"
+.Fa "Dwarf_Unsigned *fde_byte_len"
+.Fa "Dwarf_Off *cie_offset"
+.Fa "Dwarf_Signed *cie_index"
+.Fa "Dwarf_Off *fde_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_fde_range
+retrieves range and offset information from a given FDE descriptor.
+.Pp
+Argument
+.Ar fde
+should reference a valid DWARF FDE descriptor.
+.Pp
+Argument
+.Ar low_pc
+should point to a location that will be set to the lowest
+program counter address covered by the FDE descriptor.
+.Pp
+Argument
+.Ar func_len
+should point to a location that will hold the length in bytes of
+the address range covered by the FDE descriptor.
+.Pp
+Argument
+.Ar fde_bytes
+should point to a location that will be set to a pointer to the
+content of the FDE descriptor itself.
+.Pp
+Argument
+.Ar fde_byte_len
+should point to a location that will hold the length in bytes of
+the FDE descriptor itself.
+.Pp
+Argument
+.Ar cie_offset
+should point to a location that will be set to the offset, relative to
+the DWARF
+.Dq ".debug_frame"
+section, of the CIE descriptor associated with the given FDE
+descriptor.
+.Pp
+Argument
+.Ar cie_index
+should point to a location that will hold the index of the CIE
+descriptor associated with the FDE descriptor.
+The returned value is a zero-based index into the array of CIE
+descriptors returned by a prior call to functions
+.Xr dwarf_get_fde_list 3
+or
+.Xr dwarf_get_fde_list_eh 3 .
+.Pp
+Argument
+.Ar fde_offset
+should point to a location that will be set to the offset, relative to
+the DWARF
+.Dq ".debug_frame"
+section, of the FDE descriptor.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_fde_range
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_fde_range
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar fde ,
+.Ar low_pc ,
+.Ar func_len ,
+.Ar fde_bytes ,
+.Ar fde_byte_len ,
+.Ar cie_offset ,
+.Ar cie_index
+or
+.Ar fde_offset
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_cie_info 3 ,
+.Xr dwarf_get_cie_index 3 ,
+.Xr dwarf_get_cie_of_fde ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_info_for_all_regs 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_fde_instr_bytes 3 ,
+.Xr dwarf_get_fde_list 3 ,
+.Xr dwarf_get_fde_list_eh 3 ,
+.Xr dwarf_get_fde_n 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_form_class.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_form_class.3
new file mode 100644
index 0000000..82cbe1a
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_form_class.3
@@ -0,0 +1,87 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_form_class.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd June 26, 2011
+.Os
+.Dt DWARF_GET_FORM_CLASS 3
+.Sh NAME
+.Nm dwarf_get_form_class
+.Nd retrieve the form class of an attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft enum Dwarf_Form_Class
+.Fo dwarf_get_form_class
+.Fa "Dwarf_Half dwversion"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Half offset_size"
+.Fa "Dwarf_Half form"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_form_class
+returns the class of the form of a DWARF attribute.
+.Pp
+Argument
+.Ar dwversion
+should specify the version number of DWARF specification
+to use: 2 for DWARF2, 3 for DWARF3 and 4 for DWARF4.
+.Pp
+Argument
+.Ar attr
+should hold the attribute code of the attribute, i.e., one of the
+.Li DW_AT_*
+values defined in
+.In libdwarf.h .
+.Pp
+Argument
+.Ar offset_size
+should hold the size of a DWARF offset for the relevant compilation
+unit.
+.Pp
+Argument
+.Ar form
+should hold the form code of the attribute.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_get_form_class
+returns the form class code, which is one of the
+.Dv DW_FORM_CLASS_*
+contants defined in header file
+.In libdwarf.h .
+If the function was not able to determine the form class of the
+attribute, it returns the special form class code
+.Dv DW_FORM_CLASS_UNKNOWN .
+.Sh ERRORS
+Function
+.Fn dwarf_get_form_class
+does not return an error.
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_whatattr 3 ,
+.Xr dwarf_whatform 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_funcs.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_funcs.3
new file mode 100644
index 0000000..4abc1d9
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_funcs.3
@@ -0,0 +1,215 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_funcs.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd April 10, 2011
+.Os
+.Dt DWARF_GET_FUNCS 3
+.Sh NAME
+.Nm dwarf_get_funcs ,
+.Nm dwarf_func_cu_offset ,
+.Nm dwarf_func_die_offset ,
+.Nm dwarf_func_name_offsets ,
+.Nm dwarf_funcname
+.Nd retrieve information about static functions
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_funcs
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Func **funcs"
+.Fa "Dwarf_Signed *nfuncs"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_func_cu_offset
+.Fa "Dwarf_Func func"
+.Fa "Dwarf_Off *cu_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_func_die_offset
+.Fa "Dwarf_Func func"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_func_name_offsets
+.Fa "Dwarf_Func func"
+.Fa "char **name"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Off *cu_die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_funcname
+.Fa "Dwarf_Func func"
+.Fa "char **name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions retrieve information about static functions from the
+lookup tables in the (SGI-specific)
+.Dq ".debug_funcnames"
+section.
+Information about these functions is returned using opaque descriptors
+of type
+.Vt Dwarf_Func .
+Applications need to use the functions described below to retrieve
+the name and offset information contained in these descriptors.
+.Pp
+Function
+.Fn dwarf_get_funcs
+retrieves descriptors for all the static functions associated with the
+DWARF debug context specified by argument
+.Ar dbg .
+The argument
+.Ar funcs
+should point to a location that will be set to a pointer to an array
+of
+.Vt Dwarf_Func
+descriptors.
+The argument
+.Ar nfuncs
+should point to a location that will be set to the number of
+descriptors returned.
+.Pp
+Function
+.Fn dwarf_func_cu_offset
+returns the offset, relative to the
+.Dq ".debug_info"
+section, of the compilation unit that contains the debugging
+information entry associated with the argument
+.Ar func .
+Argument
+.Ar cu_offset
+should point to a location that will hold the returned offset.
+.Pp
+Function
+.Fn dwarf_func_die_offset
+retrieves the offset, relative to the
+.Dq ".debug_info"
+section, of the debugging information entry associated with the
+argument
+.Ar func ,
+and stores it into the location pointed to by the argument
+.Ar die_offset .
+.Pp
+Function
+.Fn dwarf_func_name_offsets
+retrieves the name and offsets for the debugging information entry for
+argument
+.Ar func .
+Argument
+.Ar name
+should point to a location which will be set to a pointer to a
+NUL-terminated string containing the name of the associated debugging
+information entry.
+Argument
+.Ar die_offset
+should point to a location which will be set to the offset, relative
+to the
+.Dq ".debug_info"
+section, of the associated debugging information entry.
+Argument
+.Ar cu_die_offset
+should point to a location which will be set to the offset, relative
+to the
+.Dq ".debug_info"
+section, of the first debugging information entry in the compilation
+unit associated with argument
+.Ar func .
+.Pp
+Function
+.Fn dwarf_funcname
+sets the location pointed to by argument
+.Ar name
+to a pointer to a NUL-terminated string holding the name of the
+debugging information entry associated with the argument
+.Ar func .
+.Ss Memory Management
+The memory area used for the array of
+.Vt Dwarf_Func
+descriptors returned in argument
+.Ar funcs
+by function
+.Fn dwarf_get_funcs
+is owned by the
+.Lb libdwarf .
+Application code should not attempt to directly free this pointer.
+Portable code should instead use the function
+.Xr dwarf_funcs_dealloc 3
+to indicate that the memory area may be freed.
+.Pp
+The memory area used for the string returned in the
+.Ar name
+argument to functions
+.Fn dwarf_func_name_offsets
+and
+.Fn dwarf_funcname
+is owned by the
+.Lb libdwarf .
+Portable code should indicate that the memory area can
+be freed using the
+.Xr dwarf_dealloc 3
+function.
+.Ss Error Returns
+If argument
+.Ar err
+is not NULL, these functions will use it to store error information,
+in case of an error.
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Va cu_die_offset ,
+.Va cu_offset ,
+.Va dbg ,
+.Va die_offset ,
+.Va func ,
+.Va funcs ,
+.Va name ,
+or
+.Va nfuncs
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+The DWARF debugging context referenced by argument
+.Ar dbg
+did not contain information about static functions.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_cu_die_offset_given_cu_header_offset 3 ,
+.Xr dwarf_funcs_dealloc 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_globals.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_globals.3
new file mode 100644
index 0000000..b5f976e
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_globals.3
@@ -0,0 +1,211 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_globals.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd April 2, 2011
+.Os
+.Dt DWARF_GET_GLOBALS 3
+.Sh NAME
+.Nm dwarf_get_globals ,
+.Nm dwarf_global_cu_offset ,
+.Nm dwarf_global_die_offset ,
+.Nm dwarf_global_name_offsets ,
+.Nm dwarf_globname
+.Nd retrieve information about global objects
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_globals
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Global **globals"
+.Fa "Dwarf_Signed *nglobals"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_global_cu_offset
+.Fa "Dwarf_Global global"
+.Fa "Dwarf_Off *cu_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_global_die_offset
+.Fa "Dwarf_Global global"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_global_name_offsets
+.Fa "Dwarf_Global global"
+.Fa "char **name"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Off *cu_die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_globname
+.Fa "Dwarf_Global global"
+.Fa "char **name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions retrieve information about global symbols from the
+lookup tables in the
+.Dq ".debug_pubnames"
+DWARF section.
+Information about these global symbols is returned using opaque descriptors
+of type
+.Vt Dwarf_Global .
+Applications need to use the functions described below to retrieve the
+name and the offsets for these descriptors.
+.Pp
+Function
+.Fn dwarf_get_globals
+retrieves descriptors for all the global symbols associated with the
+DWARF debug context specified by argument
+.Ar dbg .
+The argument
+.Ar globals
+should point to a location that will be set to a pointer to an array
+of
+.Vt Dwarf_Global
+descriptors.
+The argument
+.Ar nglobals
+should point to a location that will be set to the number of
+descriptors returned.
+.Pp
+Function
+.Fn dwarf_global_cu_offset
+returns the section-relative offset, relative to the
+.Dq ".debug_info"
+section, of the compilation unit that contains the debugging
+information entry associated with the argument
+.Ar global .
+Argument
+.Ar cu_offset
+should point to a location that will hold the returned offset.
+.Pp
+Function
+.Fn dwarf_global_die_offset
+retrieves the section-relative offset, relative to the
+.Dq ".debug_info"
+section, of the debugging information entry associated with the
+argument
+.Ar global ,
+and stores it into the location pointed to by the argument
+.Ar die_offset .
+.Pp
+Function
+.Fn dwarf_global_name_offsets
+retrieves the name and the offsets for the debugging information
+entry for argument
+.Ar global .
+Argument
+.Ar name
+should point to a location which will be set to a pointer to a
+NUL-terminated string containing the name of the associated debugging
+information entry.
+Argument
+.Ar die_offset
+should point to a location which will be set to a section-relative
+offset, relative to the
+.Dq ".debug_info"
+section, of the associated debugging information entry.
+Argument
+.Ar cu_die_offset
+should point to a location which will be set to a
+section-relative offset, relative to the
+.Dq ".debug_info"
+section, of the first debugging information entry in
+the compilation unit associated with argument
+.Ar global .
+.Pp
+Function
+.Fn dwarf_globname
+sets the location pointed to by argument
+.Ar name
+to a pointer to a NUL-terminated string holding the name of the
+debugging information entry associated with the argument
+.Ar global .
+.Ss Memory Management
+The memory area used for the array of
+.Vt Dwarf_Global
+descriptors returned in argument
+.Ar globals
+by function
+.Fn dwarf_get_globals
+is owned by the
+.Lb libdwarf .
+Application code should not attempt to directly free this pointer.
+Portable code should instead use the function
+.Xr dwarf_globals_dealloc 3
+to indicate that the memory area may be freed.
+.Pp
+The memory area used for the string returned in the
+.Ar name
+argument to functions
+.Fn dwarf_globname
+and
+.Fn dwarf_global_name_offsets
+is owned by the
+.Lb libdwarf .
+Portable code should use the
+.Xr dwarf_dealloc 3
+function to indicate that the memory area may be freed.
+.Ss Error Returns
+If argument
+.Ar err
+is not NULL, these functions will use it to store error information,
+in case of an error.
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Va cu_die_offset ,
+.Va cu_offset ,
+.Va dbg ,
+.Va die_offset ,
+.Va global ,
+.Va globals ,
+.Va name ,
+or
+.Va nglobals
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_dealloc 3 ,
+.Xr dwarf_get_cu_die_offset_given_cu_header_offset 3 ,
+.Xr dwarf_globals_dealloc 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_loclist_entry.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_loclist_entry.3
new file mode 100644
index 0000000..50c3455
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_loclist_entry.3
@@ -0,0 +1,156 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_loclist_entry.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd July 6, 2011
+.Os
+.Dt DWARF_GET_LOCLIST_ENTRY 3
+.Sh NAME
+.Nm dwarf_get_loclist_entry
+.Nd retrieve DWARF location list entry
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_loclist_entry
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Unsigned offset"
+.Fa "Dwarf_Addr *hipc"
+.Fa "Dwarf_Addr *lopc"
+.Fa "Dwarf_Ptr *data"
+.Fa "Dwarf_Unsigned *entry_len"
+.Fa "Dwarf_Unsigned *next_entry"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_loclist_entry
+retrieves a location list entry from the DWARF section
+.Dq ".debug_loc" .
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+.Pp
+Argument
+.Ar offset
+is an offset, relative to the
+.Dq ".debug_loc"
+section, to the start of the desired location list entry.
+.Pp
+Argument
+.Ar hipc
+should point to a location which will hold the offset, relative to the
+base address of the location list entry, of the highest program
+counter value for the entry.
+.Pp
+Argument
+.Ar lowpc
+should point to a location which will hold the offset, relative to the
+base address of the location list entry, of the lowest program counter
+value for the entry.
+.Pp
+Argument
+.Ar data
+should point to a location which will be set to a pointer to the location
+list data.
+.Pp
+Argument
+.Ar entry_len
+should point to a location which will hold the length in bytes of the
+location list data returned in argument
+.Ar data .
+.Pp
+Argument
+.Ar next_entry
+should point to a location which will hold the offset of the next
+location list entry.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_loclist_entry
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+It returns
+.Dv DW_DLV_NO_ENTRY
+if there is no location list at the specified offset
+.Ar offset .
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_loclist_entry
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar hipc ,
+.Ar lopc ,
+.Ar data ,
+.Ar entry_len
+or
+.Ar next_entry
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+There is no location list at the specified offset
+.Ar offset .
+.El
+.Sh EXAMPLE
+To iterate through all the location list entries in the
+.Dq ".debug_loc"
+section, use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Unsigned off, len, next;
+Dwarf_Addr hipc, lopc;
+Dwarf_Ptr data;
+Dwarf_Error de;
+int ret;
+
+off = 0;
+while ((ret = dwarf_get_loclist_entry(dbg, off, &hipc, &lopc, &data,
+ &len, &next, &de)) == DW_DLV_OK) {
+ /* ... use loclist entry ... */
+ off = next;
+}
+if (ret == DW_DLV_ERROR)
+ warnx("dwarf_get_loclist_entry failed: %s", dwarf_errmsg(de));
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_loclist 3 ,
+.Xr dwarf_loclist_n 3 ,
+.Xr dwarf_loclist_from_expr 3 ,
+.Xr dwarf_loclist_from_expr_a 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_macro_details.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_macro_details.3
new file mode 100644
index 0000000..71e4914
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_macro_details.3
@@ -0,0 +1,192 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_macro_details.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd March 20, 2011
+.Os
+.Dt DWARF_GET_MACRO_DETAILS 3
+.Sh NAME
+.Nm dwarf_get_macro_details
+.Nd retrieve macro information
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_macro_details
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Off offset"
+.Fa "Dwarf_Unsigned max_count"
+.Fa "Dwarf_Signed *entry_cnt"
+.Fa "Dwarf_Macro_Details **details"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_macro_details
+retrieves information about macros associated with a DWARF debug
+context.
+Information about macro entries are returned as an array of
+descriptors of type
+.Vt Dwarf_Macro_Details ,
+with each
+.Vt Dwarf_Macro_Details
+descriptor describing one macro information entry.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+Argument
+.Ar offset
+is an offset, relative to the
+.Dq ".debug_macinfo"
+section, to the start of the desired macro information.
+Argument
+.Ar max_count
+specifies the maximum number of macro information entries
+to be returned, or 0 if all entries are to be returned.
+Argument
+.Ar entry_cnt
+should point to a location that will be set to the number
+of entries actually returned.
+Argument
+.Ar details
+should point to a location that will be set to a pointer to
+an array of
+.Vt Dwarf_Macro_Details
+descriptors.
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Pp
+.Vt Dwarf_Macro_Details
+descriptors are defined in the header file
+.In libdwarf.h ,
+and consist of the following fields:
+.Bl -tag -width ".Va dmd_fileindex" -compact
+.It Va dmd_offset
+The section-relative offset within the
+.Dq ".debug_macinfo"
+section of the macro information entry being described.
+.It Va dmd_type
+The type code of this macro information entry; one of the
+.Dv DW_MACINFO_*
+constants defined by the DWARF specification.
+.It Va dmd_lineno
+The line number associated with the macro information
+entry, or 0 if there is no applicable line number.
+.It Va dmd_fileindex
+The source file index for the macro information entry.
+This field is only meaningful when
+.Va dmd_type
+field is set to
+.Dv DW_MACINFO_start_file .
+.It Va dmd_macro
+The contents of this field is a pointer to a NUL-terminated string
+whose meaning depends on the value of the
+.Va dmd_type
+field:
+.Bl -tag -width ".Dv DW_MACINFO_vendor_ext" -compact
+.It Dv DW_MACINFO_define
+The returned string contains the macro name and value.
+.It Dv DW_MACINFO_undef
+The string holds the macro name.
+.It Dv DW_MACINFO_vendor_ext
+The
+.Va dmd_macro
+field points to a vendor defined string.
+.El
+The field is NULL for other values of
+.Va dmd_type .
+.El
+.Ss Memory Management
+The memory area used for the array of
+.Vt Dwarf_Macro_Details
+descriptors returned in argument
+.Ar details
+is owned by the
+.Lb libdwarf .
+The application should not attempt to directly free this pointer.
+Portable code should instead use
+.Fn dwarf_dealloc
+with the allocation type
+.Dv DW_DLA_STRING
+to indicate that the memory may be freed.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_macro_details
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+It returns
+.Dv DW_DLV_NO_ENTRY
+if there is no more macro information at the specified offset
+.Ar offset .
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_macro_details
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar entry_cnt
+or
+.Ar details
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+There is no more macro information at the specified offset
+.Ar offset .
+.El
+.Sh EXAMPLE
+To loop through all the macro information entries associated with
+a DWARF debug context:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Unsigned offset;
+Dwarf_Signed cnt;
+Dwarf_Macro_Details *md;
+Dwarf_Error de;
+
+offset = 0;
+while (dwarf_get_macro_details(dbg, offset, 0,
+ &cnt, &md, &de) == DW_DLV_OK) {
+ for (i = 0; i < cnt; i++) {
+ /* Access fields of md[i] ... */
+ }
+ offset = md[cnt - 1].dmd_offset + 1;
+}
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_dealloc 3 ,
+.Xr dwarf_find_macro_value_start 3 ,
+.Xr dwarf_init 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_pubtypes.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_pubtypes.3
new file mode 100644
index 0000000..23ad783
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_pubtypes.3
@@ -0,0 +1,243 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_pubtypes.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd April 4, 2011
+.Os
+.Dt DWARF_GET_PUBTYPES 3
+.Sh NAME
+.Nm dwarf_get_pubtypes ,
+.Nm dwarf_pubtype_cu_offset ,
+.Nm dwarf_pubtype_die_offset ,
+.Nm dwarf_pubtype_name_offsets ,
+.Nm dwarf_pubtypename
+.Nd retrieve information about user-defined types
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_pubtypes
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Type **types"
+.Fa "Dwarf_Signed *ntypes"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_pubtype_cu_offset
+.Fa "Dwarf_Type type"
+.Fa "Dwarf_Off *cu_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_pubtype_die_offset
+.Fa "Dwarf_Type type"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_pubtype_name_offsets
+.Fa "Dwarf_Type type"
+.Fa "char **name"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Off *cu_die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_pubtypename
+.Fa "Dwarf_Type type"
+.Fa "char **name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions retrieve information about file-scope, user-defined
+types recorded in lookup tables in the
+.Dq ".debug_pubtypes"
+DWARF section.
+Information about these types is returned using opaque descriptors
+of type
+.Vt Dwarf_Type .
+Applications need to use the functions described below to retrieve
+the name and offset information contained in these descriptors.
+.Pp
+Function
+.Fn dwarf_get_pubtypes
+retrieves descriptors for all the user-defined types associated with the
+DWARF debug context specified by argument
+.Ar dbg .
+The argument
+.Ar types
+should point to a location that will be set to a pointer to an array
+of
+.Vt Dwarf_Type
+descriptors.
+The argument
+.Ar ntypes
+should point to a location that will be set to the number of
+descriptors returned.
+.Pp
+Function
+.Fn dwarf_pubtype_cu_offset
+returns the offset, relative to the
+.Dq ".debug_info"
+section, of the compilation unit that contains the debugging
+information entry associated with the argument
+.Ar type .
+Argument
+.Ar cu_offset
+should point to a location that will hold the returned offset.
+.Pp
+Function
+.Fn dwarf_pubtype_die_offset
+retrieves the offset, relative to the
+.Dq ".debug_info"
+section, of the debugging information entry associated with the
+argument
+.Ar type ,
+and stores it into the location pointed to by the argument
+.Ar die_offset .
+.Pp
+Function
+.Fn dwarf_pubtype_name_offsets
+retrieves the name and offsets for the debugging information entry for
+argument
+.Ar type .
+Argument
+.Ar name
+should point to a location which will be set to a pointer to a
+NUL-terminated string containing the name of the associated debugging
+information entry.
+Argument
+.Ar die_offset
+should point to a location which will be set to the
+offset, relative to the
+.Dq ".debug_info"
+section, of the associated debugging information entry.
+Argument
+.Ar cu_die_offset
+should point to a location which will be set to the
+offset, relative to the
+.Dq ".debug_info"
+section, of the first debugging information entry in the compilation
+unit associated with argument
+.Ar type .
+.Pp
+Function
+.Fn dwarf_pubtypename
+sets the location pointed to by argument
+.Ar name
+to a pointer to a NUL-terminated string holding the name of the
+debugging information entry associated with the argument
+.Ar type .
+.Ss Memory Management
+The memory area used for the array of
+.Vt Dwarf_Type
+descriptors returned in argument
+.Ar types
+by function
+.Fn dwarf_get_pubtypes
+is owned by the
+.Lb libdwarf .
+Application code should not attempt to directly free this pointer.
+Portable code should instead use the function
+.Xr dwarf_types_dealloc 3
+to indicate that the memory area may be freed.
+.Pp
+The memory area used for the string returned in the
+.Ar name
+argument to functions
+.Fn dwarf_pubtype_name_offsets
+and
+.Fn dwarf_pubtypename
+is owned by the
+.Lb libdwarf .
+Portable code should indicate that the memory area can
+be freed using the
+.Xr dwarf_dealloc 3
+function.
+.Ss Error Returns
+If argument
+.Ar err
+is not NULL, these functions will use it to store error information,
+in case of an error.
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh EXAMPLES
+To retrieve the list of file scope user-defined types and print
+their names, use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Signed ntypes;
+Dwarf_Type *types;
+Dwarf_Error err;
+int n, result;
+char *typename;
+
+/* Initialize dbg etc. */;
+result = dwarf_get_pubtypes(dbg, &types, &ntypes, &err);
+if (result != DW_DLV_OK) /* Handle the error. */
+ ;
+
+/* Iterate over the returned array of descriptors. */
+for (n = 0; n < ntypes; n++) {
+ result = dwarf_pubtypename(types[n], &typename, &err);
+ if (result != DW_DLV_OK) /* Handle the error. */
+ ;
+ printf("%s\en", typename);
+}
+
+/* Deallocate the returned array. */
+dwarf_types_dealloc(dbg, types, ntypes);
+.Ed
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Va cu_die_offset ,
+.Va cu_offset ,
+.Va dbg ,
+.Va die_offset ,
+.Va type ,
+.Va types ,
+.Va name ,
+or
+.Va ntypes
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+The DWARF debugging context referenced by argument
+.Ar dbg
+did not contain information about user-defined types.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_dealloc 3 ,
+.Xr dwarf_get_cu_die_offset_given_cu_header_offset 3 ,
+.Xr dwarf_pubtypes_dealloc 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_ranges.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_ranges.3
new file mode 100644
index 0000000..15bad4d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_ranges.3
@@ -0,0 +1,258 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_ranges.3 3182 2015-04-10 16:08:10Z emaste $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_GET_RANGES 3
+.Sh NAME
+.Nm dwarf_get_ranges
+.Nd retrieve non-contiguous address ranges
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_ranges
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Off offset"
+.Fa "Dwarf_Ranges **ranges"
+.Fa "Dwarf_Signed *cnt"
+.Fa "Dwarf_Unsigned *byte_cnt"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_get_ranges_a
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Off offset"
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Ranges **ranges"
+.Fa "Dwarf_Signed *cnt"
+.Fa "Dwarf_Unsigned *byte_cnt"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_ranges
+retrieves information about the non-contiguous address ranges associated
+with a DWARF debugging information entry.
+Information about address ranges is returned as an array of
+descriptors of type
+.Vt Dwarf_Ranges ,
+with each
+.Vt Dwarf_Ranges
+descriptor describing one address range entry.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+.Pp
+Argument
+.Ar offset
+is an offset, relative to the
+.Dq ".debug_ranges"
+section, to the start of the desired list of address ranges.
+The offset of an address ranges list is indicated by the
+.Dv DW_AT_ranges
+attribute of a debugging information entry.
+.Pp
+Argument
+.Ar die
+(function
+.Fn dwarf_get_ranges_a
+only) is ignored in this implementation; see the section
+.Sx "Compatibility Notes"
+below.
+.Pp
+Argument
+.Ar ranges
+should point to a location that will be set to a pointer to an array
+of
+.Vt Dwarf_Ranges
+descriptors.
+.Pp
+Argument
+.Ar cnt
+should point to a location that will be set to the number of entries
+returned.
+If argument
+.Ar byte_cnt
+is not NULL, it will be set to the number of bytes occupied by the
+returned entries in the
+.Dq ".debug_ranges"
+section.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Pp
+.Vt Dwarf_Ranges
+descriptors are defined in the header file
+.In libdwarf.h ,
+and consists of the following fields:
+.Bl -tag -width ".Va dwr_addr1"
+.It Va dwr_addr1
+The first address offset, whose meaning depends on the type of the
+entry.
+.It Va dwr_addr2
+The second address offset, whose meaning depends on the type of the
+entry.
+.It Va dwr_type
+The type of this address range entry:
+.Bl -tag -width ".Dv DW_RANGES_ENTRY" -compact
+.It Dv DW_RANGES_ENTRY
+A range list entry.
+For this type of entry, the fields
+.Va dwr_addr1
+and
+.Va dwr_addr2
+hold the beginning and ending offsets of the address range, respectively.
+.It Dv DW_RANGES_ADDRESS_SELECTION
+A base address selection entry.
+For this type of entry, the field
+.Va dwr_addr1
+is the value of the largest representable address offset, and
+.Va dwr_addr2
+is a base address for the beginning and ending address offsets of
+subsequent address range entries in the list.
+.It Dv DW_RANGES_END
+An end of list mark.
+Both
+.Va dwr_addr1
+and
+.Va dwr_addr2
+are set to 0.
+.El
+.El
+.Ss Memory Management
+The memory area used for the array of
+.Vt Dwarf_Ranges
+descriptors returned in argument
+.Ar ranges
+is owned by the
+.Lb libdwarf .
+The application should not attempt to directly free this pointer.
+Portable code should instead use
+.Fn dwarf_ranges_dealloc
+to indicate that the memory may be freed.
+.Sh COMPATIBILITY
+Function
+.Fn dwarf_get_ranges_a
+is identical to
+.Fn dwarf_get_ranges ,
+except that it requires one additional argument
+.Ar die
+denoting the debugging information entry associated with
+the address range list.
+In this implementation of the
+.Lb libdwarf ,
+the argument
+.Ar die
+is ignored, and function
+.Fn dwarf_get_ranges_a
+is only provided for compatibility with other implementations of the
+DWARF(3) API.
+.Sh RETURN VALUES
+These functions
+return
+.Dv DW_DLV_OK
+when they succeed.
+They return
+.Dv DW_DLV_NO_ENTRY
+if there is no address range list at the specified offset
+.Ar offset .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These function can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar ranges
+or
+.Ar cnt
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+There is no address range list at the specified offset
+.Ar offset .
+.El
+.Sh EXAMPLE
+To retrieve the address range list associated with a debugging
+information entry, use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Die die;
+Dwarf_Error de;
+Dwarf_Addr base;
+Dwarf_Attribute *attr_list;
+Dwarf_Ranges *ranges;
+Dwarf_Signed cnt;
+Dwarf_Unsigned off, attr_count, bytecnt;
+int i, j;
+
+if ((ret = dwarf_attrlist(die, &attr_list, &attr_count, &de)) !=
+ DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_attrlist failed: %s",
+ dwarf_errmsg(de));
+
+for (i = 0; (Dwarf_Unsigned) i < attr_count; i++) {
+ if (dwarf_whatattr(attr_list[i], &attr, &de) != DW_DLV_OK) {
+ warnx("dwarf_whatattr failed: %s",
+ dwarf_errmsg(de));
+ continue;
+ }
+ if (attr != DW_AT_ranges)
+ continue;
+ if (dwarf_formudata(attr_list[i], &off, &de) != DW_DLV_OK) {
+ warnx("dwarf_formudata failed: %s",
+ dwarf_errmsg(de));
+ continue;
+ }
+ if (dwarf_get_ranges(dbg, (Dwarf_Off) off, &ranges, &cnt,
+ &bytecnt, &de) != DW_DLV_OK)
+ continue;
+ for (j = 0; j < cnt; j++) {
+ if (ranges[j].dwr_type == DW_RANGES_END)
+ break;
+ else if (ranges[j].dwr_type ==
+ DW_RANGES_ADDRESS_SELECTION)
+ base = ranges[j].dwr_addr2;
+ else {
+ /*
+ * DW_RANGES_ENTRY entry.
+ * .. Use dwr_addr1 and dwr_addr2 ..
+ */
+ }
+ }
+}
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_ranges_dealloc 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_relocation_info.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_relocation_info.3
new file mode 100644
index 0000000..96166cf
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_relocation_info.3
@@ -0,0 +1,228 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_relocation_info.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd September 3, 2011
+.Os
+.Dt DWARF_GET_RELOCATION_INFO 3
+.Sh NAME
+.Nm dwarf_get_relocation_info
+.Nd retrieve generated relocation arrays
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_relocation_info
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Signed *elf_section_index"
+.Fa "Dwarf_Signed *elf_section_link"
+.Fa "Dwarf_Unsigned *reloc_entry_count"
+.Fa "Dwarf_Relocation_Data *reloc_buf"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+The function
+.Fn dwarf_get_relocation_info
+is used to retrieve the relocation arrays generated by a prior call to
+.Xr dwarf_transform_to_disk_form 3 .
+.Pp
+Each call to this function retrieves the next available relocation
+array.
+Application code should call this function repeatly to retrieve all
+the relocation arrays.
+The total number of generated relocation arrays retrievable
+by this function may be obtained by calling function
+.Xr dwarf_get_relocation_info_count 3 .
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3 in sequence.
+or
+.Xr dwarf_producer_init_b 3 .
+The
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+flag should have been set on the DWARF producer instance.
+.Pp
+Argument
+.Ar elf_section_index
+should point to a location which will be set to the ELF section index
+of the relocation section to which the retrieved relocation array
+belongs.
+.Pp
+Argument
+.Ar elf_section_link
+should point to a location which will be set to the section index of
+the ELF section to which the retrieved relocation array applies.
+.Pp
+Argument
+.Ar reloc_entry_count
+should point to a location which will be set to the total number of
+relocation entries contained in the relocation array.
+.Pp
+Argument
+.Ar reloc_buf
+should point to a location which will be set to a pointer to the
+retrieved array of relocation entries.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Pp
+The retrieved relocation entries are described using structure
+.Vt Dwarf_Relocation_Data_s ,
+defined in the header file
+.In libdwarf.h :
+.Bd -literal -offset indent
+typedef struct Dwarf_Relocation_Data_s {
+ unsigned char drd_type;
+ unsigned char drd_length;
+ Dwarf_Unsigned drd_offset;
+ Dwarf_Unsigned drd_symbol_index;
+} *Dwarf_Relocation_Data;
+.Ed
+.Pp
+Struct
+.Vt Dwarf_Relocation_Data_s
+consists of following fields:
+.Bl -tag -width ".Va drd_symbol_index" -compact -offset indent
+.It Va drd_type
+The type code of the relocation entry.
+The
+.Vt Dwarf_Rel_Type
+enumeration defined in the header file
+.In libdwarf.h
+specifies legal values for this field.
+.It Va drd_length
+The size in bytes of the field to be relocated.
+.It Va drd_offset
+The section-relative offset of the field to be relocated.
+.It Va drd_symbol_index
+The symbol index associated with the relocation entry.
+.El
+.Ss Memory Management
+The memory area used for the relocation arrays is managed by the
+.Lb libdwarf .
+The function
+.Fn dwarf_producer_finish
+may be used to release it, along with other resources associated
+with the producer instance.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_get_relocation_info
+returns
+.Dv DW_DLV_OK .
+It returns
+.Dv DW_DLV_NO_ENTRY
+if there were no more relocation arrays to retrieve, or if the flag
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+was not set on the producer instance.
+In case of an error, function
+.Fn dwarf_get_relocation_info
+returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_relocation_info
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar elf_section_index ,
+.Ar elf_section_link ,
+.Ar reloc_entry_count
+or
+.Ar reloc_buf
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+There were no more ELF relocation arrays to retrieve.
+.It Bq Er DW_DLE_NO_ENTRY
+The flag
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+was not set on the producer instance.
+.It Bq Er DW_DLE_NO_ENTRY
+Function
+.Xr dwarf_transform_to_disk_form 3
+was not called prior to calling function
+.Fn dwarf_get_relocation_info .
+.El
+.Sh EXAMPLES
+To generate relocation entries and retrieve them, use:
+.Bd -literal -offset indent
+Dwarf_P_Debug dbg;
+Dwarf_Relocation_Data buf;
+Dwarf_Signed count, index, link;
+Dwarf_Unsigned reloc_cnt, entry_cnt;
+Dwarf_Error de;
+int version, i, j;
+
+/*
+ * Assume that dbg refers to a DWARF producer instance created
+ * created with DW_DLC_SYMBOLIC_RELOCATIONS flag set and that
+ * application code has added DWARF debugging information
+ * to the producer instance.
+ */
+if ((count = dwarf_transform_to_disk_form(dbg, &de)) ==
+ DW_DLV_NOCOUNT) {
+ warnx("dwarf_transform_to_disk_form failed: %s",
+ dwarf_errmsg(-1));
+ return;
+}
+
+/* ... process generated section byte streams ... */
+if (dwarf_get_relocation_info_count(dbg, &reloc_cnt, &version, &de) !=
+ DW_DLV_OK) {
+ warnx("dwarf_get_relocation_info_count failed: %s",
+ dwarf_errmsg(-1));
+ return;
+}
+
+for (i = 0; (Dwarf_Unsigned) i < reloc_cnt; i++) {
+ if (dwarf_get_relocation_info(dbg, &index, &link, &entry_cnt,
+ &buf, &de) != DW_DLV_OK) {
+ warnx("dwarf_get_relocation_info failed: %s",
+ dwarf_errmsg(-1));
+ continue;
+ }
+ for (j = 0; (Dwarf_Unsigned) j < entry_cnt; j++) {
+ /* ...use each reloc data in buf[j]... */
+ }
+}
+
+dwarf_producer_finish(dbg, &de);
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_relocation_info_count 3 ,
+.Xr dwarf_reset_section_bytes 3 ,
+.Xr dwarf_producer_finish 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3 ,
+.Xr dwarf_transform_to_disk_form 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_relocation_info_count.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_relocation_info_count.3
new file mode 100644
index 0000000..38e1a00
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_relocation_info_count.3
@@ -0,0 +1,116 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_relocation_info_count.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd September 3, 2011
+.Os
+.Dt DWARF_GET_RELOCATION_INFO_COUNT 3
+.Sh NAME
+.Nm dwarf_get_relocation_info_count
+.Nd return the number of relocation arrays
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_relocation_info_count
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Unsigned *reloc_cnt"
+.Fa "int *drd_buffer_version"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_relocation_info_count
+retrieves the total number of relocation arrays generated by a prior
+call to
+.Xr dwarf_transform_to_disk_form 3 .
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+The
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+flag should have been set on the producer instance.
+.Pp
+Argument
+.Ar reloc_cnt
+should point to a location which will be set to the total number of
+relocation arrays generated.
+.Pp
+Argument
+.Ar drd_buffer_version
+should point to a location which will be set to the version number
+of the relocation structures returned (see the symbol
+.Dv DWARF_DRD_BUFFER_VERSION ,
+defined in the header file
+.In libdwarf.h ) .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_get_relocation_info_count
+returns
+.Dv DW_DLV_OK .
+It returns
+.Dv DW_DLV_NO_ENTRY
+if the
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+flag is not set on the producer instance.
+In case of an error, function
+.Fn dwarf_get_relocation_info_count
+returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_relocation_info_count
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar reloc_cnt
+or
+.Ar drd_buffer_version
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+The
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+flag was not set.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_relocation_info 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3 ,
+.Xr dwarf_transform_to_disk_form 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_section_bytes.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_section_bytes.3
new file mode 100644
index 0000000..1b0ac9e
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_section_bytes.3
@@ -0,0 +1,157 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_section_bytes.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd August 26, 2011
+.Os
+.Dt DWARF_GET_SECTION_BYTES 3
+.Sh NAME
+.Nm dwarf_get_section_bytes
+.Nd retrieve ELF section byte streams
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_Ptr
+.Fo dwarf_get_section_bytes
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Signed dwarf_section"
+.Fa "Dwarf_Signed *elf_section_index"
+.Fa "Dwarf_Unsigned *length"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_section_bytes
+returns the ELF section byte streams generated by a prior call
+to function
+.Xr dwarf_transform_to_disk_form 3 .
+.Pp
+Each call to function
+.Fn dwarf_get_section_bytes
+will return the byte stream for one ELF section.
+The first call to this function will always return the first ELF
+section, and the subsequent calls will return the rest of sections
+in the order when they were generated, until the last one.
+The total number of sections generated is returned by the function
+.Xr dwarf_transform_to_disk_form 3 .
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using the
+functions
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar dwarf_section
+is currently ignored.
+.Pp
+Argument
+.Ar elf_section_index
+should point to a location which will be set to the section index value
+of the returned ELF section.
+.Pp
+Argument
+.Ar length
+should point to a location which will hold the length in bytes of the
+returned ELF section.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Ss Memory Management
+The memory areas used for the returned ELF section byte streams should
+be freed using the function
+.Fn dwarf_producer_finish .
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_get_section_bytes
+returns a pointer to a ELF section byte stream.
+In case of an error, function
+.Fn dwarf_get_section_bytes
+will return NULL and set the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_section_bytes
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar elf_section_index ,
+or
+.Ar length
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+There were no more ELF sections to retrieve, or the function was
+called before a call to
+.Xr dwarf_transform_to_disk_form 3 .
+.El
+.Sh EXAMPLES
+To generate and retrieve ELF section byte streams, use:
+.Bd -literal -offset indent
+Dwarf_P_Debug dbg;
+Dwarf_Signed count, i, sec_index;
+Dwarf_Unsigned len;
+Dwarf_Ptr bytes;
+Dwarf_Error de;
+
+/* ... Assume that `dbg' refers to a DWARF producer instance,
+ * and that application code has added DWARF debugging
+ * information to the producer instance. ...
+ */
+if ((count = dwarf_transform_to_disk_form(dbg, &de)) ==
+ DW_DLV_NOCOUNT) {
+ warnx("dwarf_transform_to_disk_form failed: %s",
+ dwarf_errmsg(-1));
+ return;
+}
+
+/* Retrieve section data. */
+for (i = 0; i < count; i++) {
+ bytes = dwarf_get_section_bytes(dbg, i, &sec_index, &len,
+ &de);
+ if (bytes == NULL) {
+ warnx("dwarf_get_section_bytes failed: %s",
+ dwarf_errmsg(-1));
+ continue;
+ }
+ /* ... use the returned byte stream ... */
+}
+
+/* Release resources. */
+dwarf_producer_finish(dbg, &de);
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_reset_section_bytes 3 ,
+.Xr dwarf_producer_finish 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3 ,
+.Xr dwarf_transform_to_disk_form 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_section_max_offsets.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_section_max_offsets.3
new file mode 100644
index 0000000..963d4ac
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_section_max_offsets.3
@@ -0,0 +1,116 @@
+.\" Copyright (c) 2014 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_section_max_offsets.3 3141 2015-01-29 23:11:10Z jkoshy $
+.\"
+.Dd December 21, 2014
+.Os
+.Dt DWARF_GET_SECTION_MAX_OFFSETS
+.Sh NAME
+.Nm dwarf_get_section_max_offsets ,
+.Nm dwarf_get_section_max_offsets_b
+.Nd return the size of DWARF sections
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_section_max_offsets
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Unsigned *debug_info"
+.Fa "Dwarf_Unsigned *debug_abbrev"
+.Fa "Dwarf_Unsigned *debug_line"
+.Fa "Dwarf_Unsigned *debug_loc"
+.Fa "Dwarf_Unsigned *debug_aranges"
+.Fa "Dwarf_Unsigned *debug_macinfo"
+.Fa "Dwarf_Unsigned *debug_pubnames"
+.Fa "Dwarf_Unsigned *debug_str"
+.Fa "Dwarf_Unsigned *debug_frame"
+.Fa "Dwarf_Unsigned *debug_ranges"
+.Fa "Dwarf_Unsigned *debug_pubtypes"
+.Fc
+.Ft int
+.Fo dwarf_get_section_max_offsets_b
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Unsigned *debug_info"
+.Fa "Dwarf_Unsigned *debug_abbrev"
+.Fa "Dwarf_Unsigned *debug_line"
+.Fa "Dwarf_Unsigned *debug_loc"
+.Fa "Dwarf_Unsigned *debug_aranges"
+.Fa "Dwarf_Unsigned *debug_macinfo"
+.Fa "Dwarf_Unsigned *debug_pubnames"
+.Fa "Dwarf_Unsigned *debug_str"
+.Fa "Dwarf_Unsigned *debug_frame"
+.Fa "Dwarf_Unsigned *debug_ranges"
+.Fa "Dwarf_Unsigned *debug_pubtypes"
+.Fa "Dwarf_Unsigned *debug_types"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_section_max_offsets_b
+retrieves the sizes of the DWARF sections in a DWARF debug context.
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+The function stores the size of each DWARF section to the location
+pointed to by the argument corresponding to the section name.
+If a DWARF section does not exist, the location pointed to by the
+argument corresponding to that section will be set to zero.
+.Pp
+A value of NULL may be used for any of the arguments
+.Ar debug_info ,
+.Ar debug_abbrev ,
+.Ar debug_line ,
+.Ar debug_loc ,
+.Ar debug_aranges ,
+.Ar debug_macinfo ,
+.Ar debug_pubnames ,
+.Ar debug_str ,
+.Ar debug_frame ,
+.Ar debug_ranges ,
+.Ar debug_pubtypes
+and
+.Ar debug_types
+if the caller is not interested in the respective section size.
+.Pp
+Function
+.Fn dwarf_get_section_max_offsets
+is identical to function
+.Fn dwarf_get_section_max_offsets_b
+except that it does not provide argument
+.Ar debug_types ,
+and thus cannot return the size of the
+.Dq \&.debug_types
+section.
+.Sh RETURN VALUES
+On success, these functions return
+.Dv DW_DLV_OK .
+If argument
+.Ar dbg
+is NULL, they return
+.Dv DW_DLV_ERROR .
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_init 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_str.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_str.3
new file mode 100644
index 0000000..5917c97
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_str.3
@@ -0,0 +1,149 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_str.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd April 3, 2011
+.Os
+.Dt DWARF_GET_STR 3
+.Sh NAME
+.Nm dwarf_get_str
+.Nd retrieve a string from the DWARF string section
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_str
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Off offset"
+.Fa "char **string"
+.Fa "Dwarf_Signed *len"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_get_str
+retrieves a NUL-terminated string from the DWARF string section
+.Dq ".debug_str" .
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+.Pp
+Argument
+.Ar offset
+should be an offset, relative to the
+.Dq ".debug_str"
+section, specifying the start of the desired string.
+.Pp
+Argument
+.Ar string
+should point to a location which will hold a returned
+pointer to a NUL-terminated string.
+.Pp
+Argument
+.Ar len
+should point to a location which will hold the length
+of the returned string.
+The returned length does not include the space needed for
+the NUL-terminator.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_get_str
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+It returns
+.Dv DW_DLV_NO_ENTRY
+if there is no
+.Dq ".debug_str"
+section associated with the specified debugging context,
+or if the provided offset
+.Ar offset
+is at the very end of
+.Dq ".debug_str"
+section.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_get_str
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar dbg ,
+.Ar string
+or
+.Ar len
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar offset
+was out of range.
+.It Bq Er DW_DLE_NO_ENTRY
+The debugging context
+.Ar dbg
+did not contain a
+.Dq ".debug_str"
+string section.
+.It Bq Er DW_DLE_NO_ENTRY
+Argument
+.Ar offset
+was at the very end of the
+.Dq ".debug_str"
+section.
+.El
+.Sh EXAMPLE
+To retrieve all the strings in the DWARF string section, use:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Off offset;
+Dwarf_Signed len;
+Dwarf_Error de;
+char *str;
+int ret
+
+offset = 0;
+while ((ret = dwarf_get_str(dbg, offset, &str, &len, &de)) ==
+ DW_DLV_OK) {
+ /* .. Use the retrieved string. .. */
+ offset += len + 1; /* Account for the terminating NUL. */
+}
+
+if (ret == DW_DLV_ERROR)
+ warnx("dwarf_get_str: %s", dwarf_errmsg(de));
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_init 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_types.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_types.3
new file mode 100644
index 0000000..59e5868
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_types.3
@@ -0,0 +1,232 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_types.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd April 10, 2011
+.Os
+.Dt DWARF_GET_TYPES 3
+.Sh NAME
+.Nm dwarf_get_types ,
+.Nm dwarf_type_cu_offset ,
+.Nm dwarf_type_die_offset ,
+.Nm dwarf_type_name_offsets ,
+.Nm dwarf_typename
+.Nd retrieve information about user-defined types
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_types
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Type **types"
+.Fa "Dwarf_Signed *ntypes"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_type_cu_offset
+.Fa "Dwarf_Type type"
+.Fa "Dwarf_Off *cu_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_type_die_offset
+.Fa "Dwarf_Type type"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_type_name_offsets
+.Fa "Dwarf_Type type"
+.Fa "char **name"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Off *cu_die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_typename
+.Fa "Dwarf_Type type"
+.Fa "char **name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These APIs retrieve information about user-defined types from the
+SGI-specific
+.Dq ".debug_typenames"
+section.
+.Pp
+Standards-conformant applications should use the functions
+.Xr dwarf_get_pubtypes 3 ,
+.Xr dwarf_pubtype_cu_offset 3 ,
+.Xr dwarf_pubtype_die_offset 3 ,
+.Xr dwarf_pubtype_name_offsets 3
+and
+.Xr dwarf_pubtypename 3 ,
+which operate on the equivalent
+.Dq ".debug_pubtypes"
+section defined by the DWARF3 standard.
+.Pp
+Information about user-defined types is returned using opaque descriptors
+of type
+.Vt Dwarf_Type .
+Applications need to use the functions described below to retrieve
+the name and offset information contained in these descriptors.
+.Pp
+Function
+.Fn dwarf_get_types
+retrieves descriptors for all user-defined types associated with the
+DWARF debug context specified by argument
+.Ar dbg .
+The argument
+.Ar types
+should point to a location that will be set to a pointer to an array
+of
+.Vt Dwarf_Type
+descriptors.
+The argument
+.Ar ntypes
+should point to a location that will be set to the number of
+descriptors returned.
+.Pp
+Function
+.Fn dwarf_type_cu_offset
+returns the offset, relative to the
+.Dq ".debug_info"
+section, of the compilation unit that contains the debugging
+information entry associated with the argument
+.Ar type .
+Argument
+.Ar cu_offset
+should point to a location that will hold the returned offset.
+.Pp
+Function
+.Fn dwarf_type_die_offset
+retrieves the offset, relative to the
+.Dq ".debug_info"
+section, of the debugging information entry associated with the
+argument
+.Ar type ,
+and stores it into the location pointed to by the argument
+.Ar die_offset .
+.Pp
+Function
+.Fn dwarf_type_name_offsets
+retrieves the name and offsets for the debugging information
+entry for argument
+.Ar type .
+Argument
+.Ar name
+should point to a location which will be set to a pointer to a
+NUL-terminated string containing the name of the associated debugging
+information entry.
+Argument
+.Ar die_offset
+should point to a location which will be set to the offset, relative
+to the
+.Dq ".debug_info"
+section, of the associated debugging information entry.
+Argument
+.Ar cu_die_offset
+should point to a location which will be set to a offset, relative to
+the
+.Dq ".debug_info"
+section, of the first debugging information entry in the compilation
+unit associated with argument
+.Ar type .
+.Pp
+Function
+.Fn dwarf_typename
+sets the location pointed to by argument
+.Ar name
+to a pointer to a NUL-terminated string holding the name of the
+debugging information entry associated with the argument
+.Ar type .
+.Ss Memory Management
+The memory area used for the array of
+.Vt Dwarf_Type
+descriptors returned in argument
+.Ar types
+by function
+.Fn dwarf_get_types
+is owned by the
+.Lb libdwarf .
+Application code should not attempt to directly free this pointer.
+Portable code should instead use the function
+.Xr dwarf_types_dealloc 3
+to indicate that the memory area may be freed.
+.Pp
+The memory area used for the string returned in the
+.Ar name
+argument to functions
+.Fn dwarf_type_name_offsets
+and
+.Fn dwarf_typename
+is owned by the
+.Lb libdwarf .
+Portable code should indicate that the memory area can
+be freed using the
+.Xr dwarf_dealloc 3
+function.
+.Ss Error Returns
+If argument
+.Ar err
+is not NULL, these functions will use it to store error information,
+in case of an error.
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Va cu_die_offset ,
+.Va cu_offset ,
+.Va dbg ,
+.Va die_offset ,
+.Va type ,
+.Va types ,
+.Va name ,
+or
+.Va ntypes
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+The DWARF debugging context referenced by argument
+.Ar dbg
+did not contain information about user-defined types.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_cu_die_offset_given_cu_header_offset 3 ,
+.Xr dwarf_get_pubtypes 3 ,
+.Xr dwarf_pubtype_cu_offset 3 ,
+.Xr dwarf_pubtype_die_offset 3 ,
+.Xr dwarf_pubtype_name_offsets 3 ,
+.Xr dwarf_pubtypename 3 ,
+.Xr dwarf_types_dealloc 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_vars.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_vars.3
new file mode 100644
index 0000000..d2c3ebd
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_vars.3
@@ -0,0 +1,210 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_vars.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd April 2, 2011
+.Os
+.Dt DWARF_GET_VARS 3
+.Sh NAME
+.Nm dwarf_get_vars ,
+.Nm dwarf_var_cu_offset ,
+.Nm dwarf_var_die_offset ,
+.Nm dwarf_var_name_offsets ,
+.Nm dwarf_varname
+.Nd retrieve information about static variables
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_vars
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Var **vars"
+.Fa "Dwarf_Signed *nvars"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_var_cu_offset
+.Fa "Dwarf_Var var"
+.Fa "Dwarf_Off *cu_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_var_die_offset
+.Fa "Dwarf_Var var"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_var_name_offsets
+.Fa "Dwarf_Var var"
+.Fa "char **name"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Off *cu_die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_varname
+.Fa "Dwarf_Var var"
+.Fa "char **name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions retrieve information about the file scope static
+variables associated with a DWARF debug context.
+Information about these static variables is returned using opaque
+descriptors of type
+.Vt Dwarf_Var .
+Applications need to use the functions described below to retrieve
+the name and offset information contained in these descriptors.
+.Pp
+Function
+.Fn dwarf_get_vars
+retrieves descriptors for all the static variables associated with the
+DWARF debug context specified by argument
+.Ar dbg .
+The argument
+.Ar vars
+should point to a location that will be set to a pointer to an array
+of
+.Vt Dwarf_Var
+descriptors.
+The argument
+.Ar nvars
+should point to a location that will be set to the number of
+descriptors returned.
+.Pp
+Function
+.Fn dwarf_var_cu_offset
+returns the section-relative offset, relative to the
+.Dq ".debug_info"
+section, of the compilation unit that
+contains the debugging information entry associated with the argument
+.Ar var .
+Argument
+.Ar cu_offset
+should point to a location that will hold the returned offset.
+.Pp
+Function
+.Fn dwarf_var_die_offset
+retrieves the section-relative offset, relative to the
+.Dq ".debug_info"
+section, of the debugging information
+entry associated with the argument
+.Ar var ,
+and stores it into the location pointed to by the argument
+.Ar die_offset .
+.Pp
+Function
+.Fn dwarf_var_name_offsets
+retrieves both the name and the associated offsets for the debugging
+information entry for argument
+.Ar var .
+Argument
+.Ar name
+should point to a location which will be set to a pointer to a
+NUL-terminated string containing the name of the associated debugging
+information entry.
+Argument
+.Ar die_offset
+should point to a location which will be set to a section-relative
+offset, relative to the
+.Dq ".debug_info"
+section, of the associated debugging information entry.
+Argument
+.Ar cu_die_offset
+should point to a location which will be set to a
+section-relative offset, relative to the
+.Dq ".debug_info"
+section, of the first debugging information entry in
+the compilation unit associated with argument
+.Ar var .
+.Pp
+Function
+.Fn dwarf_varname
+sets the location pointed to by argument
+.Ar name
+to a pointer to a NUL-terminated string holding the name of the
+debugging information entry associated with the argument
+.Ar var .
+.Ss Memory Management
+The memory area used for the array of
+.Vt Dwarf_Var
+descriptors returned in argument
+.Ar vars
+by function
+.Fn dwarf_get_vars
+is owned by the
+.Lb libdwarf .
+Application code should not attempt to directly free this pointer.
+Portable code should instead use the function
+.Xr dwarf_vars_dealloc 3
+to indicate that the memory area may be freed.
+.Pp
+The memory area used for the string returned in the
+.Ar name
+argument to functions
+.Fn dwarf_var_name_offsets
+and
+.Fn dwarf_varname
+is owned by the
+.Lb libdwarf .
+Portable code should indicate that the memory area can
+be freed using the
+.Xr dwarf_dealloc 3
+function.
+.Ss Error Returns
+If argument
+.Ar err
+is not NULL, these functions will use it to store error information,
+in case of an error.
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Va cu_die_offset ,
+.Va cu_offset ,
+.Va dbg ,
+.Va die_offset ,
+.Va var ,
+.Va vars ,
+.Va name ,
+or
+.Va nvars
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_dealloc 3 ,
+.Xr dwarf_get_cu_die_offset_given_cu_header_offset 3 ,
+.Xr dwarf_vars_dealloc 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_weaks.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_weaks.3
new file mode 100644
index 0000000..470973e
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_weaks.3
@@ -0,0 +1,215 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_get_weaks.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\"
+.Dd April 10, 2011
+.Os
+.Dt DWARF_GET_WEAKS 3
+.Sh NAME
+.Nm dwarf_get_weaks ,
+.Nm dwarf_weak_cu_offset ,
+.Nm dwarf_weak_die_offset ,
+.Nm dwarf_weak_name_offsets ,
+.Nm dwarf_weakname
+.Nd retrieve information about weak symbols
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_get_weaks
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Weak **weaks"
+.Fa "Dwarf_Signed *nweaks"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_weak_cu_offset
+.Fa "Dwarf_Weak weak"
+.Fa "Dwarf_Off *cu_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_weak_die_offset
+.Fa "Dwarf_Weak weak"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_weak_name_offsets
+.Fa "Dwarf_Weak weak"
+.Fa "char **name"
+.Fa "Dwarf_Off *die_offset"
+.Fa "Dwarf_Off *cu_die_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_weakname
+.Fa "Dwarf_Weak weak"
+.Fa "char **name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions retrieve information about weak symbols from the
+lookup tables in the (SGI-specific)
+.Dq ".debug_weaknames"
+section.
+Information about weak symbols is returned using opaque descriptors
+of type
+.Vt Dwarf_Weak .
+Applications need to use the functions described below to retrieve
+the name and offset information contained in these descriptors.
+.Pp
+Function
+.Fn dwarf_get_weaks
+retrieves descriptors for all the weak symbols associated with the
+DWARF debug context specified by argument
+.Ar dbg .
+The argument
+.Ar weaks
+should point to a location that will be set to a pointer to an array
+of
+.Vt Dwarf_Weak
+descriptors.
+The argument
+.Ar nweaks
+should point to a location that will be set to the number of
+descriptors returned.
+.Pp
+Function
+.Fn dwarf_weak_cu_offset
+returns the offset, relative to the
+.Dq ".debug_info"
+section, of the compilation unit that contains the debugging
+information entry associated with the argument
+.Ar weak .
+Argument
+.Ar cu_offset
+should point to a location that will hold the returned offset.
+.Pp
+Function
+.Fn dwarf_weak_die_offset
+retrieves the offset, relative to the
+.Dq ".debug_info"
+section, of the debugging information entry associated with the
+argument
+.Ar weak ,
+and stores it into the location pointed to by the argument
+.Ar die_offset .
+.Pp
+Function
+.Fn dwarf_weak_name_offsets
+retrieves the name and offsets for the debugging information
+entry for argument
+.Ar weak .
+Argument
+.Ar name
+should point to a location which will be set to a pointer to a
+NUL-terminated string containing the name of the associated debugging
+information entry.
+Argument
+.Ar die_offset
+should point to a location which will be set to the offset, relative
+to the
+.Dq ".debug_info"
+section, of the associated debugging information entry.
+Argument
+.Ar cu_die_offset
+should point to a location which will be set to the
+offset, relative to the
+.Dq ".debug_info"
+section, of the first debugging information entry in the compilation
+unit associated with argument
+.Ar weak .
+.Pp
+Function
+.Fn dwarf_weakname
+sets the location pointed to by argument
+.Ar name
+to a pointer to a NUL-terminated string holding the name of the
+debugging information entry associated with the argument
+.Ar weak .
+.Ss Memory Management
+The memory area used for the array of
+.Vt Dwarf_Weak
+descriptors returned in argument
+.Ar weaks
+by function
+.Fn dwarf_get_weaks
+is owned by the
+.Lb libdwarf .
+Application code should not attempt to directly free this pointer.
+Portable code should instead use the function
+.Xr dwarf_weaks_dealloc 3
+to indicate that the memory area may be freed.
+.Pp
+The memory area used for the string returned in the
+.Ar name
+argument to functions
+.Fn dwarf_weak_name_offsets
+and
+.Fn dwarf_weakname
+is owned by the
+.Lb libdwarf .
+Portable code should indicate that the memory area can
+be freed using the
+.Xr dwarf_dealloc 3
+function.
+.Ss Error Returns
+If argument
+.Ar err
+is not NULL, these functions will use it to store error information,
+in case of an error.
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Va cu_die_offset ,
+.Va cu_offset ,
+.Va dbg ,
+.Va die_offset ,
+.Va weak ,
+.Va weaks ,
+.Va name ,
+or
+.Va nweaks
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+The DWARF debugging context referenced by argument
+.Ar dbg
+did not contain information about weak symbols.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_cu_die_offset_given_cu_header_offset 3 ,
+.Xr dwarf_weaks_dealloc 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_hasattr.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_hasattr.3
new file mode 100644
index 0000000..6598875
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_hasattr.3
@@ -0,0 +1,92 @@
+.\" Copyright (c) 2010 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_hasattr.3 3181 2015-04-10 13:22:51Z emaste $
+.\"
+.Dd April 17, 2010
+.Os
+.Dt DWARF_HASATTR 3
+.Sh NAME
+.Nm dwarf_hasattr
+.Nd check for the presence of an attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_hasattr
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Half attr"
+.Fa "Dwarf_Bool *ret_bool"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_hasattr
+tests whether the debugging information entry referenced in argument
+.Ar die
+contains the attribute named by argument
+.Ar attr .
+Legal values for argument
+.Ar attr
+are those denoted by the
+.Dv DW_AT_*
+constants in the DWARF specification.
+.Pp
+If the named attribute is present in the debugging information entry,
+function
+.Fn dwarf_hasattr
+returns a non-zero value in the location pointed to by argument
+.Ar ret_bool .
+If the named attribute is not present, a zero is written instead.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_hasattr
+returns
+.Dv DW_DLV_OK .
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_hasattr
+can fail with the following error:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of argument
+.Va die
+or
+.Va ret_bool
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_whatattr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_hasform.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_hasform.3
new file mode 100644
index 0000000..2cb6fc5
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_hasform.3
@@ -0,0 +1,127 @@
+.\" Copyright (c) 2010 Joseph Koshy. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" This software is provided by Joseph Koshy ``as is'' and
+.\" any express or implied warranties, including, but not limited to, the
+.\" implied warranties of merchantability and fitness for a particular purpose
+.\" are disclaimed. in no event shall Joseph Koshy be liable
+.\" for any direct, indirect, incidental, special, exemplary, or consequential
+.\" damages (including, but not limited to, procurement of substitute goods
+.\" or services; loss of use, data, or profits; or business interruption)
+.\" however caused and on any theory of liability, whether in contract, strict
+.\" liability, or tort (including negligence or otherwise) arising in any way
+.\" out of the use of this software, even if advised of the possibility of
+.\" such damage.
+.\"
+.\" $Id: dwarf_hasform.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\"
+.Dd May 22, 2010
+.Os
+.Dt DWARF_HASFORM 3
+.Sh NAME
+.Nm dwarf_hasform ,
+.Nm dwarf_whatform ,
+.Nm dwarf_whatform_direct
+.Nd query attribute forms
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_hasform
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Half form"
+.Fa "Dwarf_Bool *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_whatform
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Half *retform"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_whatform_direct
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Half *retform"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_hasform
+indicates whether the DWARF attribute denoted by argument
+.Ar attr
+has the attribute form specified by argument
+.Ar form .
+If the attribute has the specified form, then
+argument
+.Ar ret
+is set to a non-zero value, otherwise it is set to zero.
+If argument
+.Ar err
+is non-NULL, it will be used to return an error descriptor in
+case of an error.
+.Pp
+Function
+.Fn dwarf_whatform
+sets the location specified by argument
+.Ar retform
+to the attribute form code for the DWARF attribute referenced
+by argument
+.Ar attr .
+If the attribute referenced by argument
+.Ar attr
+has an indirect form attribute, this function will return the final
+form for the attribute.
+If argument
+.Ar err
+is non-NULL, it will be used to return an error descriptor in
+case of an error.
+.Pp
+Function
+.Fn dwarf_whatform_direct
+sets the location specified by argument
+.Ar retform
+to the attribute form code for the DWARF attribute referenced
+by argument
+.Ar attr .
+If the form is an indirect form, the function sets the location
+specified by argument
+.Ar retform
+to
+.Dv DW_FORM_indirect .
+If argument
+.Ar err
+is non-NULL, it will be used to return an error descriptor in
+case of an error.
+.Sh RETURN VALUES
+These functions return
+.Dv DW_DLV_OK
+on success.
+In case of an error, these functions return
+.Dv DW_DLV_ERR
+and set argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Any of the arguments
+.Ar attr ,
+.Ar ret ,
+or
+.Ar retform
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_hasattr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_highpc.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_highpc.3
new file mode 100644
index 0000000..4d31f5c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_highpc.3
@@ -0,0 +1,193 @@
+.\" Copyright (c) 2010,2014 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_highpc.3 3092 2014-09-02 22:09:30Z kaiwang27 $
+.\"
+.Dd July 22, 2014
+.Os
+.Dt DWARF_HIGHPC 3
+.Sh NAME
+.Nm dwarf_arrayorder ,
+.Nm dwarf_bitoffset ,
+.Nm dwarf_bitsize ,
+.Nm dwarf_bytesize ,
+.Nm dwarf_highpc ,
+.Nm dwarf_highpc_b ,
+.Nm dwarf_lowpc ,
+.Nm dwarf_srclang
+.Nd retrieve the value of a DWARF attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_arrayorder
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Unsigned *ret_order"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_bitoffset
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Unsigned *ret_size"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_bitsize
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Unsigned *ret_size"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_bytesize
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Unsigned *ret_size"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_highpc
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Addr *ret_highpc"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_highpc_b
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Addr *ret_highpc"
+.Fa "Dwarf_Half *ret_form"
+.Fa "enum Dwarf_Form_Class *ret_class"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_lowpc
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Addr *ret_lowpc"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_srclang
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Unsigned *ret_lang"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These convenience functions are used to retrieve DWARF attribute
+values associated with a Debugging Information Entry (DIE) descriptor
+denoted by argument
+.Ar die .
+These functions store the value of the requested attribute into the
+location pointed to by their second argument, provided that the requested
+attribute exists in the debugging information entry.
+.Pp
+The list of functions and the DWARF attribute that they retrieve are:
+.Pp
+.Bl -tag -width ".Fn dwarf_arrayorder" -compact
+.It Fn dwarf_arrayorder
+Retrieve the
+.Dv DW_AT_ordering
+attribute value.
+.It Fn dwarf_bitoffset
+Retrieve the
+.Dv DW_AT_bit_offset
+attribute value.
+.It Fn dwarf_bitsize
+Retrieve the
+.Dv DW_AT_bit_size
+attribute value.
+.It Fn dwarf_bytesize
+Retrieve the
+.Dv DW_AT_byte_size
+attribute value.
+.It Fn dwarf_highpc
+Retrieve the
+.Dv DW_AT_high_pc
+attribute value.
+.It Fn dwarf_highpc_b
+Retrieve the
+.Dv DW_AT_high_pc
+attribute value.
+.It Fn dwarf_lowpc
+Retrieve the
+.Dv DW_AT_low_pc
+attribute value.
+.It Fn dwarf_srclang
+Retrieve the
+.Dv DW_AT_language
+attribute value.
+.El
+.Pp
+Function
+.Fn dwarf_highpc_b
+is an enhanced version of function
+.Fn dwarf_highpc .
+It sets the location specified by argument
+.Ar ret_form
+to the form code of the attribute
+.Dv DW_AT_high_pc ,
+and sets the location specified by argument
+.Ar ret_class
+to the class of that form.
+A value of NULL may be used for either of the arguments
+.Ar ret_form
+or
+.Ar ret_class
+if the caller is not interested in the respective value.
+.Sh RETURN VALUES
+These functions return
+.Dv DW_DLV_OK on success.
+.Pp
+If the debugging information entry descriptor denoted by argument
+.Ar die
+does not contain the requested attribute, these functions return
+.Dv DW_DLV_NO_ENTRY
+and set argument
+.Ar err .
+For other errors, they return
+.Dv DW_DLV_ERROR
+and set argument
+.Ar err .
+.Sh ERRORS
+These functions can fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Arguments
+.Ar die ,
+.Ar ret_highpc ,
+.Ar ret_lowpc ,
+.Ar ret_size ,
+.Ar ret_lang
+or
+.Ar ret_order
+were NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+Argument
+.Ar die
+had no requested attribute.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_attrlist 3 ,
+.Xr dwarf_hasattr 3 ,
+.Xr dwarf_get_form_class 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_init.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_init.3
new file mode 100644
index 0000000..36c6449
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_init.3
@@ -0,0 +1,178 @@
+.\" Copyright (c) 2009 Joseph Koshy. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" This software is provided by Joseph Koshy ``as is'' and
+.\" any express or implied warranties, including, but not limited to, the
+.\" implied warranties of merchantability and fitness for a particular purpose
+.\" are disclaimed. in no event shall Joseph Koshy be liable
+.\" for any direct, indirect, incidental, special, exemplary, or consequential
+.\" damages (including, but not limited to, procurement of substitute goods
+.\" or services; loss of use, data, or profits; or business interruption)
+.\" however caused and on any theory of liability, whether in contract, strict
+.\" liability, or tort (including negligence or otherwise) arising in any way
+.\" out of the use of this software, even if advised of the possibility of
+.\" such damage.
+.\"
+.\" $Id: dwarf_init.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_INIT 3
+.Sh NAME
+.Nm dwarf_init ,
+.Nm dwarf_elf_init
+.Nd allocate a DWARF debug descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_init
+.Fa "int fd"
+.Fa "int mode"
+.Fa "Dwarf_Handler errhand"
+.Fa "Dwarf_Ptr errarg"
+.Fa "Dwarf_Debug *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft in
+.Fo dwarf_elf_init
+.Fa "Elf *elf"
+.Fa "int mode"
+.Fa "Dwarf_Handler errhand"
+.Fa "Dwarf_Ptr errarg"
+.Fa "Dwarf_Debug *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions allocate and return a
+.Vt Dwarf_Debug
+instance for the object denoted by argument
+.Ar fd
+or
+.Ar elf .
+This instance would be used for subsequent access to debugging information in the object by other functions in the DWARF(3) library.
+.Pp
+For function
+.Fn dwarf_init ,
+argument
+.Ar fd
+denotes an open file descriptor referencing a compilation object.
+Function
+.Fn dwarf_init
+implicitly allocates an
+.Vt Elf
+descriptor for argument
+.Ar fd .
+.Pp
+For function
+.Fn dwarf_elf_init ,
+argument
+.Ar elf
+denotes a descriptor returned by
+.Xr elf_begin 3
+or
+.Xr elf_memory 3 .
+.Pp
+Argument
+.Ar mode
+specifies the access mode desired.
+It should be at least as permissive as the mode with which
+the file descriptor
+.Ar fd
+or the ELF descriptor
+.Ar elf
+was created with.
+Legal values for argument
+.Ar mode
+are:
+.Pp
+.Bl -tag -width "DW_DLC_WRITE" -compact
+.It DW_DLC_RDWR
+Permit reading and writing of DWARF information.
+.It DW_DLC_READ
+Operate in read-only mode.
+.It DW_DLC_WRITE
+Permit writing of DWARF information.
+.El
+.Pp
+Argument
+.Ar errhand
+denotes a function to be called in case of an error.
+If this argument is
+.Dv NULL
+then a default error handling scheme is used.
+See
+.Xr dwarf 3
+for a description of the error handling scheme used by the
+DWARF(3) library.
+.Pp
+Argument
+.Ar errarg
+is passed to the error handler function denoted by argument
+.Ar errhand
+when it is invoked.
+.Pp
+Argument
+.Ar ret
+points to the memory location that will hold a
+.Vt Dwarf_Debug
+reference on a successful call these functions.
+.Pp
+Argument
+.Ar err
+references a memory location that would hold a
+.Vt Dwarf_Error
+descriptor in case of an error.
+.Ss Memory Management
+The
+.Vt Dwarf_Debug
+instance returned by these functions should be freed using
+.Fn dwarf_finish .
+.Sh RETURN VALUES
+These functions return the following values:
+.Bl -tag -width ".Bq Er DW_DLV_NO_ENTRY"
+.It Bq Er DW_DLV_OK
+This return value indicates a successful return.
+.It Bq Er DW_DLV_ERROR
+The operation failed.
+.It Bq Er DW_DLV_NO_ENTRY
+The object specified by arguments
+.Ar "fd"
+or
+.Ar "elf"
+did not contain debug information.
+.El
+.Sh IMPLEMENTATION NOTES
+The current implementation does not support access modes
+.Dv DW_DLC_RDWR
+and
+.Dv DW_DLC_WRITE .
+.Sh EXAMPLES
+To initialize a
+.Vt Dwarf_Debug
+instance from a open file descriptor referencing an ELF object, and
+with the default error handler, use:
+.Bd -literal -offset indent
+Dwarf_Error err;
+Dwarf_Debug dbg;
+
+if (dwarf_init(fd, DW_DLC_READ, NULL, NULL, &dbg, &err) !=
+ DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_init: %s", dwarf_errmsg(err));
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_errmsg 3 ,
+.Xr dwarf_finish 3 ,
+.Xr dwarf_get_elf 3 ,
+.Xr elf_begin 3 ,
+.Xr elf_memory 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_init.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_init.c
new file mode 100644
index 0000000..16ec53c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_init.c
@@ -0,0 +1,163 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_init.c 2073 2011-10-27 03:30:47Z jkoshy $");
+
+int
+dwarf_elf_init(Elf *elf, int mode, Dwarf_Handler errhand, Dwarf_Ptr errarg,
+ Dwarf_Debug *ret_dbg, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ int ret;
+
+ if (elf == NULL || ret_dbg == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (mode != DW_DLC_READ) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (_dwarf_alloc(&dbg, mode, error) != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ if (_dwarf_elf_init(dbg, elf, error) != DW_DLE_NONE) {
+ free(dbg);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((ret = _dwarf_init(dbg, 0, errhand, errarg, error)) !=
+ DW_DLE_NONE) {
+ _dwarf_elf_deinit(dbg);
+ free(dbg);
+ if (ret == DW_DLE_DEBUG_INFO_NULL)
+ return (DW_DLV_NO_ENTRY);
+ else
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_dbg = dbg;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_elf(Dwarf_Debug dbg, Elf **elf, Dwarf_Error *error)
+{
+ Dwarf_Elf_Object *e;
+
+ if (dbg == NULL || elf == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ e = dbg->dbg_iface->object;
+ *elf = e->eo_elf;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_init(int fd, int mode, Dwarf_Handler errhand, Dwarf_Ptr errarg,
+ Dwarf_Debug *ret_dbg, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ Elf *elf;
+ int ret;
+
+ if (fd < 0 || ret_dbg == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (mode != DW_DLC_READ) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (elf_version(EV_CURRENT) == EV_NONE) {
+ DWARF_SET_ELF_ERROR(NULL, error);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
+ DWARF_SET_ELF_ERROR(NULL, error);
+ return (DW_DLV_ERROR);
+ }
+
+ if (_dwarf_alloc(&dbg, mode, error) != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ if (_dwarf_elf_init(dbg, elf, error) != DW_DLE_NONE) {
+ free(dbg);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((ret = _dwarf_init(dbg, 0, errhand, errarg, error)) !=
+ DW_DLE_NONE) {
+ _dwarf_elf_deinit(dbg);
+ free(dbg);
+ if (ret == DW_DLE_DEBUG_INFO_NULL)
+ return (DW_DLV_NO_ENTRY);
+ else
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_dbg = dbg;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_object_init(Dwarf_Obj_Access_Interface *iface, Dwarf_Handler errhand,
+ Dwarf_Ptr errarg, Dwarf_Debug *ret_dbg, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ if (iface == NULL || ret_dbg == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (_dwarf_alloc(&dbg, DW_DLC_READ, error) != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ dbg->dbg_iface = iface;
+
+ if (_dwarf_init(dbg, 0, errhand, errarg, error) != DW_DLE_NONE) {
+ free(dbg);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_dbg = dbg;
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_lineno.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_lineno.3
new file mode 100644
index 0000000..0a0362f
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_lineno.3
@@ -0,0 +1,202 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_lineno.3 2074 2011-10-27 03:34:33Z jkoshy $
+.\"
+.Dd February 5, 2011
+.Os
+.Dt DWARF_LINENO 3
+.Sh NAME
+.Nm dwarf_lineaddr ,
+.Nm dwarf_linebeginstatement ,
+.Nm dwarf_lineblock ,
+.Nm dwarf_lineendsequence ,
+.Nm dwarf_lineno ,
+.Nm dwarf_lineoff ,
+.Nm dwarf_linesrc ,
+.Nm dwarf_line_srcfileno
+.Nd retrieve information associated with a DWARF line descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_lineaddr
+.Fa "Dwarf_Line ln"
+.Fa "Dwarf_Addr *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_linebeginstatement
+.Fa "Dwarf_Line ln"
+.Fa "Dwarf_Bool *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_lineblock
+.Fa "Dwarf_Line ln"
+.Fa "Dwarf_Bool *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_lineendsequence
+.Fa "Dwarf_Line ln"
+.Fa "Dwarf_Bool *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_lineno
+.Fa "Dwarf_Line ln"
+.Fa "Dwarf_Unsigned *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_lineoff
+.Fa "Dwarf_Line ln"
+.Fa "Dwarf_Signed *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_linesrc
+.Fa "Dwarf_Line ln"
+.Fa "char **ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_line_srcfileno
+.Fa "Dwarf_Line ln"
+.Fa "Dwarf_Unsigned *ret"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions retrieve specific line information associated with
+the line descriptor specified by argument
+.Ar ln ,
+and stores it in the location pointed to by argument
+.Ar ret .
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Pp
+Function
+.Fn dwarf_lineaddr
+stores the program address corresponding to the source line specified
+in argument
+.Ar ln
+into the location pointed to by argument
+.Ar ret .
+.Pp
+Function
+.Fn dwarf_linebeginstatement
+sets the location pointed to by argument
+.Ar ret
+to 1 if the source line specified by the line descriptor
+.Ar ln
+is the beginning of a statement, or to 0 otherwise.
+.Pp
+Function
+.Fn dwarf_lineblock
+sets the location pointed to by argument
+.Ar ret
+to 1 if the source line specified by the line descriptor
+.Ar ln
+is the beginning of a basic block, or to 0 otherwise.
+.Pp
+Function
+.Fn dwarf_lineendsequence
+sets the location pointed to by argument
+.Ar ret
+to 1 if the program address associated with the line descriptor
+.Ar ln
+is the address immediately following the end of a sequence of target
+machine instructions, or to 0 otherwise.
+.Pp
+Function
+.Fn dwarf_lineno
+stores the line number of the source line associated with the line
+descriptor
+.Ar ln
+into the location pointed to by argument
+.Ar ret .
+.Pp
+Function
+.Fn dwarf_lineoff
+stores the column number within a line associated with descriptor
+.Ar ln
+into the location pointed to by argument
+.Ar ret .
+The retrieved column numbers are 1-based, with the value -1 indicating
+that column number information was not available.
+.Pp
+Function
+.Fn dwarf_linesrc
+stores a pointer to a NUL-terminated string containing the source file
+name associated with line descriptor
+.Ar ln
+into the location pointed to by argument
+.Ar ret .
+The full path of the source file is returned if possible.
+The memory used for the source file name string is managed by the DWARF(3)
+library and should not be directly freed by application code.
+Instead, portable code should use
+.Xr dwarf_dealloc 3
+to indicate that the string should be freed.
+.Pp
+Function
+.Fn dwarf_line_srcfileno
+stores the index of the source file associated with the line descriptor
+.Ar ln
+in the location pointed to by argument
+.Ar ret .
+The returned value is 1-based index into the array of source file
+names returned by
+.Xr dwarf_srcfiles 3 .
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_LINE_FILE_NUM_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+Either of the arguments
+.Va ln
+or
+.Va ret
+was NULL.
+.It Bq Er DW_DLE_LINE_FILE_NUM_BAD
+The source file name associated with the line descriptor
+.Ar ln
+could not be retrieved by function
+.Fn dwarf_linesrc .
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_dealloc 3 ,
+.Xr dwarf_srcfiles 3 ,
+.Xr dwarf_srclines 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_lineno.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_lineno.c
new file mode 100644
index 0000000..cbcc9ae
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_lineno.c
@@ -0,0 +1,294 @@
+/*-
+ * Copyright (c) 2009,2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_lineno.c 2983 2014-02-09 00:24:31Z kaiwang27 $");
+
+int
+dwarf_srclines(Dwarf_Die die, Dwarf_Line **linebuf, Dwarf_Signed *linecount,
+ Dwarf_Error *error)
+{
+ Dwarf_LineInfo li;
+ Dwarf_Debug dbg;
+ Dwarf_Line ln;
+ Dwarf_CU cu;
+ Dwarf_Attribute at;
+ int i;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || linebuf == NULL || linecount == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((at = _dwarf_attr_find(die, DW_AT_stmt_list)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ cu = die->die_cu;
+ if (cu->cu_lineinfo == NULL) {
+ if (_dwarf_lineno_init(die, at->u[0].u64, error) !=
+ DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ }
+ if (cu->cu_lineinfo == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ li = cu->cu_lineinfo;
+ *linecount = (Dwarf_Signed) li->li_lnlen;
+
+ if (*linecount == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ if (li->li_lnarray != NULL) {
+ *linebuf = li->li_lnarray;
+ return (DW_DLV_OK);
+ }
+
+ if ((li->li_lnarray = malloc(*linecount * sizeof(Dwarf_Line))) ==
+ NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_ERROR);
+ }
+
+ for (i = 0, ln = STAILQ_FIRST(&li->li_lnlist);
+ i < *linecount && ln != NULL; i++, ln = STAILQ_NEXT(ln, ln_next))
+ li->li_lnarray[i] = ln;
+
+ *linebuf = li->li_lnarray;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_srcfiles(Dwarf_Die die, char ***srcfiles, Dwarf_Signed *srccount,
+ Dwarf_Error *error)
+{
+ Dwarf_LineInfo li;
+ Dwarf_LineFile lf;
+ Dwarf_Debug dbg;
+ Dwarf_CU cu;
+ Dwarf_Attribute at;
+ int i;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL || srcfiles == NULL || srccount == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((at = _dwarf_attr_find(die, DW_AT_stmt_list)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ cu = die->die_cu;
+ if (cu->cu_lineinfo == NULL) {
+ if (_dwarf_lineno_init(die, at->u[0].u64, error) !=
+ DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ }
+ if (cu->cu_lineinfo == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ li = cu->cu_lineinfo;
+ *srccount = (Dwarf_Signed) li->li_lflen;
+
+ if (*srccount == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ if (li->li_lfnarray != NULL) {
+ *srcfiles = li->li_lfnarray;
+ return (DW_DLV_OK);
+ }
+
+ if ((li->li_lfnarray = malloc(*srccount * sizeof(char *))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_ERROR);
+ }
+
+ for (i = 0, lf = STAILQ_FIRST(&li->li_lflist);
+ i < *srccount && lf != NULL; i++, lf = STAILQ_NEXT(lf, lf_next)) {
+ if (lf->lf_fullpath)
+ li->li_lfnarray[i] = lf->lf_fullpath;
+ else
+ li->li_lfnarray[i] = lf->lf_fname;
+ }
+
+ *srcfiles = li->li_lfnarray;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_linebeginstatement(Dwarf_Line ln, Dwarf_Bool *ret_bool,
+ Dwarf_Error *error)
+{
+
+ if (ln == NULL || ret_bool == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_bool = ln->ln_stmt;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_lineendsequence(Dwarf_Line ln, Dwarf_Bool *ret_bool, Dwarf_Error *error)
+{
+
+ if (ln == NULL || ret_bool == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_bool = ln->ln_endseq;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_lineno(Dwarf_Line ln, Dwarf_Unsigned *ret_lineno, Dwarf_Error *error)
+{
+
+ if (ln == NULL || ret_lineno == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_lineno = ln->ln_lineno;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_line_srcfileno(Dwarf_Line ln, Dwarf_Unsigned *ret_fileno,
+ Dwarf_Error *error)
+{
+
+ if (ln == NULL || ret_fileno == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_fileno = ln->ln_fileno;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_lineaddr(Dwarf_Line ln, Dwarf_Addr *ret_lineaddr, Dwarf_Error *error)
+{
+
+ if (ln == NULL || ret_lineaddr == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_lineaddr = ln->ln_addr;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_lineoff(Dwarf_Line ln, Dwarf_Signed *ret_lineoff, Dwarf_Error *error)
+{
+
+ if (ln == NULL || ret_lineoff == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (ln->ln_column == 0)
+ *ret_lineoff = -1;
+ else
+ *ret_lineoff = (Dwarf_Signed) ln->ln_column;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_linesrc(Dwarf_Line ln, char **ret_linesrc, Dwarf_Error *error)
+{
+ Dwarf_LineInfo li;
+ Dwarf_LineFile lf;
+ int i;
+
+ if (ln == NULL || ret_linesrc == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ li = ln->ln_li;
+ assert(li != NULL);
+
+ for (i = 1, lf = STAILQ_FIRST(&li->li_lflist);
+ (Dwarf_Unsigned) i < ln->ln_fileno && lf != NULL;
+ i++, lf = STAILQ_NEXT(lf, lf_next))
+ ;
+
+ if (lf == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_LINE_FILE_NUM_BAD);
+ return (DW_DLV_ERROR);
+ }
+
+ if (lf->lf_fullpath) {
+ *ret_linesrc = (char *) lf->lf_fullpath;
+ return (DW_DLV_OK);
+ }
+
+ *ret_linesrc = lf->lf_fname;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_lineblock(Dwarf_Line ln, Dwarf_Bool *ret_bool, Dwarf_Error *error)
+{
+
+ if (ln == NULL || ret_bool == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_bool = ln->ln_bblock;
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_lne_end_sequence.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_lne_end_sequence.3
new file mode 100644
index 0000000..a826acb
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_lne_end_sequence.3
@@ -0,0 +1,100 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_lne_end_sequence.3 2074 2011-10-27 03:34:33Z jkoshy $
+.\"
+.Dd September 15, 2011
+.Os
+.Dt DWARF_LNE_END_SEQUENCE 3
+.Sh NAME
+.Nm dwarf_lne_end_sequence
+.Nd set the end of instruction sequence
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_lne_end_sequence
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Addr addr"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_lne_end_sequence
+sets the address that indicates the end of a sequence of target machine
+instructions.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar addr
+specifies an address value which is the first byte after the end of a
+instruction sequence.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_lne_end_sequence
+returns
+.Dv DW_DLV_OK .
+In case of an error, function
+.Fn dwarf_lne_end_sequence
+returns
+.Dv DW_DLV_NOCOUNT
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_lne_end_sequence
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+The value in argument
+.Ar addr
+overlapped an existing line information entry.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_directory_decl 3 ,
+.Xr dwarf_add_file_decl 3 ,
+.Xr dwarf_add_line_entry 3 ,
+.Xr dwarf_lne_set_address 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_lne_set_address.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_lne_set_address.3
new file mode 100644
index 0000000..8a46b7b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_lne_set_address.3
@@ -0,0 +1,105 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_lne_set_address.3 2074 2011-10-27 03:34:33Z jkoshy $
+.\"
+.Dd September 14, 2011
+.Os
+.Dt DWARF_LNE_SET_ADDRESS 3
+.Sh NAME
+.Nm dwarf_lne_set_address
+.Nd set the base address for line number information
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_Unsigned"
+.Fo dwarf_lne_set_address
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Addr off"
+.Fa "Dwarf_Unsigned symndx"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_lne_set_address
+sets the base address used by subsequent invocations of the
+.Xr dwarf_add_line_entry 3
+function.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar off
+specifies a relocatable program address.
+.Pp
+Argument
+.Ar symndx
+specifies the index of the ELF symbol to be used for relocation.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_lne_set_address
+returns
+.Dv DW_DLV_OK .
+In case of an error, function
+.Fn dwarf_lne_set_address
+returns
+.Dv DW_DLV_NOCOUNT
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_lne_set_address
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+The argument
+.Ar symndx
+had an illegal value.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_directory_decl 3 ,
+.Xr dwarf_add_file_decl 3 ,
+.Xr dwarf_add_line_entry 3 ,
+.Xr dwarf_lne_end_sequence 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist.3
new file mode 100644
index 0000000..2e95d74
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist.3
@@ -0,0 +1,230 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_loclist.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_LOCLIST 3
+.Sh NAME
+.Nm dwarf_loclist ,
+.Nm dwarf_loclist_n
+.Nd retrieve DWARF location expression information
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_loclist
+.Fa "Dwarf_Attribute at"
+.Fa "Dwarf_Locdesc **llbuf"
+.Fa "Dwarf_Signed *listlen"
+.Fa "Dwarf_Error *error"
+.Fc
+.Ft int
+.Fo dwarf_loclist_n
+.Fa "Dwarf_Attribute at"
+.Fa "Dwarf_Locdesc ***llbuf"
+.Fa "Dwarf_Signed *listlen"
+.Fa "Dwarf_Error *error"
+.Fc
+.Sh DESCRIPTION
+These functions retrieve the location expressions
+associated with a DWARF attribute.
+.Pp
+Note: function
+.Fn dwarf_loclist
+is deprecated.
+New application code should instead use function
+.Fn dwarf_loclist_n
+.Pp
+Function
+.Fn dwarf_loclist_n
+retrieves the list of location expressions associated with a DWARF
+attribute.
+Argument
+.Ar at
+should reference a valid DWARF attribute.
+Argument
+.Ar llbuf
+should point to a location which will hold a returned array of
+pointers to
+.Vt Dwarf_Locdesc
+descriptors.
+Argument
+.Ar listlen
+should point to a location which will be set to the number of
+elements contained in the returned array.
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Pp
+Function
+.Fn dwarf_loclist
+retrieves the first location expression associated with an attribute.
+Argument
+.Ar at
+should reference a valid DWARF attribute.
+Argument
+.Ar llbuf
+should point to a location which will hold the returned pointer
+to a
+.Vt Dwarf_Locdesc
+descriptor.
+Argument
+.Ar listlen
+should point to a location which will be always set to 1.
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Pp
+.Vt Dwarf_Locdesc
+descriptors are defined in the header file
+.In libdwarf.h ,
+and consist of following fields:
+.Pp
+.Bl -tag -width ".Va ld_cents" -compact
+.It Va ld_lopc
+The lowest program counter address covered by the descriptor.
+This field will be set to 0 if the descriptor is not associated with
+an address range.
+.It Va ld_hipc
+The highest program counter address covered by the descriptor.
+This field will be set to 0 if the descriptor is not associated with
+an address range.
+.It Va ld_cents
+The number of entries returned in
+.Va ld_s
+field.
+.It Va ld_s
+Pointer to an array of
+.Vt Dwarf_Loc
+descriptors.
+.El
+.Pp
+Each
+.Vt Dwarf_Loc
+descriptor represents one operation of a location expression.
+These descriptors are defined in the header file
+.In libdwarf.h ,
+and consist of following fields:
+.Pp
+.Bl -tag -width ".Va lr_number2" -compact
+.It Va lr_atom
+The operator name, one of the
+.Dv DW_OP_*
+constants defined in the header file
+.In dwarf.h .
+.It Va lr_number
+The first operand of this operation.
+.It Va lr_number2
+The second operand of this operation.
+.It Va lr_offset
+The byte offset of this operation within the containing location
+expression.
+.El
+.Ss Memory Management
+The memory area used for the descriptor array returned in argument
+.Ar llbuf
+is allocated by the
+.Lb libdwarf .
+When the descriptor array is no longer needed, application code should
+use function
+.Xr dwarf_dealloc 3
+to free the memory area in the following manner:
+.Bl -enum
+.It
+First, the
+.Ar ld_s
+field of each
+.Vt Dwarf_Locdesc
+descriptor should be deallocated using the allocation type
+.Dv DW_DLA_LOC_BLOCK .
+.It
+Then, the application should free each
+.Vt Dwarf_Locdesc
+descriptor using the allocation type
+.Dv DW_DLA_LOCDESC .
+.It
+Finally, the
+.Va llbuf
+pointer should be deallocated using the allocation type
+.Dv DW_DLA_LIST .
+.El
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar at ,
+.Ar llbuf
+or
+.Ar listlen
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+The attribute provided by argument
+.Ar at
+does not contain a location expression or is not associated with a
+location expression list.
+.El
+.Sh EXAMPLE
+To retrieve the location list associated with an attribute, use:
+.Bd -literal -offset indent
+Dwarf_Attribute at;
+Dwarf_Locdesc **llbuf;
+Dwarf_Signed lcnt;
+Dwarf_Loc *lr;
+Dwarf_Error de;
+int i;
+
+if (dwarf_loclist_n(at, &llbuf, &lcnt, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_loclist_n failed: %s",
+ dwarf_errmsg(de));
+
+for (i = 0; i < lcnt; i++) {
+ /* ... Use llbuf[i] ... */
+ for (j = 0; (Dwarf_Half) j < llbuf[i]->ld_cents; j++) {
+ lr = &llbuf[i]->ld_s[j];
+ /* ... Use each Dwarf_Loc descriptor ... */
+ }
+ dwarf_dealloc(dbg, llbuf[i]->ld_s, DW_DLA_LOC_BLOCK);
+ dwarf_dealloc(dbg, llbuf[i], DW_DLA_LOCDESC);
+}
+dwarf_dealloc(dbg, llbuf, DW_DLA_LIST);
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_dealloc 3 ,
+.Xr dwarf_loclist_from_expr 3 ,
+.Xr dwarf_loclist_from_expr_a 3 ,
+.Xr dwarf_get_loclist_entry 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist.c
new file mode 100644
index 0000000..e780a87
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist.c
@@ -0,0 +1,302 @@
+/*-
+ * Copyright (c) 2009,2014 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_loclist.c 3066 2014-06-06 19:36:06Z kaiwang27 $");
+
+static int
+copy_locdesc(Dwarf_Debug dbg, Dwarf_Locdesc *dst, Dwarf_Locdesc *src,
+ Dwarf_Error *error)
+{
+
+ assert(src != NULL && dst != NULL);
+
+ dst->ld_lopc = src->ld_lopc;
+ dst->ld_hipc = src->ld_hipc;
+ dst->ld_cents = src->ld_cents;
+
+ if (dst->ld_cents > 0) {
+ dst->ld_s = calloc(dst->ld_cents, sizeof(Dwarf_Loc));
+ if (dst->ld_s == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ memcpy(dst->ld_s, src->ld_s, src->ld_cents *
+ sizeof(Dwarf_Loc));
+ } else
+ dst->ld_s = NULL;
+
+ return (DW_DLE_NONE);
+}
+
+int
+dwarf_loclist_n(Dwarf_Attribute at, Dwarf_Locdesc ***llbuf,
+ Dwarf_Signed *listlen, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ int ret;
+
+ dbg = at != NULL ? at->at_die->die_dbg : NULL;
+
+ if (at == NULL || llbuf == NULL || listlen == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ switch (at->at_attrib) {
+ case DW_AT_location:
+ case DW_AT_string_length:
+ case DW_AT_return_addr:
+ case DW_AT_data_member_location:
+ case DW_AT_frame_base:
+ case DW_AT_segment:
+ case DW_AT_static_link:
+ case DW_AT_use_location:
+ case DW_AT_vtable_elem_location:
+ switch (at->at_form) {
+ case DW_FORM_data4:
+ case DW_FORM_data8:
+ /*
+ * DW_FORM_data[48] can not be used as section offset
+ * since DWARF4. For DWARF[23], the application needs
+ * to determine if DW_FORM_data[48] is representing
+ * a constant or a section offset.
+ */
+ if (at->at_die->die_cu->cu_version >= 4) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+ /* FALLTHROUGH */
+ case DW_FORM_sec_offset:
+ ret = _dwarf_loclist_find(dbg, at->at_die->die_cu,
+ at->u[0].u64, llbuf, listlen, NULL, error);
+ if (ret == DW_DLE_NO_ENTRY) {
+ DWARF_SET_ERROR(dbg, error, ret);
+ return (DW_DLV_NO_ENTRY);
+ }
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ return (DW_DLV_OK);
+ case DW_FORM_block:
+ case DW_FORM_block1:
+ case DW_FORM_block2:
+ case DW_FORM_block4:
+ case DW_FORM_exprloc:
+ if (at->at_ld == NULL) {
+ ret = _dwarf_loc_add(at->at_die, at, error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ }
+ *llbuf = calloc(1, sizeof(Dwarf_Locdesc *));
+ if (*llbuf == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_ERROR);
+ }
+ (*llbuf)[0] = calloc(1, sizeof(Dwarf_Locdesc));
+ if ((*llbuf)[0] == NULL) {
+ free(*llbuf);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_ERROR);
+ }
+ if (copy_locdesc(dbg, (*llbuf)[0], at->at_ld, error) !=
+ DW_DLE_NONE) {
+ free((*llbuf)[0]);
+ free(*llbuf);
+ return (DW_DLV_ERROR);
+ }
+ *listlen = 1;
+ return (DW_DLV_OK);
+ default:
+ /* Malformed Attr? */
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ return (DW_DLV_NO_ENTRY);
+ }
+ default:
+ /* Wrong attr supplied. */
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+}
+
+int
+dwarf_loclist(Dwarf_Attribute at, Dwarf_Locdesc **llbuf,
+ Dwarf_Signed *listlen, Dwarf_Error *error)
+{
+ Dwarf_Locdesc **_llbuf;
+ int i, ret;
+
+ ret = dwarf_loclist_n(at, &_llbuf, listlen, error);
+ if (ret != DW_DLV_OK)
+ return (ret);
+
+ /* Only return the first location description of the list. */
+ *llbuf = _llbuf[0];
+
+ /* Free the rest of the list. */
+ for (i = 1; i < *listlen; i++) {
+ if (_llbuf[i]->ld_s)
+ free(_llbuf[i]->ld_s);
+ free(_llbuf[i]);
+ }
+ free(_llbuf);
+
+ *listlen = 1;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_loclist_entry(Dwarf_Debug dbg, Dwarf_Unsigned offset,
+ Dwarf_Addr *hipc, Dwarf_Addr *lopc, Dwarf_Ptr *data,
+ Dwarf_Unsigned *entry_len, Dwarf_Unsigned *next_entry,
+ Dwarf_Error *error)
+{
+ Dwarf_Locdesc *ld, **llbuf;
+ Dwarf_Section *ds;
+ Dwarf_Signed listlen;
+ int i, ret;
+
+ /*
+ * Note that this API sometimes will not work correctly because
+ * it assumes that all units have the same pointer size and offset
+ * size.
+ */
+
+ if (dbg == NULL || hipc == NULL || lopc == NULL || data == NULL ||
+ entry_len == NULL || next_entry == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ ret = _dwarf_loclist_find(dbg, STAILQ_FIRST(&dbg->dbg_cu), offset,
+ &llbuf, &listlen, entry_len, error);
+ if (ret == DW_DLE_NO_ENTRY) {
+ DWARF_SET_ERROR(dbg, error, DW_DLV_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ } else if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ *hipc = *lopc = 0;
+ for (i = 0; i < listlen; i++) {
+ ld = llbuf[i];
+ if (i == 0) {
+ *hipc = ld->ld_hipc;
+ *lopc = ld->ld_lopc;
+ } else {
+ if (ld->ld_lopc < *lopc)
+ *lopc = ld->ld_lopc;
+ if (ld->ld_hipc > *hipc)
+ *hipc = ld->ld_hipc;
+ }
+ }
+
+ ds = _dwarf_find_section(dbg, ".debug_loc");
+ assert(ds != NULL);
+ *data = (uint8_t *) ds->ds_data + offset;
+ *next_entry = offset + *entry_len;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_loclist_from_expr(Dwarf_Debug dbg, Dwarf_Ptr bytes_in,
+ Dwarf_Unsigned bytes_len, Dwarf_Locdesc **llbuf, Dwarf_Signed *listlen,
+ Dwarf_Error *error)
+{
+
+ return (dwarf_loclist_from_expr_a(dbg, bytes_in, bytes_len,
+ dbg->dbg_pointer_size, llbuf, listlen, error));
+}
+
+int
+dwarf_loclist_from_expr_a(Dwarf_Debug dbg, Dwarf_Ptr bytes_in,
+ Dwarf_Unsigned bytes_len, Dwarf_Half addr_size, Dwarf_Locdesc **llbuf,
+ Dwarf_Signed *listlen, Dwarf_Error *error)
+{
+ Dwarf_Half offset_size;
+ Dwarf_Small version;
+
+ /*
+ * Obtain offset size and DWARF version from the current
+ * Compilation Unit or Type Unit. These values are needed
+ * for correctly parsing DW_OP_GNU_implicit_pointer operator.
+ *
+ * Note that dwarf_loclist_from_expr_b() should be used instead
+ * if the application knows correct values for offset size
+ * and DWARF version.
+ */
+ if (dbg->dbg_cu_current) {
+ offset_size = dbg->dbg_cu_current->cu_length_size == 4 ? 4 : 8;
+ version = dbg->dbg_cu_current->cu_version;
+ } else if (dbg->dbg_tu_current) {
+ offset_size = dbg->dbg_tu_current->cu_length_size == 4 ? 4 : 8;
+ version = dbg->dbg_tu_current->cu_version;
+ } else {
+ /* Default values if no CU/TU context. */
+ offset_size = 4;
+ version = 2; /* DWARF2 */
+ }
+
+ return (dwarf_loclist_from_expr_b(dbg, bytes_in, bytes_len, addr_size,
+ offset_size, version, llbuf, listlen, error));
+}
+
+int
+dwarf_loclist_from_expr_b(Dwarf_Debug dbg, Dwarf_Ptr bytes_in,
+ Dwarf_Unsigned bytes_len, Dwarf_Half addr_size, Dwarf_Half offset_size,
+ Dwarf_Small version, Dwarf_Locdesc **llbuf, Dwarf_Signed *listlen,
+ Dwarf_Error *error)
+{
+ Dwarf_Locdesc *ld;
+ int ret;
+
+ if (dbg == NULL || bytes_in == NULL || bytes_len == 0 ||
+ llbuf == NULL || listlen == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (addr_size != 4 && addr_size != 8) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (offset_size != 4 && offset_size != 8) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ ret = _dwarf_loc_fill_locexpr(dbg, &ld, bytes_in, bytes_len, addr_size,
+ offset_size, version, error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+
+ *llbuf = ld;
+ *listlen = 1;
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist_from_expr.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist_from_expr.3
new file mode 100644
index 0000000..d0eb88c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_loclist_from_expr.3
@@ -0,0 +1,201 @@
+.\" Copyright (c) 2011,2014 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_loclist_from_expr.3 3129 2014-12-21 20:06:26Z jkoshy $
+.\"
+.Dd December 21, 2014
+.Os
+.Dt DWARF_LOCLIST_FROM_EXPR 3
+.Sh NAME
+.Nm dwarf_loclist_from_expr ,
+.Nm dwarf_loclist_from_expr_a ,
+.Nm dwarf_loclist_from_expr_b
+.Nd translate DWARF location expression bytes
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_loclist_from_expr
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Ptr bytes_in"
+.Fa "Dwarf_Unsigned bytes_len"
+.Fa "Dwarf_Locdesc **llbuf"
+.Fa "Dwarf_Signed *listlen"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_loclist_from_expr_a
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Ptr bytes_in"
+.Fa "Dwarf_Unsigned bytes_len"
+.Fa "Dwarf_Half addr_size"
+.Fa "Dwarf_Locdesc **llbuf"
+.Fa "Dwarf_Signed *listlen"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_loclist_from_expr_b
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Ptr bytes_in"
+.Fa "Dwarf_Unsigned bytes_len"
+.Fa "Dwarf_Half addr_size"
+.Fa "Dwarf_Half offset_size"
+.Fa "Dwarf_Small version"
+.Fa "Dwarf_Locdesc **llbuf"
+.Fa "Dwarf_Signed *listlen"
+.Fa "Dwarf_Error *error"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_loclist_from_expr
+translates DWARF location expression bytes into a
+.Vt Dwarf_Locdesc
+descriptor.
+The size for address related data is taken to be the default address
+size for the object being read.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+.Pp
+Argument
+.Ar bytes_in
+should point to an array of DWARF location expression bytes.
+.Pp
+Argument
+.Ar bytes_len
+should specify the number of the location expression bytes to be
+translated.
+.Pp
+Argument
+.Ar llbuf
+should point to a location which will be set to a pointer
+to a returned
+.Vt Dwarf_Locdesc
+descriptor.
+.Pp
+Argument
+.Ar listlen
+should point to a location which will hold the number of the
+.Vt Dwarf_Locdesc
+descriptors returned.
+In this case it is always set to 1.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Pp
+Function
+.Fn dwarf_loclist_from_expr_a
+is identical to function
+.Fn dwarf_loclist_from_expr ,
+except that it requires one additional argument
+.Ar addr_size ,
+which specifies the address size to use when translating the location
+expression bytes.
+.Pp
+Function
+.Fn dwarf_loclist_from_expr_b
+is identical to function
+.Fn dwarf_loclist_from_expr_a
+except that it requires two additional arguments for translating the
+location expression bytes.
+Argument
+.Ar offset_size
+specifies the offset size, and argument
+.Ar version
+specifies the DWARF version.
+These values are required to correctly translate the
+.Dv DW_OP_GNU_implicit_pointer
+opcode.
+.Ss Memory Management
+The memory area used for the descriptor returned in argument
+.Ar llbuf
+is allocated by
+.Lb libdwarf .
+When the descriptor is no longer needed, application code should use
+function
+.Xr dwarf_dealloc 3
+to free the memory area in two steps:
+.Bl -enum -compact
+.It
+First, the array of
+.Vt Dwarf_Loc
+descriptors pointed to by the
+.Ar ld_s
+field of the
+.Vt Dwarf_Locdesc
+descriptor should be deallocated using the allocation type
+.Dv DW_DLA_LOC_BLOCK .
+.It
+Next, the application should free the
+.Ar llbuf
+pointer using the allocation type
+.Dv DW_DLA_LOCDESC .
+.El
+.Sh RETURN VALUES
+On success, these functions returns
+.Dv DW_DLV_OK .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_LOC_EXPR_BAD"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Va dbg ,
+.Va bytes_in ,
+.Va llbuf
+or
+.Va listlen
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar bytes_len
+was 0.
+.It Bq Er DW_DLE_ARGUMENT
+The value of argument
+.Ar addr_size
+was invalid.
+.It Bq Er DW_DLE_LOC_EXPR_BAD
+An unknown or invalid operation was found in the location expression
+bytes provided in argument
+.Ar bytes_in .
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+this function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_dealloc 3 ,
+.Xr dwarf_loclist_n 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_loclist_entry 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_macinfo.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_macinfo.c
new file mode 100644
index 0000000..325c653
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_macinfo.c
@@ -0,0 +1,88 @@
+/*-
+ * Copyright (c) 2009,2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_macinfo.c 2074 2011-10-27 03:34:33Z jkoshy $");
+
+char *
+dwarf_find_macro_value_start(char *macro_string)
+{
+ char *p;
+
+ if (macro_string == NULL)
+ return (NULL);
+
+ p = macro_string;
+ while (*p != '\0' && *p != ' ')
+ p++;
+ if (*p == ' ')
+ p++;
+
+ return (p);
+}
+
+int
+dwarf_get_macro_details(Dwarf_Debug dbg, Dwarf_Off offset,
+ Dwarf_Unsigned max_count, Dwarf_Signed *entry_cnt,
+ Dwarf_Macro_Details **details, Dwarf_Error *error)
+{
+ Dwarf_MacroSet ms;
+ Dwarf_Unsigned cnt;
+ int i;
+
+ if (dbg == NULL || entry_cnt == NULL || details == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (STAILQ_EMPTY(&dbg->dbg_mslist)) {
+ if (_dwarf_macinfo_init(dbg, error) != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ if (STAILQ_EMPTY(&dbg->dbg_mslist)) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+ }
+
+ STAILQ_FOREACH(ms, &dbg->dbg_mslist, ms_next) {
+ for (i = 0; (Dwarf_Unsigned) i < ms->ms_cnt; i++)
+ if (ms->ms_mdlist[i].dmd_offset == offset) {
+ cnt = ms->ms_cnt - i;
+ if (max_count != 0 && cnt > max_count)
+ cnt = max_count;
+
+ *details = &ms->ms_mdlist[i];
+ *entry_cnt = cnt;
+
+ return (DW_DLV_OK);
+ }
+ }
+
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+
+ return (DW_DLV_NO_ENTRY);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_nametbl.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_nametbl.m4
new file mode 100644
index 0000000..34ec280
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_nametbl.m4
@@ -0,0 +1,159 @@
+/*-
+ * Copyright (c) 2009,2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: dwarf_nametbl.m4 2074 2011-10-27 03:34:33Z jkoshy $
+ */
+
+define(`MAKE_NAMETBL_API',`
+int
+dwarf_get_$1s(Dwarf_Debug dbg, Dwarf_$2 **$1s,
+ Dwarf_Signed *ret_count, Dwarf_Error *error)
+{
+ Dwarf_Section *ds;
+ int ret;
+
+ if (dbg == NULL || $1s == NULL || ret_count == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (dbg->dbg_$1s == NULL) {
+ if ((ds = _dwarf_find_section(dbg, ".debug_$4")) != NULL) {
+ ret = _dwarf_nametbl_init(dbg, &dbg->dbg_$1s, ds,
+ error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ }
+ if (dbg->dbg_$1s == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+ }
+
+ *$1s = dbg->dbg_$1s->ns_array;
+ *ret_count = dbg->dbg_$1s->ns_len;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_$3name(Dwarf_$2 $1, char **ret_name, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
+
+ if ($1 == NULL || ret_name == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ *ret_name = $1->np_name;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_$1_die_offset(Dwarf_$2 $1, Dwarf_Off *ret_offset,
+ Dwarf_Error *error)
+{
+ Dwarf_NameTbl nt;
+ Dwarf_Debug dbg;
+
+ dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
+
+ if ($1 == NULL || ret_offset == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ nt = $1->np_nt;
+ assert(nt != NULL);
+
+ *ret_offset = nt->nt_cu_offset + $1->np_offset;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_$1_cu_offset(Dwarf_$2 $1, Dwarf_Off *ret_offset,
+ Dwarf_Error *error)
+{
+ Dwarf_NameTbl nt;
+ Dwarf_Debug dbg;
+
+ dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
+
+ if ($1 == NULL || ret_offset == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ nt = $1->np_nt;
+ assert(nt != NULL);
+
+ *ret_offset = nt->nt_cu_offset;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_$1_name_offsets(Dwarf_$2 $1, char **ret_name, Dwarf_Off *die_offset,
+ Dwarf_Off *cu_offset, Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ Dwarf_Debug dbg;
+ Dwarf_NameTbl nt;
+
+ dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
+
+ if ($1 == NULL || ret_name == NULL || die_offset == NULL ||
+ cu_offset == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ nt = $1->np_nt;
+ assert(nt != NULL);
+
+ cu = nt->nt_cu;
+ assert(cu != NULL);
+
+ *ret_name = $1->np_name;
+ *die_offset = nt->nt_cu_offset + $1->np_offset;
+ *cu_offset = cu->cu_1st_offset;
+
+ return (DW_DLV_OK);
+}
+
+void
+dwarf_$1s_dealloc(Dwarf_Debug dbg, Dwarf_$2 *$1s, Dwarf_Signed count)
+{
+
+ (void) dbg;
+ (void) $1s;
+ (void) count;
+}
+')
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_new_die.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_new_die.3
new file mode 100644
index 0000000..1c463d3
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_new_die.3
@@ -0,0 +1,164 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_new_die.3 2074 2011-10-27 03:34:33Z jkoshy $
+.\"
+.Dd September 4, 2011
+.Os
+.Dt DWARF_NEW_DIE 3
+.Sh NAME
+.Nm dwarf_new_die
+.Nd allocate a new debugging information entry
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_P_Die
+.Fo dwarf_new_die
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Tag tag"
+.Fa "Dwarf_P_Die parent"
+.Fa "Dwarf_P_Die child"
+.Fa "Dwarf_P_Die left"
+.Fa "Dwarf_P_Die right"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_new_die
+allocates a new DWARF debugging information entry and links it
+to another debugging information entry.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar tag
+should specify the tag of the newly created debugging information entry.
+Valid values for this argument are those for the
+.Dv DW_TAG_ Ns *
+symbols defined in
+.In libdwarf.h .
+.Pp
+Argument
+.Ar parent
+specifies the parent link of the debugging information entry.
+.Pp
+Argument
+.Ar child
+specifies the first child link of the debugging information entry.
+.Pp
+Argument
+.Ar left
+specifies the left sibling link of the debugging information entry.
+.Pp
+Argument
+.Ar right
+specifies the right sibling link of the debugging information entry.
+.Pp
+Only one of arguments
+.Ar parent ,
+.Ar child ,
+.Ar left
+and
+.Ar right
+is allowed to be non-NULL.
+Application code can subsequently call the function
+.Xr dwarf_die_link 3
+to change the links for the created debugging information entry.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_new_die
+returns the newly created debugging information entry.
+In case of an error, function
+.Fn dwarf_new_die
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_new_die
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+More than one of the arguments
+.Ar parent ,
+.Ar child ,
+.Ar left
+and
+.Ar right
+were non-NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh EXAMPLES
+To create debugging information entries and add them to the producer
+instance, use:
+.Bd -literal -offset indent
+Dwarf_P_Debug dbg;
+Dwarf_P_Die die1, die2;
+Dwarf_Error de;
+
+/* ... assume dbg refers to a DWARF producer instance ... */
+
+die1 = dwarf_new_die(dbg, DW_TAG_compilation_unit, NULL, NULL, NULL,
+ NULL, &de);
+if (die1 == NULL) {
+ warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1));
+ return;
+}
+
+die2 = dwarf_new_die(dbg, DW_TAG_base_type, die1, NULL, NULL,
+ NULL, &de);
+if (die1 == NULL) {
+ warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1));
+ return;
+}
+
+if (dwarf_add_die_to_debug(dbg, die1, &de) != DW_DLV_OK) {
+ warnx("dwarf_add_die_to_debug failed: %s", dwarf_errmsg(-1));
+ return;
+}
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_die_to_debug 3 ,
+.Xr dwarf_die_link 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_new_expr.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_new_expr.3
new file mode 100644
index 0000000..d8f4c8a
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_new_expr.3
@@ -0,0 +1,135 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_new_expr.3 2074 2011-10-27 03:34:33Z jkoshy $
+.\"
+.Dd September 8, 2011
+.Os
+.Dt DWARF_NEW_EXPR 3
+.Sh NAME
+.Nm dwarf_new_expr
+.Nd create a location expression descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_P_Expr"
+.Fo dwarf_new_expr
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_new_expr
+allocates a DWARF location expression descriptor used to build up a
+location expression stream.
+.Pp
+The application can use the functions
+.Xr dwarf_add_expr_gen 3
+and
+.Xr dwarf_add_expr_addr_b 3
+to add location expression operators to the created descriptor.
+When done, the application can call the function
+.Xr dwarf_expr_into_block 3
+to retrieve the generated byte stream for the location expression,
+or call the function
+.Xr dwarf_add_AT_location_expr 3
+to create an attribute with the location expression stream as its
+value.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_new_expr
+returns the created location expression descriptor.
+In case of an error, function
+.Fn dwarf_new_expr
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_new_expr
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+the function.
+.El
+.Sh EXAMPLES
+To create a location expression descriptor, add location expression
+operators to it and to retrieve the generated byte stream,
+use:
+.Bd -literal -offset indent
+Dwarf_P_Debug dbg;
+Dwarf_Error de;
+Dwarf_P_Expr pe;
+Dwarf_Addr buf;
+Dwarf_Unsigned len;
+
+/* ...Assume that `dbg' refers to a DWARF producer instance... */
+
+if ((pe = dwarf_new_expr(dbg, &de)) == DW_DLV_BADADDR) {
+ warnx("dwarf_new_expr failed: %s", dwarf_errmsg(-1));
+ return;
+}
+
+if (dwarf_add_expr_gen(pe, DW_OP_regx, 55, 0, &de) ==
+ DW_DLV_NOCOUNT) {
+ warnx("dwarf_add_expr_gen failed: %s", dwarf_errmsg(-1));
+ return;
+}
+
+if ((buf = dwarf_expr_into_block(pe, &len, &de)) ==
+ DW_DLV_BADADDR) {
+ warnx("dwarf_expr_into_block failed: %s",
+ dwarf_errmsg(-1));
+ return;
+}
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_AT_location_expr 3 ,
+.Xr dwarf_add_expr_gen 3 ,
+.Xr dwarf_add_expr_addr 3 ,
+.Xr dwarf_add_expr_addr_b 3 ,
+.Xr dwarf_expr_current_offset 3 ,
+.Xr dwarf_expr_into_block 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_new_fde.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_new_fde.3
new file mode 100644
index 0000000..1ca19a8
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_new_fde.3
@@ -0,0 +1,87 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_new_fde.3 2074 2011-10-27 03:34:33Z jkoshy $
+.\"
+.Dd September 24, 2011
+.Os
+.Dt DWARF_NEW_FDE 3
+.Sh NAME
+.Nm dwarf_new_fde
+.Nd allocate a DWARF frame descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "Dwarf_P_Fde"
+.Fo dwarf_new_fde
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_new_fde
+allocates a new DWARF frame descriptor.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_new_fde
+returns the newly created frame descriptor.
+In case of an error, function
+.Fn dwarf_new_fde
+returns
+.Dv DW_DLV_BADADDR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_new_fde
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_fde_inst 3 ,
+.Xr dwarf_add_frame_fde 3 ,
+.Xr dwarf_add_frame_fde_b 3 ,
+.Xr dwarf_add_frame_cie 3 ,
+.Xr dwarf_fde_cfa_offset 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_next_cu_header.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_next_cu_header.3
new file mode 100644
index 0000000..f68867d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_next_cu_header.3
@@ -0,0 +1,288 @@
+.\" Copyright (c) 2010,2014 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_next_cu_header.3 3182 2015-04-10 16:08:10Z emaste $
+.\"
+.Dd December 21, 2014
+.Os
+.Dt DWARF_NEXT_CU_HEADER 3
+.Sh NAME
+.Nm dwarf_next_cu_header ,
+.Nm dwarf_next_cu_header_b ,
+.Nm dwarf_next_cu_header_c
+.Nd step through compilation units in a DWARF debug context
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_next_cu_header
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Unsigned *cu_length"
+.Fa "Dwarf_Half *cu_version"
+.Fa "Dwarf_Off *cu_abbrev_offset"
+.Fa "Dwarf_Half *cu_pointer_size"
+.Fa "Dwarf_Unsigned *cu_next_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_next_cu_header_b
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Unsigned *cu_length"
+.Fa "Dwarf_Half *cu_version"
+.Fa "Dwarf_Off *cu_abbrev_offset"
+.Fa "Dwarf_Half *cu_pointer_size"
+.Fa "Dwarf_Half *cu_offset_size"
+.Fa "Dwarf_Half *cu_extension_size"
+.Fa "Dwarf_Unsigned *cu_next_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft int
+.Fo dwarf_next_cu_header_c
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Bool is_info"
+.Fa "Dwarf_Unsigned *cu_length"
+.Fa "Dwarf_Half *cu_version"
+.Fa "Dwarf_Off *cu_abbrev_offset"
+.Fa "Dwarf_Half *cu_pointer_size"
+.Fa "Dwarf_Half *cu_offset_size"
+.Fa "Dwarf_Half *cu_extension_size"
+.Fa "Dwarf_Sig8 *type_signature"
+.Fa "Dwarf_Unsigned *type_offset"
+.Fa "Dwarf_Unsigned *cu_next_offset"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+These functions are used to step through compilation or type units
+associated with a DWARF debug context, optionally returning information
+about the unit.
+.Pp
+Function
+.Fn dwarf_next_cu_header_c
+is the API recommended for new application code.
+Function
+.Fn dwarf_next_cu_header
+and
+.Fn dwarf_next_cu_header_b
+can only operate on compilation units associated with the
+.Dq \&.debug_info
+section.
+They are less general than function
+.Fn dwarf_next_cu_header_c ,
+and are deprecated for use by new application code.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+If argument
+.Ar is_info
+is set to 1,
+the function returns information for compilation units found in the
+.Dq \&.debug_info
+section.
+If argument
+.Ar is_info
+is set to 0,
+the function returns information for type units found in the
+.Dq \&.debug_types
+sections.
+Argument
+.Ar cu_length
+should point to a location that will be set to the
+length of the compilation or type unit.
+Argument
+.Ar cu_version
+should point to a location that will be set to the
+version number for the compilation or type unit.
+Argument
+.Ar cu_abbrev_offset
+should point to a location that will be set to the
+starting offset (in the
+.Dq .debug_abbrev
+section) of the set of debugging information entry abbreviations
+associated with this compilation or type unit.
+Argument
+.Ar cu_pointer_size
+should point to a location that will be set to the
+size in bytes of an address for the machine architecture of the
+underlying object being debugged.
+Argument
+.Ar cu_offset_size
+should point to a location that will be set to the
+size in bytes for a DWARF offset in the compilation or type unit.
+Argument
+.Ar cu_extension_size
+is only needed for processing MIPS/IRIX objects that use
+a non-standard DWARF format.
+It should point to a location that will be set to 4 for normal
+objects and to 0 for non-standard ones.
+Argument
+.Ar type_signature
+and
+.Ar type_offset
+is only needed for processing type units.
+Argument
+.Ar type_signature
+should point to a location that will be set to the 64-bit unique signature
+of the type described in the type unit.
+Argument
+.Ar type_offset
+should point to a location that will be set to the offset of the debugging
+information entry that describes the type.
+Argument
+.Ar cu_next_offset
+should point to a location that will be set to the
+offset of the next compilation unit header in the
+.Dq \&.debug_info
+section,
+or the offset of the next type unit header in the
+.Dq \&.debug_types
+section.
+Argument
+.Ar err
+should point to a location that will hold an error descriptor in case
+of an error.
+.Pp
+Function
+.Fn dwarf_next_cu_header_b
+is identical to function
+.Fn dwarf_next_cu_header_c
+except that it does not provide arguments
+.Ar is_info ,
+.Ar type_signature
+and
+.Ar type_offset .
+.Pp
+Function
+.Fn dwarf_next_cu_header
+is identical to function
+.Fn dwarf_next_cu_header_b
+except that it does not provide arguments
+.Ar cu_offset_size
+and
+.Ar cu_extension_size .
+.Pp
+A value of NULL may be used for any of the arguments
+.Ar cu_length ,
+.Ar cu_version ,
+.Ar cu_abbrev_offset ,
+.Ar cu_pointer_size ,
+.Ar cu_offset_size ,
+.Ar cu_extension_size ,
+.Ar type_signature ,
+.Ar type_offset ,
+.Ar cu_next_offset
+and
+.Ar err
+if the caller is not interested in the respective value.
+.Ss Iterating Through Compilation Units in a Debug Context
+.Pp
+The first call to function
+.Fn dwarf_next_cu_header_c
+for a given debug context with argument
+.Ar is_info
+set to 1 will return information about the first
+compilation unit in the
+.Dq \&.debug_info
+section.
+Subsequent calls to the function will iterate through the remaining
+compilation units in the section.
+On stepping past the last compilation unit in the section,
+function
+.Fn dwarf_next_cu_header_c
+returns
+.Dv DW_DLV_NO_ENTRY
+and resets its internal state.
+The next call to the function will restart from the first compilation
+unit in the section.
+.Ss Iterating Through Type Units in a Debug Context
+When a DWARF debug context is allocated using
+.Xr dwarf_init 3 ,
+an internal pointer associated with the context will point to the first
+.Dq \&.debug_types
+section found in the debug object.
+The first call to function
+.Fn dwarf_next_cu_header_c
+for the debug context with argument
+.Ar is_info
+set to 0 will return information about the first
+type unit in that
+.Dq \&.debug_types
+section.
+Subsequent calls to the function will iterate through the remaining
+type units in the section.
+On stepping past the last type unit in the debug context,
+function
+.Fn dwarf_next_cu_header_c
+returns
+.Dv DW_DLV_NO_ENTRY
+and resets its internal state.
+The next call to the function will restart from the first type
+unit in the
+.Dq \&.debug_types
+section.
+.Pp
+If the debug object contains multiple
+.Dq \&.debug_types
+sections, the function
+.Fn dwarf_next_types_section
+can be called to move the internal pointer to the next
+.Dq \&.debug_types
+section.
+As a result, subsequent calls of the function
+.Fn dwarf_next_cu_header_c
+will operate on the new
+.Dq \&.debug_types
+section.
+Function
+.Fn dwarf_next_types_section
+returns
+.Dv DW_DLV_NO_ENTRY
+when there are no more
+.Dq \&.debug_types
+sections left in the debug object.
+.Sh RETURN VALUES
+On success, these functions return
+.Dv DW_DLV_OK .
+In case of an error, they return
+.Dv DW_DLV_ERROR
+and set argument
+.Ar err .
+When there are no more compilation units left to traverse, they return
+.Dv DW_DLV_NO_ENTRY .
+.Sh ERRORS
+These functions can fail with the following error:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Va dbg
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_cu_die_offset_given_cu_header_offset 3 ,
+.Xr dwarf_init 3 ,
+.Xr dwarf_next_types_section 3 ,
+.Xr dwarf_siblingof 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_next_types_section.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_next_types_section.3
new file mode 100644
index 0000000..98ff70d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_next_types_section.3
@@ -0,0 +1,134 @@
+.\" Copyright (c) 2014 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_next_types_section.3 3116 2014-12-20 18:26:55Z jkoshy $
+.\"
+.Dd December 20, 2014
+.Os
+.Dt DWARF_NEXT_TYPES_SECTION 3
+.Sh NAME
+.Nm dwarf_next_types_section
+.Nd step through .debug_types sections in a debug context
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_next_types_section
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_next_types_section
+steps through the
+.Dq \&.debug_types
+sections found in a debug context.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+Argument
+.Ar err
+should point to a location that will hold an error descriptor in case
+of an error.
+.Pp
+When a DWARF debug context is allocated using
+.Xr dwarf_init 3 ,
+an internal pointer associated with the context will point to the
+first
+.Dq \&.debug_types
+section present in the debug object.
+When the application calls function
+.Fn dwarf_next_types_section ,
+this internal pointer will move to the next
+.Dq \&.debug_types
+section present.
+On stepping past the last
+.Dq \&.debug_types
+section left in the debug context, function
+.Fn dwarf_next_types_section
+returns
+.Dv DW_DLV_NO_ENTRY .
+The next call to the function will restart from the first
+.Dq \&.debug_types
+section in the debug context.
+.Pp
+Application code should call function
+.Xr dwarf_next_cu_header_c 3
+to iterate though the type units associated with the current
+.Dq \&.debug_types
+section.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_next_types_section
+returns
+.Dv DW_DLV_OK .
+.Pp
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+When there are no more
+.Dq \&.debug_types
+sections left to traverse, it returns
+.Dv DW_DLV_NO_ENTRY .
+.Sh COMPATIBILITY
+This function is an extension to the
+.Xr DWARF 3
+API.
+.Sh ERRORS
+The
+.Fn dwarf_next_types_section
+function may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Va dbg
+was NULL.
+.El
+.Sh EXAMPLES
+To iterate though every type unit in all the
+.Dq \&.debug_types
+sections found in a debug context:
+.Bd -literal -offset indent
+Dwarf_Debug dbg;
+Dwarf_Sig8 sig8;
+Dwarf_Unsigned typeoff;
+Dwarf_Error de;
+
+\&... allocate dbg using dwarf_init() etc ...
+
+do {
+ while ((ret = dwarf_next_cu_header_c(dbg, 0, NULL, NULL, NULL,
+ NULL, NULL, NULL, &sig8, &typeoff, NULL, &de)) == DW_DLV_OK) {
+ /* Access DIEs etc ... */
+ }
+} while (dwarf_next_types_section(dbg, &de) == DW_DLV_OK);
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_init 3 ,
+.Xr dwarf_next_cu_header_c 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_object_init.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_object_init.3
new file mode 100644
index 0000000..2915669
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_object_init.3
@@ -0,0 +1,227 @@
+.\" Copyright (c) 2011 Joseph Koshy
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_object_init.3 2074 2011-10-27 03:34:33Z jkoshy $
+.\"
+.Dd September 29, 2011
+.Os
+.Dt DWARF_OBJECT_INIT 3
+.Sh NAME
+.Nm dwarf_object_init
+.Nd allocate a DWARF debug descriptor with application-specific file \
+access methods
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_object_init
+.Fa "Dwarf_Obj_Access_Interface *iface"
+.Fa "Dwarf_Handler errhand"
+.Fa "Dwarf_Ptr errarg"
+.Fa "Dwarf_Debug *dbg"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+.Pp
+The
+.Fn dwarf_object_init
+function allocates and returns a
+.Vt Dwarf_Debug
+instance that uses application-supplied access methods to read file
+content.
+.Pp
+The argument
+.Ar iface
+should point to a populated
+.Vt Dwarf_Obj_Access_Interface
+structure.
+The contents of the
+.Vt Dwarf_Obj_Access_Interface
+structure are described in the section
+.Sx "Object Access Functions"
+below.
+.Pp
+The argument
+.Ar errhand
+should point to a function to be called in case of an error.
+If this argument is
+.Dv NULL
+then a default error handling scheme is used.
+See
+.Xr dwarf 3
+for a description of the error handling schemes available.
+.Pp
+The argument
+.Ar errarg
+will be passed to the error handler function pointed to by argument
+.Ar errhand .
+.Pp
+The argument
+.Ar dbg
+should point to a memory location that will be set to a reference to
+the returned
+.Vt Dwarf_Debug
+descriptor.
+.Pp
+The argument
+.Ar err
+will be used to return a
+.Vt Dwarf_Error
+descriptor in case of an error.
+.Ss Object Access Functions
+The data structures used to specify object access methods are defined
+in
+.In libdwarf.h .
+.Bl -tag -width indent
+.It Vt "Dwarf_Obj_Access_Interface"
+This structure bundles together a set of file access methods along
+with a pointer to application-private state.
+.Bd -literal -offset indent
+typedef struct {
+ void *object;
+ const Dwarf_Obj_Access_Methods *methods;
+} Dwarf_Obj_Access_Interface;
+.Ed
+.Pp
+.Bl -tag -width ".Ar methods" -compact
+.It Ar object
+This field points to application-specific state that will be passed as
+the first parameter to the actual access object methods.
+.It Ar methods
+This structure contains pointers to the functions implementing the
+access methods, as described below.
+.El
+.It Vt Dwarf_Obj_Access_Methods
+This structure specifies the functions implementing low-level access.
+.Bd -literal -offset indent
+typedef struct {
+ int (*get_section_info)(void *obj, Dwarf_Half index,
+ Dwarf_Obj_Access_Section *ret, int *error);
+ Dwarf_Endianness (*get_byte_order)(void *obj);
+ Dwarf_Small (*get_length_size)(void *obj);
+ Dwarf_Small (*get_pointer_size)(void *obj);
+ Dwarf_Unsigned (*get_section_count)(void *obj);
+ int (*load_section)(void *obj, Dwarf_Half ndx,
+ Dwarf_Small **ret_data, int *error);
+} Dwarf_Obj_Access_Methods;
+.Ed
+.Pp
+.Bl -tag -width ".Ar get_section_count" -compact
+.It Ar get_byte_order
+This function should return the endianness of the DWARF object by
+returning one of the constants
+.Dv DW_OBJECT_MSB
+or
+.Dv DW_OBJECT_LSB .
+.It Ar get_length_size
+This function should return the number of bytes needed to represent a
+DWARF offset in the object being debugged.
+.It Ar get_pointer_size
+This function should return the size in bytes, in the object being
+debugged, of a memory address.
+.It Ar get_section_count
+This function should return the number of sections in the object being
+debugged.
+.It Ar get_section_info
+This function should return information about the section at the
+index
+.Ar ndx
+by filling in the structure of type
+.Vt Dwarf_Obj_Access_Section
+pointed to by argument
+.Ar ret .
+The
+.Vt Dwarf_Obj_Access_Section
+structure is described below.
+.It Ar load_section
+This function should load the section specified by argument
+.Ar ndx
+into memory and place a pointer to the section's data into
+the location pointed to by argument
+.Ar ret_data .
+.El
+.Pp
+The argument
+.Ar obj
+passed to these functions will be set to the pointer value in the
+.Ar object
+field of the associated
+.Vt Dwarf_Obj_Access_Interface
+structure.
+.Pp
+The argument
+.Ar error
+is used to return an error code in case of an error.
+.It Vt Dwarf_Obj_Access_Section
+This structure describes the layout of a section in the DWARF object.
+.Bd -literal -offset indent
+typedef struct {
+ Dwarf_Addr addr;
+ Dwarf_Unsigned size;
+ const char *name;
+} Dwarf_Obj_Access_Section;
+.Ed
+.Pp
+.Bl -tag -width ".Ar name" -compact
+.It Ar addr
+A pointer to the start of the section's data.
+.It Ar size
+The size of the section in bytes.
+.It Ar name
+A pointer to a NUL-terminated string containing the name of the
+section.
+.El
+.El
+.Sh RETURN VALUES
+On success, the
+.Fn dwarf_object_init
+function returns
+.Dv DW_DLV_OK .
+In case of an error, the function returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err.
+.Sh ERRORS
+The
+.Fn dwarf_object_init
+function may fail with the following errors:
+.Bl -tag -width ".Bq Er DW_DLE_DEBUG_INFO_NULL"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar iface
+or
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_DEBUG_INFO_NULL
+The underlying object did not contain debugging information.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_init 3 ,
+.Xr dwarf_init_elf 3 ,
+.Xr dwarf_object_finish 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_arange.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_arange.c
new file mode 100644
index 0000000..61e14db
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_arange.c
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_arange.c 2074 2011-10-27 03:34:33Z jkoshy $");
+
+Dwarf_Unsigned
+dwarf_add_arange(Dwarf_P_Debug dbg, Dwarf_Addr start, Dwarf_Unsigned length,
+ Dwarf_Signed symbol_index, Dwarf_Error *error)
+{
+
+ return (dwarf_add_arange_b(dbg, start, length, symbol_index, 0, 0,
+ error));
+}
+
+Dwarf_Unsigned
+dwarf_add_arange_b(Dwarf_P_Debug dbg, Dwarf_Addr start, Dwarf_Unsigned length,
+ Dwarf_Unsigned symbol_index, Dwarf_Unsigned end_symbol_index,
+ Dwarf_Addr offset_from_end_symbol, Dwarf_Error *error)
+{
+ Dwarf_ArangeSet as;
+ Dwarf_Arange ar;
+
+ if (dbg == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (0);
+ }
+ as = dbg->dbgp_as;
+
+ if (end_symbol_index > 0 &&
+ (dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS) == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (0);
+ }
+
+ if ((ar = calloc(1, sizeof(struct _Dwarf_Arange))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (0);
+ }
+ ar->ar_as = as;
+ ar->ar_address = start;
+ ar->ar_range = length;
+ ar->ar_symndx = symbol_index;
+ ar->ar_esymndx = end_symbol_index;
+ ar->ar_eoff = offset_from_end_symbol;
+ STAILQ_INSERT_TAIL(&as->as_arlist, ar, ar_next);
+
+ return (1);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_attr.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_attr.c
new file mode 100644
index 0000000..f46672b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_attr.c
@@ -0,0 +1,384 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_attr.c 2074 2011-10-27 03:34:33Z jkoshy $");
+
+Dwarf_P_Attribute
+dwarf_add_AT_location_expr(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
+ Dwarf_P_Expr loc_expr, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (dbg == NULL || die == NULL || loc_expr == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_attr_alloc(die, &at, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ at->at_die = die;
+ at->at_attrib = attr;
+ at->at_expr = loc_expr;
+
+ if (_dwarf_expr_into_block(loc_expr, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+ at->u[0].u64 = loc_expr->pe_length;
+ at->u[1].u8p = loc_expr->pe_block;
+ if (loc_expr->pe_length <= UCHAR_MAX)
+ at->at_form = DW_FORM_block1;
+ else if (loc_expr->pe_length <= USHRT_MAX)
+ at->at_form = DW_FORM_block2;
+ else if (loc_expr->pe_length <= UINT_MAX)
+ at->at_form = DW_FORM_block4;
+ else
+ at->at_form = DW_FORM_block;
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_name(Dwarf_P_Die die, char *name, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (_dwarf_add_string_attr(die, &at, DW_AT_name, name, error) !=
+ DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_comp_dir(Dwarf_P_Die die, char *dir, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (_dwarf_add_string_attr(die, &at, DW_AT_comp_dir, dir, error) !=
+ DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_producer(Dwarf_P_Die die, char *producer, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (_dwarf_add_string_attr(die, &at, DW_AT_producer, producer, error) !=
+ DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_const_value_signedint(Dwarf_P_Die die, Dwarf_Signed value,
+ Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_attr_alloc(die, &at, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ at->at_die = die;
+ at->at_attrib = DW_AT_const_value;
+ at->at_form = DW_FORM_sdata;
+ at->u[0].s64 = value;
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_const_value_unsignedint(Dwarf_P_Die die, Dwarf_Unsigned value,
+ Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ if (die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_attr_alloc(die, &at, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ at->at_die = die;
+ at->at_attrib = DW_AT_const_value;
+ at->at_form = DW_FORM_udata;
+ at->u[0].u64 = value;
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_const_value_string(Dwarf_P_Die die, char *string,
+ Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (_dwarf_add_string_attr(die, &at, DW_AT_const_value, string,
+ error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_targ_address(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
+ Dwarf_Unsigned pc_value, Dwarf_Signed sym_index, Dwarf_Error *error)
+{
+
+ return (dwarf_add_AT_targ_address_b(dbg, die, attr, pc_value, sym_index,
+ error));
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_targ_address_b(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
+ Dwarf_Unsigned pc_value, Dwarf_Unsigned sym_index, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (dbg == NULL || die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_attr_alloc(die, &at, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ at->at_die = die;
+ at->at_attrib = attr;
+ at->at_form = DW_FORM_addr;
+ at->at_relsym = sym_index;
+ at->u[0].u64 = pc_value;
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_dataref(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
+ Dwarf_Unsigned pc_value, Dwarf_Unsigned sym_index, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ int ret;
+
+ if (dbg == NULL || die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ ret = _dwarf_add_AT_dataref(dbg, die, attr, pc_value, sym_index,
+ NULL, &at, error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ return (at);
+
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_ref_address(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
+ Dwarf_Unsigned pc_value, Dwarf_Unsigned sym_index, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (dbg == NULL || die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_attr_alloc(die, &at, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ at->at_die = die;
+ at->at_attrib = attr;
+ at->at_form = DW_FORM_ref_addr;
+ at->at_relsym = sym_index;
+ at->u[0].u64 = pc_value;
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_unsigned_const(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
+ Dwarf_Unsigned value, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (dbg == NULL || die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_attr_alloc(die, &at, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ at->at_die = die;
+ at->at_attrib = attr;
+ at->u[0].u64 = value;
+
+ if (value <= UCHAR_MAX)
+ at->at_form = DW_FORM_data1;
+ else if (value <= USHRT_MAX)
+ at->at_form = DW_FORM_data2;
+ else if (value <= UINT_MAX)
+ at->at_form = DW_FORM_data4;
+ else
+ at->at_form = DW_FORM_data8;
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_signed_const(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
+ Dwarf_Signed value, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (dbg == NULL || die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_attr_alloc(die, &at, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ at->at_die = die;
+ at->at_attrib = attr;
+ at->u[0].u64 = value;
+
+ if (value >= SCHAR_MIN && value <= SCHAR_MAX)
+ at->at_form = DW_FORM_data1;
+ else if (value >= SHRT_MIN && value <= SHRT_MAX)
+ at->at_form = DW_FORM_data2;
+ else if (value >= INT_MIN && value <= INT_MAX)
+ at->at_form = DW_FORM_data4;
+ else
+ at->at_form = DW_FORM_data8;
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_reference(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
+ Dwarf_P_Die ref_die, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (dbg == NULL || die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_attr_alloc(die, &at, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ at->at_die = die;
+ at->at_attrib = attr;
+ if (dbg->dbg_offset_size == 4)
+ at->at_form = DW_FORM_ref4;
+ else
+ at->at_form = DW_FORM_ref8;
+
+ at->at_refdie = ref_die;
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_flag(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
+ Dwarf_Small flag, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (dbg == NULL || die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_attr_alloc(die, &at, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ at->at_die = die;
+ at->at_attrib = attr;
+ at->at_form = DW_FORM_flag;
+ at->u[0].u64 = flag ? 1 : 0;
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ return (at);
+}
+
+Dwarf_P_Attribute
+dwarf_add_AT_string(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
+ char *string, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ if (dbg == NULL || die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ /* XXX Add DW_FORM_string style string instead? */
+
+ if (_dwarf_add_string_attr(die, &at, attr, string, error) !=
+ DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ return (at);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_die.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_die.c
new file mode 100644
index 0000000..3d28236
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_die.c
@@ -0,0 +1,110 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_die.c 2074 2011-10-27 03:34:33Z jkoshy $");
+
+Dwarf_Unsigned
+dwarf_add_die_to_debug(Dwarf_P_Debug dbg, Dwarf_P_Die first_die,
+ Dwarf_Error *error)
+{
+
+ if (dbg == NULL || first_die == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ dbg->dbgp_root_die = first_die;
+
+ return (DW_DLV_OK);
+}
+
+Dwarf_P_Die
+dwarf_new_die(Dwarf_P_Debug dbg, Dwarf_Tag new_tag,
+ Dwarf_P_Die parent, Dwarf_P_Die child, Dwarf_P_Die left_sibling,
+ Dwarf_P_Die right_sibling, Dwarf_Error *error)
+{
+ Dwarf_P_Die die;
+ int count;
+
+ if (dbg == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ count = _dwarf_die_count_links(parent, child, left_sibling,
+ right_sibling);
+
+ if (count > 1) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_die_alloc(dbg, &die, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ die->die_dbg = dbg;
+ die->die_tag = new_tag;
+
+ STAILQ_INSERT_TAIL(&dbg->dbgp_dielist, die, die_pro_next);
+
+ if (count == 0)
+ return (die);
+
+ _dwarf_die_link(die, parent, child, left_sibling, right_sibling);
+
+ return (die);
+}
+
+Dwarf_P_Die
+dwarf_die_link(Dwarf_P_Die die, Dwarf_P_Die parent,
+ Dwarf_P_Die child, Dwarf_P_Die left_sibling, Dwarf_P_Die right_sibling,
+ Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ int count;
+
+
+ if (die == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ dbg = die->die_dbg;
+ count = _dwarf_die_count_links(parent, child, left_sibling,
+ right_sibling);
+
+ if (count > 1) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ } else if (count == 0)
+ return (die);
+
+ _dwarf_die_link(die, parent, child, left_sibling, right_sibling);
+
+ return (die);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_expr.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_expr.c
new file mode 100644
index 0000000..eb1f59c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_expr.c
@@ -0,0 +1,223 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_expr.c 2074 2011-10-27 03:34:33Z jkoshy $");
+
+static struct _Dwarf_P_Expr_Entry *
+_dwarf_add_expr(Dwarf_P_Expr expr, Dwarf_Small opcode, Dwarf_Unsigned val1,
+ Dwarf_Unsigned val2, Dwarf_Error *error)
+{
+ struct _Dwarf_P_Expr_Entry *ee;
+ Dwarf_Debug dbg;
+ int len;
+
+ dbg = expr != NULL ? expr->pe_dbg : NULL;
+
+ if (_dwarf_loc_expr_add_atom(expr->pe_dbg, NULL, NULL, opcode, val1,
+ val2, &len, error) != DW_DLE_NONE)
+ return (NULL);
+ assert(len > 0);
+
+ if ((ee = calloc(1, sizeof(*ee))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (NULL);
+ }
+
+ STAILQ_INSERT_TAIL(&expr->pe_eelist, ee, ee_next);
+
+ ee->ee_loc.lr_atom = opcode;
+ ee->ee_loc.lr_number = val1;
+ ee->ee_loc.lr_number2 = val2;
+ ee->ee_loc.lr_offset = expr->pe_length;
+ expr->pe_length += len;
+ expr->pe_invalid = 1;
+
+ return (ee);
+}
+
+int
+_dwarf_expr_into_block(Dwarf_P_Expr expr, Dwarf_Error *error)
+{
+ struct _Dwarf_P_Expr_Entry *ee;
+ Dwarf_Debug dbg;
+ int len, pos, ret;
+
+ dbg = expr != NULL ? expr->pe_dbg : NULL;
+
+ if (expr->pe_block != NULL) {
+ free(expr->pe_block);
+ expr->pe_block = NULL;
+ }
+
+ if (expr->pe_length <= 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_EXPR_LENGTH_BAD);
+ return (DW_DLE_EXPR_LENGTH_BAD);
+ }
+
+
+ if ((expr->pe_block = calloc((size_t) expr->pe_length, 1)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ pos = 0;
+ STAILQ_FOREACH(ee, &expr->pe_eelist, ee_next) {
+ assert((Dwarf_Unsigned) pos < expr->pe_length);
+ ret = _dwarf_loc_expr_add_atom(expr->pe_dbg,
+ &expr->pe_block[pos], &expr->pe_block[expr->pe_length],
+ ee->ee_loc.lr_atom, ee->ee_loc.lr_number,
+ ee->ee_loc.lr_number2, &len, error);
+ assert(ret == DW_DLE_NONE);
+ assert(len > 0);
+ pos += len;
+ }
+
+ expr->pe_invalid = 0;
+
+ return (DW_DLE_NONE);
+}
+
+void
+_dwarf_expr_cleanup(Dwarf_P_Debug dbg)
+{
+ Dwarf_P_Expr pe, tpe;
+ struct _Dwarf_P_Expr_Entry *ee, *tee;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_WRITE);
+
+ STAILQ_FOREACH_SAFE(pe, &dbg->dbgp_pelist, pe_next, tpe) {
+ STAILQ_REMOVE(&dbg->dbgp_pelist, pe, _Dwarf_P_Expr, pe_next);
+ STAILQ_FOREACH_SAFE(ee, &pe->pe_eelist, ee_next, tee) {
+ STAILQ_REMOVE(&pe->pe_eelist, ee, _Dwarf_P_Expr_Entry,
+ ee_next);
+ free(ee);
+ }
+ if (pe->pe_block)
+ free(pe->pe_block);
+ free(pe);
+ }
+}
+
+Dwarf_P_Expr
+dwarf_new_expr(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_P_Expr pe;
+
+ if (dbg == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if ((pe = calloc(1, sizeof(struct _Dwarf_P_Expr))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_BADADDR);
+ }
+ STAILQ_INIT(&pe->pe_eelist);
+
+ STAILQ_INSERT_TAIL(&dbg->dbgp_pelist, pe, pe_next);
+ pe->pe_dbg = dbg;
+
+ return (pe);
+}
+
+Dwarf_Unsigned
+dwarf_add_expr_gen(Dwarf_P_Expr expr, Dwarf_Small opcode, Dwarf_Unsigned val1,
+ Dwarf_Unsigned val2, Dwarf_Error *error)
+{
+
+ if (expr == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ if (_dwarf_add_expr(expr, opcode, val1, val2, error) == NULL)
+ return (DW_DLV_NOCOUNT);
+
+ return (expr->pe_length);
+}
+
+Dwarf_Unsigned
+dwarf_add_expr_addr(Dwarf_P_Expr expr, Dwarf_Unsigned address,
+ Dwarf_Signed sym_index, Dwarf_Error *error)
+{
+
+ return (dwarf_add_expr_addr_b(expr, address, sym_index, error));
+}
+
+Dwarf_Unsigned
+dwarf_add_expr_addr_b(Dwarf_P_Expr expr, Dwarf_Unsigned address,
+ Dwarf_Unsigned sym_index, Dwarf_Error *error)
+{
+ struct _Dwarf_P_Expr_Entry *ee;
+
+ if (expr == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ if ((ee = _dwarf_add_expr(expr, DW_OP_addr, address, 0, error)) == NULL)
+ return (DW_DLV_NOCOUNT);
+
+ ee->ee_sym = sym_index;
+
+ return (expr->pe_length);
+}
+
+Dwarf_Unsigned
+dwarf_expr_current_offset(Dwarf_P_Expr expr, Dwarf_Error *error)
+{
+
+ if (expr == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ return (expr->pe_length);
+}
+
+Dwarf_Addr
+dwarf_expr_into_block(Dwarf_P_Expr expr, Dwarf_Unsigned *length,
+ Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ dbg = expr != NULL ? expr->pe_dbg : NULL;
+
+ if (expr == NULL || length == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return ((Dwarf_Addr) (uintptr_t) DW_DLV_BADADDR);
+ }
+
+ if (expr->pe_block == NULL || expr->pe_invalid)
+ if (_dwarf_expr_into_block(expr, error) != DW_DLE_NONE)
+ return ((Dwarf_Addr) (uintptr_t) DW_DLV_BADADDR);
+
+ *length = expr->pe_length;
+
+ return ((Dwarf_Addr) (uintptr_t) expr->pe_block);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_finish.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_finish.c
new file mode 100644
index 0000000..8e1dc4a
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_finish.c
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_finish.c 2074 2011-10-27 03:34:33Z jkoshy $");
+
+Dwarf_Unsigned
+dwarf_producer_finish(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+
+ if (dbg == NULL || dbg->dbg_mode != DW_DLC_WRITE) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ _dwarf_deinit(dbg);
+
+ free(dbg);
+
+ return (1);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_frame.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_frame.c
new file mode 100644
index 0000000..fac390e
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_frame.c
@@ -0,0 +1,195 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_frame.c 2074 2011-10-27 03:34:33Z jkoshy $");
+
+Dwarf_P_Fde
+dwarf_new_fde(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_P_Fde fde;
+
+ if (dbg == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if ((fde = calloc(1, sizeof(struct _Dwarf_Fde))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_BADADDR);
+ }
+
+ fde->fde_dbg = dbg;
+
+ return (fde);
+}
+
+Dwarf_Unsigned
+dwarf_add_frame_cie(Dwarf_P_Debug dbg, char *augmenter, Dwarf_Small caf,
+ Dwarf_Small daf, Dwarf_Small ra, Dwarf_Ptr initinst,
+ Dwarf_Unsigned inst_len, Dwarf_Error *error)
+{
+ Dwarf_P_Cie cie;
+
+ if (dbg == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ if ((cie = calloc(1, sizeof(struct _Dwarf_Cie))) == NULL) {
+ DWARF_SET_ERROR(dbg, error,DW_DLE_MEMORY);
+ return (DW_DLV_NOCOUNT);
+ }
+ STAILQ_INSERT_TAIL(&dbg->dbgp_cielist, cie, cie_next);
+
+ cie->cie_index = dbg->dbgp_cielen++;
+
+ if (augmenter != NULL) {
+ cie->cie_augment = (uint8_t *) strdup(augmenter);
+ if (cie->cie_augment == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_NOCOUNT);
+ }
+ }
+
+ cie->cie_caf = caf;
+ cie->cie_daf = (int8_t) daf; /* daf is signed. */
+ cie->cie_ra = ra;
+ if (initinst != NULL && inst_len > 0) {
+ cie->cie_initinst = malloc((size_t) inst_len);
+ if (cie->cie_initinst == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_NOCOUNT);
+ }
+ memcpy(cie->cie_initinst, initinst, inst_len);
+ cie->cie_instlen = inst_len;
+ }
+
+ return (cie->cie_index);
+}
+
+Dwarf_Unsigned
+dwarf_add_frame_fde(Dwarf_P_Debug dbg, Dwarf_P_Fde fde, Dwarf_P_Die die,
+ Dwarf_Unsigned cie, Dwarf_Addr virt_addr, Dwarf_Unsigned code_len,
+ Dwarf_Unsigned symbol_index, Dwarf_Error *error)
+{
+
+ return (dwarf_add_frame_fde_b(dbg, fde, die, cie, virt_addr, code_len,
+ symbol_index, 0, 0, error));
+}
+
+Dwarf_Unsigned
+dwarf_add_frame_fde_b(Dwarf_P_Debug dbg, Dwarf_P_Fde fde, Dwarf_P_Die die,
+ Dwarf_Unsigned cie, Dwarf_Addr virt_addr, Dwarf_Unsigned code_len,
+ Dwarf_Unsigned symbol_index, Dwarf_Unsigned end_symbol_index,
+ Dwarf_Addr offset_from_end_sym, Dwarf_Error *error)
+{
+ Dwarf_P_Cie ciep;
+ int i;
+
+ /*
+ * XXX SGI libdwarf need the DIE arg because later it will insert a
+ * DW_AT_MIPS_fde attribute, which points to the offset the
+ * correspoding FDE, into this DIE. Do we need this?
+ */
+ (void) die;
+
+ if (dbg == NULL || fde == NULL || fde->fde_dbg != dbg) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ ciep = STAILQ_FIRST(&dbg->dbgp_cielist);
+ for (i = 0; (Dwarf_Unsigned) i < cie; i++) {
+ ciep = STAILQ_NEXT(ciep, cie_next);
+ if (ciep == NULL)
+ break;
+ }
+ if (ciep == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ if (end_symbol_index > 0 &&
+ (dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS) == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ fde->fde_cie = ciep;
+ fde->fde_initloc = virt_addr;
+ fde->fde_adrange = code_len;
+ fde->fde_symndx = symbol_index;
+ fde->fde_esymndx = end_symbol_index;
+ fde->fde_eoff = offset_from_end_sym;
+
+ STAILQ_INSERT_TAIL(&dbg->dbgp_fdelist, fde, fde_next);
+
+ return (dbg->dbgp_fdelen++);
+}
+
+Dwarf_P_Fde
+dwarf_fde_cfa_offset(Dwarf_P_Fde fde, Dwarf_Unsigned reg, Dwarf_Signed offset,
+ Dwarf_Error *error)
+{
+ int ret;
+ Dwarf_Debug dbg;
+
+ dbg = fde != NULL ? fde->fde_dbg : NULL;
+
+ if (fde == NULL || reg > 0x3f) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ ret = _dwarf_frame_fde_add_inst(fde, DW_CFA_offset | (reg & 0x3f),
+ offset, 0, error);
+
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ return (fde);
+}
+
+Dwarf_P_Fde
+dwarf_add_fde_inst(Dwarf_P_Fde fde, Dwarf_Small op, Dwarf_Unsigned val1,
+ Dwarf_Unsigned val2, Dwarf_Error *error)
+{
+ int ret;
+
+ if (fde == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ ret = _dwarf_frame_fde_add_inst(fde, op, val1, val2, error);
+
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ return (fde);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_funcs.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_funcs.m4
new file mode 100644
index 0000000..6e8bee1
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_funcs.m4
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_funcs.m4 2074 2011-10-27 03:34:33Z jkoshy $");
+
+/* WARNING: GENERATED FROM __file__. */
+
+divert(-1)
+include(SRCDIR`/dwarf_pro_nametbl.m4')
+divert(0)
+MAKE_NAMETBL_PRO_API(func)
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_init.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_init.c
new file mode 100644
index 0000000..de7a2d5
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_init.c
@@ -0,0 +1,122 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_init.c 2074 2011-10-27 03:34:33Z jkoshy $");
+
+Dwarf_P_Debug
+dwarf_producer_init(Dwarf_Unsigned flags, Dwarf_Callback_Func func,
+ Dwarf_Handler errhand, Dwarf_Ptr errarg, Dwarf_Error *error)
+{
+ Dwarf_P_Debug dbg;
+ int mode;
+
+ if (flags & DW_DLC_READ || flags & DW_DLC_RDWR) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (flags & DW_DLC_WRITE)
+ mode = DW_DLC_WRITE;
+ else {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (func == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_alloc(&dbg, DW_DLC_WRITE, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ dbg->dbg_mode = mode;
+
+ if (_dwarf_init(dbg, flags, errhand, errarg, error) != DW_DLE_NONE) {
+ free(dbg);
+ return (DW_DLV_BADADDR);
+ }
+
+ dbg->dbgp_func = func;
+
+ return (dbg);
+}
+
+Dwarf_P_Debug
+dwarf_producer_init_b(Dwarf_Unsigned flags, Dwarf_Callback_Func_b func,
+ Dwarf_Handler errhand, Dwarf_Ptr errarg, Dwarf_Error *error)
+{
+ Dwarf_P_Debug dbg;
+ int mode;
+
+ if (flags & DW_DLC_READ || flags & DW_DLC_RDWR) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (flags & DW_DLC_WRITE)
+ mode = DW_DLC_WRITE;
+ else {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (func == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_BADADDR);
+ }
+
+ if (_dwarf_alloc(&dbg, DW_DLC_WRITE, error) != DW_DLE_NONE)
+ return (DW_DLV_BADADDR);
+
+ dbg->dbg_mode = mode;
+
+ if (_dwarf_init(dbg, flags, errhand, errarg, error) != DW_DLE_NONE) {
+ free(dbg);
+ return (DW_DLV_BADADDR);
+ }
+
+ dbg->dbgp_func_b = func;
+
+ return (dbg);
+}
+
+int
+dwarf_producer_set_isa(Dwarf_P_Debug dbg, enum Dwarf_ISA isa,
+ Dwarf_Error *error)
+{
+
+ if (dbg == NULL || isa >= DW_ISA_MAX) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ dbg->dbgp_isa = isa;
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_lineno.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_lineno.c
new file mode 100644
index 0000000..91e40ee
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_lineno.c
@@ -0,0 +1,187 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_lineno.c 2973 2013-12-23 06:46:16Z kaiwang27 $");
+
+Dwarf_Unsigned
+dwarf_add_line_entry(Dwarf_P_Debug dbg, Dwarf_Unsigned file,
+ Dwarf_Addr off, Dwarf_Unsigned lineno, Dwarf_Signed column,
+ Dwarf_Bool is_stmt, Dwarf_Bool basic_block, Dwarf_Error *error)
+{
+ Dwarf_LineInfo li;
+ Dwarf_Line ln;
+
+ if (dbg == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ li = dbg->dbgp_lineinfo;
+
+ ln = STAILQ_LAST(&li->li_lnlist, _Dwarf_Line, ln_next);
+
+ if (ln == NULL || ln->ln_addr > off) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ if ((ln = calloc(1, sizeof(struct _Dwarf_Line))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_NOCOUNT);
+ }
+ ln->ln_li = li;
+ ln->ln_addr = off;
+ ln->ln_symndx = 0;
+ ln->ln_fileno = file;
+ ln->ln_lineno = lineno;
+ ln->ln_column = column;
+ ln->ln_bblock = basic_block != 0;
+ ln->ln_stmt = is_stmt != 0;
+ ln->ln_endseq = 0;
+ STAILQ_INSERT_TAIL(&li->li_lnlist, ln, ln_next);
+ li->li_lnlen++;
+
+ return (DW_DLV_OK);
+}
+
+Dwarf_Unsigned
+dwarf_lne_set_address(Dwarf_P_Debug dbg, Dwarf_Addr offs, Dwarf_Unsigned symndx,
+ Dwarf_Error *error)
+{
+ Dwarf_LineInfo li;
+ Dwarf_Line ln;
+
+ if (dbg == NULL || symndx == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ li = dbg->dbgp_lineinfo;
+
+ if ((ln = calloc(1, sizeof(struct _Dwarf_Line))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_NOCOUNT);
+ }
+ ln->ln_li = li;
+ ln->ln_addr = offs;
+ ln->ln_symndx = symndx;
+ STAILQ_INSERT_TAIL(&li->li_lnlist, ln, ln_next);
+ li->li_lnlen++;
+
+ return (DW_DLV_OK);
+}
+
+Dwarf_Unsigned
+dwarf_lne_end_sequence(Dwarf_P_Debug dbg, Dwarf_Addr addr, Dwarf_Error *error)
+{
+ Dwarf_LineInfo li;
+ Dwarf_Line ln;
+
+ if (dbg == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ li = dbg->dbgp_lineinfo;
+
+ ln = STAILQ_LAST(&li->li_lnlist, _Dwarf_Line, ln_next);
+ if (ln && ln->ln_addr >= addr) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ if ((ln = calloc(1, sizeof(struct _Dwarf_Line))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_NOCOUNT);
+ }
+ ln->ln_li = li;
+ ln->ln_addr = addr;
+ ln->ln_endseq = 1;
+ STAILQ_INSERT_TAIL(&li->li_lnlist, ln, ln_next);
+ li->li_lnlen++;
+
+ return (DW_DLV_OK);
+}
+
+Dwarf_Unsigned
+dwarf_add_directory_decl(Dwarf_P_Debug dbg, char *name, Dwarf_Error *error)
+{
+ Dwarf_LineInfo li;
+
+ if (dbg == NULL || name == NULL || strlen(name) == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ li = dbg->dbgp_lineinfo;
+
+ li->li_incdirs = realloc(li->li_incdirs, (li->li_inclen + 1) *
+ sizeof(char *));
+ if (li->li_incdirs == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_NOCOUNT);
+ }
+ if ((li->li_incdirs[li->li_inclen] = strdup(name)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ return (++li->li_inclen);
+}
+
+Dwarf_Unsigned
+dwarf_add_file_decl(Dwarf_P_Debug dbg, char *name, Dwarf_Unsigned dirndx,
+ Dwarf_Unsigned mtime, Dwarf_Unsigned size, Dwarf_Error *error)
+{
+ Dwarf_LineInfo li;
+ Dwarf_LineFile lf;
+
+ if (dbg == NULL || name == NULL || strlen(name) == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ li = dbg->dbgp_lineinfo;
+
+ if ((lf = malloc(sizeof(struct _Dwarf_LineFile))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ if ((lf->lf_fname = strdup(name)) == NULL) {
+ free(lf);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ lf->lf_dirndx = dirndx;
+ lf->lf_mtime = mtime;
+ lf->lf_size = size;
+ STAILQ_INSERT_TAIL(&li->li_lflist, lf, lf_next);
+
+ return (++li->li_lflen);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_macinfo.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_macinfo.c
new file mode 100644
index 0000000..2119b5b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_macinfo.c
@@ -0,0 +1,142 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_macinfo.c 2074 2011-10-27 03:34:33Z jkoshy $");
+
+static int
+_dwarf_add_macro(Dwarf_P_Debug dbg, int type, Dwarf_Unsigned lineno,
+ Dwarf_Signed fileindex, char *str1, char *str2, Dwarf_Error *error)
+{
+ Dwarf_Macro_Details *md;
+ int len;
+
+ dbg->dbgp_mdlist = realloc(dbg->dbgp_mdlist,
+ (size_t) dbg->dbgp_mdcnt + 1);
+ if (dbg->dbgp_mdlist == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_ERROR);
+ }
+
+ md = &dbg->dbgp_mdlist[dbg->dbgp_mdcnt];
+ dbg->dbgp_mdcnt++;
+
+ md->dmd_offset = 0;
+ md->dmd_type = type;
+ md->dmd_lineno = lineno;
+ md->dmd_fileindex = fileindex;
+ md->dmd_macro = NULL;
+
+ if (str1 == NULL)
+ return (DW_DLV_OK);
+ else if (str2 == NULL) {
+ if ((md->dmd_macro = strdup(str1)) == NULL) {
+ dbg->dbgp_mdcnt--;
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_ERROR);
+ }
+ return (DW_DLV_OK);
+ } else {
+ len = strlen(str1) + strlen(str2) + 2;
+ if ((md->dmd_macro = malloc(len)) == NULL) {
+ dbg->dbgp_mdcnt--;
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_ERROR);
+ }
+ snprintf(md->dmd_macro, len, "%s %s", str1, str2);
+ return (DW_DLV_OK);
+ }
+}
+
+int
+dwarf_def_macro(Dwarf_P_Debug dbg, Dwarf_Unsigned lineno, char *name,
+ char *value, Dwarf_Error *error)
+{
+
+ if (dbg == NULL || name == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ return (_dwarf_add_macro(dbg, DW_MACINFO_define, lineno, -1, name,
+ value, error));
+}
+
+int
+dwarf_undef_macro(Dwarf_P_Debug dbg, Dwarf_Unsigned lineno, char *name,
+ Dwarf_Error *error)
+{
+
+ if (dbg == NULL || name == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ return (_dwarf_add_macro(dbg, DW_MACINFO_undef, lineno, -1, name,
+ NULL, error));
+}
+
+int
+dwarf_start_macro_file(Dwarf_P_Debug dbg, Dwarf_Unsigned lineno,
+ Dwarf_Unsigned fileindex, Dwarf_Error *error)
+{
+
+ if (dbg == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ return (_dwarf_add_macro(dbg, DW_MACINFO_start_file, lineno, fileindex,
+ NULL, NULL, error));
+}
+
+int
+dwarf_end_macro_file(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+
+ if (dbg == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ return (_dwarf_add_macro(dbg, DW_MACINFO_end_file, 0, -1,
+ NULL, NULL, error));
+}
+
+int
+dwarf_vendor_ext(Dwarf_P_Debug dbg, Dwarf_Unsigned constant, char *string,
+ Dwarf_Error *error)
+{
+
+ if (dbg == NULL || string == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ return (_dwarf_add_macro(dbg, DW_MACINFO_vendor_ext, constant, -1,
+ string, NULL, error));
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_nametbl.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_nametbl.m4
new file mode 100644
index 0000000..df57688
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_nametbl.m4
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: dwarf_pro_nametbl.m4 2074 2011-10-27 03:34:33Z jkoshy $
+ */
+
+define(`MAKE_NAMETBL_PRO_API',`
+Dwarf_Unsigned
+dwarf_add_$1name(Dwarf_P_Debug dbg, Dwarf_P_Die die, char *$1_name,
+ Dwarf_Error *error)
+{
+ Dwarf_NameTbl nt;
+ Dwarf_NamePair np;
+
+ if (dbg == NULL || die == NULL || $1_name == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (0);
+ }
+
+ if (dbg->dbgp_$1s == NULL) {
+ dbg->dbgp_$1s = calloc(1, sizeof(struct _Dwarf_NameTbl));
+ if (dbg->dbgp_$1s == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (0);
+ }
+ STAILQ_INIT(&dbg->dbgp_$1s->nt_nplist);
+ }
+
+ nt = dbg->dbgp_$1s;
+
+ if ((np = calloc(1, sizeof(struct _Dwarf_NamePair))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (0);
+ }
+
+ np->np_nt = nt;
+ np->np_die = die;
+ if ((np->np_name = strdup($1_name)) == NULL) {
+ free(np);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (0);
+ }
+
+ STAILQ_INSERT_TAIL(&nt->nt_nplist, np, np_next);
+
+ return (1);
+}
+')
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_pubnames.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_pubnames.m4
new file mode 100644
index 0000000..2ceafd5
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_pubnames.m4
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_pubnames.m4 2074 2011-10-27 03:34:33Z jkoshy $");
+
+/* WARNING: GENERATED FROM __file__. */
+
+divert(-1)
+include(SRCDIR`/dwarf_pro_nametbl.m4')
+divert(0)
+MAKE_NAMETBL_PRO_API(pub)
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_reloc.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_reloc.c
new file mode 100644
index 0000000..6b0b2e2
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_reloc.c
@@ -0,0 +1,114 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_reloc.c 2074 2011-10-27 03:34:33Z jkoshy $");
+
+int
+dwarf_get_relocation_info_count(Dwarf_P_Debug dbg, Dwarf_Unsigned *reloc_cnt,
+ int *drd_buffer_version, Dwarf_Error *error)
+{
+
+ if (dbg == NULL || reloc_cnt == NULL || drd_buffer_version == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS) == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *reloc_cnt = dbg->dbgp_drscnt;
+ *drd_buffer_version = DWARF_DRD_BUFFER_VERSION;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_relocation_info(Dwarf_P_Debug dbg, Dwarf_Signed *elf_section_index,
+ Dwarf_Signed *elf_section_link, Dwarf_Unsigned *reloc_entry_count,
+ Dwarf_Relocation_Data *reloc_buffer, Dwarf_Error *error)
+{
+ Dwarf_Rel_Section drs;
+ Dwarf_Rel_Entry dre;
+ int i;
+
+ if (dbg == NULL || elf_section_index == NULL ||
+ elf_section_link == NULL || reloc_entry_count == NULL ||
+ reloc_buffer == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if ((dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS) == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ if (dbg->dbgp_drscnt == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ if (dbg->dbgp_drspos == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ drs = dbg->dbgp_drspos;
+ assert(drs->drs_ds != NULL && drs->drs_ref != NULL);
+ assert(drs->drs_drecnt > 0);
+
+ *elf_section_index = drs->drs_ds->ds_ndx;
+ *elf_section_link = drs->drs_ref->ds_ndx;
+ *reloc_entry_count = drs->drs_drecnt;
+
+ if (drs->drs_drd == NULL) {
+ drs->drs_drd = calloc(*reloc_entry_count,
+ sizeof(struct Dwarf_Relocation_Data_s));
+ if (drs->drs_drd == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLV_ERROR);
+ }
+ for (i = 0, dre = STAILQ_FIRST(&drs->drs_dre);
+ (Dwarf_Unsigned) i < *reloc_entry_count && dre != NULL;
+ i++, dre = STAILQ_NEXT(dre, dre_next)) {
+ drs->drs_drd[i].drd_type = dre->dre_type;
+ drs->drs_drd[i].drd_length = dre->dre_length;
+ drs->drs_drd[i].drd_offset = dre->dre_offset;
+ drs->drs_drd[i].drd_symbol_index = dre->dre_symndx;
+ }
+ assert((Dwarf_Unsigned) i == *reloc_entry_count && dre == NULL);
+ }
+
+ *reloc_buffer = drs->drs_drd;
+
+ dbg->dbgp_drspos = STAILQ_NEXT(dbg->dbgp_drspos, drs_next);
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_sections.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_sections.c
new file mode 100644
index 0000000..42aa516
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_sections.c
@@ -0,0 +1,81 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_sections.c 2074 2011-10-27 03:34:33Z jkoshy $");
+
+Dwarf_Signed
+dwarf_transform_to_disk_form(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+
+ if (dbg == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_NOCOUNT);
+ }
+
+ if (_dwarf_generate_sections(dbg, error) != DW_DLE_NONE)
+ return (DW_DLV_NOCOUNT);
+
+ return (dbg->dbgp_seccnt);
+}
+
+Dwarf_Ptr
+dwarf_get_section_bytes(Dwarf_P_Debug dbg, Dwarf_Signed dwarf_section,
+ Dwarf_Signed *elf_section_index, Dwarf_Unsigned *length, Dwarf_Error *error)
+{
+ Dwarf_Ptr data;
+
+ (void) dwarf_section; /* ignored. */
+
+ if (dbg == NULL || elf_section_index == NULL || length == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (NULL);
+ }
+
+ if (dbg->dbgp_secpos == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (NULL);
+ }
+
+ *elf_section_index = dbg->dbgp_secpos->ds_ndx;
+ *length = dbg->dbgp_secpos->ds_size;
+ data = dbg->dbgp_secpos->ds_data;
+
+ dbg->dbgp_secpos = STAILQ_NEXT(dbg->dbgp_secpos, ds_next);
+
+ return (data);
+}
+
+void
+dwarf_reset_section_bytes(Dwarf_P_Debug dbg)
+{
+
+ assert(dbg != NULL);
+
+ dbg->dbgp_secpos = STAILQ_FIRST(&dbg->dbgp_seclist);
+ dbg->dbgp_drspos = STAILQ_FIRST(&dbg->dbgp_drslist);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_types.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_types.m4
new file mode 100644
index 0000000..eab6cc6
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_types.m4
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_types.m4 2074 2011-10-27 03:34:33Z jkoshy $");
+
+/* WARNING: GENERATED FROM __file__. */
+
+divert(-1)
+include(SRCDIR`/dwarf_pro_nametbl.m4')
+divert(0)
+MAKE_NAMETBL_PRO_API(type)
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_vars.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_vars.m4
new file mode 100644
index 0000000..ac7424d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_vars.m4
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_vars.m4 2074 2011-10-27 03:34:33Z jkoshy $");
+
+/* WARNING: GENERATED FROM __file__. */
+
+divert(-1)
+include(SRCDIR`/dwarf_pro_nametbl.m4')
+divert(0)
+MAKE_NAMETBL_PRO_API(var)
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_weaks.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_weaks.m4
new file mode 100644
index 0000000..60984fd
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pro_weaks.m4
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pro_weaks.m4 2074 2011-10-27 03:34:33Z jkoshy $");
+
+/* WARNING: GENERATED FROM __file__. */
+
+divert(-1)
+include(SRCDIR`/dwarf_pro_nametbl.m4')
+divert(0)
+MAKE_NAMETBL_PRO_API(weak)
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_producer_init.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_producer_init.3
new file mode 100644
index 0000000..b8ca6a9
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_producer_init.3
@@ -0,0 +1,297 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_producer_init.3 3182 2015-04-10 16:08:10Z emaste $
+.\"
+.Dd August 20, 2011
+.Os
+.Dt DWARF_PRODUCER_INIT 3
+.Sh NAME
+.Nm dwarf_producer_init
+.Nm dwarf_producer_init_b
+.Nd allocate a DWARF producer descriptor
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_P_Debug
+.Fo dwarf_producer_init
+.Fa "Dwarf_Unsigned flags"
+.Fa "Dwarf_Callback_Func func"
+.Fa "Dwarf_Handler errhand"
+.Fa "Dwarf_Ptr errarg"
+.Fa "Dwarf_Error *err"
+.Fc
+.Ft Dwarf_P_Debug
+.Fo dwarf_producer_init_b
+.Fa "Dwarf_Unsigned flags"
+.Fa "Dwarf_Callback_Func_b func"
+.Fa "Dwarf_Handler errhand"
+.Fa "Dwarf_Ptr errarg"
+.Fa "Dwarf_Error *error"
+.Fc
+.Sh DESCRIPTION
+These functions allocate and return a
+.Vt Dwarf_P_Debug
+descriptor representing a DWARF producer instance.
+.Pp
+The argument
+.Ar errhand
+should contain the address of a function to be called in case of an
+error.
+If this argument is
+.Dv NULL ,
+the default error handling scheme is used, see
+.Xr dwarf 3 .
+.Pp
+The argument
+.Ar errarg
+will be passed to the error handler function when it is invoked.
+.Pp
+The argument
+.Ar err
+references a memory location that would hold a
+.Vt Dwarf_Error
+descriptor in case of an error.
+.Pp
+The argument
+.Ar flags
+specifies additional characteristics of the DWARF producer instance.
+The following flags are recognized:
+.Pp
+.Bl -tag -width "Dv DW_DLC_ISA_MIPS"
+.It Dv DW_DLC_ISA_IA64
+.Pq Deprecated
+The target instruction set architecture is IA64.
+This flag is deprecated.
+Application code should use the
+.Xr dwarf_producer_set_isa 3
+function to specify target instruction set architecture.
+.It Dv DW_DLC_ISA_MIPS
+.Pq Deprecated
+The target instruction set architecture is MIPS.
+This flag is deprecated.
+Application code should use the
+.Xr dwarf_producer_set_isa 3
+function to specify target instruction set architecture.
+.It Dv DW_DLC_SIZE_32
+.Pq Default
+The target address size is 32-bit.
+.It Dv DW_DLC_SIZE_64
+The target address size is 64-bit.
+.It Dv DW_DLC_STREAM_RELOCATIONS
+.Pq Default
+Generate stream relocations.
+.It Dv DW_DLC_SYMBOLIC_RELOCATIONS
+Generate symbolic relocations.
+.It Dv DW_DLC_TARGET_BIGENDIAN
+The target is big endian.
+.It Dv DW_DLC_TARGET_LITTLEENDIAN
+The target is little endian.
+.It Dv DW_DLC_WRITE
+.Pq Required
+Permit writing of DWARF information.
+.El
+.Pp
+The following flags are mutually exclusive.
+.Bl -bullet -compact
+.It
+Flags
+.Dv DW_DLC_ISA_IA64
+and
+.Dv DW_DLC_ISA_MIPS .
+.It
+Flags
+.Dv DW_DLC_SIZE_32
+and
+.Dv DW_DLC_SIZE_64 .
+.It
+Flags
+.Dv DW_DLC_STREAM_RELOCATIONS
+and
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS .
+.It
+Flags
+.Dv DW_DLC_TARGET_BIGENDIAN
+and
+.Dv DW_DLC_TARGET_LITTLEENDIAN .
+.El
+If neither of the flags
+.Dv DW_DLC_TARGET_BIGENDIAN
+and
+.Dv DW_DLC_TARGET_LITTLEENDIAN
+is set, the target's endianness is assumed to be the same as the host's
+endianness.
+.Pp
+Argument
+.Ar func
+should point to an application-provided callback function of type
+.Vt Dwarf_Callback_Func_b .
+The type
+.Vt Dwarf_Callback_Func_b
+is defined in the header file
+.In libdwarf.h
+as:
+.Bd -literal -offset indent
+typedef int (*Dwarf_Callback_Func_b)(char *name, int size,
+ Dwarf_Unsigned type, Dwarf_Unsigned flags, Dwarf_Unsigned link,
+ Dwarf_Unsigned info, Dwarf_Unsigned *index, int *error);
+.Ed
+.Pp
+This function is called by the
+.Lb libdwarf
+once for each section in the object file that the library needs to
+create.
+The arguments to this callback function specify the values in the ELF
+section header for the section being created:
+.Pp
+.Bl -tag -width indent -compact -offset indent
+.It Ar name
+The name of the section being created.
+.It Ar size
+The
+.Va sh_size
+value in the section header.
+.It Ar type
+The
+.Va sh_type
+value in the section header.
+.It Ar flags
+The
+.Va sh_flags
+value in the section header.
+.It Ar link
+The
+.Va sh_link
+value in the section header.
+.It Ar info
+The
+.Va sh_info
+value in the section header.
+.El
+.Pp
+On success, the callback function should return the section index
+value of the created section, and set the location pointed to by
+argument
+.Ar index
+to the symbol table index of the symbol that associated with the newly
+created section.
+This symbol table index will be used in relocation entries
+referring to the created section.
+.Pp
+In case of failure, the callback function should return -1 and set the
+location pointed to by argument
+.Ar error
+to an application-defined error code.
+This application returned error code is currently ignored by the
+library.
+.Pp
+Function
+.Fn dwarf_producer_init
+is deprecated.
+Function
+.Fn dwarf_producer_init
+is identical to function
+.Fn dwarf_producer_init_b
+except that the callback function it expects can not properly handle
+arbitrary section symbol index values.
+.Ss Memory Management
+The
+.Vt Dwarf_P_Debug
+instance returned by these functions should be freed using the
+function
+.Fn dwarf_producer_finish .
+.Sh RETURN VALUES
+On success, these functions return the created DWARF producer
+descriptor.
+In case of an error, they return
+.Dv DW_DLV_BADADDR
+and set the argument
+.Ar err .
+.Sh ERRORS
+These functions can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar func
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+The flag
+.Dv DW_DLC_WRITE
+was not set in argument
+.Ar flags .
+.It Bq Er DW_DLE_ARGUMENT
+The flags
+.Dv DW_DLC_SIZE_32
+and
+.Dv DW_DLC_SIZE_64
+were both set in argument
+.Ar flags .
+.It Bq Er DW_DLE_ARGUMENT
+The flags
+.Dv DW_DLC_ISA_IA64
+and
+.Dv DW_DLC_ISA_MIPS
+were both set in argument
+.Ar flags .
+.It Bq Er DW_DLE_ARGUMENT
+The flags
+.Dv DW_DLC_TARGET_BIGENDIAN
+and
+.Dv DW_DLC_TARGET_LITTLEENDIAN
+were both set in argument
+.Ar flags .
+.It Bq Er DW_DLE_ARGUMENT
+The flags
+.Dv DW_DLC_STREAM_RELOCATIONS
+and
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+were both set in argument
+.Ar flags .
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered.
+.El
+.Sh EXAMPLES
+To initialize a
+.Vt Dwarf_P_Debug
+instance for a MIPS32 big endian object, use:
+.Bd -literal -offset indent
+Dwarf_P_Debug dbg;
+Dwarf_Unsigned flags;
+Dwarf_Error de;
+
+/* ... assume cb_func points to the callback function ... */
+
+flags = DW_DLC_WRITE | DW_DLC_SIZE_32 | DW_DLC_ISA_MIPS |
+ DW_DLC_STREAM_RELOCATIONS | DW_DLC_TARGET_BIGENDIAN;
+if ((dbg = dwarf_producer_init(flags, cb_func, NULL, NULL, &de)) ==
+ DW_DLV_BADADDR)
+ warnx("dwarf_producer_init failed: %s", dwarf_errmsg(-1));
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_errmsg 3 ,
+.Xr dwarf_producer_finish 3 ,
+.Xr dwarf_producer_set_isa 3 ,
+.Xr dwarf_transform_to_disk_form 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_producer_set_isa.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_producer_set_isa.3
new file mode 100644
index 0000000..fc8a31f
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_producer_set_isa.3
@@ -0,0 +1,98 @@
+.\" Copyright (c) 2011 Joseph Koshy
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_producer_set_isa.3 2074 2011-10-27 03:34:33Z jkoshy $
+.\"
+.Dd September 29, 2011
+.Os
+.Dt DWARF_PRODUCER_SET_ISA 3
+.Sh NAME
+.Nm dwarf_producer_set_isa
+.Nd specify the instruction set architecture for a DWARF producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_producer_set_isa
+.Fa "Dwarf_P_Debug dbg"
+.Fa "enum Dwarf_ISA isa"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+The function
+.Fn dwarf_producer_set_isa
+sets the instruction set architecture for a DWARF producer instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using one of
+the functions
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar isa
+specifies the desired instruction set architecture.
+Legal values for this argument are those defined by the
+.Vt "enum Dwarf_ISA"
+enumeration defined in the header file
+.In libdwarf.h .
+.Pp
+If the argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh COMPATIBILITY
+The
+.Fn dwarf_producer_set_isa
+function is a local extension.
+.Sh RETURN VALUES
+On success, the function
+.Fn dwarf_producer_set_isa
+returns
+.Dv DW_DLV_OK .
+In case of an error, this function returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+The
+.Fn dwarf_producer_set_isa
+function can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+The argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_ARGUMENT
+The argument
+.Ar isa
+was invalid.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pubnames.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pubnames.m4
new file mode 100644
index 0000000..c397106
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pubnames.m4
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pubnames.m4 2074 2011-10-27 03:34:33Z jkoshy $");
+
+/* WARNING: GENERATED FROM __file__. */
+
+divert(-1)
+include(SRCDIR`/dwarf_nametbl.m4')
+divert(0)
+MAKE_NAMETBL_API(global,Global,glob,pubnames)
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_pubtypes.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pubtypes.m4
new file mode 100644
index 0000000..5188ea7
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_pubtypes.m4
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_pubtypes.m4 2074 2011-10-27 03:34:33Z jkoshy $");
+
+/* WARNING: GENERATED FROM __file__. */
+
+divert(-1)
+include(SRCDIR`/dwarf_nametbl.m4')
+divert(0)
+MAKE_NAMETBL_API(pubtype,Type,pubtype,pubtypes)
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_ranges.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_ranges.c
new file mode 100644
index 0000000..2e01da5
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_ranges.c
@@ -0,0 +1,87 @@
+/*-
+ * Copyright (c) 2009,2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_ranges.c 3029 2014-04-21 23:26:02Z kaiwang27 $");
+
+static int
+_dwarf_get_ranges(Dwarf_Debug dbg, Dwarf_CU cu, Dwarf_Off off,
+ Dwarf_Ranges **ranges, Dwarf_Signed *ret_cnt, Dwarf_Unsigned *ret_byte_cnt,
+ Dwarf_Error *error)
+{
+ Dwarf_Rangelist rl;
+ int ret;
+
+ assert(cu != NULL);
+ if (_dwarf_ranges_find(dbg, off, &rl) == DW_DLE_NO_ENTRY) {
+ ret = _dwarf_ranges_add(dbg, cu, off, &rl, error);
+ if (ret != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ }
+
+ *ranges = rl->rl_rgarray;
+ *ret_cnt = rl->rl_rglen;
+
+ if (ret_byte_cnt != NULL)
+ *ret_byte_cnt = cu->cu_pointer_size * rl->rl_rglen * 2;
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_ranges(Dwarf_Debug dbg, Dwarf_Off offset, Dwarf_Ranges **ranges,
+ Dwarf_Signed *ret_cnt, Dwarf_Unsigned *ret_byte_cnt, Dwarf_Error *error)
+{
+
+ if (dbg == NULL || ranges == NULL || ret_cnt == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (!dbg->dbg_info_loaded) {
+ if (_dwarf_info_load(dbg, 1, 1, error) != DW_DLE_NONE)
+ return (DW_DLV_ERROR);
+ }
+
+ return (_dwarf_get_ranges(dbg, STAILQ_FIRST(&dbg->dbg_cu), offset,
+ ranges, ret_cnt, ret_byte_cnt, error));
+}
+
+int
+dwarf_get_ranges_a(Dwarf_Debug dbg, Dwarf_Off offset, Dwarf_Die die,
+ Dwarf_Ranges **ranges, Dwarf_Signed *ret_cnt, Dwarf_Unsigned *ret_byte_cnt,
+ Dwarf_Error *error)
+{
+
+ if (dbg == NULL || die == NULL || ranges == NULL || ret_cnt == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ return (_dwarf_get_ranges(dbg, die->die_cu, offset, ranges, ret_cnt,
+ ret_byte_cnt, error));
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_reloc.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_reloc.c
new file mode 100644
index 0000000..0430e4d
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_reloc.c
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_reloc.c 3161 2015-02-15 21:43:36Z emaste $");
+
+int
+dwarf_set_reloc_application(int apply)
+{
+ int oldapply;
+
+ oldapply = _libdwarf.applyreloc;
+ _libdwarf.applyreloc = apply;
+
+ return (oldapply);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_reset_section_bytes.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_reset_section_bytes.3
new file mode 100644
index 0000000..702d568
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_reset_section_bytes.3
@@ -0,0 +1,69 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_reset_section_bytes.3 2075 2011-10-27 03:47:28Z jkoshy $
+.\"
+.Dd September 3, 2011
+.Os
+.Dt DWARF_RESET_SECTION_BYTES 3
+.Sh NAME
+.Nm dwarf_reset_section_bytes
+.Nd reset the internal state of a producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft void
+.Fo dwarf_reset_section_bytes
+.Fa "Dwarf_P_Debug dbg"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_reset_section_bytes
+resets the internal state of a DWARF producer instance, so that the
+next call to the function
+.Xr dwarf_get_section_bytes 3
+will return the byte stream for the first generated section, and
+the next call to the function
+.Xr dwarf_get_relocation_info 3
+will return the first relocation array for the DWARF producer
+instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Sh RETURN VALUES
+Function
+.Fn dwarf_reset_section_bytes
+has no return value.
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_relocation_info 3 ,
+.Xr dwarf_get_section_bytes 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3 ,
+.Xr dwarf_transform_to_disk_form 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_sections.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_sections.c
new file mode 100644
index 0000000..dc676a3
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_sections.c
@@ -0,0 +1,111 @@
+/*-
+ * Copyright (c) 2014 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_sections.c 3226 2015-06-23 13:00:16Z emaste $");
+
+#define SET(N, V) \
+ do { \
+ if ((N) != NULL) \
+ *(N) = (V); \
+ } while (0)
+
+int
+dwarf_get_section_max_offsets_b(Dwarf_Debug dbg, Dwarf_Unsigned *debug_info,
+ Dwarf_Unsigned *debug_abbrev, Dwarf_Unsigned *debug_line,
+ Dwarf_Unsigned *debug_loc, Dwarf_Unsigned *debug_aranges,
+ Dwarf_Unsigned *debug_macinfo, Dwarf_Unsigned *debug_pubnames,
+ Dwarf_Unsigned *debug_str, Dwarf_Unsigned *debug_frame,
+ Dwarf_Unsigned *debug_ranges, Dwarf_Unsigned *debug_pubtypes,
+ Dwarf_Unsigned *debug_types)
+{
+ const char *n;
+ Dwarf_Unsigned sz;
+ int i;
+
+ if (dbg == NULL)
+ return (DW_DLV_ERROR);
+
+ SET(debug_info, 0);
+ SET(debug_abbrev, 0);
+ SET(debug_line, 0);
+ SET(debug_loc, 0);
+ SET(debug_aranges, 0);
+ SET(debug_macinfo, 0);
+ SET(debug_pubnames, 0);
+ SET(debug_str, 0);
+ SET(debug_frame, 0);
+ SET(debug_ranges, 0);
+ SET(debug_pubtypes, 0);
+ SET(debug_types, 0);
+
+ for (i = 0; (Dwarf_Unsigned) i < dbg->dbg_seccnt; i++) {
+ n = dbg->dbg_section[i].ds_name;
+ sz = dbg->dbg_section[i].ds_size;
+ if (!strcmp(n, ".debug_info"))
+ SET(debug_info, sz);
+ else if (!strcmp(n, ".debug_abbrev"))
+ SET(debug_abbrev, sz);
+ else if (!strcmp(n, ".debug_line"))
+ SET(debug_line, sz);
+ else if (!strcmp(n, ".debug_loc"))
+ SET(debug_loc, sz);
+ else if (!strcmp(n, ".debug_aranges"))
+ SET(debug_aranges, sz);
+ else if (!strcmp(n, ".debug_macinfo"))
+ SET(debug_macinfo, sz);
+ else if (!strcmp(n, ".debug_pubnames"))
+ SET(debug_pubnames, sz);
+ else if (!strcmp(n, ".debug_str"))
+ SET(debug_str, sz);
+ else if (!strcmp(n, ".debug_frame"))
+ SET(debug_frame, sz);
+ else if (!strcmp(n, ".debug_ranges"))
+ SET(debug_ranges, sz);
+ else if (!strcmp(n, ".debug_pubtypes"))
+ SET(debug_pubtypes, sz);
+ else if (!strcmp(n, ".debug_types"))
+ SET(debug_types, sz);
+ }
+
+ return (DW_DLV_OK);
+}
+
+int
+dwarf_get_section_max_offsets(Dwarf_Debug dbg, Dwarf_Unsigned *debug_info,
+ Dwarf_Unsigned *debug_abbrev, Dwarf_Unsigned *debug_line,
+ Dwarf_Unsigned *debug_loc, Dwarf_Unsigned *debug_aranges,
+ Dwarf_Unsigned *debug_macinfo, Dwarf_Unsigned *debug_pubnames,
+ Dwarf_Unsigned *debug_str, Dwarf_Unsigned *debug_frame,
+ Dwarf_Unsigned *debug_ranges, Dwarf_Unsigned *debug_pubtypes)
+{
+
+ return (dwarf_get_section_max_offsets_b(dbg, debug_info, debug_abbrev,
+ debug_line, debug_loc, debug_aranges, debug_macinfo,
+ debug_pubnames, debug_str, debug_frame, debug_ranges,
+ debug_pubtypes, NULL));
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_set_frame_cfa_value.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_set_frame_cfa_value.3
new file mode 100644
index 0000000..c3d9c48
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_set_frame_cfa_value.3
@@ -0,0 +1,140 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_set_frame_cfa_value.3 2075 2011-10-27 03:47:28Z jkoshy $
+.\"
+.Dd June 18, 2011
+.Os
+.Dt DWARF_SET_FRAME_CFA_VALUE 3
+.Sh NAME
+.Nm dwarf_set_frame_cfa_value ,
+.Nm dwarf_set_frame_rule_initial_value ,
+.Nm dwarf_set_frame_rule_table_size ,
+.Nm dwarf_set_frame_same_value ,
+.Nm dwarf_set_frame_undefined_value
+.Nd set internal register rule table parameters
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_Half
+.Fo dwarf_set_frame_cfa_value
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Half value"
+.Fc
+.Ft Dwarf_Half
+.Fo dwarf_set_frame_rule_initial_value
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Half value"
+.Fc
+.Ft Dwarf_Half
+.Fo dwarf_set_frame_rule_table_size
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Half value"
+.Fc
+.Ft Dwarf_Half
+.Fo dwarf_set_frame_same_value
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Half value"
+.Fc
+.Ft Dwarf_Half
+.Fo dwarf_set_frame_undefined_value
+.Fa "Dwarf_Debug dbg"
+.Fa "Dwarf_Half value"
+.Fc
+.Sh DESCRIPTION
+These functions set the parameters of the internal register
+rule table.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF debug context allocated using
+.Xr dwarf_init 3 .
+.Pp
+Argument
+.Ar value
+should hold the parameter value to set.
+.Pp
+Function
+.Fn dwarf_set_frame_cfa_value
+sets the column number for the CFA register rule in the internal
+register rule table.
+The constant
+.Dv DW_FRAME_CFA_COL
+is the default CFA register column number for DWARF2-only
+interfaces, and the constant
+.Dv DW_FRAME_CFA_COL3
+is the default CFA column number for DWARF3-compatible interfaces.
+.Pp
+Function
+.Fn dwarf_set_frame_rule_initial_value
+sets the initial value of the register rules in the internal register
+rule table.
+The default initial value is the constant
+.Dv DW_FRAME_REG_INITIAL_VALUE ,
+defined in the header file
+.In libdwarf.h .
+.Pp
+Function
+.Fn dwarf_set_frame_rule_table_size
+sets the maxmium number of columns of the internal register rule table.
+Argument
+.Ar value
+should be at least as large as the number of real registers in the ABI.
+.Pp
+Function
+.Fn dwarf_set_frame_same_value
+sets the register number representing the
+.Dq "same value"
+register rule.
+The default register number for the
+.Dq "same value"
+rule is the constant
+.Dv DW_FRAME_SAME_VAL ,
+defined in the header file
+.In libdwarf.h .
+.Pp
+Function
+.Fn dwarf_set_frame_undefined_value
+sets the register number representing the
+.Dq undefined
+register rule.
+The default register number for the
+.Dq undefined
+rule is the constant
+.Dv DW_FRAME_UNDEFINED_VAL ,
+defined in the header file
+.In libdwarf.h .
+.Sh RETURN VALUES
+These functions return the previous value of the parameter being
+set.
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_fde_at_pc 3 ,
+.Xr dwarf_get_fde_info_for_all_regs 3 ,
+.Xr dwarf_get_fde_info_for_all_regs3 3 ,
+.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
+.Xr dwarf_get_fde_info_for_reg 3 ,
+.Xr dwarf_get_fde_info_for_reg3 3 ,
+.Xr dwarf_get_fde_n 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_set_reloc_application.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_set_reloc_application.3
new file mode 100644
index 0000000..db40cbb
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_set_reloc_application.3
@@ -0,0 +1,82 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_set_reloc_application.3 3161 2015-02-15 21:43:36Z emaste $
+.\"
+.Dd February 11, 2015
+.Os
+.Dt DWARF_SET_RELOC_APPLICATION 3
+.Sh NAME
+.Nm dwarf_set_reloc_application
+.Nd set a library-wide relocation flag
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_set_reloc_application
+.Fa "int apply"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_set_reloc_application
+allows applications to specify how relocation information is to be
+handled by the DWARF(3) library.
+.Pp
+If the argument
+.Ar apply
+holds a non-zero value, the library will process all the relevant
+.Dq ".rel"
+and
+.Dq ".rela"
+relocation sections and will apply the relocation records found to
+their corresponding DWARF sections.
+.Pp
+If the argument
+.Ar apply
+is zero, the library will not attempt to apply any relocations.
+.Pp
+The default behaviour of the library is to process relocation records.
+.Sh NOTES
+Function
+.Fn dwarf_set_reloc_application
+should be called before initialising a dwarf debugging context, i.e,
+it should be called by the application before calling either of the
+functions
+.Xr dwarf_init 3
+or
+.Xr dwarf_elf_init 3 .
+.Sh RETURN VALUES
+Function
+.Fn dwarf_set_reloc_application
+returns the previous value of the library-wide relocation application
+flag.
+.Sh ERRORS
+Function
+.Fn dwarf_set_reloc_application
+does not return an error.
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_init 3 ,
+.Xr dwarf_elf_init 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_seterrarg.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_seterrarg.3
new file mode 100644
index 0000000..55d78d9
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_seterrarg.3
@@ -0,0 +1,102 @@
+.\" Copyright (c) 2010 Joseph Koshy. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" This software is provided by Joseph Koshy ``as is'' and
+.\" any express or implied warranties, including, but not limited to, the
+.\" implied warranties of merchantability and fitness for a particular purpose
+.\" are disclaimed. in no event shall Joseph Koshy be liable
+.\" for any direct, indirect, incidental, special, exemplary, or consequential
+.\" damages (including, but not limited to, procurement of substitute goods
+.\" or services; loss of use, data, or profits; or business interruption)
+.\" however caused and on any theory of liability, whether in contract, strict
+.\" liability, or tort (including negligence or otherwise) arising in any way
+.\" out of the use of this software, even if advised of the possibility of
+.\" such damage.
+.\"
+.\" $Id: dwarf_seterrarg.3 2075 2011-10-27 03:47:28Z jkoshy $
+.\"
+.Dd May 01, 2010
+.Os
+.Dt DWARF_SETERRARG 3
+.Sh NAME
+.Nm dwarf_seterrarg ,
+.Nm dwarf_seterrhand
+.Nd configure error handling
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_Ptr
+.Fn dwarf_seterrarg "Dwarf_Debug dbg" "Dwarf_Ptr arg"
+.Ft Dwarf_Handler
+.Fn dwarf_seterrhand "Dwarf_Debug dbg" "Dwarf_Handler handler"
+.Sh DESCRIPTION
+These functions may be used by applications to configure error handling
+callbacks.
+The error handling scheme used by the library is described in
+.Xr dwarf 3 .
+.Pp
+Function
+.Fn dwarf_seterrarg
+may be used to set the callback argument passed to a configured
+error handler at the time it is invoked.
+Argument
+.Ar arg
+is the callback argument being set.
+Argument
+.Ar dbg
+can be a debug context allocated by a prior call to
+.Xr dwarf_init 3 ,
+or can be NULL to indicate that the library-wide callback argument
+is to be set.
+.Pp
+Function
+.Fn dwarf_seterrhand
+may be used to associate an error handler denoted by argument
+.Ar handler
+with the DWARF debug context descriptor denoted by argument
+.Ar dbg .
+Argument
+.Ar dbg
+should be a debug context allocated by a prior call to
+.Xr dwarf_init 3 ,
+or may be NULL to indicate that the library-wide error handler
+is to be set.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_seterrhand
+returns the previous error handler associated with argument
+.Ar dbg .
+If argument
+.Ar dbg
+is NULL, function
+.Fn dwarf_seterrhand
+returns the previous library-wide error handler.
+.Pp
+Function
+.Fn dwarf_seterrarg
+returns the previous callback argument associated with argument
+.Ar dbg .
+If argument
+.Ar dbg
+is NULL, function
+.Fn dwarf_seterrarg
+returns the previous library-wide callback argument.
+.Pp
+.Sh COMPATIBILITY
+The behavior of these functions when argument
+.Ar dbg
+is NULL is a local extension.
+.Sh ERRORS
+These functions do not set an error code.
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_init 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_seterror.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_seterror.c
new file mode 100644
index 0000000..da23cdb
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_seterror.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2010 Joseph Koshy
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_seterror.c 2075 2011-10-27 03:47:28Z jkoshy $");
+
+#define _SET_FIELD(R, F, V) \
+ do { \
+ (R) = (F); \
+ (F) = (V); \
+ } while (0)
+
+#define SET_FIELD(D, R, F) \
+ do { \
+ if (D) \
+ _SET_FIELD(R, (D)->dbg_##F, F); \
+ else \
+ _SET_FIELD(R, _libdwarf.F, F); \
+ } while (0)
+
+Dwarf_Handler
+dwarf_seterrhand(Dwarf_Debug dbg, Dwarf_Handler errhand)
+{
+ Dwarf_Handler oldhandler;
+
+ SET_FIELD(dbg, oldhandler, errhand);
+
+ return (oldhandler);
+}
+
+Dwarf_Ptr
+dwarf_seterrarg(Dwarf_Debug dbg, Dwarf_Ptr errarg)
+{
+ Dwarf_Ptr oldarg;
+
+ SET_FIELD(dbg, oldarg, errarg);
+
+ return (oldarg);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_srcfiles.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_srcfiles.3
new file mode 100644
index 0000000..906bb92
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_srcfiles.3
@@ -0,0 +1,105 @@
+.\" Copyright (c) 2010 Joseph Koshy. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" This software is provided by Joseph Koshy ``as is'' and
+.\" any express or implied warranties, including, but not limited to, the
+.\" implied warranties of merchantability and fitness for a particular purpose
+.\" are disclaimed. in no event shall Joseph Koshy be liable
+.\" for any direct, indirect, incidental, special, exemplary, or consequential
+.\" damages (including, but not limited to, procurement of substitute goods
+.\" or services; loss of use, data, or profits; or business interruption)
+.\" however caused and on any theory of liability, whether in contract, strict
+.\" liability, or tort (including negligence or otherwise) arising in any way
+.\" out of the use of this software, even if advised of the possibility of
+.\" such damage.
+.\"
+.\" $Id: dwarf_srcfiles.3 2075 2011-10-27 03:47:28Z jkoshy $
+.\"
+.Dd April 28, 2010
+.Os
+.Dt DWARF_SRCFILES 3
+.Sh NAME
+.Nm dwarf_srcfiles
+.Nd retrieve source file information
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_srcfiles
+.Fa "Dwarf_Die die"
+.Fa "char ***filenames"
+.Fa "Dwarf_Signed *filenamecount"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_srcfiles
+returns the source file names associated with a compilation unit.
+Source file names are returned as an array of NUL-terminated strings.
+.Pp
+Argument
+.Ar die
+should reference a DWARF debugging information entry descriptor with
+source file information, see
+.Xr dwarf 3 .
+Argument
+.Ar filenames
+should point to a location that will hold a pointer to the returned array
+of file names.
+Argument
+.Ar filenamecount
+should point to a location that will hold the number of file names returned.
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Ss Memory Management
+The memory areas used for the file names and for array of pointers
+being returned are managed by the DWARF(3) library.
+The application should not attempt to directly free these memory areas.
+Portable code should indicate that the memory areas are to be freed
+by using
+.Xr dwarf_dealloc 3 .
+.Sh RETURN VALUES
+Function
+.Fn dwarf_srcfiles
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_srcfiles
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar die ,
+.Ar filenames
+or
+.Ar filenamecount
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+The compilation unit referenced by argument
+.Ar die
+does not have associated source file information.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+this function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_dealloc 3 ,
+.Xr dwarf_srclines 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_srclines.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_srclines.3
new file mode 100644
index 0000000..0f8d830
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_srclines.3
@@ -0,0 +1,163 @@
+.\" Copyright (c) 2010 Joseph Koshy. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" This software is provided by Joseph Koshy ``as is'' and
+.\" any express or implied warranties, including, but not limited to, the
+.\" implied warranties of merchantability and fitness for a particular purpose
+.\" are disclaimed. in no event shall Joseph Koshy be liable
+.\" for any direct, indirect, incidental, special, exemplary, or consequential
+.\" damages (including, but not limited to, procurement of substitute goods
+.\" or services; loss of use, data, or profits; or business interruption)
+.\" however caused and on any theory of liability, whether in contract, strict
+.\" liability, or tort (including negligence or otherwise) arising in any way
+.\" out of the use of this software, even if advised of the possibility of
+.\" such damage.
+.\"
+.\" $Id: dwarf_srclines.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_SRCLINES 3
+.Sh NAME
+.Nm dwarf_srclines
+.Nd retrieve line number information for a debugging information entry
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_srclines
+.Fa "Dwarf_Die die"
+.Fa "Dwarf_Line **lines"
+.Fa "Dwarf_Signed *nlines"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_srclines
+returns line number information associated with a compilation unit.
+Line number information is returned as an array of
+.Vt Dwarf_Line
+descriptors.
+.Pp
+Argument
+.Ar die
+should reference a DWARF debugging information entry descriptor
+with line number information, see
+.Xr dwarf 3 .
+Argument
+.Ar lines
+should point to a location that will hold a pointer to the returned array
+of
+.Vt Dwarf_Line
+descriptors.
+Argument
+.Ar nlines
+should point to a location that will hold the number of descriptors
+returned.
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Pp
+The returned
+.Vt Dwarf_Line
+descriptors may be passed to the other line number functions in the
+API set to retrieve specific information about each source line.
+.Ss Memory Management
+The memory area used for the array of
+.Vt Dwarf_Line
+descriptors returned in argument
+.Ar lines
+is owned by the
+.Lb libdwarf .
+The application should not attempt to free this pointer.
+Portable code should instead use
+.Fn dwarf_srclines_dealloc
+to indicate that the memory may be freed.
+.Sh RETURN VALUES
+Function
+.Fn dwarf_srclines
+returns
+.Dv DW_DLV_OK
+when it succeeds.
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_srclines
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+One of the arguments
+.Ar die ,
+.Ar lines
+or
+.Ar nlines
+was NULL.
+.It Bq Er DW_DLE_NO_ENTRY
+The compilation unit referenced by argument
+.Ar die
+does not have associated line number information.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of
+this function.
+.El
+.Sh EXAMPLE
+To obtain an array of
+.Vt Dwarf_Line
+descriptors and to retrieve the source file, line number, and virtual address
+associated with each descriptor:
+.Bd -literal -offset indent
+int n;
+Dwarf_Die die;
+Dwarf_Error de;
+char *filename;
+Dwarf_Line *lines;
+Dwarf_Signed nlines;
+Dwarf_Addr lineaddr;
+Dwarf_Unsigned lineno;
+
+/* variable "die" should reference a DIE for a compilation unit */
+
+if (dwarf_srclines(die, &lines, &nlines, &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_srclines: %s", dwarf_errmsg(de));
+
+for (n = 0; n < nlines; n++) {
+ /* Retrieve the file name for this descriptor. */
+ if (dwarf_linesrc(lines[n], &filename, &de))
+ errx(EXIT_FAILURE, "dwarf_linesrc: %s",
+ dwarf_errmsg(de));
+
+ /* Retrieve the line number in the source file. */
+ if (dwarf_lineno(lines[n], &lineno, &de))
+ errx(EXIT_FAILURE, "dwarf_lineno: %s",
+ dwarf_errmsg(de));
+ /* Retrieve the virtual address for this line. */
+ if (dwarf_lineaddr(lines[n], &lineaddr, &de))
+ errx(EXIT_FAILURE, "dwarf_lineaddr: %s",
+ dwarf_errmsg(de));
+ }
+.Ed
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_line_srcfileno 3 ,
+.Xr dwarf_lineaddr 3 ,
+.Xr dwarf_linebeginstatement 3 ,
+.Xr dwarf_lineblock 3 ,
+.Xr dwarf_lineendsequence 3 ,
+.Xr dwarf_lineno 3 ,
+.Xr dwarf_lineoff 3 ,
+.Xr dwarf_linesrc 3 ,
+.Xr dwarf_srcfiles 3 ,
+.Xr dwarf_srclines_dealloc 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_start_macro_file.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_start_macro_file.3
new file mode 100644
index 0000000..1e821d7
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_start_macro_file.3
@@ -0,0 +1,106 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_start_macro_file.3 2075 2011-10-27 03:47:28Z jkoshy $
+.\"
+.Dd September 25, 2011
+.Os
+.Dt DWARF_START_MACRO_FILE 3
+.Sh NAME
+.Nm dwarf_start_macro_file
+.Nd mark the start of a source file inclusion
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "int"
+.Fo dwarf_start_macro_file
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Unsigned lineno"
+.Fa "Dwarf_Unsigned fileindex"
+.Fa "Dwarf_Error *err"
+.Fa
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_start_macro_file
+marks the start of a new source file inclusion.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar lineno
+specifies the line number of the source line where the source
+file inclusion occurs.
+A value of zero is used to indicate the file for the compilation unit
+source itself.
+.Pp
+Argument
+.Ar fileindex
+specifies the index of the source file that is being included.
+Valid source file indices are those returned by
+.Xr dwarf_add_file_decl 3 .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_start_macro_file
+returns
+.Dv DW_DLV_OK .
+In case of an error, function
+.Fn dwarf_start_macro_file
+returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_start_macro_file
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_add_file_decl 3 ,
+.Xr dwarf_def_macro 3 ,
+.Xr dwarf_end_macro_file 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3 ,
+.Xr dwarf_undef_macro 3 ,
+.Xr dwarf_vendor_ext 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_str.c b/rtemstoolkit/elftoolchain/libdwarf/dwarf_str.c
new file mode 100644
index 0000000..c402f21
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_str.c
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_str.c 3295 2016-01-08 22:08:10Z jkoshy $");
+
+int
+dwarf_get_str(Dwarf_Debug dbg, Dwarf_Off offset, char **string,
+ Dwarf_Signed *ret_strlen, Dwarf_Error *error)
+{
+ Dwarf_Section *ds;
+
+ if (dbg == NULL || string == NULL || ret_strlen == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ ds = _dwarf_find_section(dbg, ".debug_str");
+ if (ds == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ if (offset > ds->ds_size) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLV_ERROR);
+ }
+
+ if (offset == ds->ds_size) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ *string = (char *) ds->ds_data + offset;
+ *ret_strlen = strlen(*string);
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_tag.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_tag.3
new file mode 100644
index 0000000..bb49a49
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_tag.3
@@ -0,0 +1,77 @@
+.\" Copyright (c) 2010 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_tag.3 2075 2011-10-27 03:47:28Z jkoshy $
+.\"
+.Dd April 14, 2010
+.Os
+.Dt DWARF_TAG 3
+.Sh NAME
+.Nm dwarf_tag
+.Nd retrieve the tag associated with a DWARF debugging information entry
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fn dwarf_tag "Dwarf_Die die" "Dwarf_Half *tag" "Dwarf_Error *err"
+.Sh DESCRIPTION
+Function
+.Fn dwarf_tag
+retrieves the tag associated with the debugging information entry
+referenced by argument
+.Ar die ,
+and stores it into the location pointed to by argument
+.Ar tag .
+.Pp
+If argument
+.Ar err
+if non-NULL, it will be used to return an error descriptor in case of
+an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_tag
+returns
+.Dv DW_DLV_OK .
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_tag
+can fail with the following error:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Va die
+or
+.Va tag
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_die_abbrev_code 3 ,
+.Xr dwarf_diename 3 ,
+.Xr dwarf_dieoffset 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_transform_to_disk_form.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_transform_to_disk_form.3
new file mode 100644
index 0000000..54896ca
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_transform_to_disk_form.3
@@ -0,0 +1,99 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_transform_to_disk_form.3 2075 2011-10-27 03:47:28Z jkoshy $
+.\"
+.Dd August 25, 2011
+.Os
+.Dt DWARF_TRANSFORM_TO_DISK_FORM 3
+.Sh NAME
+.Nm dwarf_transform_to_disk_form
+.Nd transform DWARF information into byte streams
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft Dwarf_Signed
+.Fo dwarf_transform_to_disk_form
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_transform_to_disk_form
+transforms the DWARF information gathered by the producer into
+byte streams for the application to write out as ELF sections.
+If the flag
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+is set on the producer, the function will also generate the associated
+relocation arrays.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case
+of an error.
+.Pp
+After a call to this function, the application can call the function
+.Xr dwarf_get_section_bytes 3
+to retrieve the byte streams for each ELF section.
+If the flag
+.Dv DW_DLC_SYMBOLIC_RELOCATIONS
+was set on the descriptor, the application can also call the function
+.Xr dwarf_get_relocation_info 3
+to retrieve the generated relocation arrays.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_transform_to_disk_form
+returns the total number of ELF sections generated.
+In case of an error, function
+.Fn dwarf_transform_to_disk_form
+returns
+.Dv DW_DLV_NOCOUNT
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_transform_to_disk_form
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Argument
+.Ar dbg
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during execution.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_get_relocation_info 3 ,
+.Xr dwarf_get_section_bytes 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_types.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_types.m4
new file mode 100644
index 0000000..ddab7f1
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_types.m4
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_types.m4 2697 2012-11-24 17:12:36Z kaiwang27 $");
+
+/* WARNING: GENERATED FROM __file__. */
+
+divert(-1)
+include(SRCDIR`/dwarf_nametbl.m4')
+divert(0)
+MAKE_NAMETBL_API(type,Type,type,typenames)
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_undef_macro.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_undef_macro.3
new file mode 100644
index 0000000..b787289
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_undef_macro.3
@@ -0,0 +1,119 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_undef_macro.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\"
+.Dd November 9, 2011
+.Os
+.Dt DWARF_UNDEF_MACRO 3
+.Sh NAME
+.Nm dwarf_undef_macro
+.Nd record the removal of a macro definition
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "int"
+.Fo dwarf_undef_macro
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Unsigned lineno"
+.Fa "char *name"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_undef_macro
+records the removal of a macro definition in a DWARF producer
+instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar lineno
+specifies the line number of the source line where the macro
+definition was removed.
+A value of zero indicates that the macro definition was removed before
+any source files were read.
+.Pp
+Argument
+.Ar name
+should point to a NUL-terminated string containing the name
+of the macro.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_undef_macro
+returns
+.Dv DW_DLV_OK .
+In case of an error, function
+.Fn dwarf_undef_macro
+returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh EXAMPLE
+To record the fact that the macro named
+.Dv _STDIO_H_
+was removed at line 220 of the current macro file, use:
+.Bd -literal -offset indent
+Dwarf_P_Debug dbg;
+Dwarf_Error de;
+
+/* ... Assume 'dbg' refers to a DWARF producer instance... */
+if (dwarf_undef_macro(dbg, 220, "_STDIO_H_", &de) != DW_DLV_OK)
+ errx(EXIT_FAILURE, "dwarf_def_macro failed: %s",
+ dwarf_errmsg(-1));
+.Ed
+.Sh ERRORS
+Function
+.Fn dwarf_undef_macro
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either arguments
+.Ar dbg
+or
+.Ar name
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_def_macro 3 ,
+.Xr dwarf_end_macro_file 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3 ,
+.Xr dwarf_start_macro_file 3 ,
+.Xr dwarf_vendor_ext 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_vars.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_vars.m4
new file mode 100644
index 0000000..b512fdf
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_vars.m4
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_vars.m4 2075 2011-10-27 03:47:28Z jkoshy $");
+
+/* WARNING: GENERATED FROM __file__. */
+
+divert(-1)
+include(SRCDIR`/dwarf_nametbl.m4')
+divert(0)
+MAKE_NAMETBL_API(var,Var,var,static_vars)
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_vendor_ext.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_vendor_ext.3
new file mode 100644
index 0000000..c7ae56f
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_vendor_ext.3
@@ -0,0 +1,110 @@
+.\" Copyright (c) 2011 Kai Wang
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_vendor_ext.3 2075 2011-10-27 03:47:28Z jkoshy $
+.\"
+.Dd September 25, 2011
+.Os
+.Dt DWARF_VENDOR_EXT 3
+.Sh NAME
+.Nm dwarf_vendor_ext
+.Nd add vendor-specific macro information to a DWARF producer instance
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft "int"
+.Fo dwarf_vendor_ext
+.Fa "Dwarf_P_Debug dbg"
+.Fa "Dwarf_Unsigned constant"
+.Fa "char *string"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_vendor_ext
+adds a vendor-specific macro information entry to a DWARF producer
+instance.
+.Pp
+Argument
+.Ar dbg
+should reference a DWARF producer instance allocated using
+.Xr dwarf_producer_init 3
+or
+.Xr dwarf_producer_init_b 3 .
+.Pp
+Argument
+.Ar constant
+specifies a constant value for the macro information entry.
+.Pp
+Argument
+.Ar string
+point to a NUL-terminated string containing the string value
+for the macro information entry.
+.Pp
+If argument
+.Ar err
+is not NULL, it will be used to store error information in case of an
+error.
+.Pp
+The meaning of the arguments
+.Ar constant
+and
+.Ar string
+are not defined by the DWARF specification, but are instead governed
+by application and vendor conventions.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_vendor_ext
+returns
+.Dv DW_DLV_OK .
+In case of an error, function
+.Fn dwarf_vendor_ext
+returns
+.Dv DW_DLV_ERROR
+and sets the argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_vendor_ext
+can fail with:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either arguments
+.Ar dbg
+or
+.Ar string
+was NULL.
+.It Bq Er DW_DLE_MEMORY
+An out of memory condition was encountered during the execution of the
+function.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_def_macro 3 ,
+.Xr dwarf_end_macro_file 3 ,
+.Xr dwarf_producer_init 3 ,
+.Xr dwarf_producer_init_b 3 ,
+.Xr dwarf_start_macro_file 3 ,
+.Xr dwarf_undef_macro 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_weaks.m4 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_weaks.m4
new file mode 100644
index 0000000..7ae335e
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_weaks.m4
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: dwarf_weaks.m4 2075 2011-10-27 03:47:28Z jkoshy $");
+
+/* WARNING: GENERATED FROM __file__. */
+
+divert(-1)
+include(SRCDIR`/dwarf_nametbl.m4')
+divert(0)
+MAKE_NAMETBL_API(weak,Weak,weak,weaknames)
diff --git a/rtemstoolkit/elftoolchain/libdwarf/dwarf_whatattr.3 b/rtemstoolkit/elftoolchain/libdwarf/dwarf_whatattr.3
new file mode 100644
index 0000000..d7f6dd4
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/dwarf_whatattr.3
@@ -0,0 +1,79 @@
+.\" Copyright (c) 2010 Joseph Koshy
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: dwarf_whatattr.3 3181 2015-04-10 13:22:51Z emaste $
+.\"
+.Dd May 22, 2010
+.Os
+.Dt DWARF_WHATATTR 3
+.Sh NAME
+.Nm dwarf_whatattr
+.Nd retrieve the attribute code for a DWARF attribute
+.Sh LIBRARY
+.Lb libdwarf
+.Sh SYNOPSIS
+.In libdwarf.h
+.Ft int
+.Fo dwarf_whatattr
+.Fa "Dwarf_Attribute attr"
+.Fa "Dwarf_Half *retcode"
+.Fa "Dwarf_Error *err"
+.Fc
+.Sh DESCRIPTION
+Function
+.Fn dwarf_whatattr
+retrieves the attribute code for the DWARF attribute referenced
+by argument
+.Ar attr ,
+and writes it to the location pointed to by argument
+.Ar retcode .
+If argument
+.Ar err
+is not NULL, it will be used to return an error descriptor in case
+of an error.
+.Sh RETURN VALUES
+On success, function
+.Fn dwarf_whatattr
+returns
+.Dv DW_DLV_OK .
+In case of an error, it returns
+.Dv DW_DLV_ERROR
+and sets argument
+.Ar err .
+.Sh ERRORS
+Function
+.Fn dwarf_whatattr
+can fail with the following error:
+.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
+.It Bq Er DW_DLE_ARGUMENT
+Either of argument
+.Va attr
+or
+.Va retcode
+was NULL.
+.El
+.Sh SEE ALSO
+.Xr dwarf 3 ,
+.Xr dwarf_attr 3 ,
+.Xr dwarf_hasattr 3
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf.c
new file mode 100644
index 0000000..b2406cb
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf.c
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf.c 3161 2015-02-15 21:43:36Z emaste $");
+
+struct _libdwarf_globals _libdwarf = {
+ .errhand = NULL,
+ .errarg = NULL,
+ .applyreloc = 1
+};
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf.h b/rtemstoolkit/elftoolchain/libdwarf/libdwarf.h
new file mode 100644
index 0000000..6ec8f99
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf.h
@@ -0,0 +1,841 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2009-2011,2014 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: libdwarf.h 3578 2017-09-14 02:21:28Z emaste $
+ */
+
+#ifndef _LIBDWARF_H_
+#define _LIBDWARF_H_
+
+#include <libelf.h>
+
+typedef int Dwarf_Bool;
+typedef uint64_t Dwarf_Off;
+typedef uint64_t Dwarf_Unsigned;
+typedef uint16_t Dwarf_Half;
+typedef uint8_t Dwarf_Small;
+typedef int64_t Dwarf_Signed;
+typedef uint64_t Dwarf_Addr;
+typedef void *Dwarf_Ptr;
+
+typedef struct _Dwarf_Abbrev *Dwarf_Abbrev;
+typedef struct _Dwarf_Arange *Dwarf_Arange;
+typedef struct _Dwarf_ArangeSet *Dwarf_ArangeSet;
+typedef struct _Dwarf_Attribute *Dwarf_Attribute;
+typedef struct _Dwarf_Attribute *Dwarf_P_Attribute;
+typedef struct _Dwarf_AttrDef *Dwarf_AttrDef;
+typedef struct _Dwarf_Cie *Dwarf_Cie;
+typedef struct _Dwarf_Cie *Dwarf_P_Cie;
+typedef struct _Dwarf_Debug *Dwarf_Debug;
+typedef struct _Dwarf_Debug *Dwarf_P_Debug;
+typedef struct _Dwarf_Die *Dwarf_Die;
+typedef struct _Dwarf_Die *Dwarf_P_Die;
+typedef struct _Dwarf_Fde *Dwarf_Fde;
+typedef struct _Dwarf_Fde *Dwarf_P_Fde;
+typedef struct _Dwarf_FrameSec *Dwarf_FrameSec;
+typedef struct _Dwarf_Line *Dwarf_Line;
+typedef struct _Dwarf_LineFile *Dwarf_LineFile;
+typedef struct _Dwarf_LineInfo *Dwarf_LineInfo;
+typedef struct _Dwarf_MacroSet *Dwarf_MacroSet;
+typedef struct _Dwarf_NamePair *Dwarf_NamePair;
+typedef struct _Dwarf_NamePair *Dwarf_Func;
+typedef struct _Dwarf_NamePair *Dwarf_Global;
+typedef struct _Dwarf_NamePair *Dwarf_Type;
+typedef struct _Dwarf_NamePair *Dwarf_Var;
+typedef struct _Dwarf_NamePair *Dwarf_Weak;
+typedef struct _Dwarf_NameTbl *Dwarf_NameTbl;
+typedef struct _Dwarf_NameSec *Dwarf_NameSec;
+typedef struct _Dwarf_P_Expr *Dwarf_P_Expr;
+typedef struct _Dwarf_Rangelist *Dwarf_Rangelist;
+
+typedef enum {
+ DW_OBJECT_MSB,
+ DW_OBJECT_LSB
+} Dwarf_Endianness;
+
+typedef struct {
+ Dwarf_Addr addr;
+ Dwarf_Unsigned size;
+ const char *name;
+} Dwarf_Obj_Access_Section;
+
+typedef struct {
+ int (*get_section_info)(void *_obj, Dwarf_Half _index,
+ Dwarf_Obj_Access_Section *_ret_section, int *_error);
+ Dwarf_Endianness (*get_byte_order)(void *_obj);
+ Dwarf_Small (*get_length_size)(void *_obj);
+ Dwarf_Small (*get_pointer_size)(void *_obj);
+ Dwarf_Unsigned (*get_section_count)(void *_obj);
+ int (*load_section)(void *_obj, Dwarf_Half _index,
+ Dwarf_Small **_ret_data, int *_error);
+} Dwarf_Obj_Access_Methods;
+
+typedef struct {
+ void *object;
+ const Dwarf_Obj_Access_Methods *methods;
+} Dwarf_Obj_Access_Interface;
+
+typedef int (*Dwarf_Callback_Func)(char *_name, int _size,
+ Dwarf_Unsigned _type, Dwarf_Unsigned _flags, Dwarf_Unsigned _link,
+ Dwarf_Unsigned _info, int *_index, int *_error);
+
+typedef int (*Dwarf_Callback_Func_b)(char *_name, int _size,
+ Dwarf_Unsigned _type, Dwarf_Unsigned _flags, Dwarf_Unsigned _link,
+ Dwarf_Unsigned _info, Dwarf_Unsigned *_index, int *_error);
+
+typedef Dwarf_Unsigned Dwarf_Tag;
+
+typedef struct {
+ Dwarf_Small lr_atom;
+ Dwarf_Unsigned lr_number;
+ Dwarf_Unsigned lr_number2;
+ Dwarf_Unsigned lr_offset;
+} Dwarf_Loc;
+
+typedef struct {
+ Dwarf_Addr ld_lopc;
+ Dwarf_Addr ld_hipc;
+ Dwarf_Half ld_cents;
+ Dwarf_Loc *ld_s;
+} Dwarf_Locdesc;
+
+typedef struct {
+ char signature[8];
+} Dwarf_Sig8;
+
+typedef struct {
+ Dwarf_Unsigned bl_len;
+ Dwarf_Ptr bl_data;
+} Dwarf_Block;
+
+enum Dwarf_Ranges_Entry_Type {
+ DW_RANGES_ENTRY,
+ DW_RANGES_ADDRESS_SELECTION,
+ DW_RANGES_END
+};
+
+typedef struct {
+ Dwarf_Unsigned dwr_addr1;
+ Dwarf_Unsigned dwr_addr2;
+ enum Dwarf_Ranges_Entry_Type dwr_type;
+} Dwarf_Ranges;
+
+enum Dwarf_Form_Class {
+ DW_FORM_CLASS_UNKNOWN,
+ DW_FORM_CLASS_ADDRESS,
+ DW_FORM_CLASS_BLOCK,
+ DW_FORM_CLASS_CONSTANT,
+ DW_FORM_CLASS_EXPRLOC,
+ DW_FORM_CLASS_FLAG,
+ DW_FORM_CLASS_LINEPTR,
+ DW_FORM_CLASS_LOCLISTPTR,
+ DW_FORM_CLASS_MACPTR,
+ DW_FORM_CLASS_RANGELISTPTR,
+ DW_FORM_CLASS_REFERENCE,
+ DW_FORM_CLASS_STRING
+};
+
+#ifndef DW_FRAME_HIGHEST_NORMAL_REGISTER
+#define DW_FRAME_HIGHEST_NORMAL_REGISTER 63
+#endif
+
+#define DW_FRAME_RA_COL (DW_FRAME_HIGHEST_NORMAL_REGISTER + 1)
+#define DW_FRAME_STATIC_LINK (DW_FRAME_HIGHEST_NORMAL_REGISTER + 2)
+
+#ifndef DW_FRAME_LAST_REG_NUM
+#define DW_FRAME_LAST_REG_NUM (DW_FRAME_HIGHEST_NORMAL_REGISTER + 3)
+#endif
+
+#ifndef DW_FRAME_REG_INITIAL_VALUE
+#define DW_FRAME_REG_INITIAL_VALUE DW_FRAME_SAME_VAL
+#endif
+
+#define DW_FRAME_UNDEFINED_VAL 1034
+#define DW_FRAME_SAME_VAL 1035
+#define DW_FRAME_CFA_COL3 1436
+
+#define DW_EXPR_OFFSET 0
+#define DW_EXPR_VAL_OFFSET 1
+#define DW_EXPR_EXPRESSION 2
+#define DW_EXPR_VAL_EXPRESSION 3
+
+/*
+ * Frame operation only for DWARF 2.
+ */
+
+#define DW_FRAME_CFA_COL 0
+
+typedef struct {
+ Dwarf_Small fp_base_op;
+ Dwarf_Small fp_extended_op;
+ Dwarf_Half fp_register;
+ Dwarf_Signed fp_offset;
+ Dwarf_Off fp_instr_offset;
+} Dwarf_Frame_Op;
+
+#ifndef DW_REG_TABLE_SIZE
+#define DW_REG_TABLE_SIZE 66
+#endif
+
+typedef struct {
+ struct {
+ Dwarf_Small dw_offset_relevant;
+ Dwarf_Half dw_regnum;
+ Dwarf_Addr dw_offset;
+ } rules[DW_REG_TABLE_SIZE];
+} Dwarf_Regtable;
+
+/*
+ * Frame operation for DWARF 3 and DWARF 2.
+ */
+
+typedef struct {
+ Dwarf_Small fp_base_op;
+ Dwarf_Small fp_extended_op;
+ Dwarf_Half fp_register;
+ Dwarf_Unsigned fp_offset_or_block_len;
+ Dwarf_Small *fp_expr_block;
+ Dwarf_Off fp_instr_offset;
+} Dwarf_Frame_Op3;
+
+typedef struct {
+ Dwarf_Small dw_offset_relevant;
+ Dwarf_Small dw_value_type;
+ Dwarf_Half dw_regnum;
+ Dwarf_Unsigned dw_offset_or_block_len;
+ Dwarf_Ptr dw_block_ptr;
+} Dwarf_Regtable_Entry3;
+
+typedef struct {
+ Dwarf_Regtable_Entry3 rt3_cfa_rule;
+ Dwarf_Half rt3_reg_table_size;
+ Dwarf_Regtable_Entry3 *rt3_rules;
+} Dwarf_Regtable3;
+
+typedef struct {
+ Dwarf_Off dmd_offset;
+ Dwarf_Small dmd_type;
+ Dwarf_Signed dmd_lineno;
+ Dwarf_Signed dmd_fileindex;
+ char *dmd_macro;
+} Dwarf_Macro_Details;
+
+/*
+ * Symbols denoting allocation types, for use with dwarf_dealloc(3).
+ */
+
+enum Dwarf_Allocation_Type {
+ DW_DLA_ABBREV,
+ DW_DLA_ADDR,
+ DW_DLA_ARANGE,
+ DW_DLA_ATTR,
+ DW_DLA_BLOCK,
+ DW_DLA_BOUNDS,
+ DW_DLA_CIE,
+ DW_DLA_DEBUG,
+ DW_DLA_DIE,
+ DW_DLA_ELLIST,
+ DW_DLA_ERROR,
+ DW_DLA_FDE,
+ DW_DLA_FRAME_BLOCK,
+ DW_DLA_FRAME_OP,
+ DW_DLA_FUNC,
+ DW_DLA_GLOBAL,
+ DW_DLA_LINE,
+ DW_DLA_LINEBUF,
+ DW_DLA_LIST,
+ DW_DLA_LOC,
+ DW_DLA_LOCDESC,
+ DW_DLA_LOC_BLOCK,
+ DW_DLA_RANGES,
+ DW_DLA_STRING,
+ DW_DLA_SUBSCR,
+ DW_DLA_TYPE,
+ DW_DLA_TYPENAME,
+ DW_DLA_VAR,
+ DW_DLA_WEAK
+};
+
+/*
+ * Relocation Type.
+ */
+enum Dwarf_Rel_Type {
+ dwarf_drt_none = 0,
+ dwarf_drt_data_reloc,
+ dwarf_drt_segment_rel,
+ dwarf_drt_first_of_length_pair,
+ dwarf_drt_second_of_length_pair
+};
+
+/*
+ * Relocation Entry.
+ */
+typedef struct Dwarf_Relocation_Data_s {
+ unsigned char drd_type;
+ unsigned char drd_length;
+ Dwarf_Unsigned drd_offset;
+ Dwarf_Unsigned drd_symbol_index;
+} *Dwarf_Relocation_Data;
+
+#define DWARF_DRD_BUFFER_VERSION 2
+
+/*
+ * Error numbers which are specific to this implementation.
+ */
+enum {
+ DW_DLE_NONE, /* No error. */
+ DW_DLE_ERROR, /* An error! */
+ DW_DLE_ARGUMENT, /* Invalid argument. */
+ DW_DLE_DEBUG_INFO_NULL, /* Debug info NULL. */
+ DW_DLE_NO_ENTRY, /* No entry. */
+ DW_DLE_MEMORY, /* Insufficient memory. */
+ DW_DLE_ELF, /* ELF error. */
+ DW_DLE_CU_LENGTH_ERROR, /* Invalid compilation unit data. */
+ DW_DLE_VERSION_STAMP_ERROR, /* Invalid version. */
+ DW_DLE_DEBUG_ABBREV_NULL, /* Abbrev not found. */
+ DW_DLE_DIE_NO_CU_CONTEXT, /* No current compilation unit. */
+ DW_DLE_LOC_EXPR_BAD, /* Invalid location expression. */
+ DW_DLE_EXPR_LENGTH_BAD, /* Invalid DWARF expression. */
+ DW_DLE_DEBUG_LOC_SECTION_SHORT, /* Loclist section too short. */
+ DW_DLE_ATTR_FORM_BAD, /* Invalid attribute form. */
+ DW_DLE_DEBUG_LINE_LENGTH_BAD, /* Line info section too short. */
+ DW_DLE_LINE_FILE_NUM_BAD, /* Invalid file number. */
+ DW_DLE_DIR_INDEX_BAD, /* Invalid dir index. */
+ DW_DLE_DEBUG_FRAME_LENGTH_BAD, /* Frame section too short. */
+ DW_DLE_NO_CIE_FOR_FDE, /* CIE not found for certain FDE. */
+ DW_DLE_FRAME_AUGMENTATION_UNKNOWN, /* Unknown CIE augmentation. */
+ DW_DLE_FRAME_INSTR_EXEC_ERROR, /* Frame instruction exec error. */
+ DW_DLE_FRAME_VERSION_BAD, /* Invalid frame section version. */
+ DW_DLE_FRAME_TABLE_COL_BAD, /* Invalid table column. */
+ DW_DLE_DF_REG_NUM_TOO_HIGH, /* Insufficient regtable space. */
+ DW_DLE_PC_NOT_IN_FDE_RANGE, /* PC requested not in the FDE range. */
+ DW_DLE_ARANGE_OFFSET_BAD, /* Invalid arange offset. */
+ DW_DLE_DEBUG_MACRO_INCONSISTENT,/* Invalid macinfo data. */
+ DW_DLE_ELF_SECT_ERR, /* Application callback failed. */
+ DW_DLE_NUM /* Max error number. */
+};
+
+/*
+ * Mapping of SGI libdwarf error codes for comptibility.
+ */
+#define DW_DLE_DBG_ALLOC DW_DLE_MEMORY
+#define DW_DLE_ALLOC_FAIL DW_DLE_MEMORY
+#define DW_DLE_SECT_ALLOC DW_DLE_MEMORY
+#define DW_DLE_FILE_ENTRY_ALLOC DW_DLE_MEMORY
+#define DW_DLE_LINE_ALLOC DW_DLE_MEMORY
+#define DW_DLE_FPGM_ALLOC DW_DLE_MEMORY
+#define DW_DLE_INCDIR_ALLOC DW_DLE_MEMORY
+#define DW_DLE_STRING_ALLOC DW_DLE_MEMORY
+#define DW_DLE_CHUNK_ALLOC DW_DLE_MEMORY
+#define DW_DLE_CIE_ALLOC DW_DLE_MEMORY
+#define DW_DLE_FDE_ALLOC DW_DLE_MEMORY
+#define DW_DLE_CIE_OFFS_ALLOC DW_DLE_MEMORY
+#define DW_DLE_DIE_ALLOC DW_DLE_MEMORY
+#define DW_DLE_ATTR_ALLOC DW_DLE_MEMORY
+#define DW_DLE_ABBREV_ALLOC DW_DLE_MEMORY
+#define DW_DLE_ADDR_ALLOC DW_DLE_MEMORY
+#define DW_DLE_REL_ALLOC DW_DLE_MEMORY
+#define DW_DLE_MACINFO_MALLOC_FAIL DW_DLE_MEMORY
+#define DW_DLE_DEBUG_MACRO_MALLOC_SPACE DW_DLE_MEMORY
+#define DW_DLE_DF_ALLOC_FAIL DW_DLE_MEMORY
+#define DW_DLE_RELOC_SECTION_MALLOC_FAIL DW_DLE_MEMORY
+#define DW_DLE_DBG_NULL DW_DLE_ARGUMENT
+#define DW_DLE_DIE_NULL DW_DLE_ARGUMENT
+#define DW_DLE_FDE_NULL DW_DLE_ARGUMENT
+#define DW_DLE_CIE_NULL DW_DLE_ARGUMENT
+#define DW_DLE_ATTR_NULL DW_DLE_ARGUMENT
+#define DW_DLE_GLOBAL_NULL DW_DLE_ARGUMENT
+#define DW_DLE_ARANGES_NULL DW_DLE_ARGUMENT
+#define DW_DLE_ARANGE_NULL DW_DLE_ARGUMENT
+#define DW_DLE_EXPR_NULL DW_DLE_ARGUMENT
+#define DW_DLE_FUNC_NULL DW_DLE_ARGUMENT
+#define DW_DLE_TYPE_NULL DW_DLE_ARGUMENT
+#define DW_DLE_VAR_NULL DW_DLE_ARGUMENT
+#define DW_DLE_WEAK_NULL DW_DLE_ARGUMENT
+#define DW_DLE_ELF_BEGIN_ERROR DW_DLE_ELF
+#define DW_DLE_ELF_GETEHDR_ERROR DW_DLE_ELF
+#define DW_DLE_ELF_GETSHDR_ERROR DW_DLE_ELF
+#define DW_DLE_ELF_STRPTR_ERROR DW_DLE_ELF
+#define DW_DLE_ELF_SECT_ERROR DW_DLE_ELF
+#define DW_DLE_ELF_GETIDENT_ERROR DW_DLE_ELF
+
+typedef struct _Dwarf_Error {
+ int err_error; /* DWARF error. */
+ int err_elferror; /* ELF error. */
+ const char *err_func; /* Function name where error occurred. */
+ int err_line; /* Line number where error occurred. */
+ char err_msg[1024]; /* Formatted error message. */
+} Dwarf_Error;
+
+/*
+ * Dwarf error handler.
+ */
+typedef void (*Dwarf_Handler)(Dwarf_Error, Dwarf_Ptr);
+
+#define dwarf_errno(error) error.err_error
+#define dwarf_errmsg(error) dwarf_errmsg_(&error)
+
+/*
+ * Return values which have to be compatible with other
+ * implementations of libdwarf.
+ */
+#define DW_DLV_NO_ENTRY -1
+#define DW_DLV_OK 0
+#define DW_DLV_ERROR 1
+#define DW_DLV_BADADDR NULL
+#define DW_DLV_NOCOUNT ((Dwarf_Signed) -1)
+
+/*
+ * Access modes.
+ */
+#define DW_DLC_READ 0x0001
+#define DW_DLC_WRITE 0x0002
+#define DW_DLC_RDWR 0x0004
+
+/*
+ * Flags used by libdwarf producer.
+ */
+#define DW_DLC_SIZE_64 0x40000000
+#define DW_DLC_SIZE_32 0x20000000
+#define DW_DLC_OFFSET_SIZE_64 0x10000000
+#define DW_DLC_ISA_MIPS 0x80000000
+#define DW_DLC_ISA_IA64 0x01000000
+#define DW_DLC_STREAM_RELOCATIONS 0x02000000
+#define DW_DLC_SYMBOLIC_RELOCATIONS 0x04000000
+#define DW_DLC_TARGET_BIGENDIAN 0x08000000
+#define DW_DLC_TARGET_LITTLEENDIAN 0x00100000
+
+/*
+ * Instruction set architectures supported by this implementation.
+ */
+enum Dwarf_ISA {
+ DW_ISA_ARM,
+ DW_ISA_IA64,
+ DW_ISA_MIPS,
+ DW_ISA_PPC,
+ DW_ISA_SPARC,
+ DW_ISA_X86,
+ DW_ISA_X86_64,
+ DW_ISA_AARCH64,
+ DW_ISA_RISCV,
+ DW_ISA_MAX
+};
+
+/* Function prototype definitions. */
+#ifdef __cplusplus
+extern "C" {
+#endif
+Dwarf_P_Attribute dwarf_add_AT_comp_dir(Dwarf_P_Die, char *, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_const_value_signedint(Dwarf_P_Die, Dwarf_Signed,
+ Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_const_value_string(Dwarf_P_Die, char *,
+ Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_const_value_unsignedint(Dwarf_P_Die,
+ Dwarf_Unsigned, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_dataref(Dwarf_P_Debug, Dwarf_P_Die, Dwarf_Half,
+ Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_flag(Dwarf_P_Debug, Dwarf_P_Die, Dwarf_Half,
+ Dwarf_Small, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_location_expr(Dwarf_P_Debug, Dwarf_P_Die,
+ Dwarf_Half, Dwarf_P_Expr, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_name(Dwarf_P_Die, char *, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_producer(Dwarf_P_Die, char *, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_ref_address(Dwarf_P_Debug, Dwarf_P_Die,
+ Dwarf_Half, Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_reference(Dwarf_P_Debug, Dwarf_P_Die, Dwarf_Half,
+ Dwarf_P_Die, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_signed_const(Dwarf_P_Debug, Dwarf_P_Die,
+ Dwarf_Half, Dwarf_Signed, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_string(Dwarf_P_Debug, Dwarf_P_Die, Dwarf_Half,
+ char *, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_targ_address(Dwarf_P_Debug, Dwarf_P_Die,
+ Dwarf_Half, Dwarf_Unsigned, Dwarf_Signed, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_targ_address_b(Dwarf_P_Debug, Dwarf_P_Die,
+ Dwarf_Half, Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Error *);
+Dwarf_P_Attribute dwarf_add_AT_unsigned_const(Dwarf_P_Debug, Dwarf_P_Die,
+ Dwarf_Half, Dwarf_Unsigned, Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_arange(Dwarf_P_Debug, Dwarf_Addr, Dwarf_Unsigned,
+ Dwarf_Signed, Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_arange_b(Dwarf_P_Debug, Dwarf_Addr, Dwarf_Unsigned,
+ Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Addr, Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_die_to_debug(Dwarf_P_Debug, Dwarf_P_Die,
+ Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_directory_decl(Dwarf_P_Debug, char *, Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_expr_addr(Dwarf_P_Expr, Dwarf_Unsigned,
+ Dwarf_Signed, Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_expr_addr_b(Dwarf_P_Expr, Dwarf_Unsigned,
+ Dwarf_Unsigned, Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_expr_gen(Dwarf_P_Expr, Dwarf_Small, Dwarf_Unsigned,
+ Dwarf_Unsigned, Dwarf_Error *);
+Dwarf_P_Fde dwarf_add_fde_inst(Dwarf_P_Fde, Dwarf_Small, Dwarf_Unsigned,
+ Dwarf_Unsigned, Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_file_decl(Dwarf_P_Debug, char *, Dwarf_Unsigned,
+ Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_frame_cie(Dwarf_P_Debug, char *, Dwarf_Small,
+ Dwarf_Small, Dwarf_Small, Dwarf_Ptr, Dwarf_Unsigned,
+ Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_frame_fde(Dwarf_P_Debug, Dwarf_P_Fde, Dwarf_P_Die,
+ Dwarf_Unsigned, Dwarf_Addr, Dwarf_Unsigned, Dwarf_Unsigned,
+ Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_frame_fde_b(Dwarf_P_Debug, Dwarf_P_Fde, Dwarf_P_Die,
+ Dwarf_Unsigned, Dwarf_Addr, Dwarf_Unsigned, Dwarf_Unsigned,
+ Dwarf_Unsigned, Dwarf_Addr, Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_funcname(Dwarf_P_Debug, Dwarf_P_Die, char *,
+ Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_line_entry(Dwarf_P_Debug, Dwarf_Unsigned,
+ Dwarf_Addr, Dwarf_Unsigned, Dwarf_Signed, Dwarf_Bool,
+ Dwarf_Bool, Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_pubname(Dwarf_P_Debug, Dwarf_P_Die, char *,
+ Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_typename(Dwarf_P_Debug, Dwarf_P_Die, char *,
+ Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_varname(Dwarf_P_Debug, Dwarf_P_Die, char *,
+ Dwarf_Error *);
+Dwarf_Unsigned dwarf_add_weakname(Dwarf_P_Debug, Dwarf_P_Die, char *,
+ Dwarf_Error *);
+int dwarf_arrayorder(Dwarf_Die, Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_attr(Dwarf_Die, Dwarf_Half, Dwarf_Attribute *,
+ Dwarf_Error *);
+int dwarf_attrlist(Dwarf_Die, Dwarf_Attribute **,
+ Dwarf_Signed *, Dwarf_Error *);
+int dwarf_attroffset(Dwarf_Attribute, Dwarf_Off *, Dwarf_Error *);
+int dwarf_attrval_flag(Dwarf_Die, Dwarf_Half, Dwarf_Bool *,
+ Dwarf_Error *);
+int dwarf_attrval_signed(Dwarf_Die, Dwarf_Half, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_attrval_string(Dwarf_Die, Dwarf_Half, const char **,
+ Dwarf_Error *);
+int dwarf_attrval_unsigned(Dwarf_Die, Dwarf_Half, Dwarf_Unsigned *,
+ Dwarf_Error *);
+int dwarf_bitoffset(Dwarf_Die, Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_bitsize(Dwarf_Die, Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_bytesize(Dwarf_Die, Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_child(Dwarf_Die, Dwarf_Die *, Dwarf_Error *);
+void dwarf_dealloc(Dwarf_Debug, Dwarf_Ptr, Dwarf_Unsigned);
+int dwarf_def_macro(Dwarf_P_Debug, Dwarf_Unsigned, char *, char *,
+ Dwarf_Error *);
+int dwarf_die_CU_offset(Dwarf_Die, Dwarf_Off *, Dwarf_Error *);
+int dwarf_die_CU_offset_range(Dwarf_Die, Dwarf_Off *, Dwarf_Off *,
+ Dwarf_Error *);
+int dwarf_die_abbrev_code(Dwarf_Die);
+Dwarf_P_Die dwarf_die_link(Dwarf_P_Die, Dwarf_P_Die, Dwarf_P_Die,
+ Dwarf_P_Die, Dwarf_P_Die, Dwarf_Error *);
+int dwarf_diename(Dwarf_Die, char **, Dwarf_Error *);
+int dwarf_dieoffset(Dwarf_Die, Dwarf_Off *, Dwarf_Error *);
+int dwarf_elf_init(Elf *, int, Dwarf_Handler, Dwarf_Ptr,
+ Dwarf_Debug *, Dwarf_Error *);
+int dwarf_end_macro_file(Dwarf_P_Debug, Dwarf_Error *);
+const char *dwarf_errmsg_(Dwarf_Error *);
+int dwarf_expand_frame_instructions(Dwarf_Cie, Dwarf_Ptr,
+ Dwarf_Unsigned, Dwarf_Frame_Op **, Dwarf_Signed *,
+ Dwarf_Error *);
+Dwarf_Unsigned dwarf_expr_current_offset(Dwarf_P_Expr, Dwarf_Error *);
+Dwarf_Addr dwarf_expr_into_block(Dwarf_P_Expr, Dwarf_Unsigned *,
+ Dwarf_Error *);
+Dwarf_P_Fde dwarf_fde_cfa_offset(Dwarf_P_Fde, Dwarf_Unsigned, Dwarf_Signed,
+ Dwarf_Error *);
+void dwarf_fde_cie_list_dealloc(Dwarf_Debug, Dwarf_Cie *,
+ Dwarf_Signed, Dwarf_Fde *, Dwarf_Signed);
+char *dwarf_find_macro_value_start(char *);
+int dwarf_finish(Dwarf_Debug, Dwarf_Error *);
+int dwarf_formaddr(Dwarf_Attribute, Dwarf_Addr *, Dwarf_Error *);
+int dwarf_formblock(Dwarf_Attribute, Dwarf_Block **, Dwarf_Error *);
+int dwarf_formexprloc(Dwarf_Attribute, Dwarf_Unsigned *,
+ Dwarf_Ptr *, Dwarf_Error *);
+int dwarf_formflag(Dwarf_Attribute, Dwarf_Bool *, Dwarf_Error *);
+int dwarf_formref(Dwarf_Attribute, Dwarf_Off *, Dwarf_Error *);
+int dwarf_formsdata(Dwarf_Attribute, Dwarf_Signed *, Dwarf_Error *);
+int dwarf_formsig8(Dwarf_Attribute, Dwarf_Sig8 *, Dwarf_Error *);
+int dwarf_formstring(Dwarf_Attribute, char **, Dwarf_Error *);
+int dwarf_formudata(Dwarf_Attribute, Dwarf_Unsigned *,
+ Dwarf_Error *);
+int dwarf_func_cu_offset(Dwarf_Func, Dwarf_Off *, Dwarf_Error *);
+int dwarf_func_die_offset(Dwarf_Func, Dwarf_Off *,
+ Dwarf_Error *);
+int dwarf_func_name_offsets(Dwarf_Func, char **,
+ Dwarf_Off *, Dwarf_Off *, Dwarf_Error *);
+int dwarf_funcname(Dwarf_Func, char **, Dwarf_Error *);
+void dwarf_funcs_dealloc(Dwarf_Debug, Dwarf_Func *, Dwarf_Signed);
+int dwarf_get_ACCESS_name(unsigned, const char **);
+int dwarf_get_ATE_name(unsigned, const char **);
+int dwarf_get_AT_name(unsigned, const char **);
+int dwarf_get_CC_name(unsigned, const char **);
+int dwarf_get_CFA_name(unsigned, const char **);
+int dwarf_get_CHILDREN_name(unsigned, const char **);
+int dwarf_get_DSC_name(unsigned, const char **);
+int dwarf_get_DS_name(unsigned, const char **);
+int dwarf_get_EH_name(unsigned, const char **);
+int dwarf_get_END_name(unsigned, const char **);
+int dwarf_get_FORM_name(unsigned, const char **);
+int dwarf_get_ID_name(unsigned, const char **);
+int dwarf_get_INL_name(unsigned, const char **);
+int dwarf_get_LANG_name(unsigned, const char **);
+int dwarf_get_LNE_name(unsigned, const char **);
+int dwarf_get_LNS_name(unsigned, const char **);
+int dwarf_get_MACINFO_name(unsigned, const char **);
+int dwarf_get_OP_name(unsigned, const char **);
+int dwarf_get_ORD_name(unsigned, const char **);
+int dwarf_get_TAG_name(unsigned, const char **);
+int dwarf_get_VIRTUALITY_name(unsigned, const char **);
+int dwarf_get_VIS_name(unsigned, const char **);
+int dwarf_get_abbrev(Dwarf_Debug, Dwarf_Unsigned, Dwarf_Abbrev *,
+ Dwarf_Unsigned *, Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_get_abbrev_children_flag(Dwarf_Abbrev, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_get_abbrev_code(Dwarf_Abbrev, Dwarf_Unsigned *,
+ Dwarf_Error *);
+int dwarf_get_abbrev_entry(Dwarf_Abbrev, Dwarf_Signed, Dwarf_Half *,
+ Dwarf_Signed *, Dwarf_Off *, Dwarf_Error *);
+int dwarf_get_abbrev_tag(Dwarf_Abbrev, Dwarf_Half *, Dwarf_Error *);
+int dwarf_get_address_size(Dwarf_Debug, Dwarf_Half *,
+ Dwarf_Error *);
+int dwarf_get_arange(Dwarf_Arange *, Dwarf_Unsigned, Dwarf_Addr,
+ Dwarf_Arange *, Dwarf_Error *);
+int dwarf_get_arange_cu_header_offset(Dwarf_Arange, Dwarf_Off *,
+ Dwarf_Error *);
+int dwarf_get_arange_info(Dwarf_Arange, Dwarf_Addr *,
+ Dwarf_Unsigned *, Dwarf_Off *, Dwarf_Error *);
+int dwarf_get_aranges(Dwarf_Debug, Dwarf_Arange **, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_get_cie_index(Dwarf_Cie, Dwarf_Signed *, Dwarf_Error *);
+int dwarf_get_cie_info(Dwarf_Cie, Dwarf_Unsigned *, Dwarf_Small *,
+ char **, Dwarf_Unsigned *, Dwarf_Unsigned *, Dwarf_Half *,
+ Dwarf_Ptr *, Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_get_cie_of_fde(Dwarf_Fde, Dwarf_Cie *, Dwarf_Error *);
+int dwarf_get_cu_die_offset(Dwarf_Arange, Dwarf_Off *,
+ Dwarf_Error *);
+int dwarf_get_cu_die_offset_given_cu_header_offset(Dwarf_Debug,
+ Dwarf_Off, Dwarf_Off *, Dwarf_Error *);
+int dwarf_get_cu_die_offset_given_cu_header_offset_b(Dwarf_Debug,
+ Dwarf_Off, Dwarf_Bool, Dwarf_Off *, Dwarf_Error *);
+Dwarf_Bool dwarf_get_die_infotypes_flag(Dwarf_Die);
+int dwarf_get_elf(Dwarf_Debug, Elf **, Dwarf_Error *);
+int dwarf_get_fde_at_pc(Dwarf_Fde *, Dwarf_Addr, Dwarf_Fde *,
+ Dwarf_Addr *, Dwarf_Addr *, Dwarf_Error *);
+int dwarf_get_fde_info_for_all_regs(Dwarf_Fde, Dwarf_Addr,
+ Dwarf_Regtable *, Dwarf_Addr *, Dwarf_Error *);
+int dwarf_get_fde_info_for_all_regs3(Dwarf_Fde, Dwarf_Addr,
+ Dwarf_Regtable3 *, Dwarf_Addr *, Dwarf_Error *);
+int dwarf_get_fde_info_for_cfa_reg3(Dwarf_Fde, Dwarf_Addr,
+ Dwarf_Small *, Dwarf_Signed *, Dwarf_Signed *, Dwarf_Signed *,
+ Dwarf_Ptr *, Dwarf_Addr *, Dwarf_Error *);
+int dwarf_get_fde_info_for_reg(Dwarf_Fde, Dwarf_Half, Dwarf_Addr,
+ Dwarf_Signed *, Dwarf_Signed *, Dwarf_Signed *,
+ Dwarf_Addr *, Dwarf_Error *);
+int dwarf_get_fde_info_for_reg3(Dwarf_Fde, Dwarf_Half, Dwarf_Addr,
+ Dwarf_Small *, Dwarf_Signed *, Dwarf_Signed *,
+ Dwarf_Signed *, Dwarf_Ptr *, Dwarf_Addr *, Dwarf_Error *);
+int dwarf_get_fde_instr_bytes(Dwarf_Fde, Dwarf_Ptr *,
+ Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_get_fde_list(Dwarf_Debug, Dwarf_Cie **, Dwarf_Signed *,
+ Dwarf_Fde **, Dwarf_Signed *, Dwarf_Error *);
+int dwarf_get_fde_list_eh(Dwarf_Debug, Dwarf_Cie **, Dwarf_Signed *,
+ Dwarf_Fde **, Dwarf_Signed *, Dwarf_Error *);
+int dwarf_get_fde_n(Dwarf_Fde *, Dwarf_Unsigned, Dwarf_Fde *,
+ Dwarf_Error *);
+int dwarf_get_fde_range(Dwarf_Fde, Dwarf_Addr *, Dwarf_Unsigned *,
+ Dwarf_Ptr *, Dwarf_Unsigned *, Dwarf_Off *, Dwarf_Signed *,
+ Dwarf_Off *, Dwarf_Error *);
+enum Dwarf_Form_Class dwarf_get_form_class(Dwarf_Half, Dwarf_Half, Dwarf_Half,
+ Dwarf_Half);
+int dwarf_get_funcs(Dwarf_Debug, Dwarf_Func **, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_get_globals(Dwarf_Debug, Dwarf_Global **, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_get_loclist_entry(Dwarf_Debug, Dwarf_Unsigned,
+ Dwarf_Addr *, Dwarf_Addr *, Dwarf_Ptr *, Dwarf_Unsigned *,
+ Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_get_macro_details(Dwarf_Debug, Dwarf_Off, Dwarf_Unsigned,
+ Dwarf_Signed *, Dwarf_Macro_Details **, Dwarf_Error *);
+int dwarf_get_pubtypes(Dwarf_Debug, Dwarf_Type **, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_get_ranges(Dwarf_Debug, Dwarf_Off, Dwarf_Ranges **,
+ Dwarf_Signed *, Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_get_ranges_a(Dwarf_Debug, Dwarf_Off, Dwarf_Die,
+ Dwarf_Ranges **, Dwarf_Signed *, Dwarf_Unsigned *,
+ Dwarf_Error *);
+int dwarf_get_relocation_info(Dwarf_P_Debug, Dwarf_Signed *,
+ Dwarf_Signed *, Dwarf_Unsigned *, Dwarf_Relocation_Data *,
+ Dwarf_Error *);
+int dwarf_get_relocation_info_count(Dwarf_P_Debug, Dwarf_Unsigned *,
+ int *, Dwarf_Error *);
+Dwarf_Ptr dwarf_get_section_bytes(Dwarf_P_Debug, Dwarf_Signed,
+ Dwarf_Signed *, Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_get_section_max_offsets(Dwarf_Debug, Dwarf_Unsigned *,
+ Dwarf_Unsigned *, Dwarf_Unsigned *, Dwarf_Unsigned *,
+ Dwarf_Unsigned *, Dwarf_Unsigned *, Dwarf_Unsigned *,
+ Dwarf_Unsigned *, Dwarf_Unsigned *, Dwarf_Unsigned *,
+ Dwarf_Unsigned *);
+int dwarf_get_section_max_offsets_b(Dwarf_Debug, Dwarf_Unsigned *,
+ Dwarf_Unsigned *, Dwarf_Unsigned *, Dwarf_Unsigned *,
+ Dwarf_Unsigned *, Dwarf_Unsigned *, Dwarf_Unsigned *,
+ Dwarf_Unsigned *, Dwarf_Unsigned *, Dwarf_Unsigned *,
+ Dwarf_Unsigned *, Dwarf_Unsigned *);
+int dwarf_get_str(Dwarf_Debug, Dwarf_Off, char **, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_get_types(Dwarf_Debug, Dwarf_Type **, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_get_vars(Dwarf_Debug, Dwarf_Var **, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_get_weaks(Dwarf_Debug, Dwarf_Weak **, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_global_cu_offset(Dwarf_Global, Dwarf_Off *, Dwarf_Error *);
+int dwarf_global_die_offset(Dwarf_Global, Dwarf_Off *,
+ Dwarf_Error *);
+int dwarf_global_formref(Dwarf_Attribute, Dwarf_Off *,
+ Dwarf_Error *);
+int dwarf_global_name_offsets(Dwarf_Global, char **,
+ Dwarf_Off *, Dwarf_Off *, Dwarf_Error *);
+void dwarf_globals_dealloc(Dwarf_Debug, Dwarf_Global *, Dwarf_Signed);
+int dwarf_globname(Dwarf_Global, char **, Dwarf_Error *);
+int dwarf_hasattr(Dwarf_Die, Dwarf_Half, Dwarf_Bool *,
+ Dwarf_Error *);
+int dwarf_hasform(Dwarf_Attribute, Dwarf_Half, Dwarf_Bool *,
+ Dwarf_Error *);
+int dwarf_highpc(Dwarf_Die, Dwarf_Addr *, Dwarf_Error *);
+int dwarf_highpc_b(Dwarf_Die, Dwarf_Addr *, Dwarf_Half *,
+ enum Dwarf_Form_Class *, Dwarf_Error *);
+int dwarf_init(int, int, Dwarf_Handler, Dwarf_Ptr, Dwarf_Debug *,
+ Dwarf_Error *);
+int dwarf_line_srcfileno(Dwarf_Line, Dwarf_Unsigned *,
+ Dwarf_Error *);
+int dwarf_lineaddr(Dwarf_Line, Dwarf_Addr *, Dwarf_Error *);
+int dwarf_linebeginstatement(Dwarf_Line, Dwarf_Bool *,
+ Dwarf_Error *);
+int dwarf_lineblock(Dwarf_Line, Dwarf_Bool *, Dwarf_Error *);
+int dwarf_lineendsequence(Dwarf_Line, Dwarf_Bool *, Dwarf_Error *);
+int dwarf_lineno(Dwarf_Line, Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_lineoff(Dwarf_Line, Dwarf_Signed *, Dwarf_Error *);
+int dwarf_linesrc(Dwarf_Line, char **, Dwarf_Error *);
+Dwarf_Unsigned dwarf_lne_end_sequence(Dwarf_P_Debug, Dwarf_Addr, Dwarf_Error *);
+Dwarf_Unsigned dwarf_lne_set_address(Dwarf_P_Debug, Dwarf_Addr, Dwarf_Unsigned,
+ Dwarf_Error *);
+int dwarf_loclist(Dwarf_Attribute, Dwarf_Locdesc **, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_loclist_from_expr(Dwarf_Debug, Dwarf_Ptr, Dwarf_Unsigned,
+ Dwarf_Locdesc **, Dwarf_Signed *, Dwarf_Error *);
+int dwarf_loclist_from_expr_a(Dwarf_Debug, Dwarf_Ptr,
+ Dwarf_Unsigned, Dwarf_Half, Dwarf_Locdesc **,
+ Dwarf_Signed *, Dwarf_Error *);
+int dwarf_loclist_from_expr_b(Dwarf_Debug, Dwarf_Ptr,
+ Dwarf_Unsigned, Dwarf_Half, Dwarf_Half,
+ Dwarf_Small, Dwarf_Locdesc **, Dwarf_Signed *,
+ Dwarf_Error *);
+int dwarf_loclist_n(Dwarf_Attribute, Dwarf_Locdesc ***,
+ Dwarf_Signed *, Dwarf_Error *);
+int dwarf_lowpc(Dwarf_Die, Dwarf_Addr *, Dwarf_Error *);
+Dwarf_P_Die dwarf_new_die(Dwarf_P_Debug, Dwarf_Tag, Dwarf_P_Die,
+ Dwarf_P_Die, Dwarf_P_Die, Dwarf_P_Die, Dwarf_Error *);
+Dwarf_P_Expr dwarf_new_expr(Dwarf_P_Debug, Dwarf_Error *);
+Dwarf_P_Fde dwarf_new_fde(Dwarf_P_Debug, Dwarf_Error *);
+int dwarf_next_cu_header(Dwarf_Debug, Dwarf_Unsigned *,
+ Dwarf_Half *, Dwarf_Off *, Dwarf_Half *,
+ Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_next_cu_header_b(Dwarf_Debug, Dwarf_Unsigned *,
+ Dwarf_Half *, Dwarf_Off *, Dwarf_Half *, Dwarf_Half *,
+ Dwarf_Half *, Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_next_cu_header_c(Dwarf_Debug, Dwarf_Bool,
+ Dwarf_Unsigned *, Dwarf_Half *, Dwarf_Off *, Dwarf_Half *,
+ Dwarf_Half *, Dwarf_Half *, Dwarf_Sig8 *, Dwarf_Unsigned *,
+ Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_next_types_section(Dwarf_Debug, Dwarf_Error *);
+int dwarf_object_finish(Dwarf_Debug, Dwarf_Error *);
+int dwarf_object_init(Dwarf_Obj_Access_Interface *, Dwarf_Handler,
+ Dwarf_Ptr, Dwarf_Debug *, Dwarf_Error *);
+int dwarf_offdie(Dwarf_Debug, Dwarf_Off, Dwarf_Die *,
+ Dwarf_Error *);
+int dwarf_offdie_b(Dwarf_Debug, Dwarf_Off, Dwarf_Bool, Dwarf_Die *,
+ Dwarf_Error *);
+Dwarf_Unsigned dwarf_producer_finish(Dwarf_P_Debug, Dwarf_Error *);
+Dwarf_P_Debug dwarf_producer_init(Dwarf_Unsigned, Dwarf_Callback_Func,
+ Dwarf_Handler, Dwarf_Ptr, Dwarf_Error *);
+Dwarf_P_Debug dwarf_producer_init_b(Dwarf_Unsigned, Dwarf_Callback_Func_b,
+ Dwarf_Handler, Dwarf_Ptr, Dwarf_Error *);
+int dwarf_producer_set_isa(Dwarf_P_Debug, enum Dwarf_ISA,
+ Dwarf_Error *);
+int dwarf_pubtype_cu_offset(Dwarf_Type, Dwarf_Off *, Dwarf_Error *);
+int dwarf_pubtype_die_offset(Dwarf_Type, Dwarf_Off *,
+ Dwarf_Error *);
+int dwarf_pubtype_name_offsets(Dwarf_Type, char **,
+ Dwarf_Off *, Dwarf_Off *, Dwarf_Error *);
+int dwarf_pubtypename(Dwarf_Type, char **, Dwarf_Error *);
+void dwarf_pubtypes_dealloc(Dwarf_Debug, Dwarf_Type *, Dwarf_Signed);
+void dwarf_ranges_dealloc(Dwarf_Debug, Dwarf_Ranges *, Dwarf_Signed);
+void dwarf_reset_section_bytes(Dwarf_P_Debug);
+Dwarf_Half dwarf_set_frame_cfa_value(Dwarf_Debug, Dwarf_Half);
+Dwarf_Half dwarf_set_frame_rule_initial_value(Dwarf_Debug, Dwarf_Half);
+Dwarf_Half dwarf_set_frame_rule_table_size(Dwarf_Debug, Dwarf_Half);
+Dwarf_Half dwarf_set_frame_same_value(Dwarf_Debug, Dwarf_Half);
+Dwarf_Half dwarf_set_frame_undefined_value(Dwarf_Debug, Dwarf_Half);
+int dwarf_set_reloc_application(int);
+Dwarf_Ptr dwarf_seterrarg(Dwarf_Debug, Dwarf_Ptr);
+Dwarf_Handler dwarf_seterrhand(Dwarf_Debug, Dwarf_Handler);
+int dwarf_siblingof(Dwarf_Debug, Dwarf_Die, Dwarf_Die *, Dwarf_Error *);
+int dwarf_siblingof_b(Dwarf_Debug, Dwarf_Die, Dwarf_Die *, Dwarf_Bool,
+ Dwarf_Error *);
+int dwarf_srcfiles(Dwarf_Die, char ***, Dwarf_Signed *, Dwarf_Error *);
+int dwarf_srclang(Dwarf_Die, Dwarf_Unsigned *, Dwarf_Error *);
+int dwarf_srclines(Dwarf_Die, Dwarf_Line **, Dwarf_Signed *,
+ Dwarf_Error *);
+void dwarf_srclines_dealloc(Dwarf_Debug, Dwarf_Line *,
+ Dwarf_Signed);
+int dwarf_start_macro_file(Dwarf_P_Debug, Dwarf_Unsigned,
+ Dwarf_Unsigned, Dwarf_Error *);
+int dwarf_tag(Dwarf_Die, Dwarf_Half *, Dwarf_Error *);
+Dwarf_Signed dwarf_transform_to_disk_form(Dwarf_P_Debug, Dwarf_Error *);
+int dwarf_type_cu_offset(Dwarf_Type, Dwarf_Off *, Dwarf_Error *);
+int dwarf_type_die_offset(Dwarf_Type, Dwarf_Off *, Dwarf_Error *);
+int dwarf_type_name_offsets(Dwarf_Type, char **,
+ Dwarf_Off *, Dwarf_Off *, Dwarf_Error *);
+int dwarf_typename(Dwarf_Type, char **, Dwarf_Error *);
+void dwarf_types_dealloc(Dwarf_Debug, Dwarf_Type *, Dwarf_Signed);
+int dwarf_undef_macro(Dwarf_P_Debug, Dwarf_Unsigned, char *,
+ Dwarf_Error *);
+int dwarf_var_cu_offset(Dwarf_Var, Dwarf_Off *, Dwarf_Error *);
+int dwarf_var_die_offset(Dwarf_Var, Dwarf_Off *,
+ Dwarf_Error *);
+int dwarf_var_name_offsets(Dwarf_Var, char **,
+ Dwarf_Off *, Dwarf_Off *, Dwarf_Error *);
+int dwarf_varname(Dwarf_Var, char **, Dwarf_Error *);
+void dwarf_vars_dealloc(Dwarf_Debug, Dwarf_Var *, Dwarf_Signed);
+int dwarf_vendor_ext(Dwarf_P_Debug, Dwarf_Unsigned, char *,
+ Dwarf_Error *);
+int dwarf_weak_cu_offset(Dwarf_Weak, Dwarf_Off *, Dwarf_Error *);
+int dwarf_weak_die_offset(Dwarf_Weak, Dwarf_Off *,
+ Dwarf_Error *);
+int dwarf_weak_name_offsets(Dwarf_Weak, char **,
+ Dwarf_Off *, Dwarf_Off *, Dwarf_Error *);
+int dwarf_weakname(Dwarf_Weak, char **, Dwarf_Error *);
+void dwarf_weaks_dealloc(Dwarf_Debug, Dwarf_Weak *, Dwarf_Signed);
+int dwarf_whatattr(Dwarf_Attribute, Dwarf_Half *, Dwarf_Error *);
+int dwarf_whatform(Dwarf_Attribute, Dwarf_Half *, Dwarf_Error *);
+int dwarf_whatform_direct(Dwarf_Attribute, Dwarf_Half *,
+ Dwarf_Error *);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_LIBDWARF_H_ */
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_abbrev.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_abbrev.c
new file mode 100644
index 0000000..9e4b6ab
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_abbrev.c
@@ -0,0 +1,266 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2009-2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_abbrev.c 3420 2016-02-27 02:14:05Z emaste $");
+
+int
+_dwarf_abbrev_add(Dwarf_CU cu, uint64_t entry, uint64_t tag, uint8_t children,
+ uint64_t aboff, Dwarf_Abbrev *abp, Dwarf_Error *error)
+{
+ Dwarf_Abbrev ab;
+ Dwarf_Debug dbg;
+
+ dbg = cu != NULL ? cu->cu_dbg : NULL;
+
+ if ((ab = malloc(sizeof(struct _Dwarf_Abbrev))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ /* Initialise the abbrev structure. */
+ ab->ab_entry = entry;
+ ab->ab_tag = tag;
+ ab->ab_children = children;
+ ab->ab_offset = aboff;
+ ab->ab_length = 0; /* fill in later. */
+ ab->ab_atnum = 0; /* fill in later. */
+
+ /* Initialise the list of attribute definitions. */
+ STAILQ_INIT(&ab->ab_attrdef);
+
+ /* Add the abbrev to the hash table of the compilation unit. */
+ if (cu != NULL)
+ HASH_ADD(ab_hh, cu->cu_abbrev_hash, ab_entry,
+ sizeof(ab->ab_entry), ab);
+
+ if (abp != NULL)
+ *abp = ab;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_attrdef_add(Dwarf_Debug dbg, Dwarf_Abbrev ab, uint64_t attr,
+ uint64_t form, uint64_t adoff, Dwarf_AttrDef *adp, Dwarf_Error *error)
+{
+ Dwarf_AttrDef ad;
+
+ if (ab == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLE_ARGUMENT);
+ }
+
+ if ((ad = malloc(sizeof(struct _Dwarf_AttrDef))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ /* Initialise the attribute definition structure. */
+ ad->ad_attrib = attr;
+ ad->ad_form = form;
+ ad->ad_offset = adoff;
+
+ /* Add the attribute definition to the list in the abbrev. */
+ STAILQ_INSERT_TAIL(&ab->ab_attrdef, ad, ad_next);
+
+ /* Increase number of attribute counter. */
+ ab->ab_atnum++;
+
+ if (adp != NULL)
+ *adp = ad;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_abbrev_parse(Dwarf_Debug dbg, Dwarf_CU cu, Dwarf_Unsigned *offset,
+ Dwarf_Abbrev *abp, Dwarf_Error *error)
+{
+ Dwarf_Section *ds;
+ uint64_t attr;
+ uint64_t entry;
+ uint64_t form;
+ uint64_t aboff;
+ uint64_t adoff;
+ uint64_t tag;
+ uint8_t children;
+ int ret;
+
+ assert(abp != NULL);
+
+ ds = _dwarf_find_section(dbg, ".debug_abbrev");
+ if (ds == NULL || *offset >= ds->ds_size)
+ return (DW_DLE_NO_ENTRY);
+
+ aboff = *offset;
+
+ entry = _dwarf_read_uleb128(ds->ds_data, offset);
+ if (entry == 0) {
+ /* Last entry. */
+ ret = _dwarf_abbrev_add(cu, entry, 0, 0, aboff, abp,
+ error);
+ if (ret == DW_DLE_NONE) {
+ (*abp)->ab_length = 1;
+ return (ret);
+ } else
+ return (ret);
+ }
+ tag = _dwarf_read_uleb128(ds->ds_data, offset);
+ children = dbg->read(ds->ds_data, offset, 1);
+ if ((ret = _dwarf_abbrev_add(cu, entry, tag, children, aboff,
+ abp, error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Parse attribute definitions. */
+ do {
+ adoff = *offset;
+ attr = _dwarf_read_uleb128(ds->ds_data, offset);
+ form = _dwarf_read_uleb128(ds->ds_data, offset);
+ if (attr != 0)
+ if ((ret = _dwarf_attrdef_add(dbg, *abp, attr,
+ form, adoff, NULL, error)) != DW_DLE_NONE)
+ return (ret);
+ } while (attr != 0);
+
+ (*abp)->ab_length = *offset - aboff;
+
+ return (ret);
+}
+
+int
+_dwarf_abbrev_find(Dwarf_CU cu, uint64_t entry, Dwarf_Abbrev *abp,
+ Dwarf_Error *error)
+{
+ Dwarf_Abbrev ab;
+ Dwarf_Section *ds;
+ Dwarf_Unsigned offset;
+ int ret;
+
+ if (entry == 0)
+ return (DW_DLE_NO_ENTRY);
+
+ /* Check if the desired abbrev entry is already in the hash table. */
+ HASH_FIND(ab_hh, cu->cu_abbrev_hash, &entry, sizeof(entry), ab);
+ if (ab != NULL) {
+ *abp = ab;
+ return (DW_DLE_NONE);
+ }
+
+ if (cu->cu_abbrev_loaded) {
+ return (DW_DLE_NO_ENTRY);
+ }
+
+ /* Load and search the abbrev table. */
+ ds = _dwarf_find_section(cu->cu_dbg, ".debug_abbrev");
+ if (ds == NULL)
+ return (DW_DLE_NO_ENTRY);
+
+ offset = cu->cu_abbrev_offset_cur;
+ while (offset < ds->ds_size) {
+ ret = _dwarf_abbrev_parse(cu->cu_dbg, cu, &offset, &ab, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ if (ab->ab_entry == entry) {
+ cu->cu_abbrev_offset_cur = offset;
+ *abp = ab;
+ return (DW_DLE_NONE);
+ }
+ if (ab->ab_entry == 0) {
+ cu->cu_abbrev_offset_cur = offset;
+ cu->cu_abbrev_loaded = 1;
+ break;
+ }
+ }
+
+ return (DW_DLE_NO_ENTRY);
+}
+
+void
+_dwarf_abbrev_cleanup(Dwarf_CU cu)
+{
+ Dwarf_Abbrev ab, tab;
+ Dwarf_AttrDef ad, tad;
+
+ assert(cu != NULL);
+
+ HASH_ITER(ab_hh, cu->cu_abbrev_hash, ab, tab) {
+ HASH_DELETE(ab_hh, cu->cu_abbrev_hash, ab);
+ STAILQ_FOREACH_SAFE(ad, &ab->ab_attrdef, ad_next, tad) {
+ STAILQ_REMOVE(&ab->ab_attrdef, ad, _Dwarf_AttrDef,
+ ad_next);
+ free(ad);
+ }
+ free(ab);
+ }
+}
+
+int
+_dwarf_abbrev_gen(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ Dwarf_Abbrev ab;
+ Dwarf_AttrDef ad;
+ Dwarf_P_Section ds;
+ int ret;
+
+ cu = STAILQ_FIRST(&dbg->dbg_cu);
+ if (cu == NULL)
+ return (DW_DLE_NONE);
+
+ /* Create .debug_abbrev section. */
+ if ((ret = _dwarf_section_init(dbg, &ds, ".debug_abbrev", 0, error)) !=
+ DW_DLE_NONE)
+ return (ret);
+
+ for (ab = cu->cu_abbrev_hash; ab != NULL; ab = ab->ab_hh.next) {
+ RCHECK(WRITE_ULEB128(ab->ab_entry));
+ RCHECK(WRITE_ULEB128(ab->ab_tag));
+ RCHECK(WRITE_VALUE(ab->ab_children, 1));
+ STAILQ_FOREACH(ad, &ab->ab_attrdef, ad_next) {
+ RCHECK(WRITE_ULEB128(ad->ad_attrib));
+ RCHECK(WRITE_ULEB128(ad->ad_form));
+ }
+ /* Signal end of attribute spec list. */
+ RCHECK(WRITE_ULEB128(0));
+ RCHECK(WRITE_ULEB128(0));
+ }
+ /* End of abbreviation for this CU. */
+ RCHECK(WRITE_ULEB128(0));
+
+ /* Notify the creation of .debug_abbrev ELF section. */
+ RCHECK(_dwarf_section_callback(dbg, ds, SHT_PROGBITS, 0, 0, 0, error));
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+
+ _dwarf_section_free(dbg, &ds);
+
+ return (ret);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_arange.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_arange.c
new file mode 100644
index 0000000..eefb63b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_arange.c
@@ -0,0 +1,260 @@
+/*-
+ * Copyright (c) 2009-2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_arange.c 3029 2014-04-21 23:26:02Z kaiwang27 $");
+
+void
+_dwarf_arange_cleanup(Dwarf_Debug dbg)
+{
+ Dwarf_ArangeSet as, tas;
+ Dwarf_Arange ar, tar;
+
+ STAILQ_FOREACH_SAFE(as, &dbg->dbg_aslist, as_next, tas) {
+ STAILQ_FOREACH_SAFE(ar, &as->as_arlist, ar_next, tar) {
+ STAILQ_REMOVE(&as->as_arlist, ar, _Dwarf_Arange,
+ ar_next);
+ free(ar);
+ }
+ STAILQ_REMOVE(&dbg->dbg_aslist, as, _Dwarf_ArangeSet, as_next);
+ free(as);
+ }
+
+ if (dbg->dbg_arange_array)
+ free(dbg->dbg_arange_array);
+
+ dbg->dbg_arange_array = NULL;
+ dbg->dbg_arange_cnt = 0;
+}
+
+int
+_dwarf_arange_init(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ Dwarf_ArangeSet as;
+ Dwarf_Arange ar;
+ Dwarf_Section *ds;
+ uint64_t offset, dwarf_size, length, addr, range;
+ int i, ret;
+
+ ret = DW_DLE_NONE;
+
+ if ((ds = _dwarf_find_section(dbg, ".debug_aranges")) == NULL)
+ return (DW_DLE_NONE);
+
+ if (!dbg->dbg_info_loaded) {
+ ret = _dwarf_info_load(dbg, 1, 1, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+
+ offset = 0;
+ while (offset < ds->ds_size) {
+
+ if ((as = malloc(sizeof(struct _Dwarf_ArangeSet))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ STAILQ_INIT(&as->as_arlist);
+ STAILQ_INSERT_TAIL(&dbg->dbg_aslist, as, as_next);
+
+ /* Read in the table header. */
+ length = dbg->read(ds->ds_data, &offset, 4);
+ if (length == 0xffffffff) {
+ dwarf_size = 8;
+ length = dbg->read(ds->ds_data, &offset, 8);
+ } else
+ dwarf_size = 4;
+
+ as->as_length = length;
+ as->as_version = dbg->read(ds->ds_data, &offset, 2);
+ if (as->as_version != 2) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_VERSION_STAMP_ERROR);
+ ret = DW_DLE_VERSION_STAMP_ERROR;
+ goto fail_cleanup;
+ }
+
+ as->as_cu_offset = dbg->read(ds->ds_data, &offset, dwarf_size);
+ STAILQ_FOREACH(cu, &dbg->dbg_cu, cu_next) {
+ if (cu->cu_offset == as->as_cu_offset)
+ break;
+ }
+ if (cu == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARANGE_OFFSET_BAD);
+ ret = DW_DLE_ARANGE_OFFSET_BAD;
+ goto fail_cleanup;
+ }
+ as->as_cu = cu;
+
+ as->as_addrsz = dbg->read(ds->ds_data, &offset, 1);
+ as->as_segsz = dbg->read(ds->ds_data, &offset, 1);
+
+ /* Skip the padding bytes. */
+ offset = roundup(offset, 2 * as->as_addrsz);
+
+ /* Read in address range descriptors. */
+ while (offset < ds->ds_size) {
+ addr = dbg->read(ds->ds_data, &offset, as->as_addrsz);
+ range = dbg->read(ds->ds_data, &offset, as->as_addrsz);
+ if (addr == 0 && range == 0)
+ break;
+ if ((ar = calloc(1, sizeof(struct _Dwarf_Arange))) ==
+ NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ goto fail_cleanup;
+ }
+ ar->ar_as = as;
+ ar->ar_address = addr;
+ ar->ar_range = range;
+ STAILQ_INSERT_TAIL(&as->as_arlist, ar, ar_next);
+ dbg->dbg_arange_cnt++;
+ }
+ }
+
+ /* Build arange array. */
+ if (dbg->dbg_arange_cnt > 0) {
+ if ((dbg->dbg_arange_array = malloc(dbg->dbg_arange_cnt *
+ sizeof(Dwarf_Arange))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ ret = DW_DLE_MEMORY;
+ goto fail_cleanup;
+ }
+
+ i = 0;
+ STAILQ_FOREACH(as, &dbg->dbg_aslist, as_next) {
+ STAILQ_FOREACH(ar, &as->as_arlist, ar_next)
+ dbg->dbg_arange_array[i++] = ar;
+ }
+ assert((Dwarf_Unsigned)i == dbg->dbg_arange_cnt);
+ }
+
+ return (DW_DLE_NONE);
+
+fail_cleanup:
+
+ _dwarf_arange_cleanup(dbg);
+
+ return (ret);
+}
+
+int
+_dwarf_arange_gen(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_P_Section ds;
+ Dwarf_Rel_Section drs;
+ Dwarf_ArangeSet as;
+ Dwarf_Arange ar;
+ uint64_t offset;
+ int ret;
+
+ as = dbg->dbgp_as;
+ assert(as != NULL);
+ if (STAILQ_EMPTY(&as->as_arlist))
+ return (DW_DLE_NONE);
+
+ as->as_length = 0;
+ as->as_version = 2;
+ as->as_cu_offset = 0; /* We have only one CU. */
+ as->as_addrsz = dbg->dbg_pointer_size;
+ as->as_segsz = 0; /* XXX */
+
+ /* Create .debug_arange section. */
+ if ((ret = _dwarf_section_init(dbg, &ds, ".debug_aranges", 0, error)) !=
+ DW_DLE_NONE)
+ goto gen_fail0;
+
+ /* Create relocation section for .debug_aranges */
+ RCHECK(_dwarf_reloc_section_init(dbg, &drs, ds, error));
+
+ /* Write section header. */
+ RCHECK(WRITE_VALUE(as->as_length, 4));
+ RCHECK(WRITE_VALUE(as->as_version, 2));
+ RCHECK(_dwarf_reloc_entry_add(dbg, drs, ds, dwarf_drt_data_reloc, 4,
+ ds->ds_size, 0, as->as_cu_offset, ".debug_info", error));
+ RCHECK(WRITE_VALUE(as->as_addrsz, 1));
+ RCHECK(WRITE_VALUE(as->as_segsz, 1));
+
+ /* Pad to (2 * address_size) */
+ offset = roundup(ds->ds_size, 2 * as->as_addrsz);
+ if (offset > ds->ds_size)
+ RCHECK(WRITE_PADDING(0, offset - ds->ds_size));
+
+ /* Write tuples. */
+ STAILQ_FOREACH(ar, &as->as_arlist, ar_next) {
+ RCHECK(_dwarf_reloc_entry_add(dbg, drs, ds,
+ dwarf_drt_data_reloc, dbg->dbg_pointer_size, ds->ds_size,
+ ar->ar_symndx, ar->ar_address, NULL, error));
+ if (ar->ar_esymndx > 0)
+ RCHECK(_dwarf_reloc_entry_add_pair(dbg, drs, ds,
+ dbg->dbg_pointer_size, ds->ds_size, ar->ar_symndx,
+ ar->ar_esymndx, ar->ar_address, ar->ar_eoff, error));
+ else
+ RCHECK(WRITE_VALUE(ar->ar_range, dbg->dbg_pointer_size));
+ }
+ RCHECK(WRITE_VALUE(0, dbg->dbg_pointer_size));
+ RCHECK(WRITE_VALUE(0, dbg->dbg_pointer_size));
+
+ /* Fill in the length field. */
+ as->as_length = ds->ds_size - 4;
+ offset = 0;
+ dbg->write(ds->ds_data, &offset, as->as_length, 4);
+
+ /* Inform application the creation of .debug_aranges ELF section. */
+ RCHECK(_dwarf_section_callback(dbg, ds, SHT_PROGBITS, 0, 0, 0, error));
+
+ /* Finalize relocation section for .debug_aranges */
+ RCHECK(_dwarf_reloc_section_finalize(dbg, drs, error));
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+ _dwarf_reloc_section_free(dbg, &drs);
+
+gen_fail0:
+ _dwarf_section_free(dbg, &ds);
+
+ return (ret);
+}
+
+void
+_dwarf_arange_pro_cleanup(Dwarf_P_Debug dbg)
+{
+ Dwarf_ArangeSet as;
+ Dwarf_Arange ar, tar;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_WRITE);
+ if (dbg->dbgp_as == NULL)
+ return;
+
+ as = dbg->dbgp_as;
+ STAILQ_FOREACH_SAFE(ar, &as->as_arlist, ar_next, tar) {
+ STAILQ_REMOVE(&as->as_arlist, ar, _Dwarf_Arange, ar_next);
+ free(ar);
+ }
+ free(as);
+ dbg->dbgp_as = NULL;
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_attr.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_attr.c
new file mode 100644
index 0000000..dfbbc48
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_attr.c
@@ -0,0 +1,459 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2009-2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_attr.c 3064 2014-06-06 19:35:55Z kaiwang27 $");
+
+int
+_dwarf_attr_alloc(Dwarf_Die die, Dwarf_Attribute *atp, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+
+ assert(die != NULL);
+ assert(atp != NULL);
+
+ if ((at = calloc(1, sizeof(struct _Dwarf_Attribute))) == NULL) {
+ DWARF_SET_ERROR(die->die_dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ *atp = at;
+
+ return (DW_DLE_NONE);
+}
+
+static int
+_dwarf_attr_add(Dwarf_Die die, Dwarf_Attribute atref, Dwarf_Attribute *atp,
+ Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ int ret;
+
+ if ((ret = _dwarf_attr_alloc(die, &at, error)) != DW_DLE_NONE)
+ return (ret);
+
+ memcpy(at, atref, sizeof(struct _Dwarf_Attribute));
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ /* Save a pointer to the attribute name if this is one. */
+ if (at->at_attrib == DW_AT_name) {
+ switch (at->at_form) {
+ case DW_FORM_strp:
+ die->die_name = at->u[1].s;
+ break;
+ case DW_FORM_string:
+ die->die_name = at->u[0].s;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (atp != NULL)
+ *atp = at;
+
+ return (DW_DLE_NONE);
+}
+
+Dwarf_Attribute
+_dwarf_attr_find(Dwarf_Die die, Dwarf_Half attr)
+{
+ Dwarf_Attribute at;
+
+ STAILQ_FOREACH(at, &die->die_attr, at_next) {
+ if (at->at_attrib == attr)
+ break;
+ }
+
+ return (at);
+}
+
+int
+_dwarf_attr_init(Dwarf_Debug dbg, Dwarf_Section *ds, uint64_t *offsetp,
+ int dwarf_size, Dwarf_CU cu, Dwarf_Die die, Dwarf_AttrDef ad,
+ uint64_t form, int indirect, Dwarf_Error *error)
+{
+ struct _Dwarf_Attribute atref;
+ Dwarf_Section *str;
+ int ret;
+
+ ret = DW_DLE_NONE;
+ memset(&atref, 0, sizeof(atref));
+ atref.at_die = die;
+ atref.at_offset = *offsetp;
+ atref.at_attrib = ad->ad_attrib;
+ atref.at_form = indirect ? form : ad->ad_form;
+ atref.at_indirect = indirect;
+ atref.at_ld = NULL;
+
+ switch (form) {
+ case DW_FORM_addr:
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp,
+ cu->cu_pointer_size);
+ break;
+ case DW_FORM_block:
+ case DW_FORM_exprloc:
+ atref.u[0].u64 = _dwarf_read_uleb128(ds->ds_data, offsetp);
+ atref.u[1].u8p = _dwarf_read_block(ds->ds_data, offsetp,
+ atref.u[0].u64);
+ break;
+ case DW_FORM_block1:
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp, 1);
+ atref.u[1].u8p = _dwarf_read_block(ds->ds_data, offsetp,
+ atref.u[0].u64);
+ break;
+ case DW_FORM_block2:
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp, 2);
+ atref.u[1].u8p = _dwarf_read_block(ds->ds_data, offsetp,
+ atref.u[0].u64);
+ break;
+ case DW_FORM_block4:
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp, 4);
+ atref.u[1].u8p = _dwarf_read_block(ds->ds_data, offsetp,
+ atref.u[0].u64);
+ break;
+ case DW_FORM_data1:
+ case DW_FORM_flag:
+ case DW_FORM_ref1:
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp, 1);
+ break;
+ case DW_FORM_data2:
+ case DW_FORM_ref2:
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp, 2);
+ break;
+ case DW_FORM_data4:
+ case DW_FORM_ref4:
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp, 4);
+ break;
+ case DW_FORM_data8:
+ case DW_FORM_ref8:
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp, 8);
+ break;
+ case DW_FORM_indirect:
+ form = _dwarf_read_uleb128(ds->ds_data, offsetp);
+ return (_dwarf_attr_init(dbg, ds, offsetp, dwarf_size, cu, die,
+ ad, form, 1, error));
+ case DW_FORM_ref_addr:
+ if (cu->cu_version == 2)
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp,
+ cu->cu_pointer_size);
+ else
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp,
+ dwarf_size);
+ break;
+ case DW_FORM_ref_udata:
+ case DW_FORM_udata:
+ atref.u[0].u64 = _dwarf_read_uleb128(ds->ds_data, offsetp);
+ break;
+ case DW_FORM_sdata:
+ atref.u[0].s64 = _dwarf_read_sleb128(ds->ds_data, offsetp);
+ break;
+ case DW_FORM_sec_offset:
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp, dwarf_size);
+ break;
+ case DW_FORM_string:
+ atref.u[0].s = _dwarf_read_string(ds->ds_data, ds->ds_size,
+ offsetp);
+ break;
+ case DW_FORM_strp:
+ atref.u[0].u64 = dbg->read(ds->ds_data, offsetp, dwarf_size);
+ str = _dwarf_find_section(dbg, ".debug_str");
+ assert(str != NULL);
+ atref.u[1].s = (char *) str->ds_data + atref.u[0].u64;
+ break;
+ case DW_FORM_ref_sig8:
+ atref.u[0].u64 = 8;
+ atref.u[1].u8p = _dwarf_read_block(ds->ds_data, offsetp,
+ atref.u[0].u64);
+ break;
+ case DW_FORM_flag_present:
+ /* This form has no value encoded in the DIE. */
+ atref.u[0].u64 = 1;
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ ret = DW_DLE_ATTR_FORM_BAD;
+ break;
+ }
+
+ if (ret == DW_DLE_NONE) {
+ if (form == DW_FORM_block || form == DW_FORM_block1 ||
+ form == DW_FORM_block2 || form == DW_FORM_block4) {
+ atref.at_block.bl_len = atref.u[0].u64;
+ atref.at_block.bl_data = atref.u[1].u8p;
+ }
+ ret = _dwarf_attr_add(die, &atref, NULL, error);
+ }
+
+ return (ret);
+}
+
+static int
+_dwarf_attr_write(Dwarf_P_Debug dbg, Dwarf_P_Section ds, Dwarf_Rel_Section drs,
+ Dwarf_CU cu, Dwarf_Attribute at, int pass2, Dwarf_Error *error)
+{
+ struct _Dwarf_P_Expr_Entry *ee;
+ uint64_t value, offset, bs;
+ int ret;
+
+ assert(dbg != NULL && ds != NULL && cu != NULL && at != NULL);
+
+ /* Fill in reference to other DIE in the second pass. */
+ if (pass2) {
+ if (at->at_form != DW_FORM_ref4 && at->at_form != DW_FORM_ref8)
+ return (DW_DLE_NONE);
+ if (at->at_refdie == NULL || at->at_offset == 0)
+ return (DW_DLE_NONE);
+ offset = at->at_offset;
+ dbg->write(ds->ds_data, &offset, at->at_refdie->die_offset,
+ at->at_form == DW_FORM_ref4 ? 4 : 8);
+ return (DW_DLE_NONE);
+ }
+
+ switch (at->at_form) {
+ case DW_FORM_addr:
+ if (at->at_relsym)
+ ret = _dwarf_reloc_entry_add(dbg, drs, ds,
+ dwarf_drt_data_reloc, cu->cu_pointer_size,
+ ds->ds_size, at->at_relsym, at->u[0].u64, NULL,
+ error);
+ else
+ ret = WRITE_VALUE(at->u[0].u64, cu->cu_pointer_size);
+ break;
+ case DW_FORM_block:
+ case DW_FORM_block1:
+ case DW_FORM_block2:
+ case DW_FORM_block4:
+ /* Write block size. */
+ if (at->at_form == DW_FORM_block) {
+ ret = _dwarf_write_uleb128_alloc(&ds->ds_data,
+ &ds->ds_cap, &ds->ds_size, at->u[0].u64, error);
+ if (ret != DW_DLE_NONE)
+ break;
+ } else {
+ if (at->at_form == DW_FORM_block1)
+ bs = 1;
+ else if (at->at_form == DW_FORM_block2)
+ bs = 2;
+ else
+ bs = 4;
+ ret = WRITE_VALUE(at->u[0].u64, bs);
+ if (ret != DW_DLE_NONE)
+ break;
+ }
+
+ /* Keep block data offset for later use. */
+ offset = ds->ds_size;
+
+ /* Write block data. */
+ ret = WRITE_BLOCK(at->u[1].u8p, at->u[0].u64);
+ if (ret != DW_DLE_NONE)
+ break;
+ if (at->at_expr == NULL)
+ break;
+
+ /* Generate relocation entry for DW_OP_addr expressions. */
+ STAILQ_FOREACH(ee, &at->at_expr->pe_eelist, ee_next) {
+ if (ee->ee_loc.lr_atom != DW_OP_addr || ee->ee_sym == 0)
+ continue;
+ ret = _dwarf_reloc_entry_add(dbg, drs, ds,
+ dwarf_drt_data_reloc, dbg->dbg_pointer_size,
+ offset + ee->ee_loc.lr_offset + 1, ee->ee_sym,
+ ee->ee_loc.lr_number, NULL, error);
+ if (ret != DW_DLE_NONE)
+ break;
+ }
+ break;
+ case DW_FORM_data1:
+ case DW_FORM_flag:
+ case DW_FORM_ref1:
+ ret = WRITE_VALUE(at->u[0].u64, 1);
+ break;
+ case DW_FORM_data2:
+ case DW_FORM_ref2:
+ ret = WRITE_VALUE(at->u[0].u64, 2);
+ break;
+ case DW_FORM_data4:
+ if (at->at_relsym || at->at_relsec != NULL)
+ ret = _dwarf_reloc_entry_add(dbg, drs, ds,
+ dwarf_drt_data_reloc, 4, ds->ds_size, at->at_relsym,
+ at->u[0].u64, at->at_relsec, error);
+ else
+ ret = WRITE_VALUE(at->u[0].u64, 4);
+ break;
+ case DW_FORM_data8:
+ if (at->at_relsym || at->at_relsec != NULL)
+ ret = _dwarf_reloc_entry_add(dbg, drs, ds,
+ dwarf_drt_data_reloc, 8, ds->ds_size, at->at_relsym,
+ at->u[0].u64, at->at_relsec, error);
+ else
+ ret = WRITE_VALUE(at->u[0].u64, 8);
+ break;
+ case DW_FORM_ref4:
+ case DW_FORM_ref8:
+ /*
+ * The value of ref4 and ref8 could be a reference to another
+ * DIE within the CU. And if we don't know the ref DIE's
+ * offset at the moement, then we remember at_offset and fill
+ * it in the second pass.
+ */
+ if (at->at_refdie) {
+ value = at->at_refdie->die_offset;
+ if (value == 0) {
+ cu->cu_pass2 = 1;
+ at->at_offset = ds->ds_size;
+ }
+ } else
+ value = at->u[0].u64;
+ ret = WRITE_VALUE(value, at->at_form == DW_FORM_ref4 ? 4 : 8);
+ break;
+ case DW_FORM_indirect:
+ /* TODO. */
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ ret = DW_DLE_ATTR_FORM_BAD;
+ break;
+ case DW_FORM_ref_addr:
+ /* DWARF2 format. */
+ if (at->at_relsym)
+ ret = _dwarf_reloc_entry_add(dbg, drs, ds,
+ dwarf_drt_data_reloc, cu->cu_pointer_size,
+ ds->ds_size, at->at_relsym, at->u[0].u64, NULL,
+ error);
+ else
+ ret = WRITE_VALUE(at->u[0].u64, cu->cu_pointer_size);
+ break;
+ case DW_FORM_ref_udata:
+ case DW_FORM_udata:
+ ret = WRITE_ULEB128(at->u[0].u64);
+ break;
+ case DW_FORM_sdata:
+ ret = WRITE_SLEB128(at->u[0].s64);
+ break;
+ case DW_FORM_string:
+ assert(at->u[0].s != NULL);
+ ret = WRITE_STRING(at->u[0].s);
+ break;
+ case DW_FORM_strp:
+ ret = _dwarf_reloc_entry_add(dbg, drs, ds, dwarf_drt_data_reloc,
+ 4, ds->ds_size, 0, at->u[0].u64, ".debug_str", error);
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
+ ret = DW_DLE_ATTR_FORM_BAD;
+ break;
+ }
+
+ return (ret);
+}
+
+int
+_dwarf_add_AT_dataref(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
+ Dwarf_Unsigned pc_value, Dwarf_Unsigned sym_index, const char *secname,
+ Dwarf_P_Attribute *atp, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ int ret;
+
+ assert(dbg != NULL && die != NULL);
+
+ if ((ret = _dwarf_attr_alloc(die, &at, error)) != DW_DLE_NONE)
+ return (ret);
+
+ at->at_die = die;
+ at->at_attrib = attr;
+ if (dbg->dbg_pointer_size == 4)
+ at->at_form = DW_FORM_data4;
+ else
+ at->at_form = DW_FORM_data8;
+ at->at_relsym = sym_index;
+ at->at_relsec = secname;
+ at->u[0].u64 = pc_value;
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ if (atp)
+ *atp = at;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_add_string_attr(Dwarf_P_Die die, Dwarf_P_Attribute *atp, Dwarf_Half attr,
+ char *string, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ Dwarf_Debug dbg;
+ int ret;
+
+ dbg = die != NULL ? die->die_dbg : NULL;
+
+ assert(atp != NULL);
+
+ if (die == NULL || string == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLE_ARGUMENT);
+ }
+
+ if ((ret = _dwarf_attr_alloc(die, &at, error)) != DW_DLE_NONE)
+ return (ret);
+
+ at->at_die = die;
+ at->at_attrib = attr;
+ at->at_form = DW_FORM_strp;
+ if ((ret = _dwarf_strtab_add(dbg, string, &at->u[0].u64,
+ error)) != DW_DLE_NONE) {
+ free(at);
+ return (ret);
+ }
+ at->u[1].s = _dwarf_strtab_get_table(dbg) + at->u[0].u64;
+
+ *atp = at;
+
+ STAILQ_INSERT_TAIL(&die->die_attr, at, at_next);
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_attr_gen(Dwarf_P_Debug dbg, Dwarf_P_Section ds, Dwarf_Rel_Section drs,
+ Dwarf_CU cu, Dwarf_Die die, int pass2, Dwarf_Error *error)
+{
+ Dwarf_Attribute at;
+ int ret;
+
+ assert(dbg != NULL && ds != NULL && cu != NULL && die != NULL);
+
+ STAILQ_FOREACH(at, &die->die_attr, at_next) {
+ ret = _dwarf_attr_write(dbg, ds, drs, cu, at, pass2, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+
+ return (DW_DLE_NONE);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_die.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_die.c
new file mode 100644
index 0000000..b7796d3
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_die.c
@@ -0,0 +1,457 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2009-2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_die.c 3039 2014-05-18 15:10:56Z kaiwang27 $");
+
+int
+_dwarf_die_alloc(Dwarf_Debug dbg, Dwarf_Die *ret_die, Dwarf_Error *error)
+{
+ Dwarf_Die die;
+
+ assert(ret_die != NULL);
+
+ if ((die = calloc(1, sizeof(struct _Dwarf_Die))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ STAILQ_INIT(&die->die_attr);
+
+ *ret_die = die;
+
+ return (DW_DLE_NONE);
+}
+
+static int
+_dwarf_die_add(Dwarf_CU cu, uint64_t offset, uint64_t abnum, Dwarf_Abbrev ab,
+ Dwarf_Die *diep, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ Dwarf_Die die;
+ int ret;
+
+ assert(cu != NULL);
+ assert(ab != NULL);
+
+ dbg = cu->cu_dbg;
+
+ if ((ret = _dwarf_die_alloc(dbg, &die, error)) != DW_DLE_NONE)
+ return (ret);
+
+ die->die_offset = offset;
+ die->die_abnum = abnum;
+ die->die_ab = ab;
+ die->die_cu = cu;
+ die->die_dbg = cu->cu_dbg;
+
+ if (diep != NULL)
+ *diep = die;
+
+ return (DW_DLE_NONE);
+}
+
+/* Find die at offset 'off' within the same CU. */
+Dwarf_Die
+_dwarf_die_find(Dwarf_Die die, Dwarf_Unsigned off)
+{
+ Dwarf_Debug dbg;
+ Dwarf_Section *ds;
+ Dwarf_CU cu;
+ Dwarf_Die die1;
+ Dwarf_Error de;
+ int ret;
+
+ cu = die->die_cu;
+ dbg = die->die_dbg;
+ ds = cu->cu_is_info ? dbg->dbg_info_sec : dbg->dbg_types_sec;
+
+ ret = _dwarf_die_parse(dbg, ds, cu, cu->cu_dwarf_size, off,
+ cu->cu_next_offset, &die1, 0, &de);
+
+ if (ret == DW_DLE_NONE)
+ return (die1);
+ else
+ return (NULL);
+}
+
+int
+_dwarf_die_parse(Dwarf_Debug dbg, Dwarf_Section *ds, Dwarf_CU cu,
+ int dwarf_size, uint64_t offset, uint64_t next_offset, Dwarf_Die *ret_die,
+ int search_sibling, Dwarf_Error *error)
+{
+ Dwarf_Abbrev ab;
+ Dwarf_AttrDef ad;
+ Dwarf_Die die;
+ uint64_t abnum;
+ uint64_t die_offset;
+ int ret, level;
+
+ assert(cu != NULL);
+
+ level = 1;
+ die = NULL;
+
+ while (offset < next_offset && offset < ds->ds_size) {
+
+ die_offset = offset;
+
+ abnum = _dwarf_read_uleb128(ds->ds_data, &offset);
+
+ if (abnum == 0) {
+ if (level == 0 || !search_sibling)
+ return (DW_DLE_NO_ENTRY);
+
+ /*
+ * Return to previous DIE level.
+ */
+ level--;
+ continue;
+ }
+
+ if ((ret = _dwarf_abbrev_find(cu, abnum, &ab, error)) !=
+ DW_DLE_NONE)
+ return (ret);
+
+ if ((ret = _dwarf_die_add(cu, die_offset, abnum, ab, &die,
+ error)) != DW_DLE_NONE)
+ return (ret);
+
+ STAILQ_FOREACH(ad, &ab->ab_attrdef, ad_next) {
+ if ((ret = _dwarf_attr_init(dbg, ds, &offset,
+ dwarf_size, cu, die, ad, ad->ad_form, 0,
+ error)) != DW_DLE_NONE)
+ return (ret);
+ }
+
+ die->die_next_off = offset;
+ if (search_sibling && level > 0) {
+ dwarf_dealloc(dbg, die, DW_DLA_DIE);
+ if (ab->ab_children == DW_CHILDREN_yes) {
+ /* Advance to next DIE level. */
+ level++;
+ }
+ } else {
+ *ret_die = die;
+ return (DW_DLE_NONE);
+ }
+ }
+
+ return (DW_DLE_NO_ENTRY);
+}
+
+void
+_dwarf_die_link(Dwarf_P_Die die, Dwarf_P_Die parent, Dwarf_P_Die child,
+ Dwarf_P_Die left_sibling, Dwarf_P_Die right_sibling)
+{
+ Dwarf_P_Die last_child;
+
+ assert(die != NULL);
+
+ if (parent) {
+
+ /* Disconnect from old parent. */
+ if (die->die_parent) {
+ if (die->die_parent != parent) {
+ if (die->die_parent->die_child == die)
+ die->die_parent->die_child = NULL;
+ die->die_parent = NULL;
+ }
+ }
+
+ /* Find the last child of this parent. */
+ last_child = parent->die_child;
+ if (last_child) {
+ while (last_child->die_right != NULL)
+ last_child = last_child->die_right;
+ }
+
+ /* Connect to new parent. */
+ die->die_parent = parent;
+
+ /*
+ * Attach this DIE to the end of sibling list. If new
+ * parent doesn't have any child, set this DIE as the
+ * first child.
+ */
+ if (last_child) {
+ assert(last_child->die_right == NULL);
+ last_child->die_right = die;
+ die->die_left = last_child;
+ } else
+ parent->die_child = die;
+ }
+
+ if (child) {
+
+ /* Disconnect from old child. */
+ if (die->die_child) {
+ if (die->die_child != child) {
+ die->die_child->die_parent = NULL;
+ die->die_child = NULL;
+ }
+ }
+
+ /* Connect to new child. */
+ die->die_child = child;
+ child->die_parent = die;
+ }
+
+ if (left_sibling) {
+
+ /* Disconnect from old left sibling. */
+ if (die->die_left) {
+ if (die->die_left != left_sibling) {
+ die->die_left->die_right = NULL;
+ die->die_left = NULL;
+ }
+ }
+
+ /* Connect to new right sibling. */
+ die->die_left = left_sibling;
+ left_sibling->die_right = die;
+ }
+
+ if (right_sibling) {
+
+ /* Disconnect from old right sibling. */
+ if (die->die_right) {
+ if (die->die_right != right_sibling) {
+ die->die_right->die_left = NULL;
+ die->die_right = NULL;
+ }
+ }
+
+ /* Connect to new right sibling. */
+ die->die_right = right_sibling;
+ right_sibling->die_left = die;
+ }
+}
+
+int
+_dwarf_die_count_links(Dwarf_P_Die parent, Dwarf_P_Die child,
+ Dwarf_P_Die left_sibling, Dwarf_P_Die right_sibling)
+{
+ int count;
+
+ count = 0;
+
+ if (parent)
+ count++;
+ if (child)
+ count++;
+ if (left_sibling)
+ count++;
+ if (right_sibling)
+ count++;
+
+ return (count);
+}
+
+static int
+_dwarf_die_gen_recursive(Dwarf_P_Debug dbg, Dwarf_CU cu, Dwarf_Rel_Section drs,
+ Dwarf_P_Die die, int pass2, Dwarf_Error *error)
+{
+ Dwarf_P_Section ds;
+ Dwarf_Abbrev ab;
+ Dwarf_Attribute at;
+ Dwarf_AttrDef ad;
+ int match, ret;
+
+ ds = dbg->dbgp_info;
+ assert(ds != NULL);
+
+ if (pass2)
+ goto attr_gen;
+
+ /*
+ * Add DW_AT_sibling attribute for DIEs with children, so consumers
+ * can quickly scan chains of siblings, while ignoring the children
+ * of individual siblings.
+ */
+ if (die->die_child && die->die_right) {
+ if (_dwarf_attr_find(die, DW_AT_sibling) == NULL)
+ (void) dwarf_add_AT_reference(dbg, die, DW_AT_sibling,
+ die->die_right, error);
+ }
+
+ /*
+ * Search abbrev list to find a matching entry.
+ */
+ die->die_ab = NULL;
+ for (ab = cu->cu_abbrev_hash; ab != NULL; ab = ab->ab_hh.next) {
+ if (die->die_tag != ab->ab_tag)
+ continue;
+ if (ab->ab_children == DW_CHILDREN_no && die->die_child != NULL)
+ continue;
+ if (ab->ab_children == DW_CHILDREN_yes &&
+ die->die_child == NULL)
+ continue;
+ at = STAILQ_FIRST(&die->die_attr);
+ ad = STAILQ_FIRST(&ab->ab_attrdef);
+ match = 1;
+ while (at != NULL && ad != NULL) {
+ if (at->at_attrib != ad->ad_attrib ||
+ at->at_form != ad->ad_form) {
+ match = 0;
+ break;
+ }
+ at = STAILQ_NEXT(at, at_next);
+ ad = STAILQ_NEXT(ad, ad_next);
+ }
+ if ((at == NULL && ad != NULL) || (at != NULL && ad == NULL))
+ match = 0;
+ if (match) {
+ die->die_ab = ab;
+ break;
+ }
+ }
+
+ /*
+ * Create a new abbrev entry if we can not reuse any existing one.
+ */
+ if (die->die_ab == NULL) {
+ ret = _dwarf_abbrev_add(cu, ++cu->cu_abbrev_cnt, die->die_tag,
+ die->die_child != NULL ? DW_CHILDREN_yes : DW_CHILDREN_no,
+ 0, &ab, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ STAILQ_FOREACH(at, &die->die_attr, at_next) {
+ ret = _dwarf_attrdef_add(dbg, ab, at->at_attrib,
+ at->at_form, 0, NULL, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+ die->die_ab = ab;
+ }
+
+ die->die_offset = ds->ds_size;
+
+ /*
+ * Transform the DIE to bytes stream.
+ */
+ ret = _dwarf_write_uleb128_alloc(&ds->ds_data, &ds->ds_cap,
+ &ds->ds_size, die->die_ab->ab_entry, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+
+attr_gen:
+
+ /* Transform the attributes of this DIE. */
+ ret = _dwarf_attr_gen(dbg, ds, drs, cu, die, pass2, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+
+ /* Proceed to child DIE. */
+ if (die->die_child != NULL) {
+ ret = _dwarf_die_gen_recursive(dbg, cu, drs, die->die_child,
+ pass2, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+
+ /* Proceed to sibling DIE. */
+ if (die->die_right != NULL) {
+ ret = _dwarf_die_gen_recursive(dbg, cu, drs, die->die_right,
+ pass2, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+
+ /* Write a null DIE indicating the end of current level. */
+ if (die->die_right == NULL) {
+ ret = _dwarf_write_uleb128_alloc(&ds->ds_data, &ds->ds_cap,
+ &ds->ds_size, 0, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_die_gen(Dwarf_P_Debug dbg, Dwarf_CU cu, Dwarf_Rel_Section drs,
+ Dwarf_Error *error)
+{
+ Dwarf_Abbrev ab, tab;
+ Dwarf_AttrDef ad, tad;
+ Dwarf_Die die;
+ int ret;
+
+ assert(dbg != NULL && cu != NULL);
+ assert(dbg->dbgp_root_die != NULL);
+
+ die = dbg->dbgp_root_die;
+
+ /*
+ * Insert a DW_AT_stmt_list attribute into root DIE, if there are
+ * line number information.
+ */
+ if (!STAILQ_EMPTY(&dbg->dbgp_lineinfo->li_lnlist))
+ RCHECK(_dwarf_add_AT_dataref(dbg, die, DW_AT_stmt_list, 0, 0,
+ ".debug_line", NULL, error));
+
+ RCHECK(_dwarf_die_gen_recursive(dbg, cu, drs, die, 0, error));
+
+ if (cu->cu_pass2)
+ RCHECK(_dwarf_die_gen_recursive(dbg, cu, drs, die, 1, error));
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+
+ HASH_ITER(ab_hh, cu->cu_abbrev_hash, ab, tab) {
+ HASH_DELETE(ab_hh, cu->cu_abbrev_hash, ab);
+ STAILQ_FOREACH_SAFE(ad, &ab->ab_attrdef, ad_next, tad) {
+ STAILQ_REMOVE(&ab->ab_attrdef, ad, _Dwarf_AttrDef,
+ ad_next);
+ free(ad);
+ }
+ free(ab);
+ }
+
+ return (ret);
+}
+
+void
+_dwarf_die_pro_cleanup(Dwarf_P_Debug dbg)
+{
+ Dwarf_P_Die die, tdie;
+ Dwarf_P_Attribute at, tat;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_WRITE);
+
+ STAILQ_FOREACH_SAFE(die, &dbg->dbgp_dielist, die_pro_next, tdie) {
+ STAILQ_FOREACH_SAFE(at, &die->die_attr, at_next, tat) {
+ STAILQ_REMOVE(&die->die_attr, at, _Dwarf_Attribute,
+ at_next);
+ free(at);
+ }
+ free(die);
+ }
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_elf_access.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_elf_access.c
new file mode 100644
index 0000000..d3e381b
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_elf_access.c
@@ -0,0 +1,164 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_elf_access.c 2070 2011-10-27 03:05:32Z jkoshy $");
+
+int
+_dwarf_elf_get_section_info(void *obj, Dwarf_Half ndx,
+ Dwarf_Obj_Access_Section *ret_section, int *error)
+{
+ Dwarf_Elf_Object *e;
+ GElf_Shdr *sh;
+
+ e = obj;
+ assert(e != NULL);
+
+ if (ret_section == NULL) {
+ if (error)
+ *error = DW_DLE_ARGUMENT;
+ return (DW_DLV_ERROR);
+ }
+
+ if (ndx >= e->eo_seccnt) {
+ if (error)
+ *error = DW_DLE_NO_ENTRY;
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ sh = &e->eo_shdr[ndx];
+
+ ret_section->addr = sh->sh_addr;
+ ret_section->size = sh->sh_size;
+
+ ret_section->name = elf_strptr(e->eo_elf, e->eo_strndx, sh->sh_name);
+ if (ret_section->name == NULL) {
+ if (error)
+ *error = DW_DLE_ELF;
+ return (DW_DLV_ERROR);
+ }
+
+ return (DW_DLV_OK);
+}
+
+Dwarf_Endianness
+_dwarf_elf_get_byte_order(void *obj)
+{
+ Dwarf_Elf_Object *e;
+
+ e = obj;
+ assert(e != NULL);
+
+ switch (e->eo_ehdr.e_ident[EI_DATA]) {
+ case ELFDATA2MSB:
+ return (DW_OBJECT_MSB);
+
+ case ELFDATA2LSB:
+ case ELFDATANONE:
+ default:
+ return (DW_OBJECT_LSB);
+ }
+}
+
+Dwarf_Small
+_dwarf_elf_get_length_size(void *obj)
+{
+ Dwarf_Elf_Object *e;
+
+ e = obj;
+ assert(e != NULL);
+
+ if (gelf_getclass(e->eo_elf) == ELFCLASS32)
+ return (4);
+ else if (e->eo_ehdr.e_machine == EM_MIPS)
+ return (8);
+ else
+ return (4);
+}
+
+Dwarf_Small
+_dwarf_elf_get_pointer_size(void *obj)
+{
+ Dwarf_Elf_Object *e;
+
+ e = obj;
+ assert(e != NULL);
+
+ if (gelf_getclass(e->eo_elf) == ELFCLASS32)
+ return (4);
+ else
+ return (8);
+}
+
+Dwarf_Unsigned
+_dwarf_elf_get_section_count(void *obj)
+{
+ Dwarf_Elf_Object *e;
+
+ e = obj;
+ assert(e != NULL);
+
+ return (e->eo_seccnt);
+}
+
+int
+_dwarf_elf_load_section(void *obj, Dwarf_Half ndx, Dwarf_Small** ret_data,
+ int *error)
+{
+ Dwarf_Elf_Object *e;
+ Dwarf_Elf_Data *ed;
+
+ e = obj;
+ assert(e != NULL);
+
+ if (ret_data == NULL) {
+ if (error)
+ *error = DW_DLE_ARGUMENT;
+ return (DW_DLV_ERROR);
+ }
+
+ if (ndx >= e->eo_seccnt) {
+ if (error)
+ *error = DW_DLE_NO_ENTRY;
+ return (DW_DLV_NO_ENTRY);
+ }
+
+ ed = &e->eo_data[ndx];
+
+ if (ed->ed_alloc != NULL)
+ *ret_data = ed->ed_alloc;
+ else {
+ if (ed->ed_data == NULL) {
+ if (error)
+ *error = DW_DLE_NO_ENTRY;
+ return (DW_DLV_NO_ENTRY);
+ }
+ *ret_data = ed->ed_data->d_buf;
+ }
+
+ return (DW_DLV_OK);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_elf_init.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_elf_init.c
new file mode 100644
index 0000000..bd68afc
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_elf_init.c
@@ -0,0 +1,390 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_elf_init.c 3475 2016-05-18 18:11:26Z emaste $");
+
+static const char *debug_name[] = {
+ ".debug_abbrev",
+ ".debug_aranges",
+ ".debug_frame",
+ ".debug_info",
+ ".debug_types",
+ ".debug_line",
+ ".debug_pubnames",
+ ".eh_frame",
+ ".debug_macinfo",
+ ".debug_str",
+ ".debug_loc",
+ ".debug_pubtypes",
+ ".debug_ranges",
+ ".debug_static_func",
+ ".debug_static_vars",
+ ".debug_typenames",
+ ".debug_weaknames",
+ NULL
+};
+
+static void
+_dwarf_elf_apply_rel_reloc(Dwarf_Debug dbg, void *buf, uint64_t bufsize,
+ Elf_Data *rel_data, Elf_Data *symtab_data, int endian)
+{
+ Dwarf_Unsigned type;
+ GElf_Rel rel;
+ GElf_Sym sym;
+ size_t symndx;
+ uint64_t offset;
+ uint64_t addend;
+ int size, j;
+
+ j = 0;
+ while (gelf_getrel(rel_data, j++, &rel) != NULL) {
+ symndx = GELF_R_SYM(rel.r_info);
+ type = GELF_R_TYPE(rel.r_info);
+
+ if (gelf_getsym(symtab_data, symndx, &sym) == NULL)
+ continue;
+
+ size = _dwarf_get_reloc_size(dbg, type);
+ if (size == 0)
+ continue; /* Unknown or non-absolute relocation. */
+
+ offset = rel.r_offset;
+ if (offset + size >= bufsize)
+ continue;
+
+ if (endian == ELFDATA2MSB)
+ addend = _dwarf_read_msb(buf, &offset, size);
+ else
+ addend = _dwarf_read_lsb(buf, &offset, size);
+
+ offset = rel.r_offset;
+ if (endian == ELFDATA2MSB)
+ _dwarf_write_msb(buf, &offset, sym.st_value + addend,
+ size);
+ else
+ _dwarf_write_lsb(buf, &offset, sym.st_value + addend,
+ size);
+ }
+}
+
+static void
+_dwarf_elf_apply_rela_reloc(Dwarf_Debug dbg, void *buf, uint64_t bufsize,
+ Elf_Data *rel_data, Elf_Data *symtab_data, int endian)
+{
+ Dwarf_Unsigned type;
+ GElf_Rela rela;
+ GElf_Sym sym;
+ size_t symndx;
+ uint64_t offset;
+ int size, j;
+
+ j = 0;
+ while (gelf_getrela(rel_data, j++, &rela) != NULL) {
+ symndx = GELF_R_SYM(rela.r_info);
+ type = GELF_R_TYPE(rela.r_info);
+
+ if (gelf_getsym(symtab_data, symndx, &sym) == NULL)
+ continue;
+
+ offset = rela.r_offset;
+ size = _dwarf_get_reloc_size(dbg, type);
+ if (size == 0)
+ continue; /* Unknown or non-absolute relocation. */
+ if (offset + size >= bufsize)
+ continue;
+
+ if (endian == ELFDATA2MSB)
+ _dwarf_write_msb(buf, &offset,
+ sym.st_value + rela.r_addend, size);
+ else
+ _dwarf_write_lsb(buf, &offset,
+ sym.st_value + rela.r_addend, size);
+ }
+}
+
+static int
+_dwarf_elf_relocate(Dwarf_Debug dbg, Elf *elf, Dwarf_Elf_Data *ed, size_t shndx,
+ size_t symtab, Elf_Data *symtab_data, Dwarf_Error *error)
+{
+ GElf_Ehdr eh;
+ GElf_Shdr sh;
+ Elf_Scn *scn;
+ Elf_Data *rel;
+ int elferr;
+
+ if (symtab == 0 || symtab_data == NULL)
+ return (DW_DLE_NONE);
+
+ if (gelf_getehdr(elf, &eh) == NULL) {
+ DWARF_SET_ELF_ERROR(dbg, error);
+ return (DW_DLE_ELF);
+ }
+
+ scn = NULL;
+ (void) elf_errno();
+ while ((scn = elf_nextscn(elf, scn)) != NULL) {
+ if (gelf_getshdr(scn, &sh) == NULL) {
+ DWARF_SET_ELF_ERROR(dbg, error);
+ return (DW_DLE_ELF);
+ }
+
+ if ((sh.sh_type != SHT_REL && sh.sh_type != SHT_RELA) ||
+ sh.sh_size == 0)
+ continue;
+
+ if (sh.sh_info == shndx && sh.sh_link == symtab) {
+ if ((rel = elf_getdata(scn, NULL)) == NULL) {
+ elferr = elf_errno();
+ if (elferr != 0) {
+ _DWARF_SET_ERROR(NULL, error,
+ DW_DLE_ELF, elferr);
+ return (DW_DLE_ELF);
+ } else
+ return (DW_DLE_NONE);
+ }
+
+ ed->ed_alloc = malloc(ed->ed_data->d_size);
+ if (ed->ed_alloc == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ memcpy(ed->ed_alloc, ed->ed_data->d_buf,
+ ed->ed_data->d_size);
+ if (sh.sh_type == SHT_REL)
+ _dwarf_elf_apply_rel_reloc(dbg,
+ ed->ed_alloc, ed->ed_data->d_size,
+ rel, symtab_data, eh.e_ident[EI_DATA]);
+ else
+ _dwarf_elf_apply_rela_reloc(dbg,
+ ed->ed_alloc, ed->ed_data->d_size,
+ rel, symtab_data, eh.e_ident[EI_DATA]);
+
+ return (DW_DLE_NONE);
+ }
+ }
+ elferr = elf_errno();
+ if (elferr != 0) {
+ DWARF_SET_ELF_ERROR(dbg, error);
+ return (DW_DLE_ELF);
+ }
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_elf_init(Dwarf_Debug dbg, Elf *elf, Dwarf_Error *error)
+{
+ Dwarf_Obj_Access_Interface *iface;
+ Dwarf_Elf_Object *e;
+ const char *name;
+ GElf_Shdr sh;
+ Elf_Scn *scn;
+ Elf_Data *symtab_data;
+ size_t symtab_ndx;
+ int elferr, i, j, n, ret;
+
+ ret = DW_DLE_NONE;
+
+ if ((iface = calloc(1, sizeof(*iface))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ if ((e = calloc(1, sizeof(*e))) == NULL) {
+ free(iface);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ e->eo_elf = elf;
+ e->eo_methods.get_section_info = _dwarf_elf_get_section_info;
+ e->eo_methods.get_byte_order = _dwarf_elf_get_byte_order;
+ e->eo_methods.get_length_size = _dwarf_elf_get_length_size;
+ e->eo_methods.get_pointer_size = _dwarf_elf_get_pointer_size;
+ e->eo_methods.get_section_count = _dwarf_elf_get_section_count;
+ e->eo_methods.load_section = _dwarf_elf_load_section;
+
+ iface->object = e;
+ iface->methods = &e->eo_methods;
+
+ dbg->dbg_iface = iface;
+
+ if (gelf_getehdr(elf, &e->eo_ehdr) == NULL) {
+ DWARF_SET_ELF_ERROR(dbg, error);
+ ret = DW_DLE_ELF;
+ goto fail_cleanup;
+ }
+
+ dbg->dbg_machine = e->eo_ehdr.e_machine;
+
+ if (!elf_getshstrndx(elf, &e->eo_strndx)) {
+ DWARF_SET_ELF_ERROR(dbg, error);
+ ret = DW_DLE_ELF;
+ goto fail_cleanup;
+ }
+
+ n = 0;
+ symtab_ndx = 0;
+ symtab_data = NULL;
+ scn = NULL;
+ (void) elf_errno();
+ while ((scn = elf_nextscn(elf, scn)) != NULL) {
+ if (gelf_getshdr(scn, &sh) == NULL) {
+ DWARF_SET_ELF_ERROR(dbg, error);
+ ret = DW_DLE_ELF;
+ goto fail_cleanup;
+ }
+
+ if ((name = elf_strptr(elf, e->eo_strndx, sh.sh_name)) ==
+ NULL) {
+ DWARF_SET_ELF_ERROR(dbg, error);
+ ret = DW_DLE_ELF;
+ goto fail_cleanup;
+ }
+
+ if (!strcmp(name, ".symtab")) {
+ symtab_ndx = elf_ndxscn(scn);
+ if ((symtab_data = elf_getdata(scn, NULL)) == NULL) {
+ elferr = elf_errno();
+ if (elferr != 0) {
+ _DWARF_SET_ERROR(NULL, error,
+ DW_DLE_ELF, elferr);
+ ret = DW_DLE_ELF;
+ goto fail_cleanup;
+ }
+ }
+ continue;
+ }
+
+ for (i = 0; debug_name[i] != NULL; i++) {
+ if (!strcmp(name, debug_name[i]))
+ n++;
+ }
+ }
+ elferr = elf_errno();
+ if (elferr != 0) {
+ DWARF_SET_ELF_ERROR(dbg, error);
+ return (DW_DLE_ELF);
+ }
+
+ e->eo_seccnt = n;
+
+ if (n == 0)
+ return (DW_DLE_NONE);
+
+ if ((e->eo_data = calloc(n, sizeof(Dwarf_Elf_Data))) == NULL ||
+ (e->eo_shdr = calloc(n, sizeof(GElf_Shdr))) == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_MEMORY);
+ ret = DW_DLE_MEMORY;
+ goto fail_cleanup;
+ }
+
+ scn = NULL;
+ j = 0;
+ while ((scn = elf_nextscn(elf, scn)) != NULL && j < n) {
+ if (gelf_getshdr(scn, &sh) == NULL) {
+ DWARF_SET_ELF_ERROR(dbg, error);
+ ret = DW_DLE_ELF;
+ goto fail_cleanup;
+ }
+
+ memcpy(&e->eo_shdr[j], &sh, sizeof(sh));
+
+ if ((name = elf_strptr(elf, e->eo_strndx, sh.sh_name)) ==
+ NULL) {
+ DWARF_SET_ELF_ERROR(dbg, error);
+ ret = DW_DLE_ELF;
+ goto fail_cleanup;
+ }
+
+ for (i = 0; debug_name[i] != NULL; i++) {
+ if (strcmp(name, debug_name[i]))
+ continue;
+
+ (void) elf_errno();
+ if ((e->eo_data[j].ed_data = elf_getdata(scn, NULL)) ==
+ NULL) {
+ elferr = elf_errno();
+ if (elferr != 0) {
+ _DWARF_SET_ERROR(dbg, error,
+ DW_DLE_ELF, elferr);
+ ret = DW_DLE_ELF;
+ goto fail_cleanup;
+ }
+ }
+
+ if (_libdwarf.applyreloc) {
+ if (_dwarf_elf_relocate(dbg, elf,
+ &e->eo_data[j], elf_ndxscn(scn), symtab_ndx,
+ symtab_data, error) != DW_DLE_NONE)
+ goto fail_cleanup;
+ }
+
+ j++;
+ }
+ }
+
+ assert(j == n);
+
+ return (DW_DLE_NONE);
+
+fail_cleanup:
+
+ _dwarf_elf_deinit(dbg);
+
+ return (ret);
+}
+
+void
+_dwarf_elf_deinit(Dwarf_Debug dbg)
+{
+ Dwarf_Obj_Access_Interface *iface;
+ Dwarf_Elf_Object *e;
+ int i;
+
+ iface = dbg->dbg_iface;
+ assert(iface != NULL);
+
+ e = iface->object;
+ assert(e != NULL);
+
+ if (e->eo_data) {
+ for (i = 0; (Dwarf_Unsigned) i < e->eo_seccnt; i++) {
+ if (e->eo_data[i].ed_alloc)
+ free(e->eo_data[i].ed_alloc);
+ }
+ free(e->eo_data);
+ }
+ if (e->eo_shdr)
+ free(e->eo_shdr);
+
+ free(e);
+ free(iface);
+
+ dbg->dbg_iface = NULL;
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_error.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_error.c
new file mode 100644
index 0000000..da16029
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_error.c
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2010 Joseph Koshy
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_error.c 2070 2011-10-27 03:05:32Z jkoshy $");
+
+void
+_dwarf_set_error(Dwarf_Debug dbg, Dwarf_Error *error, int errorcode,
+ int elferrorcode, const char *functionname, int linenumber)
+{
+ Dwarf_Error de;
+
+ de.err_error = errorcode;
+ de.err_elferror = elferrorcode;
+ de.err_func = functionname;
+ de.err_line = linenumber;
+ de.err_msg[0] = '\0';
+
+ /*
+ * If the user supplied a destination for the error, copy the
+ * error descriptor over and return. Otherwise, if the debug
+ * context is known and has an error handler, invoke that.
+ * Otherwise, if a 'default' error handler was registered,
+ * invoke it.
+ */
+ if (error)
+ *error = de;
+ else if (dbg && dbg->dbg_errhand)
+ dbg->dbg_errhand(de, dbg->dbg_errarg);
+ else if (_libdwarf.errhand)
+ _libdwarf.errhand(de, _libdwarf.errarg);
+
+ /* No handler found, do nothing. */
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_frame.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_frame.c
new file mode 100644
index 0000000..cfa6971
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_frame.c
@@ -0,0 +1,1608 @@
+/*-
+ * Copyright (c) 2009-2011,2014 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_frame.c 3589 2018-03-13 20:34:33Z kaiwang27 $");
+
+static int
+_dwarf_frame_find_cie(Dwarf_FrameSec fs, Dwarf_Unsigned offset,
+ Dwarf_Cie *ret_cie)
+{
+ Dwarf_Cie cie;
+
+ STAILQ_FOREACH(cie, &fs->fs_cielist, cie_next) {
+ if (cie->cie_offset == offset)
+ break;
+ }
+
+ if (cie == NULL)
+ return (DW_DLE_NO_ENTRY);
+
+ if (ret_cie != NULL)
+ *ret_cie = cie;
+
+ return (DW_DLE_NONE);
+}
+
+static int
+_dwarf_frame_read_lsb_encoded(Dwarf_Debug dbg, Dwarf_Cie cie, uint64_t *val,
+ uint8_t *data, uint64_t *offsetp, uint8_t encode, Dwarf_Addr pc,
+ Dwarf_Error *error)
+{
+ uint8_t application;
+
+ if (encode == DW_EH_PE_omit)
+ return (DW_DLE_NONE);
+
+ application = encode & 0xf0;
+ encode &= 0x0f;
+
+ switch (encode) {
+ case DW_EH_PE_absptr:
+ *val = dbg->read(data, offsetp, cie->cie_addrsize);
+ break;
+ case DW_EH_PE_uleb128:
+ *val = _dwarf_read_uleb128(data, offsetp);
+ break;
+ case DW_EH_PE_udata2:
+ *val = dbg->read(data, offsetp, 2);
+ break;
+ case DW_EH_PE_udata4:
+ *val = dbg->read(data, offsetp, 4);
+ break;
+ case DW_EH_PE_udata8:
+ *val = dbg->read(data, offsetp, 8);
+ break;
+ case DW_EH_PE_sleb128:
+ *val = _dwarf_read_sleb128(data, offsetp);
+ break;
+ case DW_EH_PE_sdata2:
+ *val = (int16_t) dbg->read(data, offsetp, 2);
+ break;
+ case DW_EH_PE_sdata4:
+ *val = (int32_t) dbg->read(data, offsetp, 4);
+ break;
+ case DW_EH_PE_sdata8:
+ *val = dbg->read(data, offsetp, 8);
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error, DW_DLE_FRAME_AUGMENTATION_UNKNOWN);
+ return (DW_DLE_FRAME_AUGMENTATION_UNKNOWN);
+ }
+
+ if (application == DW_EH_PE_pcrel) {
+ /*
+ * Value is relative to .eh_frame section virtual addr.
+ */
+ switch (encode) {
+ case DW_EH_PE_uleb128:
+ case DW_EH_PE_udata2:
+ case DW_EH_PE_udata4:
+ case DW_EH_PE_udata8:
+ *val += pc;
+ break;
+ case DW_EH_PE_sleb128:
+ case DW_EH_PE_sdata2:
+ case DW_EH_PE_sdata4:
+ case DW_EH_PE_sdata8:
+ *val = pc + (int64_t) *val;
+ break;
+ default:
+ /* DW_EH_PE_absptr is absolute value. */
+ break;
+ }
+ }
+
+ /* XXX Applications other than DW_EH_PE_pcrel are not handled. */
+
+ return (DW_DLE_NONE);
+}
+
+static int
+_dwarf_frame_parse_lsb_cie_augment(Dwarf_Debug dbg, Dwarf_Cie cie,
+ Dwarf_Error *error)
+{
+ uint8_t *aug_p, *augdata_p;
+ uint64_t val, offset;
+ uint8_t encode;
+ int ret;
+
+ assert(cie->cie_augment != NULL && *cie->cie_augment == 'z');
+
+ /*
+ * Here we're only interested in the presence of augment 'R'
+ * and associated CIE augment data, which describes the
+ * encoding scheme of FDE PC begin and range.
+ */
+ aug_p = &cie->cie_augment[1];
+ augdata_p = cie->cie_augdata;
+ while (*aug_p != '\0') {
+ switch (*aug_p) {
+ case 'S':
+ break;
+ case 'L':
+ /* Skip one augment in augment data. */
+ augdata_p++;
+ break;
+ case 'P':
+ /* Skip two augments in augment data. */
+ encode = *augdata_p++;
+ offset = 0;
+ ret = _dwarf_frame_read_lsb_encoded(dbg, cie, &val,
+ augdata_p, &offset, encode, 0, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ augdata_p += offset;
+ break;
+ case 'R':
+ cie->cie_fde_encode = *augdata_p++;
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error,
+ DW_DLE_FRAME_AUGMENTATION_UNKNOWN);
+ return (DW_DLE_FRAME_AUGMENTATION_UNKNOWN);
+ }
+ aug_p++;
+ }
+
+ return (DW_DLE_NONE);
+}
+
+static int
+_dwarf_frame_add_cie(Dwarf_Debug dbg, Dwarf_FrameSec fs, Dwarf_Section *ds,
+ Dwarf_Unsigned *off, Dwarf_Cie *ret_cie, Dwarf_Error *error)
+{
+ Dwarf_Cie cie;
+ uint64_t length;
+ int dwarf_size, ret;
+ char *p;
+
+ /* Check if we already added this CIE. */
+ if (_dwarf_frame_find_cie(fs, *off, &cie) != DW_DLE_NO_ENTRY) {
+ *off += cie->cie_length + 4;
+ return (DW_DLE_NONE);
+ }
+
+ if ((cie = calloc(1, sizeof(struct _Dwarf_Cie))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ STAILQ_INSERT_TAIL(&fs->fs_cielist, cie, cie_next);
+
+ cie->cie_dbg = dbg;
+ cie->cie_index = fs->fs_cielen;
+ cie->cie_offset = *off;
+
+ length = dbg->read(ds->ds_data, off, 4);
+ if (length == 0xffffffff) {
+ dwarf_size = 8;
+ length = dbg->read(ds->ds_data, off, 8);
+ } else
+ dwarf_size = 4;
+
+ if (length > ds->ds_size - *off) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_DEBUG_FRAME_LENGTH_BAD);
+ return (DW_DLE_DEBUG_FRAME_LENGTH_BAD);
+ }
+
+ (void) dbg->read(ds->ds_data, off, dwarf_size); /* Skip CIE id. */
+ cie->cie_length = length;
+
+ cie->cie_version = dbg->read(ds->ds_data, off, 1);
+ if (cie->cie_version != 1 && cie->cie_version != 3 &&
+ cie->cie_version != 4) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_FRAME_VERSION_BAD);
+ return (DW_DLE_FRAME_VERSION_BAD);
+ }
+
+ cie->cie_augment = ds->ds_data + *off;
+ p = (char *) ds->ds_data;
+ while (p[(*off)++] != '\0')
+ ;
+
+ /* We only recognize normal .dwarf_frame and GNU .eh_frame sections. */
+ if (*cie->cie_augment != 0 && *cie->cie_augment != 'z') {
+ *off = cie->cie_offset + ((dwarf_size == 4) ? 4 : 12) +
+ cie->cie_length;
+ return (DW_DLE_NONE);
+ }
+
+ /* Optional EH Data field for .eh_frame section. */
+ if (strstr((char *)cie->cie_augment, "eh") != NULL)
+ cie->cie_ehdata = dbg->read(ds->ds_data, off,
+ dbg->dbg_pointer_size);
+
+ /* DWARF4 added "address_size" and "segment_size". */
+ if (cie->cie_version == 4) {
+ cie->cie_addrsize = dbg->read(ds->ds_data, off, 1);
+ cie->cie_segmentsize = dbg->read(ds->ds_data, off, 1);
+ } else {
+ /*
+ * Otherwise (DWARF[23]) we just set CIE addrsize to the
+ * debug context pointer size.
+ */
+ cie->cie_addrsize = dbg->dbg_pointer_size;
+ }
+
+ cie->cie_caf = _dwarf_read_uleb128(ds->ds_data, off);
+ cie->cie_daf = _dwarf_read_sleb128(ds->ds_data, off);
+
+ /* Return address register. */
+ if (cie->cie_version == 1)
+ cie->cie_ra = dbg->read(ds->ds_data, off, 1);
+ else
+ cie->cie_ra = _dwarf_read_uleb128(ds->ds_data, off);
+
+ /* Optional CIE augmentation data for .eh_frame section. */
+ if (*cie->cie_augment == 'z') {
+ cie->cie_auglen = _dwarf_read_uleb128(ds->ds_data, off);
+ cie->cie_augdata = ds->ds_data + *off;
+ *off += cie->cie_auglen;
+ /*
+ * XXX Use DW_EH_PE_absptr for default FDE PC start/range,
+ * in case _dwarf_frame_parse_lsb_cie_augment fails to
+ * find out the real encode.
+ */
+ cie->cie_fde_encode = DW_EH_PE_absptr;
+ ret = _dwarf_frame_parse_lsb_cie_augment(dbg, cie, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+
+ /* CIE Initial instructions. */
+ cie->cie_initinst = ds->ds_data + *off;
+ if (dwarf_size == 4)
+ cie->cie_instlen = cie->cie_offset + 4 + length - *off;
+ else
+ cie->cie_instlen = cie->cie_offset + 12 + length - *off;
+
+ *off += cie->cie_instlen;
+
+#ifdef FRAME_DEBUG
+ printf("cie:\n");
+ printf("\tcie_version=%u cie_offset=%ju cie_length=%ju cie_augment=%s"
+ " cie_instlen=%ju cie->cie_caf=%ju cie->cie_daf=%jd off=%ju\n",
+ cie->cie_version, cie->cie_offset, cie->cie_length,
+ (char *)cie->cie_augment, cie->cie_instlen, cie->cie_caf,
+ cie->cie_daf, *off);
+#endif
+
+ if (ret_cie != NULL)
+ *ret_cie = cie;
+
+ fs->fs_cielen++;
+
+ return (DW_DLE_NONE);
+}
+
+static int
+_dwarf_frame_add_fde(Dwarf_Debug dbg, Dwarf_FrameSec fs, Dwarf_Section *ds,
+ Dwarf_Unsigned *off, int eh_frame, Dwarf_Error *error)
+{
+ Dwarf_Cie cie;
+ Dwarf_Fde fde;
+ Dwarf_Unsigned cieoff;
+ uint64_t length, val;
+ int dwarf_size, ret;
+
+ if ((fde = calloc(1, sizeof(struct _Dwarf_Fde))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ STAILQ_INSERT_TAIL(&fs->fs_fdelist, fde, fde_next);
+
+ fde->fde_dbg = dbg;
+ fde->fde_fs = fs;
+ fde->fde_addr = ds->ds_data + *off;
+ fde->fde_offset = *off;
+
+ length = dbg->read(ds->ds_data, off, 4);
+ if (length == 0xffffffff) {
+ dwarf_size = 8;
+ length = dbg->read(ds->ds_data, off, 8);
+ } else
+ dwarf_size = 4;
+
+ if (length > ds->ds_size - *off) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_DEBUG_FRAME_LENGTH_BAD);
+ return (DW_DLE_DEBUG_FRAME_LENGTH_BAD);
+ }
+
+ fde->fde_length = length;
+
+ if (eh_frame) {
+ fde->fde_cieoff = dbg->read(ds->ds_data, off, 4);
+ cieoff = *off - (4 + fde->fde_cieoff);
+ /* This delta should never be 0. */
+ if (cieoff == fde->fde_offset) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_CIE_FOR_FDE);
+ return (DW_DLE_NO_CIE_FOR_FDE);
+ }
+ } else {
+ fde->fde_cieoff = dbg->read(ds->ds_data, off, dwarf_size);
+ cieoff = fde->fde_cieoff;
+ }
+
+ if (_dwarf_frame_find_cie(fs, cieoff, &cie) ==
+ DW_DLE_NO_ENTRY) {
+ ret = _dwarf_frame_add_cie(dbg, fs, ds, &cieoff, &cie,
+ error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+ fde->fde_cie = cie;
+ if (eh_frame) {
+ /*
+ * The FDE PC start/range for .eh_frame is encoded according
+ * to the LSB spec's extension to DWARF2.
+ */
+ ret = _dwarf_frame_read_lsb_encoded(dbg, cie, &val,
+ ds->ds_data, off, cie->cie_fde_encode, ds->ds_addr + *off,
+ error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ fde->fde_initloc = val;
+ /*
+ * FDE PC range should not be relative value to anything.
+ * So pass 0 for pc value.
+ */
+ ret = _dwarf_frame_read_lsb_encoded(dbg, cie, &val,
+ ds->ds_data, off, cie->cie_fde_encode, 0, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ fde->fde_adrange = val;
+ } else {
+ fde->fde_initloc = dbg->read(ds->ds_data, off,
+ cie->cie_addrsize);
+ fde->fde_adrange = dbg->read(ds->ds_data, off,
+ cie->cie_addrsize);
+ }
+
+ /* Optional FDE augmentation data for .eh_frame section. (ignored) */
+ if (eh_frame && *cie->cie_augment == 'z') {
+ fde->fde_auglen = _dwarf_read_uleb128(ds->ds_data, off);
+ fde->fde_augdata = ds->ds_data + *off;
+ *off += fde->fde_auglen;
+ }
+
+ fde->fde_inst = ds->ds_data + *off;
+ if (dwarf_size == 4)
+ fde->fde_instlen = fde->fde_offset + 4 + length - *off;
+ else
+ fde->fde_instlen = fde->fde_offset + 12 + length - *off;
+
+ *off += fde->fde_instlen;
+
+#ifdef FRAME_DEBUG
+ printf("fde:");
+ if (eh_frame)
+ printf("(eh_frame)");
+ putchar('\n');
+ printf("\tfde_offset=%ju fde_length=%ju fde_cieoff=%ju"
+ " fde_instlen=%ju off=%ju\n", fde->fde_offset, fde->fde_length,
+ fde->fde_cieoff, fde->fde_instlen, *off);
+#endif
+
+ fs->fs_fdelen++;
+
+ return (DW_DLE_NONE);
+}
+
+static void
+_dwarf_frame_section_cleanup(Dwarf_FrameSec fs)
+{
+ Dwarf_Cie cie, tcie;
+ Dwarf_Fde fde, tfde;
+
+ STAILQ_FOREACH_SAFE(cie, &fs->fs_cielist, cie_next, tcie) {
+ STAILQ_REMOVE(&fs->fs_cielist, cie, _Dwarf_Cie, cie_next);
+ free(cie);
+ }
+
+ STAILQ_FOREACH_SAFE(fde, &fs->fs_fdelist, fde_next, tfde) {
+ STAILQ_REMOVE(&fs->fs_fdelist, fde, _Dwarf_Fde, fde_next);
+ free(fde);
+ }
+
+ if (fs->fs_ciearray != NULL)
+ free(fs->fs_ciearray);
+ if (fs->fs_fdearray != NULL)
+ free(fs->fs_fdearray);
+
+ free(fs);
+}
+
+static int
+_dwarf_frame_section_init(Dwarf_Debug dbg, Dwarf_FrameSec *frame_sec,
+ Dwarf_Section *ds, int eh_frame, Dwarf_Error *error)
+{
+ Dwarf_FrameSec fs;
+ Dwarf_Cie cie;
+ Dwarf_Fde fde;
+ uint64_t length, offset, cie_id, entry_off;
+ int dwarf_size, i, ret;
+
+ assert(frame_sec != NULL);
+ assert(*frame_sec == NULL);
+
+ if ((fs = calloc(1, sizeof(struct _Dwarf_FrameSec))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ STAILQ_INIT(&fs->fs_cielist);
+ STAILQ_INIT(&fs->fs_fdelist);
+
+ offset = 0;
+ while (offset < ds->ds_size) {
+ entry_off = offset;
+ length = dbg->read(ds->ds_data, &offset, 4);
+ if (length == 0xffffffff) {
+ dwarf_size = 8;
+ length = dbg->read(ds->ds_data, &offset, 8);
+ } else
+ dwarf_size = 4;
+
+ if (length > ds->ds_size - offset ||
+ (length == 0 && !eh_frame)) {
+ DWARF_SET_ERROR(dbg, error,
+ DW_DLE_DEBUG_FRAME_LENGTH_BAD);
+ return (DW_DLE_DEBUG_FRAME_LENGTH_BAD);
+ }
+
+ /* Check terminator for .eh_frame */
+ if (eh_frame && length == 0)
+ break;
+
+ cie_id = dbg->read(ds->ds_data, &offset, dwarf_size);
+
+ if (eh_frame) {
+ /* GNU .eh_frame use CIE id 0. */
+ if (cie_id == 0)
+ ret = _dwarf_frame_add_cie(dbg, fs, ds,
+ &entry_off, NULL, error);
+ else
+ ret = _dwarf_frame_add_fde(dbg, fs, ds,
+ &entry_off, 1, error);
+ } else {
+ /* .dwarf_frame use CIE id ~0 */
+ if ((dwarf_size == 4 && cie_id == ~0U) ||
+ (dwarf_size == 8 && cie_id == ~0ULL))
+ ret = _dwarf_frame_add_cie(dbg, fs, ds,
+ &entry_off, NULL, error);
+ else
+ ret = _dwarf_frame_add_fde(dbg, fs, ds,
+ &entry_off, 0, error);
+ }
+
+ if (ret != DW_DLE_NONE)
+ goto fail_cleanup;
+
+ offset = entry_off;
+ }
+
+ /* Create CIE array. */
+ if (fs->fs_cielen > 0) {
+ if ((fs->fs_ciearray = malloc(sizeof(Dwarf_Cie) *
+ fs->fs_cielen)) == NULL) {
+ ret = DW_DLE_MEMORY;
+ DWARF_SET_ERROR(dbg, error, ret);
+ goto fail_cleanup;
+ }
+ i = 0;
+ STAILQ_FOREACH(cie, &fs->fs_cielist, cie_next) {
+ fs->fs_ciearray[i++] = cie;
+ }
+ assert((Dwarf_Unsigned)i == fs->fs_cielen);
+ }
+
+ /* Create FDE array. */
+ if (fs->fs_fdelen > 0) {
+ if ((fs->fs_fdearray = malloc(sizeof(Dwarf_Fde) *
+ fs->fs_fdelen)) == NULL) {
+ ret = DW_DLE_MEMORY;
+ DWARF_SET_ERROR(dbg, error, ret);
+ goto fail_cleanup;
+ }
+ i = 0;
+ STAILQ_FOREACH(fde, &fs->fs_fdelist, fde_next) {
+ fs->fs_fdearray[i++] = fde;
+ }
+ assert((Dwarf_Unsigned)i == fs->fs_fdelen);
+ }
+
+ *frame_sec = fs;
+
+ return (DW_DLE_NONE);
+
+fail_cleanup:
+
+ _dwarf_frame_section_cleanup(fs);
+
+ return (ret);
+}
+
+static int
+_dwarf_frame_run_inst(Dwarf_Debug dbg, Dwarf_Regtable3 *rt, uint8_t addr_size,
+ uint8_t *insts, Dwarf_Unsigned len, Dwarf_Unsigned caf, Dwarf_Signed daf,
+ Dwarf_Addr pc, Dwarf_Addr pc_req, Dwarf_Addr *row_pc, Dwarf_Error *error)
+{
+ Dwarf_Regtable3 *init_rt, *saved_rt;
+ uint8_t *p, *pe;
+ uint8_t high2, low6;
+ uint64_t reg, reg2, uoff, soff;
+ int ret;
+
+#define CFA rt->rt3_cfa_rule
+#define INITCFA init_rt->rt3_cfa_rule
+#define RL rt->rt3_rules
+#define INITRL init_rt->rt3_rules
+
+#define CHECK_TABLE_SIZE(x) \
+ do { \
+ if ((x) >= rt->rt3_reg_table_size) { \
+ DWARF_SET_ERROR(dbg, error, \
+ DW_DLE_DF_REG_NUM_TOO_HIGH); \
+ ret = DW_DLE_DF_REG_NUM_TOO_HIGH; \
+ goto program_done; \
+ } \
+ } while(0)
+
+#ifdef FRAME_DEBUG
+ printf("frame_run_inst: (caf=%ju, daf=%jd)\n", caf, daf);
+#endif
+
+ ret = DW_DLE_NONE;
+ init_rt = saved_rt = NULL;
+ *row_pc = pc;
+
+ /* Save a copy of the table as initial state. */
+ _dwarf_frame_regtable_copy(dbg, &init_rt, rt, error);
+
+ p = insts;
+ pe = p + len;
+
+ while (p < pe) {
+
+#ifdef FRAME_DEBUG
+ printf("p=%p pe=%p pc=%#jx pc_req=%#jx\n", p, pe, pc, pc_req);
+#endif
+
+ if (*p == DW_CFA_nop) {
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_nop\n");
+#endif
+ p++;
+ continue;
+ }
+
+ high2 = *p & 0xc0;
+ low6 = *p & 0x3f;
+ p++;
+
+ if (high2 > 0) {
+ switch (high2) {
+ case DW_CFA_advance_loc:
+ pc += low6 * caf;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_advance_loc(%#jx(%u))\n", pc,
+ low6);
+#endif
+ if (pc_req < pc)
+ goto program_done;
+ break;
+ case DW_CFA_offset:
+ *row_pc = pc;
+ CHECK_TABLE_SIZE(low6);
+ RL[low6].dw_offset_relevant = 1;
+ RL[low6].dw_value_type = DW_EXPR_OFFSET;
+ RL[low6].dw_regnum = dbg->dbg_frame_cfa_value;
+ RL[low6].dw_offset_or_block_len =
+ _dwarf_decode_uleb128(&p) * daf;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_offset(%jd)\n",
+ RL[low6].dw_offset_or_block_len);
+#endif
+ break;
+ case DW_CFA_restore:
+ *row_pc = pc;
+ CHECK_TABLE_SIZE(low6);
+ memcpy(&RL[low6], &INITRL[low6],
+ sizeof(Dwarf_Regtable_Entry3));
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_restore(%u)\n", low6);
+#endif
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error,
+ DW_DLE_FRAME_INSTR_EXEC_ERROR);
+ ret = DW_DLE_FRAME_INSTR_EXEC_ERROR;
+ goto program_done;
+ }
+
+ continue;
+ }
+
+ switch (low6) {
+ case DW_CFA_set_loc:
+ pc = dbg->decode(&p, addr_size);
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_set_loc(pc=%#jx)\n", pc);
+#endif
+ if (pc_req < pc)
+ goto program_done;
+ break;
+ case DW_CFA_advance_loc1:
+ pc += dbg->decode(&p, 1) * caf;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_set_loc1(pc=%#jx)\n", pc);
+#endif
+ if (pc_req < pc)
+ goto program_done;
+ break;
+ case DW_CFA_advance_loc2:
+ pc += dbg->decode(&p, 2) * caf;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_set_loc2(pc=%#jx)\n", pc);
+#endif
+ if (pc_req < pc)
+ goto program_done;
+ break;
+ case DW_CFA_advance_loc4:
+ pc += dbg->decode(&p, 4) * caf;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_set_loc4(pc=%#jx)\n", pc);
+#endif
+ if (pc_req < pc)
+ goto program_done;
+ break;
+ case DW_CFA_offset_extended:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ uoff = _dwarf_decode_uleb128(&p);
+ CHECK_TABLE_SIZE(reg);
+ RL[reg].dw_offset_relevant = 1;
+ RL[reg].dw_value_type = DW_EXPR_OFFSET;
+ RL[reg].dw_regnum = dbg->dbg_frame_cfa_value;
+ RL[reg].dw_offset_or_block_len = uoff * daf;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_offset_extended(reg=%ju,uoff=%ju)\n",
+ reg, uoff);
+#endif
+ break;
+ case DW_CFA_restore_extended:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ CHECK_TABLE_SIZE(reg);
+ memcpy(&RL[reg], &INITRL[reg],
+ sizeof(Dwarf_Regtable_Entry3));
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_restore_extended(%ju)\n", reg);
+#endif
+ break;
+ case DW_CFA_undefined:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ CHECK_TABLE_SIZE(reg);
+ RL[reg].dw_offset_relevant = 0;
+ RL[reg].dw_regnum = dbg->dbg_frame_undefined_value;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_undefined(%ju)\n", reg);
+#endif
+ break;
+ case DW_CFA_same_value:
+ reg = _dwarf_decode_uleb128(&p);
+ CHECK_TABLE_SIZE(reg);
+ RL[reg].dw_offset_relevant = 0;
+ RL[reg].dw_regnum = dbg->dbg_frame_same_value;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_same_value(%ju)\n", reg);
+#endif
+ break;
+ case DW_CFA_register:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ reg2 = _dwarf_decode_uleb128(&p);
+ CHECK_TABLE_SIZE(reg);
+ RL[reg].dw_offset_relevant = 0;
+ RL[reg].dw_regnum = reg2;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_register(reg=%ju,reg2=%ju)\n", reg,
+ reg2);
+#endif
+ break;
+ case DW_CFA_remember_state:
+ _dwarf_frame_regtable_copy(dbg, &saved_rt, rt, error);
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_remember_state\n");
+#endif
+ break;
+ case DW_CFA_restore_state:
+ *row_pc = pc;
+ _dwarf_frame_regtable_copy(dbg, &rt, saved_rt, error);
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_restore_state\n");
+#endif
+ break;
+ case DW_CFA_def_cfa:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ uoff = _dwarf_decode_uleb128(&p);
+ CFA.dw_offset_relevant = 1;
+ CFA.dw_value_type = DW_EXPR_OFFSET;
+ CFA.dw_regnum = reg;
+ CFA.dw_offset_or_block_len = uoff;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_def_cfa(reg=%ju,uoff=%ju)\n", reg, uoff);
+#endif
+ break;
+ case DW_CFA_def_cfa_register:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ CFA.dw_regnum = reg;
+ /*
+ * Note that DW_CFA_def_cfa_register change the CFA
+ * rule register while keep the old offset. So we
+ * should not touch the CFA.dw_offset_relevant flag
+ * here.
+ */
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_def_cfa_register(%ju)\n", reg);
+#endif
+ break;
+ case DW_CFA_def_cfa_offset:
+ *row_pc = pc;
+ uoff = _dwarf_decode_uleb128(&p);
+ CFA.dw_offset_relevant = 1;
+ CFA.dw_value_type = DW_EXPR_OFFSET;
+ CFA.dw_offset_or_block_len = uoff;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_def_cfa_offset(%ju)\n", uoff);
+#endif
+ break;
+ case DW_CFA_def_cfa_expression:
+ *row_pc = pc;
+ CFA.dw_offset_relevant = 0;
+ CFA.dw_value_type = DW_EXPR_EXPRESSION;
+ CFA.dw_offset_or_block_len = _dwarf_decode_uleb128(&p);
+ CFA.dw_block_ptr = p;
+ p += CFA.dw_offset_or_block_len;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_def_cfa_expression\n");
+#endif
+ break;
+ case DW_CFA_expression:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ CHECK_TABLE_SIZE(reg);
+ RL[reg].dw_offset_relevant = 0;
+ RL[reg].dw_value_type = DW_EXPR_EXPRESSION;
+ RL[reg].dw_offset_or_block_len =
+ _dwarf_decode_uleb128(&p);
+ RL[reg].dw_block_ptr = p;
+ p += RL[reg].dw_offset_or_block_len;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_expression\n");
+#endif
+ break;
+ case DW_CFA_offset_extended_sf:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ soff = _dwarf_decode_sleb128(&p);
+ CHECK_TABLE_SIZE(reg);
+ RL[reg].dw_offset_relevant = 1;
+ RL[reg].dw_value_type = DW_EXPR_OFFSET;
+ RL[reg].dw_regnum = dbg->dbg_frame_cfa_value;
+ RL[reg].dw_offset_or_block_len = soff * daf;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_offset_extended_sf(reg=%ju,soff=%jd)\n",
+ reg, soff);
+#endif
+ break;
+ case DW_CFA_def_cfa_sf:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ soff = _dwarf_decode_sleb128(&p);
+ CFA.dw_offset_relevant = 1;
+ CFA.dw_value_type = DW_EXPR_OFFSET;
+ CFA.dw_regnum = reg;
+ CFA.dw_offset_or_block_len = soff * daf;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_def_cfa_sf(reg=%ju,soff=%jd)\n", reg,
+ soff);
+#endif
+ break;
+ case DW_CFA_def_cfa_offset_sf:
+ *row_pc = pc;
+ soff = _dwarf_decode_sleb128(&p);
+ CFA.dw_offset_relevant = 1;
+ CFA.dw_value_type = DW_EXPR_OFFSET;
+ CFA.dw_offset_or_block_len = soff * daf;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_def_cfa_offset_sf(soff=%jd)\n", soff);
+#endif
+ break;
+ case DW_CFA_val_offset:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ uoff = _dwarf_decode_uleb128(&p);
+ CHECK_TABLE_SIZE(reg);
+ RL[reg].dw_offset_relevant = 1;
+ RL[reg].dw_value_type = DW_EXPR_VAL_OFFSET;
+ RL[reg].dw_regnum = dbg->dbg_frame_cfa_value;
+ RL[reg].dw_offset_or_block_len = uoff * daf;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_val_offset(reg=%ju,uoff=%ju)\n", reg,
+ uoff);
+#endif
+ break;
+ case DW_CFA_val_offset_sf:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ soff = _dwarf_decode_sleb128(&p);
+ CHECK_TABLE_SIZE(reg);
+ RL[reg].dw_offset_relevant = 1;
+ RL[reg].dw_value_type = DW_EXPR_VAL_OFFSET;
+ RL[reg].dw_regnum = dbg->dbg_frame_cfa_value;
+ RL[reg].dw_offset_or_block_len = soff * daf;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_val_offset_sf(reg=%ju,soff=%jd)\n", reg,
+ soff);
+#endif
+ break;
+ case DW_CFA_val_expression:
+ *row_pc = pc;
+ reg = _dwarf_decode_uleb128(&p);
+ CHECK_TABLE_SIZE(reg);
+ RL[reg].dw_offset_relevant = 0;
+ RL[reg].dw_value_type = DW_EXPR_VAL_EXPRESSION;
+ RL[reg].dw_offset_or_block_len =
+ _dwarf_decode_uleb128(&p);
+ RL[reg].dw_block_ptr = p;
+ p += RL[reg].dw_offset_or_block_len;
+#ifdef FRAME_DEBUG
+ printf("DW_CFA_val_expression\n");
+#endif
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error,
+ DW_DLE_FRAME_INSTR_EXEC_ERROR);
+ ret = DW_DLE_FRAME_INSTR_EXEC_ERROR;
+ goto program_done;
+ }
+ }
+
+program_done:
+
+ free(init_rt->rt3_rules);
+ free(init_rt);
+ if (saved_rt) {
+ free(saved_rt->rt3_rules);
+ free(saved_rt);
+ }
+
+ return (ret);
+
+#undef CFA
+#undef INITCFA
+#undef RL
+#undef INITRL
+#undef CHECK_TABLE_SIZE
+}
+
+static int
+_dwarf_frame_convert_inst(Dwarf_Debug dbg, uint8_t addr_size, uint8_t *insts,
+ Dwarf_Unsigned len, Dwarf_Unsigned *count, Dwarf_Frame_Op *fop,
+ Dwarf_Frame_Op3 *fop3, Dwarf_Error *error)
+{
+ uint8_t *p, *pe;
+ uint8_t high2, low6;
+ uint64_t reg, reg2, uoff, soff, blen;
+
+#define SET_BASE_OP(x) \
+ do { \
+ if (fop != NULL) \
+ fop[*count].fp_base_op = (x) >> 6; \
+ if (fop3 != NULL) \
+ fop3[*count].fp_base_op = (x) >> 6; \
+ } while(0)
+
+#define SET_EXTENDED_OP(x) \
+ do { \
+ if (fop != NULL) \
+ fop[*count].fp_extended_op = (x); \
+ if (fop3 != NULL) \
+ fop3[*count].fp_extended_op = (x); \
+ } while(0)
+
+#define SET_REGISTER(x) \
+ do { \
+ if (fop != NULL) \
+ fop[*count].fp_register = (x); \
+ if (fop3 != NULL) \
+ fop3[*count].fp_register = (x); \
+ } while(0)
+
+#define SET_OFFSET(x) \
+ do { \
+ if (fop != NULL) \
+ fop[*count].fp_offset = (x); \
+ if (fop3 != NULL) \
+ fop3[*count].fp_offset_or_block_len = \
+ (x); \
+ } while(0)
+
+#define SET_INSTR_OFFSET(x) \
+ do { \
+ if (fop != NULL) \
+ fop[*count].fp_instr_offset = (x); \
+ if (fop3 != NULL) \
+ fop3[*count].fp_instr_offset = (x); \
+ } while(0)
+
+#define SET_BLOCK_LEN(x) \
+ do { \
+ if (fop3 != NULL) \
+ fop3[*count].fp_offset_or_block_len = \
+ (x); \
+ } while(0)
+
+#define SET_EXPR_BLOCK(addr, len) \
+ do { \
+ if (fop3 != NULL) { \
+ fop3[*count].fp_expr_block = \
+ malloc((size_t) (len)); \
+ if (fop3[*count].fp_expr_block == NULL) { \
+ DWARF_SET_ERROR(dbg, error, \
+ DW_DLE_MEMORY); \
+ return (DW_DLE_MEMORY); \
+ } \
+ memcpy(&fop3[*count].fp_expr_block, \
+ (addr), (len)); \
+ } \
+ } while(0)
+
+ *count = 0;
+
+ p = insts;
+ pe = p + len;
+
+ while (p < pe) {
+
+ SET_INSTR_OFFSET(p - insts);
+
+ if (*p == DW_CFA_nop) {
+ p++;
+ (*count)++;
+ continue;
+ }
+
+ high2 = *p & 0xc0;
+ low6 = *p & 0x3f;
+ p++;
+
+ if (high2 > 0) {
+ switch (high2) {
+ case DW_CFA_advance_loc:
+ SET_BASE_OP(high2);
+ SET_OFFSET(low6);
+ break;
+ case DW_CFA_offset:
+ SET_BASE_OP(high2);
+ SET_REGISTER(low6);
+ uoff = _dwarf_decode_uleb128(&p);
+ SET_OFFSET(uoff);
+ break;
+ case DW_CFA_restore:
+ SET_BASE_OP(high2);
+ SET_REGISTER(low6);
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error,
+ DW_DLE_FRAME_INSTR_EXEC_ERROR);
+ return (DW_DLE_FRAME_INSTR_EXEC_ERROR);
+ }
+
+ (*count)++;
+ continue;
+ }
+
+ SET_EXTENDED_OP(low6);
+
+ switch (low6) {
+ case DW_CFA_set_loc:
+ uoff = dbg->decode(&p, addr_size);
+ SET_OFFSET(uoff);
+ break;
+ case DW_CFA_advance_loc1:
+ uoff = dbg->decode(&p, 1);
+ SET_OFFSET(uoff);
+ break;
+ case DW_CFA_advance_loc2:
+ uoff = dbg->decode(&p, 2);
+ SET_OFFSET(uoff);
+ break;
+ case DW_CFA_advance_loc4:
+ uoff = dbg->decode(&p, 4);
+ SET_OFFSET(uoff);
+ break;
+ case DW_CFA_offset_extended:
+ case DW_CFA_def_cfa:
+ case DW_CFA_val_offset:
+ reg = _dwarf_decode_uleb128(&p);
+ uoff = _dwarf_decode_uleb128(&p);
+ SET_REGISTER(reg);
+ SET_OFFSET(uoff);
+ break;
+ case DW_CFA_restore_extended:
+ case DW_CFA_undefined:
+ case DW_CFA_same_value:
+ case DW_CFA_def_cfa_register:
+ reg = _dwarf_decode_uleb128(&p);
+ SET_REGISTER(reg);
+ break;
+ case DW_CFA_register:
+ reg = _dwarf_decode_uleb128(&p);
+ reg2 = _dwarf_decode_uleb128(&p);
+ SET_REGISTER(reg);
+ SET_OFFSET(reg2);
+ break;
+ case DW_CFA_remember_state:
+ case DW_CFA_restore_state:
+ break;
+ case DW_CFA_def_cfa_offset:
+ uoff = _dwarf_decode_uleb128(&p);
+ SET_OFFSET(uoff);
+ break;
+ case DW_CFA_def_cfa_expression:
+ blen = _dwarf_decode_uleb128(&p);
+ SET_BLOCK_LEN(blen);
+ SET_EXPR_BLOCK(p, blen);
+ p += blen;
+ break;
+ case DW_CFA_expression:
+ case DW_CFA_val_expression:
+ reg = _dwarf_decode_uleb128(&p);
+ blen = _dwarf_decode_uleb128(&p);
+ SET_REGISTER(reg);
+ SET_BLOCK_LEN(blen);
+ SET_EXPR_BLOCK(p, blen);
+ p += blen;
+ break;
+ case DW_CFA_offset_extended_sf:
+ case DW_CFA_def_cfa_sf:
+ case DW_CFA_val_offset_sf:
+ reg = _dwarf_decode_uleb128(&p);
+ soff = _dwarf_decode_sleb128(&p);
+ SET_REGISTER(reg);
+ SET_OFFSET(soff);
+ break;
+ case DW_CFA_def_cfa_offset_sf:
+ soff = _dwarf_decode_sleb128(&p);
+ SET_OFFSET(soff);
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error,
+ DW_DLE_FRAME_INSTR_EXEC_ERROR);
+ return (DW_DLE_FRAME_INSTR_EXEC_ERROR);
+ }
+
+ (*count)++;
+ }
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_frame_get_fop(Dwarf_Debug dbg, uint8_t addr_size, uint8_t *insts,
+ Dwarf_Unsigned len, Dwarf_Frame_Op **ret_oplist, Dwarf_Signed *ret_opcnt,
+ Dwarf_Error *error)
+{
+ Dwarf_Frame_Op *oplist;
+ Dwarf_Unsigned count;
+ int ret;
+
+ ret = _dwarf_frame_convert_inst(dbg, addr_size, insts, len, &count,
+ NULL, NULL, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+
+ if ((oplist = calloc(count, sizeof(Dwarf_Frame_Op))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ ret = _dwarf_frame_convert_inst(dbg, addr_size, insts, len, &count,
+ oplist, NULL, error);
+ if (ret != DW_DLE_NONE) {
+ free(oplist);
+ return (ret);
+ }
+
+ *ret_oplist = oplist;
+ *ret_opcnt = count;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_frame_regtable_copy(Dwarf_Debug dbg, Dwarf_Regtable3 **dest,
+ Dwarf_Regtable3 *src, Dwarf_Error *error)
+{
+ int i;
+
+ assert(dest != NULL);
+ assert(src != NULL);
+
+ if (*dest == NULL) {
+ if ((*dest = malloc(sizeof(Dwarf_Regtable3))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ (*dest)->rt3_reg_table_size = src->rt3_reg_table_size;
+ (*dest)->rt3_rules = malloc(src->rt3_reg_table_size *
+ sizeof(Dwarf_Regtable_Entry3));
+ if ((*dest)->rt3_rules == NULL) {
+ free(*dest);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ }
+
+ memcpy(&(*dest)->rt3_cfa_rule, &src->rt3_cfa_rule,
+ sizeof(Dwarf_Regtable_Entry3));
+
+ for (i = 0; i < (*dest)->rt3_reg_table_size &&
+ i < src->rt3_reg_table_size; i++)
+ memcpy(&(*dest)->rt3_rules[i], &src->rt3_rules[i],
+ sizeof(Dwarf_Regtable_Entry3));
+
+ for (; i < (*dest)->rt3_reg_table_size; i++)
+ (*dest)->rt3_rules[i].dw_regnum =
+ dbg->dbg_frame_undefined_value;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_frame_get_internal_table(Dwarf_Fde fde, Dwarf_Addr pc_req,
+ Dwarf_Regtable3 **ret_rt, Dwarf_Addr *ret_row_pc, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ Dwarf_Cie cie;
+ Dwarf_Regtable3 *rt;
+ Dwarf_Addr row_pc;
+ int i, ret;
+
+ assert(ret_rt != NULL);
+
+ dbg = fde->fde_dbg;
+ assert(dbg != NULL);
+
+ rt = dbg->dbg_internal_reg_table;
+
+ /* Clear the content of regtable from previous run. */
+ memset(&rt->rt3_cfa_rule, 0, sizeof(Dwarf_Regtable_Entry3));
+ memset(rt->rt3_rules, 0, rt->rt3_reg_table_size *
+ sizeof(Dwarf_Regtable_Entry3));
+
+ /* Set rules to initial values. */
+ for (i = 0; i < rt->rt3_reg_table_size; i++)
+ rt->rt3_rules[i].dw_regnum = dbg->dbg_frame_rule_initial_value;
+
+ /* Run initial instructions in CIE. */
+ cie = fde->fde_cie;
+ assert(cie != NULL);
+ ret = _dwarf_frame_run_inst(dbg, rt, cie->cie_addrsize,
+ cie->cie_initinst, cie->cie_instlen, cie->cie_caf, cie->cie_daf, 0,
+ ~0ULL, &row_pc, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+
+ /* Run instructions in FDE. */
+ if (pc_req >= fde->fde_initloc) {
+ ret = _dwarf_frame_run_inst(dbg, rt, cie->cie_addrsize,
+ fde->fde_inst, fde->fde_instlen, cie->cie_caf,
+ cie->cie_daf, fde->fde_initloc, pc_req, &row_pc, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+
+ *ret_rt = rt;
+ *ret_row_pc = row_pc;
+
+ return (DW_DLE_NONE);
+}
+
+void
+_dwarf_frame_cleanup(Dwarf_Debug dbg)
+{
+ Dwarf_Regtable3 *rt;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_READ);
+
+ if (dbg->dbg_internal_reg_table) {
+ rt = dbg->dbg_internal_reg_table;
+ free(rt->rt3_rules);
+ free(rt);
+ dbg->dbg_internal_reg_table = NULL;
+ }
+
+ if (dbg->dbg_frame) {
+ _dwarf_frame_section_cleanup(dbg->dbg_frame);
+ dbg->dbg_frame = NULL;
+ }
+
+ if (dbg->dbg_eh_frame) {
+ _dwarf_frame_section_cleanup(dbg->dbg_eh_frame);
+ dbg->dbg_eh_frame = NULL;
+ }
+}
+
+int
+_dwarf_frame_section_load(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_Section *ds;
+
+ if ((ds = _dwarf_find_section(dbg, ".debug_frame")) != NULL) {
+ return (_dwarf_frame_section_init(dbg, &dbg->dbg_frame,
+ ds, 0, error));
+ }
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_frame_section_load_eh(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_Section *ds;
+
+ if ((ds = _dwarf_find_section(dbg, ".eh_frame")) != NULL) {
+ return (_dwarf_frame_section_init(dbg, &dbg->dbg_eh_frame,
+ ds, 1, error));
+ }
+
+ return (DW_DLE_NONE);
+}
+
+void
+_dwarf_frame_params_init(Dwarf_Debug dbg)
+{
+
+ /* Initialise call frame related parameters. */
+ dbg->dbg_frame_rule_table_size = DW_FRAME_LAST_REG_NUM;
+ dbg->dbg_frame_rule_initial_value = DW_FRAME_REG_INITIAL_VALUE;
+ dbg->dbg_frame_cfa_value = DW_FRAME_CFA_COL3;
+ dbg->dbg_frame_same_value = DW_FRAME_SAME_VAL;
+ dbg->dbg_frame_undefined_value = DW_FRAME_UNDEFINED_VAL;
+}
+
+int
+_dwarf_frame_interal_table_init(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_Regtable3 *rt;
+
+ if (dbg->dbg_internal_reg_table != NULL)
+ return (DW_DLE_NONE);
+
+ /* Initialise internal register table. */
+ if ((rt = calloc(1, sizeof(Dwarf_Regtable3))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ rt->rt3_reg_table_size = dbg->dbg_frame_rule_table_size;
+ if ((rt->rt3_rules = calloc(rt->rt3_reg_table_size,
+ sizeof(Dwarf_Regtable_Entry3))) == NULL) {
+ free(rt);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ dbg->dbg_internal_reg_table = rt;
+
+ return (DW_DLE_NONE);
+}
+
+#define _FDE_INST_INIT_SIZE 128
+
+int
+_dwarf_frame_fde_add_inst(Dwarf_P_Fde fde, Dwarf_Small op, Dwarf_Unsigned val1,
+ Dwarf_Unsigned val2, Dwarf_Error *error)
+{
+ Dwarf_P_Debug dbg;
+ uint8_t high2, low6;
+ int ret;
+
+#define ds fde
+#define ds_data fde_inst
+#define ds_cap fde_instcap
+#define ds_size fde_instlen
+
+ assert(fde != NULL && fde->fde_dbg != NULL);
+ dbg = fde->fde_dbg;
+
+ if (fde->fde_inst == NULL) {
+ fde->fde_instcap = _FDE_INST_INIT_SIZE;
+ fde->fde_instlen = 0;
+ if ((fde->fde_inst = malloc((size_t) fde->fde_instcap)) ==
+ NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ }
+ assert(fde->fde_instcap != 0);
+
+ RCHECK(WRITE_VALUE(op, 1));
+ if (op == DW_CFA_nop)
+ return (DW_DLE_NONE);
+
+ high2 = op & 0xc0;
+ low6 = op & 0x3f;
+
+ if (high2 > 0) {
+ switch (high2) {
+ case DW_CFA_advance_loc:
+ case DW_CFA_restore:
+ break;
+ case DW_CFA_offset:
+ RCHECK(WRITE_ULEB128(val1));
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error,
+ DW_DLE_FRAME_INSTR_EXEC_ERROR);
+ return (DW_DLE_FRAME_INSTR_EXEC_ERROR);
+ }
+ return (DW_DLE_NONE);
+ }
+
+ switch (low6) {
+ case DW_CFA_set_loc:
+ RCHECK(WRITE_VALUE(val1, dbg->dbg_pointer_size));
+ break;
+ case DW_CFA_advance_loc1:
+ RCHECK(WRITE_VALUE(val1, 1));
+ break;
+ case DW_CFA_advance_loc2:
+ RCHECK(WRITE_VALUE(val1, 2));
+ break;
+ case DW_CFA_advance_loc4:
+ RCHECK(WRITE_VALUE(val1, 4));
+ break;
+ case DW_CFA_offset_extended:
+ case DW_CFA_def_cfa:
+ case DW_CFA_register:
+ RCHECK(WRITE_ULEB128(val1));
+ RCHECK(WRITE_ULEB128(val2));
+ break;
+ case DW_CFA_restore_extended:
+ case DW_CFA_undefined:
+ case DW_CFA_same_value:
+ case DW_CFA_def_cfa_register:
+ case DW_CFA_def_cfa_offset:
+ RCHECK(WRITE_ULEB128(val1));
+ break;
+ case DW_CFA_remember_state:
+ case DW_CFA_restore_state:
+ break;
+ default:
+ DWARF_SET_ERROR(dbg, error, DW_DLE_FRAME_INSTR_EXEC_ERROR);
+ return (DW_DLE_FRAME_INSTR_EXEC_ERROR);
+ }
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+ return (ret);
+
+#undef ds
+#undef ds_data
+#undef ds_cap
+#undef ds_size
+}
+
+static int
+_dwarf_frame_gen_cie(Dwarf_P_Debug dbg, Dwarf_P_Section ds, Dwarf_P_Cie cie,
+ Dwarf_Error *error)
+{
+ Dwarf_Unsigned len;
+ uint64_t offset;
+ int ret;
+
+ assert(dbg != NULL && ds != NULL && cie != NULL);
+
+ cie->cie_offset = offset = ds->ds_size;
+ cie->cie_length = 0;
+ cie->cie_version = 1;
+
+ /* Length placeholder. */
+ RCHECK(WRITE_VALUE(cie->cie_length, 4));
+
+ /* .debug_frame use CIE id ~0. */
+ RCHECK(WRITE_VALUE(~0U, 4));
+
+ /* .debug_frame version is 1. (DWARF2) */
+ RCHECK(WRITE_VALUE(cie->cie_version, 1));
+
+ /* Write augmentation, if present. */
+ if (cie->cie_augment != NULL)
+ RCHECK(WRITE_BLOCK(cie->cie_augment,
+ strlen((char *) cie->cie_augment) + 1));
+ else
+ RCHECK(WRITE_VALUE(0, 1));
+
+ /* Write caf, daf and ra. */
+ RCHECK(WRITE_ULEB128(cie->cie_caf));
+ RCHECK(WRITE_SLEB128(cie->cie_daf));
+ RCHECK(WRITE_VALUE(cie->cie_ra, 1));
+
+ /* Write initial instructions, if present. */
+ if (cie->cie_initinst != NULL)
+ RCHECK(WRITE_BLOCK(cie->cie_initinst, cie->cie_instlen));
+
+ /* Add padding. */
+ len = ds->ds_size - cie->cie_offset - 4;
+ cie->cie_length = roundup(len, dbg->dbg_pointer_size);
+ while (len++ < cie->cie_length)
+ RCHECK(WRITE_VALUE(DW_CFA_nop, 1));
+
+ /* Fill in the length field. */
+ dbg->write(ds->ds_data, &offset, cie->cie_length, 4);
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+ return (ret);
+}
+
+static int
+_dwarf_frame_gen_fde(Dwarf_P_Debug dbg, Dwarf_P_Section ds,
+ Dwarf_Rel_Section drs, Dwarf_P_Fde fde, Dwarf_Error *error)
+{
+ Dwarf_Unsigned len;
+ uint64_t offset;
+ int ret;
+
+ assert(dbg != NULL && ds != NULL && drs != NULL);
+ assert(fde != NULL && fde->fde_cie != NULL);
+
+ fde->fde_offset = offset = ds->ds_size;
+ fde->fde_length = 0;
+ fde->fde_cieoff = fde->fde_cie->cie_offset;
+
+ /* Length placeholder. */
+ RCHECK(WRITE_VALUE(fde->fde_length, 4));
+
+ /* Write CIE pointer. */
+ RCHECK(_dwarf_reloc_entry_add(dbg, drs, ds, dwarf_drt_data_reloc, 4,
+ ds->ds_size, 0, fde->fde_cieoff, ".debug_frame", error));
+
+ /* Write FDE initial location. */
+ RCHECK(_dwarf_reloc_entry_add(dbg, drs, ds, dwarf_drt_data_reloc,
+ dbg->dbg_pointer_size, ds->ds_size, fde->fde_symndx,
+ fde->fde_initloc, NULL, error));
+
+ /*
+ * Write FDE address range. Use a pair of relocation entries if
+ * application provided end symbol index. Otherwise write the
+ * length without assoicating any relocation info.
+ */
+ if (fde->fde_esymndx > 0)
+ RCHECK(_dwarf_reloc_entry_add_pair(dbg, drs, ds,
+ dbg->dbg_pointer_size, ds->ds_size, fde->fde_symndx,
+ fde->fde_esymndx, fde->fde_initloc, fde->fde_eoff, error));
+ else
+ RCHECK(WRITE_VALUE(fde->fde_adrange, dbg->dbg_pointer_size));
+
+ /* Write FDE frame instructions. */
+ RCHECK(WRITE_BLOCK(fde->fde_inst, fde->fde_instlen));
+
+ /* Add padding. */
+ len = ds->ds_size - fde->fde_offset - 4;
+ fde->fde_length = roundup(len, dbg->dbg_pointer_size);
+ while (len++ < fde->fde_length)
+ RCHECK(WRITE_VALUE(DW_CFA_nop, 1));
+
+ /* Fill in the length field. */
+ dbg->write(ds->ds_data, &offset, fde->fde_length, 4);
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+ return (ret);
+}
+
+int
+_dwarf_frame_gen(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_P_Section ds;
+ Dwarf_Rel_Section drs;
+ Dwarf_P_Cie cie;
+ Dwarf_P_Fde fde;
+ int ret;
+
+ if (STAILQ_EMPTY(&dbg->dbgp_cielist))
+ return (DW_DLE_NONE);
+
+ /* Create .debug_frame section. */
+ if ((ret = _dwarf_section_init(dbg, &ds, ".debug_frame", 0, error)) !=
+ DW_DLE_NONE)
+ goto gen_fail0;
+
+ /* Create relocation section for .debug_frame */
+ RCHECK(_dwarf_reloc_section_init(dbg, &drs, ds, error));
+
+ /* Generate list of CIE. */
+ STAILQ_FOREACH(cie, &dbg->dbgp_cielist, cie_next)
+ RCHECK(_dwarf_frame_gen_cie(dbg, ds, cie, error));
+
+ /* Generate list of FDE. */
+ STAILQ_FOREACH(fde, &dbg->dbgp_fdelist, fde_next)
+ RCHECK(_dwarf_frame_gen_fde(dbg, ds, drs, fde, error));
+
+ /* Inform application the creation of .debug_frame ELF section. */
+ RCHECK(_dwarf_section_callback(dbg, ds, SHT_PROGBITS, 0, 0, 0, error));
+
+ /* Finalize relocation section for .debug_frame */
+ RCHECK(_dwarf_reloc_section_finalize(dbg, drs, error));
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+ _dwarf_reloc_section_free(dbg, &drs);
+
+gen_fail0:
+ _dwarf_section_free(dbg, &ds);
+
+ return (ret);
+}
+
+void
+_dwarf_frame_pro_cleanup(Dwarf_P_Debug dbg)
+{
+ Dwarf_P_Cie cie, tcie;
+ Dwarf_P_Fde fde, tfde;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_WRITE);
+
+ STAILQ_FOREACH_SAFE(cie, &dbg->dbgp_cielist, cie_next, tcie) {
+ STAILQ_REMOVE(&dbg->dbgp_cielist, cie, _Dwarf_Cie, cie_next);
+ if (cie->cie_augment)
+ free(cie->cie_augment);
+ if (cie->cie_initinst)
+ free(cie->cie_initinst);
+ free(cie);
+ }
+ dbg->dbgp_cielen = 0;
+
+ STAILQ_FOREACH_SAFE(fde, &dbg->dbgp_fdelist, fde_next, tfde) {
+ STAILQ_REMOVE(&dbg->dbgp_fdelist, fde, _Dwarf_Fde, fde_next);
+ if (fde->fde_inst != NULL)
+ free(fde->fde_inst);
+ free(fde);
+ }
+ dbg->dbgp_fdelen = 0;
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_info.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_info.c
new file mode 100644
index 0000000..7476593
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_info.c
@@ -0,0 +1,383 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2010,2011,2014 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_info.c 3136 2014-12-24 16:04:38Z kaiwang27 $");
+
+int
+_dwarf_info_first_cu(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ int ret;
+
+ assert(dbg->dbg_cu_current == NULL);
+ cu = STAILQ_FIRST(&dbg->dbg_cu);
+ if (cu != NULL) {
+ dbg->dbg_cu_current = cu;
+ return (DW_DLE_NONE);
+ }
+
+ if (dbg->dbg_info_loaded)
+ return (DW_DLE_NO_ENTRY);
+
+ dbg->dbg_info_off = 0;
+ ret = _dwarf_info_load(dbg, 0, 1, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+
+ dbg->dbg_cu_current = STAILQ_FIRST(&dbg->dbg_cu);
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_info_first_tu(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_CU tu;
+ int ret;
+
+ assert(dbg->dbg_tu_current == NULL);
+ tu = STAILQ_FIRST(&dbg->dbg_tu);
+ if (tu != NULL) {
+ dbg->dbg_tu_current = tu;
+ return (DW_DLE_NONE);
+ }
+
+ if (dbg->dbg_types_loaded)
+ return (DW_DLE_NO_ENTRY);
+
+ dbg->dbg_types_off = 0;
+ ret = _dwarf_info_load(dbg, 0, 0, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+
+ dbg->dbg_tu_current = STAILQ_FIRST(&dbg->dbg_tu);
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_info_next_cu(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ int ret;
+
+ assert(dbg->dbg_cu_current != NULL);
+ cu = STAILQ_NEXT(dbg->dbg_cu_current, cu_next);
+ if (cu != NULL) {
+ dbg->dbg_cu_current = cu;
+ return (DW_DLE_NONE);
+ }
+
+ if (dbg->dbg_info_loaded) {
+ dbg->dbg_cu_current = NULL;
+ return (DW_DLE_NO_ENTRY);
+ }
+
+ ret = _dwarf_info_load(dbg, 0, 1, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+
+ dbg->dbg_cu_current = STAILQ_NEXT(dbg->dbg_cu_current, cu_next);
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_info_next_tu(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ int ret;
+
+ assert(dbg->dbg_tu_current != NULL);
+ cu = STAILQ_NEXT(dbg->dbg_tu_current, cu_next);
+ if (cu != NULL) {
+ dbg->dbg_tu_current = cu;
+ return (DW_DLE_NONE);
+ }
+
+ if (dbg->dbg_types_loaded) {
+ dbg->dbg_tu_current = NULL;
+ return (DW_DLE_NO_ENTRY);
+ }
+
+ ret = _dwarf_info_load(dbg, 0, 0, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+
+ dbg->dbg_tu_current = STAILQ_NEXT(dbg->dbg_tu_current, cu_next);
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_info_load(Dwarf_Debug dbg, Dwarf_Bool load_all, Dwarf_Bool is_info,
+ Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ Dwarf_Section *ds;
+ int dwarf_size, ret;
+ uint64_t length;
+ uint64_t next_offset;
+ uint64_t offset;
+
+ ret = DW_DLE_NONE;
+
+ if (is_info) {
+ if (dbg->dbg_info_loaded)
+ return (ret);
+ offset = dbg->dbg_info_off;
+ ds = dbg->dbg_info_sec;
+ if (ds == NULL)
+ return (DW_DLE_NO_ENTRY);
+ } else {
+ if (dbg->dbg_types_loaded)
+ return (ret);
+ offset = dbg->dbg_types_off;
+ ds = dbg->dbg_types_sec;
+ if (ds == NULL)
+ return (DW_DLE_NO_ENTRY);
+ }
+
+ while (offset < ds->ds_size) {
+ if ((cu = calloc(1, sizeof(struct _Dwarf_CU))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ cu->cu_dbg = dbg;
+ cu->cu_is_info = is_info;
+ cu->cu_offset = offset;
+
+ length = dbg->read(ds->ds_data, &offset, 4);
+ if (length == 0xffffffff) {
+ length = dbg->read(ds->ds_data, &offset, 8);
+ dwarf_size = 8;
+ } else
+ dwarf_size = 4;
+ cu->cu_dwarf_size = dwarf_size;
+
+ /*
+ * Check if there is enough ELF data for this CU. This assumes
+ * that libelf gives us the entire section in one Elf_Data
+ * object.
+ */
+ if (length > ds->ds_size - offset) {
+ free(cu);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_CU_LENGTH_ERROR);
+ return (DW_DLE_CU_LENGTH_ERROR);
+ }
+
+ /* Compute the offset to the next compilation unit: */
+ next_offset = offset + length;
+ if (is_info)
+ dbg->dbg_info_off = next_offset;
+ else
+ dbg->dbg_types_off = next_offset;
+
+ /* Initialise the compilation unit. */
+ cu->cu_length = length;
+ cu->cu_length_size = (dwarf_size == 4 ? 4 : 12);
+ cu->cu_version = dbg->read(ds->ds_data, &offset, 2);
+ cu->cu_abbrev_offset = dbg->read(ds->ds_data, &offset,
+ dwarf_size);
+ cu->cu_abbrev_offset_cur = cu->cu_abbrev_offset;
+ cu->cu_pointer_size = dbg->read(ds->ds_data, &offset, 1);
+ cu->cu_next_offset = next_offset;
+
+ /* .debug_types extra fields. */
+ if (!is_info) {
+ memcpy(cu->cu_type_sig.signature,
+ (char *) ds->ds_data + offset, 8);
+ offset += 8;
+ cu->cu_type_offset = dbg->read(ds->ds_data, &offset,
+ dwarf_size);
+ }
+
+ /* Add the compilation unit to the list. */
+ if (is_info)
+ STAILQ_INSERT_TAIL(&dbg->dbg_cu, cu, cu_next);
+ else
+ STAILQ_INSERT_TAIL(&dbg->dbg_tu, cu, cu_next);
+
+ if (cu->cu_version < 2 || cu->cu_version > 4) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_VERSION_STAMP_ERROR);
+ ret = DW_DLE_VERSION_STAMP_ERROR;
+ break;
+ }
+
+ cu->cu_1st_offset = offset;
+
+ offset = next_offset;
+
+ if (!load_all)
+ break;
+ }
+
+ if (is_info) {
+ if ((Dwarf_Unsigned) dbg->dbg_info_off >= ds->ds_size)
+ dbg->dbg_info_loaded = 1;
+ } else {
+ if ((Dwarf_Unsigned) dbg->dbg_types_off >= ds->ds_size)
+ dbg->dbg_types_loaded = 1;
+ }
+
+ return (ret);
+}
+
+void
+_dwarf_info_cleanup(Dwarf_Debug dbg)
+{
+ Dwarf_CU cu, tcu;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_READ);
+
+ STAILQ_FOREACH_SAFE(cu, &dbg->dbg_cu, cu_next, tcu) {
+ STAILQ_REMOVE(&dbg->dbg_cu, cu, _Dwarf_CU, cu_next);
+ _dwarf_abbrev_cleanup(cu);
+ if (cu->cu_lineinfo != NULL) {
+ _dwarf_lineno_cleanup(cu->cu_lineinfo);
+ cu->cu_lineinfo = NULL;
+ }
+ free(cu);
+ }
+
+ _dwarf_type_unit_cleanup(dbg);
+}
+
+void
+_dwarf_type_unit_cleanup(Dwarf_Debug dbg)
+{
+ Dwarf_CU cu, tcu;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_READ);
+
+ STAILQ_FOREACH_SAFE(cu, &dbg->dbg_tu, cu_next, tcu) {
+ STAILQ_REMOVE(&dbg->dbg_tu, cu, _Dwarf_CU, cu_next);
+ _dwarf_abbrev_cleanup(cu);
+ free(cu);
+ }
+}
+
+int
+_dwarf_info_gen(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_P_Section ds;
+ Dwarf_Rel_Section drs;
+ Dwarf_Unsigned offset;
+ Dwarf_CU cu;
+ int ret;
+
+ assert(dbg != NULL && dbg->write_alloc != NULL);
+
+ if (dbg->dbgp_root_die == NULL)
+ return (DW_DLE_NONE);
+
+ /* Create the single CU for this debugging object. */
+ if ((cu = calloc(1, sizeof(struct _Dwarf_CU))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ cu->cu_dbg = dbg;
+ cu->cu_version = 2; /* DWARF2 */
+ cu->cu_pointer_size = dbg->dbg_pointer_size;
+ STAILQ_INSERT_TAIL(&dbg->dbg_cu, cu, cu_next);
+
+ /* Create .debug_info section. */
+ if ((ret = _dwarf_section_init(dbg, &dbg->dbgp_info, ".debug_info", 0,
+ error)) != DW_DLE_NONE)
+ goto gen_fail1;
+ ds = dbg->dbgp_info;
+
+ /* Create relocation section for .debug_init */
+ if ((ret = _dwarf_reloc_section_init(dbg, &drs, ds, error)) !=
+ DW_DLE_NONE)
+ goto gen_fail0;
+
+ /* Length placeholder. (We only use 32-bit DWARF format) */
+ RCHECK(WRITE_VALUE(cu->cu_length, 4));
+
+ /* Write CU version */
+ RCHECK(WRITE_VALUE(cu->cu_version, 2));
+
+ /*
+ * Write abbrev offset. (always 0, we only support single CU)
+ * Also generate a relocation entry for this offset.
+ */
+ RCHECK(_dwarf_reloc_entry_add(dbg, drs, ds, dwarf_drt_data_reloc, 4,
+ ds->ds_size, 0, cu->cu_abbrev_offset, ".debug_abbrev", error));
+
+ /* Pointer size. */
+ RCHECK(WRITE_VALUE(cu->cu_pointer_size, 1));
+
+ /* Transform the DIE(s) of this CU. */
+ RCHECK(_dwarf_die_gen(dbg, cu, drs, error));
+
+ /* Now we can fill in the length of this CU. */
+ cu->cu_length = ds->ds_size - 4;
+ offset = 0;
+ dbg->write(ds->ds_data, &offset, cu->cu_length, 4);
+
+ /* Inform application the creation of .debug_info ELF section. */
+ RCHECK(_dwarf_section_callback(dbg, ds, SHT_PROGBITS, 0, 0, 0, error));
+
+ /*
+ * Inform application the creation of relocation section for
+ * .debug_info.
+ */
+ RCHECK(_dwarf_reloc_section_finalize(dbg, drs, error));
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+ _dwarf_reloc_section_free(dbg, &drs);
+
+gen_fail0:
+ _dwarf_section_free(dbg, &dbg->dbgp_info);
+
+gen_fail1:
+ STAILQ_REMOVE(&dbg->dbg_cu, cu, _Dwarf_CU, cu_next);
+ free(cu);
+
+ return (ret);
+}
+
+void
+_dwarf_info_pro_cleanup(Dwarf_P_Debug dbg)
+{
+ Dwarf_CU cu;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_WRITE);
+
+ cu = STAILQ_FIRST(&dbg->dbg_cu);
+ if (cu != NULL) {
+ STAILQ_REMOVE(&dbg->dbg_cu, cu, _Dwarf_CU, cu_next);
+ _dwarf_abbrev_cleanup(cu);
+ free(cu);
+ }
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_init.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_init.c
new file mode 100644
index 0000000..b85c87c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_init.c
@@ -0,0 +1,315 @@
+/*-
+ * Copyright (c) 2009,2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_init.c 3136 2014-12-24 16:04:38Z kaiwang27 $");
+
+static int
+_dwarf_consumer_init(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ const Dwarf_Obj_Access_Methods *m;
+ Dwarf_Obj_Access_Section sec;
+ void *obj;
+ Dwarf_Unsigned cnt;
+ Dwarf_Half i;
+ int ret;
+
+ assert(dbg != NULL);
+ assert(dbg->dbg_iface != NULL);
+
+ m = dbg->dbg_iface->methods;
+ obj = dbg->dbg_iface->object;
+
+ assert(m != NULL);
+ assert(obj != NULL);
+
+ if (m->get_byte_order(obj) == DW_OBJECT_MSB) {
+ dbg->read = _dwarf_read_msb;
+ dbg->write = _dwarf_write_msb;
+ dbg->decode = _dwarf_decode_msb;
+ } else {
+ dbg->read = _dwarf_read_lsb;
+ dbg->write = _dwarf_write_lsb;
+ dbg->decode = _dwarf_decode_lsb;
+ }
+
+ dbg->dbg_pointer_size = m->get_pointer_size(obj);
+ dbg->dbg_offset_size = m->get_length_size(obj);
+
+ cnt = m->get_section_count(obj);
+
+ if (cnt == 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_DEBUG_INFO_NULL);
+ return (DW_DLE_DEBUG_INFO_NULL);
+ }
+
+ dbg->dbg_seccnt = cnt;
+
+ if ((dbg->dbg_section = calloc(cnt + 1, sizeof(Dwarf_Section))) ==
+ NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ for (i = 0; i < cnt; i++) {
+ if (m->get_section_info(obj, i, &sec, &ret) != DW_DLV_OK) {
+ DWARF_SET_ERROR(dbg, error, ret);
+ return (ret);
+ }
+
+ dbg->dbg_section[i].ds_addr = sec.addr;
+ dbg->dbg_section[i].ds_size = sec.size;
+ dbg->dbg_section[i].ds_name = sec.name;
+
+ if (m->load_section(obj, i, &dbg->dbg_section[i].ds_data, &ret)
+ != DW_DLV_OK) {
+ DWARF_SET_ERROR(dbg, error, ret);
+ return (ret);
+ }
+ }
+ dbg->dbg_section[cnt].ds_name = NULL;
+
+ dbg->dbg_info_sec = _dwarf_find_section(dbg, ".debug_info");
+
+ /* Try to find the optional DWARF4 .debug_types section. */
+ dbg->dbg_types_sec = _dwarf_find_next_types_section(dbg, NULL);
+
+ /* Initialise call frame API related parameters. */
+ _dwarf_frame_params_init(dbg);
+
+ return (DW_DLV_OK);
+}
+
+static int
+_dwarf_producer_init(Dwarf_Debug dbg, Dwarf_Unsigned pf, Dwarf_Error *error)
+{
+
+ /* Producer only support DWARF2 which has fixed 32bit offset. */
+ dbg->dbg_offset_size = 4;
+
+ if (pf & DW_DLC_SIZE_32 && pf & DW_DLC_SIZE_64) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLE_ARGUMENT);
+ }
+
+ if ((pf & DW_DLC_SIZE_32) == 0 && (pf & DW_DLC_SIZE_64) == 0)
+ pf |= DW_DLC_SIZE_32;
+
+ if (pf & DW_DLC_SIZE_64)
+ dbg->dbg_pointer_size = 8;
+ else
+ dbg->dbg_pointer_size = 4;
+
+ if (pf & DW_DLC_ISA_IA64 && pf & DW_DLC_ISA_MIPS) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLE_ARGUMENT);
+ }
+
+ if (pf & DW_DLC_ISA_IA64)
+ dbg->dbgp_isa = DW_ISA_IA64;
+ else
+ dbg->dbgp_isa = DW_ISA_MIPS;
+
+ if (pf & DW_DLC_TARGET_BIGENDIAN && pf & DW_DLC_TARGET_LITTLEENDIAN) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLE_ARGUMENT);
+ }
+
+ if ((pf & DW_DLC_TARGET_BIGENDIAN) == 0 &&
+ (pf & DW_DLC_TARGET_LITTLEENDIAN) == 0) {
+#if ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_BIG_ENDIAN
+ pf |= DW_DLC_TARGET_BIGENDIAN;
+#else
+ pf |= DW_DLC_TARGET_LITTLEENDIAN;
+#endif
+ }
+
+ if (pf & DW_DLC_TARGET_BIGENDIAN) {
+ dbg->write = _dwarf_write_msb;
+ dbg->write_alloc = _dwarf_write_msb_alloc;
+ } else if (pf & DW_DLC_TARGET_LITTLEENDIAN) {
+ dbg->write = _dwarf_write_lsb;
+ dbg->write_alloc = _dwarf_write_lsb_alloc;
+ } else
+ assert(0);
+
+ if (pf & DW_DLC_STREAM_RELOCATIONS &&
+ pf & DW_DLC_SYMBOLIC_RELOCATIONS) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
+ return (DW_DLE_ARGUMENT);
+ }
+
+ if ((pf & DW_DLC_STREAM_RELOCATIONS) == 0 &&
+ (pf & DW_DLC_SYMBOLIC_RELOCATIONS) == 0)
+ pf |= DW_DLC_STREAM_RELOCATIONS;
+
+ dbg->dbgp_flags = pf;
+
+ STAILQ_INIT(&dbg->dbgp_dielist);
+ STAILQ_INIT(&dbg->dbgp_pelist);
+ STAILQ_INIT(&dbg->dbgp_seclist);
+ STAILQ_INIT(&dbg->dbgp_drslist);
+ STAILQ_INIT(&dbg->dbgp_cielist);
+ STAILQ_INIT(&dbg->dbgp_fdelist);
+
+ if ((dbg->dbgp_lineinfo = calloc(1, sizeof(struct _Dwarf_LineInfo))) ==
+ NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ STAILQ_INIT(&dbg->dbgp_lineinfo->li_lflist);
+ STAILQ_INIT(&dbg->dbgp_lineinfo->li_lnlist);
+
+ if ((dbg->dbgp_as = calloc(1, sizeof(struct _Dwarf_ArangeSet))) ==
+ NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ STAILQ_INIT(&dbg->dbgp_as->as_arlist);
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_init(Dwarf_Debug dbg, Dwarf_Unsigned pro_flags, Dwarf_Handler errhand,
+ Dwarf_Ptr errarg, Dwarf_Error *error)
+{
+ int ret;
+
+ ret = DW_DLE_NONE;
+
+ /*
+ * Set the error handler fields early, so that the application
+ * is notified of initialization errors.
+ */
+ dbg->dbg_errhand = errhand;
+ dbg->dbg_errarg = errarg;
+
+ STAILQ_INIT(&dbg->dbg_cu);
+ STAILQ_INIT(&dbg->dbg_tu);
+ STAILQ_INIT(&dbg->dbg_rllist);
+ STAILQ_INIT(&dbg->dbg_aslist);
+ STAILQ_INIT(&dbg->dbg_mslist);
+
+ if (dbg->dbg_mode == DW_DLC_READ || dbg->dbg_mode == DW_DLC_RDWR) {
+ ret = _dwarf_consumer_init(dbg, error);
+ if (ret != DW_DLE_NONE) {
+ _dwarf_deinit(dbg);
+ return (ret);
+ }
+ }
+
+ if (dbg->dbg_mode == DW_DLC_WRITE) {
+ ret = _dwarf_producer_init(dbg, pro_flags, error);
+ if (ret != DW_DLE_NONE) {
+ _dwarf_deinit(dbg);
+ return (ret);
+ }
+ }
+
+ /*
+ * Initialise internal string table.
+ */
+ if ((ret = _dwarf_strtab_init(dbg, error)) != DW_DLE_NONE)
+ return (ret);
+
+ return (DW_DLE_NONE);
+}
+
+static void
+_dwarf_producer_deinit(Dwarf_P_Debug dbg)
+{
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_WRITE);
+
+ _dwarf_info_pro_cleanup(dbg);
+ _dwarf_die_pro_cleanup(dbg);
+ _dwarf_expr_cleanup(dbg);
+ _dwarf_lineno_pro_cleanup(dbg);
+ _dwarf_frame_pro_cleanup(dbg);
+ _dwarf_arange_pro_cleanup(dbg);
+ _dwarf_macinfo_pro_cleanup(dbg);
+ _dwarf_strtab_cleanup(dbg);
+ _dwarf_nametbl_pro_cleanup(&dbg->dbgp_pubs);
+ _dwarf_nametbl_pro_cleanup(&dbg->dbgp_weaks);
+ _dwarf_nametbl_pro_cleanup(&dbg->dbgp_funcs);
+ _dwarf_nametbl_pro_cleanup(&dbg->dbgp_types);
+ _dwarf_nametbl_pro_cleanup(&dbg->dbgp_vars);
+ _dwarf_section_cleanup(dbg);
+ _dwarf_reloc_cleanup(dbg);
+}
+
+static void
+_dwarf_consumer_deinit(Dwarf_Debug dbg)
+{
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_READ);
+
+ _dwarf_info_cleanup(dbg);
+ _dwarf_ranges_cleanup(dbg);
+ _dwarf_frame_cleanup(dbg);
+ _dwarf_arange_cleanup(dbg);
+ _dwarf_macinfo_cleanup(dbg);
+ _dwarf_strtab_cleanup(dbg);
+ _dwarf_nametbl_cleanup(&dbg->dbg_globals);
+ _dwarf_nametbl_cleanup(&dbg->dbg_pubtypes);
+ _dwarf_nametbl_cleanup(&dbg->dbg_weaks);
+ _dwarf_nametbl_cleanup(&dbg->dbg_funcs);
+ _dwarf_nametbl_cleanup(&dbg->dbg_vars);
+ _dwarf_nametbl_cleanup(&dbg->dbg_types);
+
+ free(dbg->dbg_section);
+}
+
+void
+_dwarf_deinit(Dwarf_Debug dbg)
+{
+
+ assert(dbg != NULL);
+
+ if (dbg->dbg_mode == DW_DLC_READ)
+ _dwarf_consumer_deinit(dbg);
+ else if (dbg->dbg_mode == DW_DLC_WRITE)
+ _dwarf_producer_deinit(dbg);
+}
+
+int
+_dwarf_alloc(Dwarf_Debug *ret_dbg, int mode, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+
+ if ((dbg = calloc(sizeof(struct _Dwarf_Debug), 1)) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ dbg->dbg_mode = mode;
+
+ *ret_dbg = dbg;
+
+ return (DW_DLE_NONE);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_lineno.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_lineno.c
new file mode 100644
index 0000000..d0ff5f8
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_lineno.c
@@ -0,0 +1,777 @@
+/*-
+ * Copyright (c) 2009,2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_lineno.c 3164 2015-02-19 01:20:12Z kaiwang27 $");
+
+static int
+_dwarf_lineno_add_file(Dwarf_LineInfo li, uint8_t **p, const char *compdir,
+ Dwarf_Error *error, Dwarf_Debug dbg)
+{
+ Dwarf_LineFile lf;
+ const char *dirname;
+ uint8_t *src;
+ int slen;
+
+ src = *p;
+
+ if ((lf = malloc(sizeof(struct _Dwarf_LineFile))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ lf->lf_fullpath = NULL;
+ lf->lf_fname = (char *) src;
+ src += strlen(lf->lf_fname) + 1;
+ lf->lf_dirndx = _dwarf_decode_uleb128(&src);
+ if (lf->lf_dirndx > li->li_inclen) {
+ free(lf);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_DIR_INDEX_BAD);
+ return (DW_DLE_DIR_INDEX_BAD);
+ }
+
+ /* Make full pathname if need. */
+ if (*lf->lf_fname != '/') {
+ dirname = compdir;
+ if (lf->lf_dirndx > 0)
+ dirname = li->li_incdirs[lf->lf_dirndx - 1];
+ if (dirname != NULL) {
+ slen = strlen(dirname) + strlen(lf->lf_fname) + 2;
+ if ((lf->lf_fullpath = malloc(slen)) == NULL) {
+ free(lf);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ snprintf(lf->lf_fullpath, slen, "%s/%s", dirname,
+ lf->lf_fname);
+ }
+ }
+
+ lf->lf_mtime = _dwarf_decode_uleb128(&src);
+ lf->lf_size = _dwarf_decode_uleb128(&src);
+ STAILQ_INSERT_TAIL(&li->li_lflist, lf, lf_next);
+ li->li_lflen++;
+
+ *p = src;
+
+ return (DW_DLE_NONE);
+}
+
+static int
+_dwarf_lineno_run_program(Dwarf_CU cu, Dwarf_LineInfo li, uint8_t *p,
+ uint8_t *pe, const char *compdir, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ Dwarf_Line ln, tln;
+ uint64_t address, file, line, column, opsize;
+ int is_stmt, basic_block, end_sequence;
+ int ret;
+
+#define RESET_REGISTERS \
+ do { \
+ address = 0; \
+ file = 1; \
+ line = 1; \
+ column = 0; \
+ is_stmt = li->li_defstmt; \
+ basic_block = 0; \
+ end_sequence = 0; \
+ } while(0)
+
+#define APPEND_ROW \
+ do { \
+ ln = malloc(sizeof(struct _Dwarf_Line)); \
+ if (ln == NULL) { \
+ ret = DW_DLE_MEMORY; \
+ DWARF_SET_ERROR(dbg, error, ret); \
+ goto prog_fail; \
+ } \
+ ln->ln_li = li; \
+ ln->ln_addr = address; \
+ ln->ln_symndx = 0; \
+ ln->ln_fileno = file; \
+ ln->ln_lineno = line; \
+ ln->ln_column = column; \
+ ln->ln_bblock = basic_block; \
+ ln->ln_stmt = is_stmt; \
+ ln->ln_endseq = end_sequence; \
+ STAILQ_INSERT_TAIL(&li->li_lnlist, ln, ln_next);\
+ li->li_lnlen++; \
+ } while(0)
+
+#define LINE(x) (li->li_lbase + (((x) - li->li_opbase) % li->li_lrange))
+#define ADDRESS(x) ((((x) - li->li_opbase) / li->li_lrange) * li->li_minlen)
+
+ dbg = cu->cu_dbg;
+
+ /*
+ * Set registers to their default values.
+ */
+ RESET_REGISTERS;
+
+ /*
+ * Start line number program.
+ */
+ while (p < pe) {
+ if (*p == 0) {
+
+ /*
+ * Extended Opcodes.
+ */
+
+ p++;
+ opsize = _dwarf_decode_uleb128(&p);
+ switch (*p) {
+ case DW_LNE_end_sequence:
+ p++;
+ end_sequence = 1;
+ APPEND_ROW;
+ RESET_REGISTERS;
+ break;
+ case DW_LNE_set_address:
+ p++;
+ address = dbg->decode(&p, cu->cu_pointer_size);
+ break;
+ case DW_LNE_define_file:
+ p++;
+ ret = _dwarf_lineno_add_file(li, &p, compdir,
+ error, dbg);
+ if (ret != DW_DLE_NONE)
+ goto prog_fail;
+ break;
+ default:
+ /* Unrecognized extened opcodes. */
+ p += opsize;
+ }
+
+ } else if (*p > 0 && *p < li->li_opbase) {
+
+ /*
+ * Standard Opcodes.
+ */
+
+ switch (*p++) {
+ case DW_LNS_copy:
+ APPEND_ROW;
+ basic_block = 0;
+ break;
+ case DW_LNS_advance_pc:
+ address += _dwarf_decode_uleb128(&p) *
+ li->li_minlen;
+ break;
+ case DW_LNS_advance_line:
+ line += _dwarf_decode_sleb128(&p);
+ break;
+ case DW_LNS_set_file:
+ file = _dwarf_decode_uleb128(&p);
+ break;
+ case DW_LNS_set_column:
+ column = _dwarf_decode_uleb128(&p);
+ break;
+ case DW_LNS_negate_stmt:
+ is_stmt = !is_stmt;
+ break;
+ case DW_LNS_set_basic_block:
+ basic_block = 1;
+ break;
+ case DW_LNS_const_add_pc:
+ address += ADDRESS(255);
+ break;
+ case DW_LNS_fixed_advance_pc:
+ address += dbg->decode(&p, 2);
+ break;
+ case DW_LNS_set_prologue_end:
+ break;
+ case DW_LNS_set_epilogue_begin:
+ break;
+ case DW_LNS_set_isa:
+ (void) _dwarf_decode_uleb128(&p);
+ break;
+ default:
+ /* Unrecognized extened opcodes. What to do? */
+ break;
+ }
+
+ } else {
+
+ /*
+ * Special Opcodes.
+ */
+
+ line += LINE(*p);
+ address += ADDRESS(*p);
+ APPEND_ROW;
+ basic_block = 0;
+ p++;
+ }
+ }
+
+ return (DW_DLE_NONE);
+
+prog_fail:
+
+ STAILQ_FOREACH_SAFE(ln, &li->li_lnlist, ln_next, tln) {
+ STAILQ_REMOVE(&li->li_lnlist, ln, _Dwarf_Line, ln_next);
+ free(ln);
+ }
+
+ return (ret);
+
+#undef RESET_REGISTERS
+#undef APPEND_ROW
+#undef LINE
+#undef ADDRESS
+}
+
+int
+_dwarf_lineno_init(Dwarf_Die die, uint64_t offset, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ Dwarf_Section *ds;
+ Dwarf_CU cu;
+ Dwarf_Attribute at;
+ Dwarf_LineInfo li;
+ Dwarf_LineFile lf, tlf;
+ const char *compdir;
+ uint64_t length, hdroff, endoff;
+ uint8_t *p;
+ int dwarf_size, i, ret;
+
+ cu = die->die_cu;
+ assert(cu != NULL);
+
+ dbg = cu->cu_dbg;
+ assert(dbg != NULL);
+
+ if ((ds = _dwarf_find_section(dbg, ".debug_line")) == NULL)
+ return (DW_DLE_NONE);
+
+ /*
+ * Try to find out the dir where the CU was compiled. Later we
+ * will use the dir to create full pathnames, if need.
+ */
+ compdir = NULL;
+ at = _dwarf_attr_find(die, DW_AT_comp_dir);
+ if (at != NULL) {
+ switch (at->at_form) {
+ case DW_FORM_strp:
+ compdir = at->u[1].s;
+ break;
+ case DW_FORM_string:
+ compdir = at->u[0].s;
+ break;
+ default:
+ break;
+ }
+ }
+
+ length = dbg->read(ds->ds_data, &offset, 4);
+ if (length == 0xffffffff) {
+ dwarf_size = 8;
+ length = dbg->read(ds->ds_data, &offset, 8);
+ } else
+ dwarf_size = 4;
+
+ if (length > ds->ds_size - offset) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_DEBUG_LINE_LENGTH_BAD);
+ return (DW_DLE_DEBUG_LINE_LENGTH_BAD);
+ }
+
+ if ((li = calloc(1, sizeof(struct _Dwarf_LineInfo))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ /*
+ * Read in line number program header.
+ */
+ li->li_length = length;
+ endoff = offset + length;
+ li->li_version = dbg->read(ds->ds_data, &offset, 2); /* FIXME: verify version */
+ li->li_hdrlen = dbg->read(ds->ds_data, &offset, dwarf_size);
+ hdroff = offset;
+ li->li_minlen = dbg->read(ds->ds_data, &offset, 1);
+ if (li->li_version == 4)
+ li->li_maxop = dbg->read(ds->ds_data, &offset, 1);
+ li->li_defstmt = dbg->read(ds->ds_data, &offset, 1);
+ li->li_lbase = dbg->read(ds->ds_data, &offset, 1);
+ li->li_lrange = dbg->read(ds->ds_data, &offset, 1);
+ li->li_opbase = dbg->read(ds->ds_data, &offset, 1);
+ STAILQ_INIT(&li->li_lflist);
+ STAILQ_INIT(&li->li_lnlist);
+
+ if ((int)li->li_hdrlen - 5 < li->li_opbase - 1) {
+ ret = DW_DLE_DEBUG_LINE_LENGTH_BAD;
+ DWARF_SET_ERROR(dbg, error, ret);
+ goto fail_cleanup;
+ }
+
+ if ((li->li_oplen = malloc(li->li_opbase)) == NULL) {
+ ret = DW_DLE_MEMORY;
+ DWARF_SET_ERROR(dbg, error, ret);
+ goto fail_cleanup;
+ }
+
+ /*
+ * Read in std opcode arg length list. Note that the first
+ * element is not used.
+ */
+ for (i = 1; i < li->li_opbase; i++)
+ li->li_oplen[i] = dbg->read(ds->ds_data, &offset, 1);
+
+ /*
+ * Check how many strings in the include dir string array.
+ */
+ length = 0;
+ p = ds->ds_data + offset;
+ while (*p != '\0') {
+ while (*p++ != '\0')
+ ;
+ length++;
+ }
+ li->li_inclen = length;
+
+ /* Sanity check. */
+ if (p - ds->ds_data > (int) ds->ds_size) {
+ ret = DW_DLE_DEBUG_LINE_LENGTH_BAD;
+ DWARF_SET_ERROR(dbg, error, ret);
+ goto fail_cleanup;
+ }
+
+ if (length != 0) {
+ if ((li->li_incdirs = malloc(length * sizeof(char *))) ==
+ NULL) {
+ ret = DW_DLE_MEMORY;
+ DWARF_SET_ERROR(dbg, error, ret);
+ goto fail_cleanup;
+ }
+ }
+
+ /* Fill in include dir array. */
+ i = 0;
+ p = ds->ds_data + offset;
+ while (*p != '\0') {
+ li->li_incdirs[i++] = (char *) p;
+ while (*p++ != '\0')
+ ;
+ }
+
+ p++;
+
+ /*
+ * Process file list.
+ */
+ while (*p != '\0') {
+ ret = _dwarf_lineno_add_file(li, &p, compdir, error, dbg);
+ if (ret != DW_DLE_NONE)
+ goto fail_cleanup;
+ if (p - ds->ds_data > (int) ds->ds_size) {
+ ret = DW_DLE_DEBUG_LINE_LENGTH_BAD;
+ DWARF_SET_ERROR(dbg, error, ret);
+ goto fail_cleanup;
+ }
+ }
+
+ p++;
+
+ /* Sanity check. */
+ if (p - ds->ds_data - hdroff != li->li_hdrlen) {
+ ret = DW_DLE_DEBUG_LINE_LENGTH_BAD;
+ DWARF_SET_ERROR(dbg, error, ret);
+ goto fail_cleanup;
+ }
+
+ /*
+ * Process line number program.
+ */
+ ret = _dwarf_lineno_run_program(cu, li, p, ds->ds_data + endoff, compdir,
+ error);
+ if (ret != DW_DLE_NONE)
+ goto fail_cleanup;
+
+ cu->cu_lineinfo = li;
+
+ return (DW_DLE_NONE);
+
+fail_cleanup:
+
+ STAILQ_FOREACH_SAFE(lf, &li->li_lflist, lf_next, tlf) {
+ STAILQ_REMOVE(&li->li_lflist, lf, _Dwarf_LineFile, lf_next);
+ if (lf->lf_fullpath)
+ free(lf->lf_fullpath);
+ free(lf);
+ }
+
+ if (li->li_oplen)
+ free(li->li_oplen);
+ if (li->li_incdirs)
+ free(li->li_incdirs);
+ free(li);
+
+ return (ret);
+}
+
+void
+_dwarf_lineno_cleanup(Dwarf_LineInfo li)
+{
+ Dwarf_LineFile lf, tlf;
+ Dwarf_Line ln, tln;
+
+ if (li == NULL)
+ return;
+ STAILQ_FOREACH_SAFE(lf, &li->li_lflist, lf_next, tlf) {
+ STAILQ_REMOVE(&li->li_lflist, lf,
+ _Dwarf_LineFile, lf_next);
+ if (lf->lf_fullpath)
+ free(lf->lf_fullpath);
+ free(lf);
+ }
+ STAILQ_FOREACH_SAFE(ln, &li->li_lnlist, ln_next, tln) {
+ STAILQ_REMOVE(&li->li_lnlist, ln, _Dwarf_Line,
+ ln_next);
+ free(ln);
+ }
+ if (li->li_oplen)
+ free(li->li_oplen);
+ if (li->li_incdirs)
+ free(li->li_incdirs);
+ if (li->li_lnarray)
+ free(li->li_lnarray);
+ if (li->li_lfnarray)
+ free(li->li_lfnarray);
+ free(li);
+}
+
+static int
+_dwarf_lineno_gen_program(Dwarf_P_Debug dbg, Dwarf_P_Section ds,
+ Dwarf_Rel_Section drs, Dwarf_Error * error)
+{
+ Dwarf_LineInfo li;
+ Dwarf_Line ln;
+ Dwarf_Unsigned address, file, line, spc;
+ Dwarf_Unsigned addr0, maddr;
+ Dwarf_Signed line0, column;
+ int is_stmt, basic_block;
+ int need_copy;
+ int ret;
+
+#define RESET_REGISTERS \
+ do { \
+ address = 0; \
+ file = 1; \
+ line = 1; \
+ column = 0; \
+ is_stmt = li->li_defstmt; \
+ basic_block = 0; \
+ } while(0)
+
+ li = dbg->dbgp_lineinfo;
+ maddr = (255 - li->li_opbase) / li->li_lrange;
+
+ RESET_REGISTERS;
+
+ STAILQ_FOREACH(ln, &li->li_lnlist, ln_next) {
+ if (ln->ln_symndx > 0) {
+ /*
+ * Generate DW_LNE_set_address extended op.
+ */
+ RCHECK(WRITE_VALUE(0, 1));
+ RCHECK(WRITE_ULEB128(dbg->dbg_pointer_size + 1));
+ RCHECK(WRITE_VALUE(DW_LNE_set_address, 1));
+ RCHECK(_dwarf_reloc_entry_add(dbg, drs, ds,
+ dwarf_drt_data_reloc, dbg->dbg_pointer_size,
+ ds->ds_size, ln->ln_symndx, ln->ln_addr,
+ NULL, error));
+ address = ln->ln_addr;
+ continue;
+ } else if (ln->ln_endseq) {
+ addr0 = (ln->ln_addr - address) / li->li_minlen;
+ if (addr0 != 0) {
+ RCHECK(WRITE_VALUE(DW_LNS_advance_pc, 1));
+ RCHECK(WRITE_ULEB128(addr0));
+ }
+
+ /*
+ * Generate DW_LNE_end_sequence.
+ */
+ RCHECK(WRITE_VALUE(0, 1));
+ RCHECK(WRITE_ULEB128(1));
+ RCHECK(WRITE_VALUE(DW_LNE_end_sequence, 1));
+ RESET_REGISTERS;
+ continue;
+ }
+
+ /*
+ * Generate standard opcodes for file, column, is_stmt or
+ * basic_block changes.
+ */
+ if (ln->ln_fileno != file) {
+ RCHECK(WRITE_VALUE(DW_LNS_set_file, 1));
+ RCHECK(WRITE_ULEB128(ln->ln_fileno));
+ file = ln->ln_fileno;
+ }
+ if (ln->ln_column != column) {
+ RCHECK(WRITE_VALUE(DW_LNS_set_column, 1));
+ RCHECK(WRITE_ULEB128(ln->ln_column));
+ column = ln->ln_column;
+ }
+ if (ln->ln_stmt != is_stmt) {
+ RCHECK(WRITE_VALUE(DW_LNS_negate_stmt, 1));
+ is_stmt = ln->ln_stmt;
+ }
+ if (ln->ln_bblock && !basic_block) {
+ RCHECK(WRITE_VALUE(DW_LNS_set_basic_block, 1));
+ basic_block = 1;
+ }
+
+ /*
+ * Calculate address and line number change.
+ */
+ addr0 = (ln->ln_addr - address) / li->li_minlen;
+ line0 = ln->ln_lineno - line;
+
+ if (addr0 == 0 && line0 == 0)
+ continue;
+
+ /*
+ * Check if line delta is with the range and if the special
+ * opcode can be used.
+ */
+ assert(li->li_lbase <= 0);
+ if (line0 >= li->li_lbase &&
+ line0 <= li->li_lbase + li->li_lrange - 1) {
+ spc = (line0 - li->li_lbase) +
+ (li->li_lrange * addr0) + li->li_opbase;
+ if (spc <= 255) {
+ RCHECK(WRITE_VALUE(spc, 1));
+ basic_block = 0;
+ goto next_line;
+ }
+ }
+
+ /* Generate DW_LNS_advance_line for line number change. */
+ if (line0 != 0) {
+ RCHECK(WRITE_VALUE(DW_LNS_advance_line, 1));
+ RCHECK(WRITE_SLEB128(line0));
+ line0 = 0;
+ need_copy = 1;
+ } else
+ need_copy = basic_block;
+
+ if (addr0 != 0) {
+ /* See if it can be handled by DW_LNS_const_add_pc. */
+ spc = (line0 - li->li_lbase) +
+ (li->li_lrange * (addr0 - maddr)) + li->li_opbase;
+ if (addr0 >= maddr && spc <= 255) {
+ RCHECK(WRITE_VALUE(DW_LNS_const_add_pc, 1));
+ RCHECK(WRITE_VALUE(spc, 1));
+ } else {
+ /* Otherwise we use DW_LNS_advance_pc. */
+ RCHECK(WRITE_VALUE(DW_LNS_advance_pc, 1));
+ RCHECK(WRITE_ULEB128(addr0));
+ }
+ }
+
+ if (need_copy) {
+ RCHECK(WRITE_VALUE(DW_LNS_copy, 1));
+ basic_block = 0;
+ }
+
+ next_line:
+ address = ln->ln_addr;
+ line = ln->ln_lineno;
+ }
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+ return (ret);
+
+#undef RESET_REGISTERS
+}
+
+static uint8_t
+_dwarf_get_minlen(Dwarf_P_Debug dbg)
+{
+
+ assert(dbg != NULL);
+
+ switch (dbg->dbgp_isa) {
+ case DW_ISA_ARM:
+ return (2);
+ case DW_ISA_X86:
+ case DW_ISA_X86_64:
+ return (1);
+ default:
+ return (4);
+ }
+}
+
+static uint8_t oplen[] = {0, 1, 1, 1, 1, 0, 0, 0, 1};
+
+int
+_dwarf_lineno_gen(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_LineInfo li;
+ Dwarf_LineFile lf;
+ Dwarf_P_Section ds;
+ Dwarf_Rel_Section drs;
+ Dwarf_Unsigned offset;
+ int i, ret;
+
+ assert(dbg != NULL && dbg->dbgp_lineinfo != NULL);
+
+ li = dbg->dbgp_lineinfo;
+ if (STAILQ_EMPTY(&li->li_lnlist))
+ return (DW_DLE_NONE);
+
+ li->li_length = 0;
+ li->li_version = 2;
+ li->li_hdrlen = 0;
+ li->li_minlen = _dwarf_get_minlen(dbg);
+ li->li_defstmt = 1;
+ li->li_lbase = -5;
+ li->li_lrange = 14;
+ li->li_opbase = 10;
+
+ /* Create .debug_line section. */
+ if ((ret = _dwarf_section_init(dbg, &ds, ".debug_line", 0, error)) !=
+ DW_DLE_NONE)
+ return (ret);
+
+ /* Create relocation section for .debug_line */
+ if ((ret = _dwarf_reloc_section_init(dbg, &drs, ds, error)) !=
+ DW_DLE_NONE)
+ goto gen_fail1;
+
+ /* Length placeholder. (We only use 32-bit DWARF format) */
+ RCHECK(WRITE_VALUE(0, 4));
+
+ /* Write line number dwarf version. (DWARF2) */
+ RCHECK(WRITE_VALUE(li->li_version, 2));
+
+ /* Header length placeholder. */
+ offset = ds->ds_size;
+ RCHECK(WRITE_VALUE(li->li_hdrlen, 4));
+
+ /* Write minimum instruction length. */
+ RCHECK(WRITE_VALUE(li->li_minlen, 1));
+
+ /*
+ * Write initial value for is_stmt. XXX Which default value we
+ * should use?
+ */
+ RCHECK(WRITE_VALUE(li->li_defstmt, 1));
+
+ /*
+ * Write line_base and line_range. FIXME These value needs to be
+ * fine tuned.
+ */
+ RCHECK(WRITE_VALUE(li->li_lbase, 1));
+ RCHECK(WRITE_VALUE(li->li_lrange, 1));
+
+ /* Write opcode_base. (DWARF2) */
+ RCHECK(WRITE_VALUE(li->li_opbase, 1));
+
+ /* Write standard op length array. */
+ RCHECK(WRITE_BLOCK(oplen, sizeof(oplen) / sizeof(oplen[0])));
+
+ /* Write the list of include directories. */
+ for (i = 0; (Dwarf_Unsigned) i < li->li_inclen; i++)
+ RCHECK(WRITE_STRING(li->li_incdirs[i]));
+ RCHECK(WRITE_VALUE(0, 1));
+
+ /* Write the list of filenames. */
+ STAILQ_FOREACH(lf, &li->li_lflist, lf_next) {
+ RCHECK(WRITE_STRING(lf->lf_fname));
+ RCHECK(WRITE_ULEB128(lf->lf_dirndx));
+ RCHECK(WRITE_ULEB128(lf->lf_mtime));
+ RCHECK(WRITE_ULEB128(lf->lf_size));
+ }
+ RCHECK(WRITE_VALUE(0, 1));
+
+ /* Fill in the header length. */
+ li->li_hdrlen = ds->ds_size - offset - 4;
+ dbg->write(ds->ds_data, &offset, li->li_hdrlen, 4);
+
+ /* Generate the line number program. */
+ RCHECK(_dwarf_lineno_gen_program(dbg, ds, drs, error));
+
+ /* Fill in the length of this line info. */
+ li->li_length = ds->ds_size - 4;
+ offset = 0;
+ dbg->write(ds->ds_data, &offset, li->li_length, 4);
+
+ /* Notify the creation of .debug_line ELF section. */
+ RCHECK(_dwarf_section_callback(dbg, ds, SHT_PROGBITS, 0, 0, 0, error));
+
+ /* Finalize relocation section for .debug_line. */
+ RCHECK(_dwarf_reloc_section_finalize(dbg, drs, error));
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+ _dwarf_reloc_section_free(dbg, &drs);
+
+gen_fail1:
+ _dwarf_section_free(dbg, &ds);
+
+ return (ret);
+}
+
+void
+_dwarf_lineno_pro_cleanup(Dwarf_P_Debug dbg)
+{
+ Dwarf_LineInfo li;
+ Dwarf_LineFile lf, tlf;
+ Dwarf_Line ln, tln;
+ int i;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_WRITE);
+ if (dbg->dbgp_lineinfo == NULL)
+ return;
+
+ li = dbg->dbgp_lineinfo;
+ STAILQ_FOREACH_SAFE(lf, &li->li_lflist, lf_next, tlf) {
+ STAILQ_REMOVE(&li->li_lflist, lf, _Dwarf_LineFile,
+ lf_next);
+ if (lf->lf_fname)
+ free(lf->lf_fname);
+ free(lf);
+ }
+ STAILQ_FOREACH_SAFE(ln, &li->li_lnlist, ln_next, tln) {
+ STAILQ_REMOVE(&li->li_lnlist, ln, _Dwarf_Line, ln_next);
+ free(ln);
+ }
+ if (li->li_incdirs) {
+ for (i = 0; (Dwarf_Unsigned) i < li->li_inclen; i++)
+ free(li->li_incdirs[i]);
+ free(li->li_incdirs);
+ }
+ free(li);
+ dbg->dbgp_lineinfo = NULL;
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_loc.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_loc.c
new file mode 100644
index 0000000..c2d3f5c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_loc.c
@@ -0,0 +1,701 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2014 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_loc.c 3070 2014-06-23 03:08:33Z kaiwang27 $");
+
+/*
+ * Given an array of bytes of length 'len' representing a
+ * DWARF expression, compute the number of operations based
+ * on there being one byte describing the operation and
+ * zero or more bytes of operands as defined in the standard
+ * for each operation type. Also, if lbuf is non-null, store
+ * the opcode and oprand in it.
+ */
+static int
+_dwarf_loc_fill_loc(Dwarf_Debug dbg, Dwarf_Locdesc *lbuf, uint8_t pointer_size,
+ uint8_t offset_size, uint8_t version, uint8_t *p, int len)
+{
+ int count;
+ uint64_t operand1;
+ uint64_t operand2;
+ uint8_t *ps, *pe, s;
+
+ count = 0;
+ ps = p;
+ pe = p + len;
+
+ /*
+ * Process each byte. If an error occurs, then the
+ * count will be set to -1.
+ */
+ while (p < pe) {
+
+ operand1 = 0;
+ operand2 = 0;
+
+ if (lbuf != NULL) {
+ lbuf->ld_s[count].lr_atom = *p;
+ lbuf->ld_s[count].lr_offset = p - ps;
+ }
+
+ switch (*p++) {
+ /* Operations with no operands. */
+ case DW_OP_deref:
+ case DW_OP_reg0:
+ case DW_OP_reg1:
+ case DW_OP_reg2:
+ case DW_OP_reg3:
+ case DW_OP_reg4:
+ case DW_OP_reg5:
+ case DW_OP_reg6:
+ case DW_OP_reg7:
+ case DW_OP_reg8:
+ case DW_OP_reg9:
+ case DW_OP_reg10:
+ case DW_OP_reg11:
+ case DW_OP_reg12:
+ case DW_OP_reg13:
+ case DW_OP_reg14:
+ case DW_OP_reg15:
+ case DW_OP_reg16:
+ case DW_OP_reg17:
+ case DW_OP_reg18:
+ case DW_OP_reg19:
+ case DW_OP_reg20:
+ case DW_OP_reg21:
+ case DW_OP_reg22:
+ case DW_OP_reg23:
+ case DW_OP_reg24:
+ case DW_OP_reg25:
+ case DW_OP_reg26:
+ case DW_OP_reg27:
+ case DW_OP_reg28:
+ case DW_OP_reg29:
+ case DW_OP_reg30:
+ case DW_OP_reg31:
+
+ case DW_OP_lit0:
+ case DW_OP_lit1:
+ case DW_OP_lit2:
+ case DW_OP_lit3:
+ case DW_OP_lit4:
+ case DW_OP_lit5:
+ case DW_OP_lit6:
+ case DW_OP_lit7:
+ case DW_OP_lit8:
+ case DW_OP_lit9:
+ case DW_OP_lit10:
+ case DW_OP_lit11:
+ case DW_OP_lit12:
+ case DW_OP_lit13:
+ case DW_OP_lit14:
+ case DW_OP_lit15:
+ case DW_OP_lit16:
+ case DW_OP_lit17:
+ case DW_OP_lit18:
+ case DW_OP_lit19:
+ case DW_OP_lit20:
+ case DW_OP_lit21:
+ case DW_OP_lit22:
+ case DW_OP_lit23:
+ case DW_OP_lit24:
+ case DW_OP_lit25:
+ case DW_OP_lit26:
+ case DW_OP_lit27:
+ case DW_OP_lit28:
+ case DW_OP_lit29:
+ case DW_OP_lit30:
+ case DW_OP_lit31:
+
+ case DW_OP_dup:
+ case DW_OP_drop:
+
+ case DW_OP_over:
+
+ case DW_OP_swap:
+ case DW_OP_rot:
+ case DW_OP_xderef:
+
+ case DW_OP_abs:
+ case DW_OP_and:
+ case DW_OP_div:
+ case DW_OP_minus:
+ case DW_OP_mod:
+ case DW_OP_mul:
+ case DW_OP_neg:
+ case DW_OP_not:
+ case DW_OP_or:
+ case DW_OP_plus:
+
+ case DW_OP_shl:
+ case DW_OP_shr:
+ case DW_OP_shra:
+ case DW_OP_xor:
+
+ case DW_OP_eq:
+ case DW_OP_ge:
+ case DW_OP_gt:
+ case DW_OP_le:
+ case DW_OP_lt:
+ case DW_OP_ne:
+
+ case DW_OP_nop:
+ case DW_OP_push_object_address:
+ case DW_OP_form_tls_address:
+ case DW_OP_call_frame_cfa:
+ case DW_OP_stack_value:
+ case DW_OP_GNU_push_tls_address:
+ case DW_OP_GNU_uninit:
+ break;
+
+ /* Operations with 1-byte operands. */
+ case DW_OP_const1u:
+ case DW_OP_pick:
+ case DW_OP_deref_size:
+ case DW_OP_xderef_size:
+ operand1 = *p++;
+ break;
+
+ case DW_OP_const1s:
+ operand1 = (int8_t) *p++;
+ break;
+
+ /* Operations with 2-byte operands. */
+ case DW_OP_call2:
+ case DW_OP_const2u:
+ case DW_OP_bra:
+ case DW_OP_skip:
+ operand1 = dbg->decode(&p, 2);
+ break;
+
+ case DW_OP_const2s:
+ operand1 = (int16_t) dbg->decode(&p, 2);
+ break;
+
+ /* Operations with 4-byte operands. */
+ case DW_OP_call4:
+ case DW_OP_const4u:
+ case DW_OP_GNU_parameter_ref:
+ operand1 = dbg->decode(&p, 4);
+ break;
+
+ case DW_OP_const4s:
+ operand1 = (int32_t) dbg->decode(&p, 4);
+ break;
+
+ /* Operations with 8-byte operands. */
+ case DW_OP_const8u:
+ case DW_OP_const8s:
+ operand1 = dbg->decode(&p, 8);
+ break;
+
+ /* Operations with an unsigned LEB128 operand. */
+ case DW_OP_constu:
+ case DW_OP_plus_uconst:
+ case DW_OP_regx:
+ case DW_OP_piece:
+ case DW_OP_GNU_deref_type:
+ case DW_OP_GNU_convert:
+ case DW_OP_GNU_reinterpret:
+ operand1 = _dwarf_decode_uleb128(&p);
+ break;
+
+ /* Operations with a signed LEB128 operand. */
+ case DW_OP_consts:
+ case DW_OP_breg0:
+ case DW_OP_breg1:
+ case DW_OP_breg2:
+ case DW_OP_breg3:
+ case DW_OP_breg4:
+ case DW_OP_breg5:
+ case DW_OP_breg6:
+ case DW_OP_breg7:
+ case DW_OP_breg8:
+ case DW_OP_breg9:
+ case DW_OP_breg10:
+ case DW_OP_breg11:
+ case DW_OP_breg12:
+ case DW_OP_breg13:
+ case DW_OP_breg14:
+ case DW_OP_breg15:
+ case DW_OP_breg16:
+ case DW_OP_breg17:
+ case DW_OP_breg18:
+ case DW_OP_breg19:
+ case DW_OP_breg20:
+ case DW_OP_breg21:
+ case DW_OP_breg22:
+ case DW_OP_breg23:
+ case DW_OP_breg24:
+ case DW_OP_breg25:
+ case DW_OP_breg26:
+ case DW_OP_breg27:
+ case DW_OP_breg28:
+ case DW_OP_breg29:
+ case DW_OP_breg30:
+ case DW_OP_breg31:
+ case DW_OP_fbreg:
+ operand1 = _dwarf_decode_sleb128(&p);
+ break;
+
+ /*
+ * Oeration with two unsigned LEB128 operands.
+ */
+ case DW_OP_bit_piece:
+ case DW_OP_GNU_regval_type:
+ operand1 = _dwarf_decode_uleb128(&p);
+ operand2 = _dwarf_decode_uleb128(&p);
+ break;
+
+ /*
+ * Operations with an unsigned LEB128 operand
+ * followed by a signed LEB128 operand.
+ */
+ case DW_OP_bregx:
+ operand1 = _dwarf_decode_uleb128(&p);
+ operand2 = _dwarf_decode_sleb128(&p);
+ break;
+
+ /*
+ * Operation with an unsigned LEB128 operand
+ * representing the size of a block, followed
+ * by the block content.
+ *
+ * Store the size of the block in the operand1
+ * and a pointer to the block in the operand2.
+ */
+ case DW_OP_implicit_value:
+ case DW_OP_GNU_entry_value:
+ operand1 = _dwarf_decode_uleb128(&p);
+ operand2 = (Dwarf_Unsigned) (uintptr_t) p;
+ p += operand1;
+ break;
+
+ /* Target address size operand. */
+ case DW_OP_addr:
+ case DW_OP_GNU_addr_index:
+ case DW_OP_GNU_const_index:
+ operand1 = dbg->decode(&p, pointer_size);
+ break;
+
+ /* Offset size operand. */
+ case DW_OP_call_ref:
+ operand1 = dbg->decode(&p, offset_size);
+ break;
+
+ /*
+ * The first byte is address byte length, followed by
+ * the address value. If the length is 0, the address
+ * size is the same as target pointer size.
+ */
+ case DW_OP_GNU_encoded_addr:
+ s = *p++;
+ if (s == 0)
+ s = pointer_size;
+ operand1 = dbg->decode(&p, s);
+ break;
+
+ /*
+ * Operand1: DIE offset (size depending on DWARF version)
+ * DWARF2: pointer size
+ * DWARF{3,4}: offset size
+ *
+ * Operand2: SLEB128
+ */
+ case DW_OP_GNU_implicit_pointer:
+ if (version == 2)
+ operand1 = dbg->decode(&p, pointer_size);
+ else
+ operand1 = dbg->decode(&p, offset_size);
+ operand2 = _dwarf_decode_sleb128(&p);
+ break;
+
+ /*
+ * Operand1: DIE offset (ULEB128)
+ * Operand2: pointer to a block. The block's first byte
+ * is its size.
+ */
+ case DW_OP_GNU_const_type:
+ operand1 = _dwarf_decode_uleb128(&p);
+ operand2 = (Dwarf_Unsigned) (uintptr_t) p;
+ s = *p++;
+ p += s;
+ break;
+
+ /* All other operations cause an error. */
+ default:
+ count = -1;
+ goto done;
+ }
+
+ if (lbuf != NULL) {
+ lbuf->ld_s[count].lr_number = operand1;
+ lbuf->ld_s[count].lr_number2 = operand2;
+ }
+
+ count++;
+ }
+
+done:
+ return (count);
+}
+
+int
+_dwarf_loc_expr_add_atom(Dwarf_Debug dbg, uint8_t *out, uint8_t *end,
+ Dwarf_Small atom, Dwarf_Unsigned operand1, Dwarf_Unsigned operand2,
+ int *length, Dwarf_Error *error)
+{
+ uint8_t buf[64];
+ uint8_t *p, *pe;
+ uint64_t offset;
+ int len;
+
+ if (out != NULL && end != NULL) {
+ p = out;
+ pe = end;
+ } else {
+ p = out = buf;
+ pe = &buf[sizeof(buf)];
+ }
+
+ switch (atom) {
+ /* Operations with no operands. */
+ case DW_OP_deref:
+ case DW_OP_reg0:
+ case DW_OP_reg1:
+ case DW_OP_reg2:
+ case DW_OP_reg3:
+ case DW_OP_reg4:
+ case DW_OP_reg5:
+ case DW_OP_reg6:
+ case DW_OP_reg7:
+ case DW_OP_reg8:
+ case DW_OP_reg9:
+ case DW_OP_reg10:
+ case DW_OP_reg11:
+ case DW_OP_reg12:
+ case DW_OP_reg13:
+ case DW_OP_reg14:
+ case DW_OP_reg15:
+ case DW_OP_reg16:
+ case DW_OP_reg17:
+ case DW_OP_reg18:
+ case DW_OP_reg19:
+ case DW_OP_reg20:
+ case DW_OP_reg21:
+ case DW_OP_reg22:
+ case DW_OP_reg23:
+ case DW_OP_reg24:
+ case DW_OP_reg25:
+ case DW_OP_reg26:
+ case DW_OP_reg27:
+ case DW_OP_reg28:
+ case DW_OP_reg29:
+ case DW_OP_reg30:
+ case DW_OP_reg31:
+
+ case DW_OP_lit0:
+ case DW_OP_lit1:
+ case DW_OP_lit2:
+ case DW_OP_lit3:
+ case DW_OP_lit4:
+ case DW_OP_lit5:
+ case DW_OP_lit6:
+ case DW_OP_lit7:
+ case DW_OP_lit8:
+ case DW_OP_lit9:
+ case DW_OP_lit10:
+ case DW_OP_lit11:
+ case DW_OP_lit12:
+ case DW_OP_lit13:
+ case DW_OP_lit14:
+ case DW_OP_lit15:
+ case DW_OP_lit16:
+ case DW_OP_lit17:
+ case DW_OP_lit18:
+ case DW_OP_lit19:
+ case DW_OP_lit20:
+ case DW_OP_lit21:
+ case DW_OP_lit22:
+ case DW_OP_lit23:
+ case DW_OP_lit24:
+ case DW_OP_lit25:
+ case DW_OP_lit26:
+ case DW_OP_lit27:
+ case DW_OP_lit28:
+ case DW_OP_lit29:
+ case DW_OP_lit30:
+ case DW_OP_lit31:
+
+ case DW_OP_dup:
+ case DW_OP_drop:
+
+ case DW_OP_over:
+
+ case DW_OP_swap:
+ case DW_OP_rot:
+ case DW_OP_xderef:
+
+ case DW_OP_abs:
+ case DW_OP_and:
+ case DW_OP_div:
+ case DW_OP_minus:
+ case DW_OP_mod:
+ case DW_OP_mul:
+ case DW_OP_neg:
+ case DW_OP_not:
+ case DW_OP_or:
+ case DW_OP_plus:
+
+ case DW_OP_shl:
+ case DW_OP_shr:
+ case DW_OP_shra:
+ case DW_OP_xor:
+
+ case DW_OP_eq:
+ case DW_OP_ge:
+ case DW_OP_gt:
+ case DW_OP_le:
+ case DW_OP_lt:
+ case DW_OP_ne:
+
+ case DW_OP_nop:
+ case DW_OP_GNU_push_tls_address:
+ *p++ = atom;
+ break;
+
+ /* Operations with 1-byte operands. */
+ case DW_OP_const1u:
+ case DW_OP_const1s:
+ case DW_OP_pick:
+ case DW_OP_deref_size:
+ case DW_OP_xderef_size:
+ *p++ = atom;
+ *p++ = (uint8_t) operand1;
+ break;
+
+ /* Operations with 2-byte operands. */
+ case DW_OP_const2u:
+ case DW_OP_const2s:
+ case DW_OP_bra:
+ case DW_OP_skip:
+ *p++ = atom;
+ offset = 0;
+ dbg->write(p, &offset, operand1, 2);
+ p += 2;
+ break;
+
+ /* Operations with 4-byte operands. */
+ case DW_OP_const4u:
+ case DW_OP_const4s:
+ *p++ = atom;
+ offset = 0;
+ dbg->write(p, &offset, operand1, 4);
+ p += 4;
+ break;
+
+ /* Operations with 8-byte operands. */
+ case DW_OP_const8u:
+ case DW_OP_const8s:
+ *p++ = atom;
+ offset = 0;
+ dbg->write(p, &offset, operand1, 8);
+ p += 8;
+ break;
+
+ /* Operations with an unsigned LEB128 operand. */
+ case DW_OP_constu:
+ case DW_OP_plus_uconst:
+ case DW_OP_regx:
+ case DW_OP_piece:
+ *p++ = atom;
+ len = _dwarf_write_uleb128(p, pe, operand1);
+ assert(len > 0);
+ p += len;
+ break;
+
+ /* Operations with a signed LEB128 operand. */
+ case DW_OP_consts:
+ case DW_OP_breg0:
+ case DW_OP_breg1:
+ case DW_OP_breg2:
+ case DW_OP_breg3:
+ case DW_OP_breg4:
+ case DW_OP_breg5:
+ case DW_OP_breg6:
+ case DW_OP_breg7:
+ case DW_OP_breg8:
+ case DW_OP_breg9:
+ case DW_OP_breg10:
+ case DW_OP_breg11:
+ case DW_OP_breg12:
+ case DW_OP_breg13:
+ case DW_OP_breg14:
+ case DW_OP_breg15:
+ case DW_OP_breg16:
+ case DW_OP_breg17:
+ case DW_OP_breg18:
+ case DW_OP_breg19:
+ case DW_OP_breg20:
+ case DW_OP_breg21:
+ case DW_OP_breg22:
+ case DW_OP_breg23:
+ case DW_OP_breg24:
+ case DW_OP_breg25:
+ case DW_OP_breg26:
+ case DW_OP_breg27:
+ case DW_OP_breg28:
+ case DW_OP_breg29:
+ case DW_OP_breg30:
+ case DW_OP_breg31:
+ case DW_OP_fbreg:
+ *p++ = atom;
+ len = _dwarf_write_sleb128(p, pe, operand1);
+ assert(len > 0);
+ p += len;
+ break;
+
+ /*
+ * Operations with an unsigned LEB128 operand
+ * followed by a signed LEB128 operand.
+ */
+ case DW_OP_bregx:
+ *p++ = atom;
+ len = _dwarf_write_uleb128(p, pe, operand1);
+ assert(len > 0);
+ p += len;
+ len = _dwarf_write_sleb128(p, pe, operand2);
+ assert(len > 0);
+ p += len;
+ break;
+
+ /* Target address size operand. */
+ case DW_OP_addr:
+ *p++ = atom;
+ offset = 0;
+ dbg->write(p, &offset, operand1, dbg->dbg_pointer_size);
+ p += dbg->dbg_pointer_size;
+ break;
+
+ /* All other operations cause an error. */
+ default:
+ DWARF_SET_ERROR(dbg, error, DW_DLE_LOC_EXPR_BAD);
+ return (DW_DLE_LOC_EXPR_BAD);
+ }
+
+ if (length)
+ *length = p - out;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_loc_fill_locdesc(Dwarf_Debug dbg, Dwarf_Locdesc *llbuf, uint8_t *in,
+ uint64_t in_len, uint8_t pointer_size, uint8_t offset_size,
+ uint8_t version, Dwarf_Error *error)
+{
+ int num;
+
+ assert(llbuf != NULL);
+ assert(in != NULL);
+ assert(in_len > 0);
+
+ /* Compute the number of locations. */
+ if ((num = _dwarf_loc_fill_loc(dbg, NULL, pointer_size, offset_size,
+ version, in, in_len)) < 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_LOC_EXPR_BAD);
+ return (DW_DLE_LOC_EXPR_BAD);
+ }
+
+ llbuf->ld_cents = num;
+ if (num <= 0)
+ return (DW_DLE_NONE);
+
+ if ((llbuf->ld_s = calloc(num, sizeof(Dwarf_Loc))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ (void) _dwarf_loc_fill_loc(dbg, llbuf, pointer_size, offset_size,
+ version, in, in_len);
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_loc_fill_locexpr(Dwarf_Debug dbg, Dwarf_Locdesc **ret_llbuf, uint8_t *in,
+ uint64_t in_len, uint8_t pointer_size, uint8_t offset_size,
+ uint8_t version, Dwarf_Error *error)
+{
+ Dwarf_Locdesc *llbuf;
+ int ret;
+
+ if ((llbuf = malloc(sizeof(Dwarf_Locdesc))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ llbuf->ld_lopc = 0;
+ llbuf->ld_hipc = ~0ULL;
+ llbuf->ld_s = NULL;
+
+ ret = _dwarf_loc_fill_locdesc(dbg, llbuf, in, in_len, pointer_size,
+ offset_size, version, error);
+ if (ret != DW_DLE_NONE) {
+ free(llbuf);
+ return (ret);
+ }
+
+ *ret_llbuf = llbuf;
+
+ return (ret);
+}
+
+int
+_dwarf_loc_add(Dwarf_Die die, Dwarf_Attribute at, Dwarf_Error *error)
+{
+ Dwarf_Debug dbg;
+ Dwarf_CU cu;
+ int ret;
+
+ assert(at->at_ld == NULL);
+ assert(at->u[1].u8p != NULL);
+ assert(at->u[0].u64 > 0);
+
+ cu = die->die_cu;
+ assert(cu != NULL);
+
+ dbg = cu->cu_dbg;
+ assert(dbg != NULL);
+
+ ret = _dwarf_loc_fill_locexpr(dbg, &at->at_ld, at->u[1].u8p,
+ at->u[0].u64, cu->cu_pointer_size, cu->cu_length_size == 4 ? 4 : 8,
+ cu->cu_version, error);
+
+ return (ret);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_loclist.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_loclist.c
new file mode 100644
index 0000000..bb3e39f
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_loclist.c
@@ -0,0 +1,165 @@
+/*-
+ * Copyright (c) 2009,2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_loclist.c 3061 2014-06-02 00:42:41Z kaiwang27 $");
+
+static int
+_dwarf_loclist_add_locdesc(Dwarf_Debug dbg, Dwarf_CU cu, Dwarf_Section *ds,
+ Dwarf_Unsigned *off, Dwarf_Locdesc **ld, Dwarf_Signed *ldlen,
+ Dwarf_Unsigned *total_len, Dwarf_Error *error)
+{
+ uint64_t start, end;
+ int i, len, ret;
+
+ if (total_len != NULL)
+ *total_len = 0;
+
+ for (i = 0; *off < ds->ds_size; i++) {
+ start = dbg->read(ds->ds_data, off, cu->cu_pointer_size);
+ end = dbg->read(ds->ds_data, off, cu->cu_pointer_size);
+ if (ld != NULL) {
+ ld[i]->ld_lopc = start;
+ ld[i]->ld_hipc = end;
+ }
+
+ if (total_len != NULL)
+ *total_len += 2 * cu->cu_pointer_size;
+
+ /* Check if it is the end entry. */
+ if (start == 0 && end ==0) {
+ i++;
+ break;
+ }
+
+ /* Check if it is base-select entry. */
+ if ((cu->cu_pointer_size == 4 && start == ~0U) ||
+ (cu->cu_pointer_size == 8 && start == ~0ULL))
+ continue;
+
+ /* Otherwise it's normal entry. */
+ len = dbg->read(ds->ds_data, off, 2);
+ if (*off + len > ds->ds_size) {
+ DWARF_SET_ERROR(dbg, error,
+ DW_DLE_DEBUG_LOC_SECTION_SHORT);
+ return (DW_DLE_DEBUG_LOC_SECTION_SHORT);
+ }
+
+ if (total_len != NULL)
+ *total_len += len;
+
+ if (ld != NULL) {
+ ret = _dwarf_loc_fill_locdesc(dbg, ld[i],
+ ds->ds_data + *off, len, cu->cu_pointer_size,
+ cu->cu_length_size == 4 ? 4 : 8, cu->cu_version,
+ error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+
+ *off += len;
+ }
+
+ if (ldlen != NULL)
+ *ldlen = i;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_loclist_find(Dwarf_Debug dbg, Dwarf_CU cu, uint64_t lloff,
+ Dwarf_Locdesc ***ret_llbuf, Dwarf_Signed *listlen,
+ Dwarf_Unsigned *entry_len, Dwarf_Error *error)
+{
+ Dwarf_Locdesc **llbuf;
+ Dwarf_Section *ds;
+ Dwarf_Signed ldlen;
+ Dwarf_Unsigned off;
+ int i, ret;
+
+ if ((ds = _dwarf_find_section(dbg, ".debug_loc")) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLE_NO_ENTRY);
+ }
+
+ if (lloff >= ds->ds_size) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLE_NO_ENTRY);
+ }
+
+ /* Get the number of locdesc the first round. */
+ off = lloff;
+ ret = _dwarf_loclist_add_locdesc(dbg, cu, ds, &off, NULL, &ldlen,
+ NULL, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+
+ if (ldlen == 0)
+ return (DW_DLE_NO_ENTRY);
+
+ /*
+ * Dwarf_Locdesc list memory is allocated in this way (one more level
+ * of indirect) to make the loclist API be compatible with SGI libdwarf.
+ */
+ if ((llbuf = calloc(ldlen, sizeof(Dwarf_Locdesc *))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ for (i = 0; i < ldlen; i++) {
+ if ((llbuf[i] = calloc(1, sizeof(Dwarf_Locdesc))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ ret = DW_DLE_MEMORY;
+ goto fail_cleanup;
+ }
+ }
+
+ off = lloff;
+
+ /* Fill in locdesc. */
+ ret = _dwarf_loclist_add_locdesc(dbg, cu, ds, &off, llbuf, NULL,
+ entry_len, error);
+ if (ret != DW_DLE_NONE)
+ goto fail_cleanup;
+
+ *ret_llbuf = llbuf;
+ *listlen = ldlen;
+
+ return (DW_DLE_NONE);
+
+fail_cleanup:
+
+ if (llbuf != NULL) {
+ for (i = 0; i < ldlen; i++) {
+ if (llbuf[i]->ld_s)
+ free(llbuf[i]->ld_s);
+ free(llbuf[i]);
+ }
+ free(llbuf);
+ }
+
+ return (ret);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_macinfo.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_macinfo.c
new file mode 100644
index 0000000..1c9101c
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_macinfo.c
@@ -0,0 +1,254 @@
+/*-
+ * Copyright (c) 2009-2011 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_macinfo.c 2974 2013-12-23 06:46:22Z kaiwang27 $");
+
+#define _FILEINDEX_STACK_SIZE 16384
+
+static int
+_dwarf_macinfo_parse(Dwarf_Debug dbg, Dwarf_Section *ds, uint64_t *off,
+ Dwarf_Macro_Details *dmd, Dwarf_Unsigned *cnt, Dwarf_Error *error)
+{
+ Dwarf_Unsigned lineno;
+ Dwarf_Signed fileindex[_FILEINDEX_STACK_SIZE];
+ char *p;
+ int i, type, sp;
+
+ i = 0;
+ sp = 0;
+ fileindex[sp] = -1;
+ while (*off < ds->ds_size) {
+
+ if (dmd != NULL)
+ dmd[i].dmd_offset = *off;
+
+ type = dbg->read(ds->ds_data, off, 1);
+
+ if (dmd != NULL) {
+ dmd[i].dmd_type = type;
+ dmd[i].dmd_fileindex = fileindex[sp];
+ }
+
+ switch (type) {
+ case 0:
+ break;
+ case DW_MACINFO_define:
+ case DW_MACINFO_undef:
+ case DW_MACINFO_vendor_ext:
+ lineno = _dwarf_read_uleb128(ds->ds_data, off);
+ p = (char *) ds->ds_data;
+ if (dmd != NULL) {
+ dmd[i].dmd_lineno = lineno;
+ dmd[i].dmd_macro = p + *off;
+
+ }
+ while (p[(*off)++] != '\0')
+ ;
+ break;
+ case DW_MACINFO_start_file:
+ lineno = _dwarf_read_uleb128(ds->ds_data, off);
+ if (sp >= _FILEINDEX_STACK_SIZE - 1) {
+ assert(0);
+ }
+ fileindex[++sp] = _dwarf_read_uleb128(ds->ds_data, off);
+ if (dmd != NULL) {
+ dmd[i].dmd_lineno = lineno;
+ dmd[i].dmd_fileindex = fileindex[sp];
+ }
+ break;
+ case DW_MACINFO_end_file:
+ if (sp > 0) {
+ sp--;
+ break;
+ }
+ /* FALLTHROUGH */
+ default:
+ DWARF_SET_ERROR(dbg, error,
+ DW_DLE_DEBUG_MACRO_INCONSISTENT);
+ return (DW_DLE_DEBUG_MACRO_INCONSISTENT);
+ }
+
+ i++;
+
+ if (type == 0)
+ break;
+ }
+
+ if (cnt != NULL)
+ *cnt = i;
+
+ return (DW_DLE_NONE);
+}
+
+void
+_dwarf_macinfo_cleanup(Dwarf_Debug dbg)
+{
+ Dwarf_MacroSet ms, tms;
+
+ if (STAILQ_EMPTY(&dbg->dbg_mslist))
+ return;
+
+ STAILQ_FOREACH_SAFE(ms, &dbg->dbg_mslist, ms_next, tms) {
+ STAILQ_REMOVE(&dbg->dbg_mslist, ms, _Dwarf_MacroSet, ms_next);
+ if (ms->ms_mdlist)
+ free(ms->ms_mdlist);
+ free(ms);
+ }
+}
+
+int
+_dwarf_macinfo_init(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_MacroSet ms;
+ Dwarf_Unsigned cnt;
+ Dwarf_Section *ds;
+ uint64_t offset, entry_off;
+ int ret;
+
+ if ((ds = _dwarf_find_section(dbg, ".debug_macinfo")) == NULL)
+ return (DW_DLE_NONE);
+
+ offset = 0;
+ while (offset < ds->ds_size) {
+
+ entry_off = offset;
+
+ ret = _dwarf_macinfo_parse(dbg, ds, &offset, NULL, &cnt, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+
+ if (cnt == 0)
+ break;
+
+ if ((ms = calloc(1, sizeof(struct _Dwarf_MacroSet))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ ret = DW_DLE_MEMORY;
+ goto fail_cleanup;
+ }
+ STAILQ_INSERT_TAIL(&dbg->dbg_mslist, ms, ms_next);
+
+ if ((ms->ms_mdlist = calloc(cnt, sizeof(Dwarf_Macro_Details)))
+ == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ ret = DW_DLE_MEMORY;
+ goto fail_cleanup;
+ }
+
+ ms->ms_cnt = cnt;
+
+ offset = entry_off;
+
+ ret = _dwarf_macinfo_parse(dbg, ds, &offset, ms->ms_mdlist,
+ NULL, error);
+
+ if (ret != DW_DLE_NONE) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ ret = DW_DLE_MEMORY;
+ goto fail_cleanup;
+ }
+ }
+
+ return (DW_DLE_NONE);
+
+fail_cleanup:
+
+ _dwarf_macinfo_cleanup(dbg);
+
+ return (ret);
+}
+
+int
+_dwarf_macinfo_gen(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_P_Section ds;
+ Dwarf_Macro_Details *md;
+ int i, ret;
+
+ if (dbg->dbgp_mdcnt == 0)
+ return (DW_DLE_NONE);
+
+ /* Create .debug_frame section. */
+ RCHECK(_dwarf_section_init(dbg, &ds, ".debug_macinfo", 0, error));
+
+ /* Write the list of Dwarf_Macro_Details. */
+ for (i = 0; (Dwarf_Unsigned) i < dbg->dbgp_mdcnt; i++) {
+ md = &dbg->dbgp_mdlist[i];
+ md->dmd_offset = ds->ds_size;
+ RCHECK(WRITE_VALUE(md->dmd_type, 1));
+ switch (md->dmd_type) {
+ case DW_MACINFO_define:
+ case DW_MACINFO_undef:
+ case DW_MACINFO_vendor_ext:
+ RCHECK(WRITE_ULEB128(md->dmd_lineno));
+ assert(md->dmd_macro != NULL);
+ RCHECK(WRITE_STRING(md->dmd_macro));
+ break;
+ case DW_MACINFO_start_file:
+ RCHECK(WRITE_ULEB128(md->dmd_lineno));
+ RCHECK(WRITE_ULEB128(md->dmd_fileindex));
+ break;
+ case DW_MACINFO_end_file:
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ }
+ RCHECK(WRITE_VALUE(0, 1));
+
+ /* Inform application the creation of .debug_macinfo ELF section. */
+ RCHECK(_dwarf_section_callback(dbg, ds, SHT_PROGBITS, 0, 0, 0, error));
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+ _dwarf_section_free(dbg, &ds);
+
+ return (ret);
+}
+
+void
+_dwarf_macinfo_pro_cleanup(Dwarf_P_Debug dbg)
+{
+ Dwarf_Macro_Details *md;
+ int i;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_WRITE);
+ if (dbg->dbgp_mdlist == NULL)
+ return;
+
+ assert(dbg->dbgp_mdcnt > 0);
+ for (i = 0; (Dwarf_Unsigned) i < dbg->dbgp_mdcnt; i++) {
+ md = &dbg->dbgp_mdlist[i];
+ if (md->dmd_macro)
+ free(md->dmd_macro);
+ }
+ free(dbg->dbgp_mdlist);
+ dbg->dbgp_mdlist = NULL;
+ dbg->dbgp_mdcnt = 0;
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_nametbl.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_nametbl.c
new file mode 100644
index 0000000..661b56f
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_nametbl.c
@@ -0,0 +1,253 @@
+/*-
+ * Copyright (c) 2009,2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_nametbl.c 3029 2014-04-21 23:26:02Z kaiwang27 $");
+
+void
+_dwarf_nametbl_cleanup(Dwarf_NameSec *nsp)
+{
+ Dwarf_NameSec ns;
+ Dwarf_NameTbl nt, tnt;
+ Dwarf_NamePair np, tnp;
+
+ assert(nsp != NULL);
+ if ((ns = *nsp) == NULL)
+ return;
+
+ STAILQ_FOREACH_SAFE(nt, &ns->ns_ntlist, nt_next, tnt) {
+ STAILQ_FOREACH_SAFE(np, &nt->nt_nplist, np_next, tnp) {
+ STAILQ_REMOVE(&nt->nt_nplist, np, _Dwarf_NamePair,
+ np_next);
+ free(np);
+ }
+ STAILQ_REMOVE(&ns->ns_ntlist, nt, _Dwarf_NameTbl, nt_next);
+ free(nt);
+ }
+ if (ns->ns_array)
+ free(ns->ns_array);
+ free(ns);
+ *nsp = NULL;
+}
+
+int
+_dwarf_nametbl_init(Dwarf_Debug dbg, Dwarf_NameSec *namesec, Dwarf_Section *ds,
+ Dwarf_Error *error)
+{
+ Dwarf_CU cu;
+ Dwarf_NameSec ns;
+ Dwarf_NameTbl nt;
+ Dwarf_NamePair np;
+ uint64_t offset, dwarf_size, length, cuoff;
+ char *p;
+ int i, ret;
+
+ assert(*namesec == NULL);
+
+ if ((ns = malloc(sizeof(struct _Dwarf_NameSec))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ STAILQ_INIT(&ns->ns_ntlist);
+ ns->ns_array = NULL;
+ ns->ns_len = 0;
+
+ offset = 0;
+ while (offset < ds->ds_size) {
+
+ /* Allocate a new name table. */
+ if ((nt = malloc(sizeof(struct _Dwarf_NameTbl))) == NULL) {
+ ret = DW_DLE_MEMORY;
+ DWARF_SET_ERROR(dbg, error, ret);
+ goto fail_cleanup;
+ }
+ STAILQ_INIT(&nt->nt_nplist);
+ STAILQ_INSERT_TAIL(&ns->ns_ntlist, nt, nt_next);
+
+ /* Read in the table header. */
+ length = dbg->read(ds->ds_data, &offset, 4);
+ if (length == 0xffffffff) {
+ dwarf_size = 8;
+ length = dbg->read(ds->ds_data, &offset, 8);
+ } else
+ dwarf_size = 4;
+
+ nt->nt_length = length;
+ /* FIXME: verify version */
+ nt->nt_version = dbg->read(ds->ds_data, &offset, 2);
+ nt->nt_cu_offset = dbg->read(ds->ds_data, &offset, dwarf_size);
+ nt->nt_cu_length = dbg->read(ds->ds_data, &offset, dwarf_size);
+
+ if (!dbg->dbg_info_loaded) {
+ ret = _dwarf_info_load(dbg, 1, 1, error);
+ if (ret != DW_DLE_NONE)
+ goto fail_cleanup;
+ }
+
+ /* Find the referenced CU. */
+ STAILQ_FOREACH(cu, &dbg->dbg_cu, cu_next) {
+ if (cu->cu_offset == nt->nt_cu_offset)
+ break;
+ }
+ nt->nt_cu = cu; /* FIXME: Check if NULL here */
+
+ /* Add name pairs. */
+ while (offset < ds->ds_size) {
+ cuoff = dbg->read(ds->ds_data, &offset, dwarf_size);
+ if (cuoff == 0)
+ break;
+ if ((np = malloc(sizeof(struct _Dwarf_NamePair))) ==
+ NULL) {
+ ret = DW_DLE_MEMORY;
+ DWARF_SET_ERROR(dbg, error, ret);
+ goto fail_cleanup;
+ }
+ np->np_nt = nt;
+ np->np_offset = cuoff;
+ p = (char *) ds->ds_data;
+ np->np_name = &p[offset];
+ while (p[offset++] != '\0')
+ ;
+ STAILQ_INSERT_TAIL(&nt->nt_nplist, np, np_next);
+ ns->ns_len++;
+ }
+ }
+
+ /* Build array of name pairs from all tables. */
+ if (ns->ns_len > 0) {
+ if ((ns->ns_array = malloc(sizeof(Dwarf_NamePair) *
+ ns->ns_len)) == NULL) {
+ ret = DW_DLE_MEMORY;
+ DWARF_SET_ERROR(dbg, error, ret);
+ goto fail_cleanup;
+ }
+
+ i = 0;
+ STAILQ_FOREACH(nt, &ns->ns_ntlist, nt_next) {
+ STAILQ_FOREACH(np, &nt->nt_nplist, np_next)
+ ns->ns_array[i++] = np;
+ }
+ assert((Dwarf_Unsigned)i == ns->ns_len);
+ }
+
+ *namesec = ns;
+
+ return (DW_DLE_NONE);
+
+fail_cleanup:
+
+ _dwarf_nametbl_cleanup(&ns);
+
+ return (ret);
+}
+
+int
+_dwarf_nametbl_gen(Dwarf_P_Debug dbg, const char *name, Dwarf_NameTbl nt,
+ Dwarf_Error *error)
+{
+ Dwarf_P_Section ds;
+ Dwarf_Rel_Section drs;
+ Dwarf_NamePair np;
+ uint64_t offset;
+ int ret;
+
+ assert(dbg != NULL && name != NULL);
+ if (nt == NULL || STAILQ_EMPTY(&nt->nt_nplist))
+ return (DW_DLE_NONE);
+
+ nt->nt_length = 0;
+ nt->nt_version = 2;
+ nt->nt_cu = STAILQ_FIRST(&dbg->dbg_cu);
+ assert(nt->nt_cu != NULL);
+ nt->nt_cu_offset = nt->nt_cu->cu_offset;
+ nt->nt_cu_length = nt->nt_cu->cu_length;
+
+ /* Create name lookup section. */
+ if ((ret = _dwarf_section_init(dbg, &ds, name, 0, error)) !=
+ DW_DLE_NONE)
+ goto gen_fail0;
+
+ /* Create relocation section for the name lookup section. */
+ RCHECK(_dwarf_reloc_section_init(dbg, &drs, ds, error));
+
+ /* Write table header. */
+ RCHECK(WRITE_VALUE(nt->nt_length, 4));
+ RCHECK(WRITE_VALUE(nt->nt_version, 2));
+ RCHECK(_dwarf_reloc_entry_add(dbg, drs, ds, dwarf_drt_data_reloc, 4,
+ ds->ds_size, 0, nt->nt_cu_offset, ".debug_info", error));
+ RCHECK(WRITE_VALUE(nt->nt_cu_length, 4));
+
+ /* Write tuples. */
+ STAILQ_FOREACH(np, &nt->nt_nplist, np_next) {
+ assert(np->np_die != NULL);
+ np->np_offset = np->np_die->die_offset;
+ RCHECK(WRITE_VALUE(np->np_offset, 4));
+ RCHECK(WRITE_STRING(np->np_name));
+ }
+ RCHECK(WRITE_VALUE(0, 4));
+
+ /* Fill in the length field. */
+ nt->nt_length = ds->ds_size - 4;
+ offset = 0;
+ dbg->write(ds->ds_data, &offset, nt->nt_length, 4);
+
+ /* Inform application the creation of name lookup ELF section. */
+ RCHECK(_dwarf_section_callback(dbg, ds, SHT_PROGBITS, 0, 0, 0, error));
+
+ /* Finalize relocation section for the name lookup section. */
+ RCHECK(_dwarf_reloc_section_finalize(dbg, drs, error));
+
+ return (DW_DLE_NONE);
+
+gen_fail:
+ _dwarf_reloc_section_free(dbg, &drs);
+
+gen_fail0:
+ _dwarf_section_free(dbg, &ds);
+
+ return (ret);
+}
+
+void
+_dwarf_nametbl_pro_cleanup(Dwarf_NameTbl *ntp)
+{
+ Dwarf_NameTbl nt;
+ Dwarf_NamePair np, tnp;
+
+ assert(ntp != NULL);
+ if ((nt = *ntp) == NULL)
+ return;
+
+ STAILQ_FOREACH_SAFE(np, &nt->nt_nplist, np_next, tnp) {
+ STAILQ_REMOVE(&nt->nt_nplist, np, _Dwarf_NamePair, np_next);
+ if (np->np_name)
+ free(np->np_name);
+ free(np);
+ }
+ free(nt);
+ *ntp = NULL;
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_ranges.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_ranges.c
new file mode 100644
index 0000000..3396bb9
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_ranges.c
@@ -0,0 +1,152 @@
+/*-
+ * Copyright (c) 2009 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_ranges.c 2972 2013-12-23 06:46:04Z kaiwang27 $");
+
+static int
+_dwarf_ranges_parse(Dwarf_Debug dbg, Dwarf_CU cu, Dwarf_Section *ds,
+ uint64_t off, Dwarf_Ranges *rg, Dwarf_Unsigned *cnt)
+{
+ Dwarf_Unsigned start, end;
+ int i;
+
+ i = 0;
+ while (off < ds->ds_size) {
+
+ start = dbg->read(ds->ds_data, &off, cu->cu_pointer_size);
+ end = dbg->read(ds->ds_data, &off, cu->cu_pointer_size);
+
+ if (rg != NULL) {
+ rg[i].dwr_addr1 = start;
+ rg[i].dwr_addr2 = end;
+ if (start == 0 && end == 0)
+ rg[i].dwr_type = DW_RANGES_END;
+ else if ((start == ~0U && cu->cu_pointer_size == 4) ||
+ (start == ~0ULL && cu->cu_pointer_size == 8))
+ rg[i].dwr_type = DW_RANGES_ADDRESS_SELECTION;
+ else
+ rg[i].dwr_type = DW_RANGES_ENTRY;
+ }
+
+ i++;
+
+ if (start == 0 && end == 0)
+ break;
+ }
+
+ if (cnt != NULL)
+ *cnt = i;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_ranges_find(Dwarf_Debug dbg, uint64_t off, Dwarf_Rangelist *ret_rl)
+{
+ Dwarf_Rangelist rl;
+
+ STAILQ_FOREACH(rl, &dbg->dbg_rllist, rl_next)
+ if (rl->rl_offset == off)
+ break;
+
+ if (rl == NULL)
+ return (DW_DLE_NO_ENTRY);
+
+ if (ret_rl != NULL)
+ *ret_rl = rl;
+
+ return (DW_DLE_NONE);
+}
+
+void
+_dwarf_ranges_cleanup(Dwarf_Debug dbg)
+{
+ Dwarf_Rangelist rl, trl;
+
+ if (STAILQ_EMPTY(&dbg->dbg_rllist))
+ return;
+
+ STAILQ_FOREACH_SAFE(rl, &dbg->dbg_rllist, rl_next, trl) {
+ STAILQ_REMOVE(&dbg->dbg_rllist, rl, _Dwarf_Rangelist, rl_next);
+ if (rl->rl_rgarray)
+ free(rl->rl_rgarray);
+ free(rl);
+ }
+}
+
+int
+_dwarf_ranges_add(Dwarf_Debug dbg, Dwarf_CU cu, uint64_t off,
+ Dwarf_Rangelist *ret_rl, Dwarf_Error *error)
+{
+ Dwarf_Section *ds;
+ Dwarf_Rangelist rl;
+ Dwarf_Unsigned cnt;
+ int ret;
+
+ if ((ds = _dwarf_find_section(dbg, ".debug_ranges")) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
+ return (DW_DLE_NO_ENTRY);
+ }
+
+ if ((rl = malloc(sizeof(struct _Dwarf_Rangelist))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ rl->rl_offset = off;
+
+ ret = _dwarf_ranges_parse(dbg, cu, ds, off, NULL, &cnt);
+ if (ret != DW_DLE_NONE) {
+ free(rl);
+ return (ret);
+ }
+
+ rl->rl_rglen = cnt;
+ if (cnt != 0) {
+ if ((rl->rl_rgarray = calloc(cnt, sizeof(Dwarf_Ranges))) ==
+ NULL) {
+ free(rl);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ ret = _dwarf_ranges_parse(dbg, cu, ds, off, rl->rl_rgarray,
+ NULL);
+ if (ret != DW_DLE_NONE) {
+ free(rl->rl_rgarray);
+ free(rl);
+ return (ret);
+ }
+ } else
+ rl->rl_rgarray = NULL;
+
+ STAILQ_INSERT_TAIL(&dbg->dbg_rllist, rl, rl_next);
+ *ret_rl = rl;
+
+ return (DW_DLE_NONE);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_reloc.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_reloc.c
new file mode 100644
index 0000000..2b1ad72
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_reloc.c
@@ -0,0 +1,493 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_reloc.c 3578 2017-09-14 02:21:28Z emaste $");
+
+Dwarf_Unsigned
+_dwarf_get_reloc_type(Dwarf_P_Debug dbg, int is64)
+{
+
+ assert(dbg != NULL);
+
+ switch (dbg->dbgp_isa) {
+ case DW_ISA_AARCH64:
+ return (is64 ? R_AARCH64_ABS64 : R_AARCH64_ABS32);
+ case DW_ISA_X86:
+ return (R_386_32);
+ case DW_ISA_X86_64:
+ return (is64 ? R_X86_64_64 : R_X86_64_32);
+ case DW_ISA_SPARC:
+ return (is64 ? R_SPARC_UA64 : R_SPARC_UA32);
+ case DW_ISA_PPC:
+ return (R_PPC_ADDR32);
+ case DW_ISA_ARM:
+ return (R_ARM_ABS32);
+ case DW_ISA_MIPS:
+ return (is64 ? R_MIPS_64 : R_MIPS_32);
+ case DW_ISA_RISCV:
+ return (is64 ? R_RISCV_64 : R_RISCV_32);
+ case DW_ISA_IA64:
+ return (is64 ? R_IA_64_DIR64LSB : R_IA_64_DIR32LSB);
+ default:
+ break;
+ }
+ return (0); /* NOT REACHED */
+}
+
+int
+_dwarf_get_reloc_size(Dwarf_Debug dbg, Dwarf_Unsigned rel_type)
+{
+
+ switch (dbg->dbg_machine) {
+ case EM_NONE:
+ break;
+ case EM_AARCH64:
+ if (rel_type == R_AARCH64_ABS32)
+ return (4);
+ else if (rel_type == R_AARCH64_ABS64)
+ return (8);
+ break;
+ case EM_ARM:
+ if (rel_type == R_ARM_ABS32)
+ return (4);
+ break;
+ case EM_386:
+ case EM_IAMCU:
+ if (rel_type == R_386_32)
+ return (4);
+ break;
+ case EM_X86_64:
+ if (rel_type == R_X86_64_32)
+ return (4);
+ else if (rel_type == R_X86_64_64)
+ return (8);
+ break;
+ case EM_SPARC:
+ if (rel_type == R_SPARC_UA32)
+ return (4);
+ else if (rel_type == R_SPARC_UA64)
+ return (8);
+ break;
+ case EM_PPC:
+ if (rel_type == R_PPC_ADDR32)
+ return (4);
+ break;
+ case EM_MIPS:
+ if (rel_type == R_MIPS_32)
+ return (4);
+ else if (rel_type == R_MIPS_64)
+ return (8);
+ break;
+ case EM_RISCV:
+ if (rel_type == R_RISCV_32)
+ return (4);
+ else if (rel_type == R_RISCV_64)
+ return (8);
+ break;
+ case EM_IA_64:
+ if (rel_type == R_IA_64_SECREL32LSB)
+ return (4);
+ else if (rel_type == R_IA_64_DIR64LSB)
+ return (8);
+ break;
+ default:
+ break;
+ }
+
+ /* unknown relocation. */
+ return (0);
+}
+
+int
+_dwarf_reloc_section_init(Dwarf_P_Debug dbg, Dwarf_Rel_Section *drsp,
+ Dwarf_P_Section ref, Dwarf_Error *error)
+{
+ Dwarf_Rel_Section drs;
+ char name[128];
+ int pseudo;
+
+ assert(dbg != NULL && drsp != NULL && ref != NULL);
+
+ if ((drs = calloc(1, sizeof(struct _Dwarf_Rel_Section))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ drs->drs_ref = ref;
+
+ /*
+ * FIXME The logic here is most likely wrong. It should
+ * be the ISA that determines relocation type.
+ */
+ if (dbg->dbgp_flags & DW_DLC_SIZE_64)
+ drs->drs_addend = 1;
+ else
+ drs->drs_addend = 0;
+
+ if (dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS)
+ pseudo = 1;
+ else
+ pseudo = 0;
+
+ snprintf(name, sizeof(name), "%s%s",
+ drs->drs_addend ? ".rela" : ".rel", ref->ds_name);
+ if (_dwarf_section_init(dbg, &drs->drs_ds, name, pseudo, error) !=
+ DW_DLE_NONE) {
+ free(drs);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ STAILQ_INIT(&drs->drs_dre);
+ STAILQ_INSERT_TAIL(&dbg->dbgp_drslist, drs, drs_next);
+ dbg->dbgp_drscnt++;
+ *drsp = drs;
+
+ return (DW_DLE_NONE);
+}
+
+void
+_dwarf_reloc_section_free(Dwarf_P_Debug dbg, Dwarf_Rel_Section *drsp)
+{
+ Dwarf_Rel_Section drs, tdrs;
+ Dwarf_Rel_Entry dre, tdre;
+
+ assert(dbg != NULL && drsp != NULL);
+
+ if (*drsp == NULL)
+ return;
+
+ STAILQ_FOREACH_SAFE(drs, &dbg->dbgp_drslist, drs_next, tdrs) {
+ if (drs != *drsp)
+ continue;
+ STAILQ_REMOVE(&dbg->dbgp_drslist, drs, _Dwarf_Rel_Section,
+ drs_next);
+ STAILQ_FOREACH_SAFE(dre, &drs->drs_dre, dre_next, tdre) {
+ STAILQ_REMOVE(&drs->drs_dre, dre, _Dwarf_Rel_Entry,
+ dre_next);
+ free(dre);
+ }
+ if ((dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS) == 0)
+ _dwarf_section_free(dbg, &drs->drs_ds);
+ else {
+ if (drs->drs_ds->ds_name)
+ free(drs->drs_ds->ds_name);
+ free(drs->drs_ds);
+ }
+ free(drs);
+ *drsp = NULL;
+ dbg->dbgp_drscnt--;
+ break;
+ }
+}
+
+int
+_dwarf_reloc_entry_add(Dwarf_P_Debug dbg, Dwarf_Rel_Section drs,
+ Dwarf_P_Section ds, unsigned char type, unsigned char length,
+ Dwarf_Unsigned offset, Dwarf_Unsigned symndx, Dwarf_Unsigned addend,
+ const char *secname, Dwarf_Error *error)
+{
+ Dwarf_Rel_Entry dre;
+ Dwarf_Unsigned reloff;
+ int ret;
+
+ assert(drs != NULL);
+ assert(offset <= ds->ds_size);
+ reloff = offset;
+
+ /*
+ * If the DW_DLC_SYMBOLIC_RELOCATIONS flag is set or ElfXX_Rel
+ * is used instead of ELfXX_Rela, we need to write the addend
+ * in the storage unit to be relocated. Otherwise write 0 in the
+ * storage unit and the addend will be written into relocation
+ * section later.
+ */
+ if ((dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS) ||
+ drs->drs_addend == 0)
+ ret = dbg->write_alloc(&ds->ds_data, &ds->ds_cap, &offset,
+ addend, length, error);
+ else
+ ret = dbg->write_alloc(&ds->ds_data, &ds->ds_cap, &offset,
+ 0, length, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ if (offset > ds->ds_size)
+ ds->ds_size = offset;
+
+ if ((dre = calloc(1, sizeof(struct _Dwarf_Rel_Entry))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ STAILQ_INSERT_TAIL(&drs->drs_dre, dre, dre_next);
+ dre->dre_type = type;
+ dre->dre_length = length;
+ dre->dre_offset = reloff;
+ dre->dre_symndx = symndx;
+ dre->dre_addend = addend;
+ dre->dre_secname = secname;
+ drs->drs_drecnt++;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_reloc_entry_add_pair(Dwarf_P_Debug dbg, Dwarf_Rel_Section drs,
+ Dwarf_P_Section ds, unsigned char length, Dwarf_Unsigned offset,
+ Dwarf_Unsigned symndx, Dwarf_Unsigned esymndx, Dwarf_Unsigned symoff,
+ Dwarf_Unsigned esymoff, Dwarf_Error *error)
+{
+ Dwarf_Rel_Entry dre;
+ Dwarf_Unsigned reloff;
+ int ret;
+
+ assert(drs != NULL);
+ assert(offset <= ds->ds_size);
+ assert(dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS);
+ reloff = offset;
+
+ /* Write net offset into section stream. */
+ ret = dbg->write_alloc(&ds->ds_data, &ds->ds_cap, &offset,
+ esymoff - symoff, length, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ if (offset > ds->ds_size)
+ ds->ds_size = offset;
+
+ if ((dre = calloc(2, sizeof(struct _Dwarf_Rel_Entry))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ STAILQ_INSERT_TAIL(&drs->drs_dre, &dre[0], dre_next);
+ STAILQ_INSERT_TAIL(&drs->drs_dre, &dre[1], dre_next);
+ dre[0].dre_type = dwarf_drt_first_of_length_pair;
+ dre[0].dre_length = length;
+ dre[0].dre_offset = reloff;
+ dre[0].dre_symndx = symndx;
+ dre[0].dre_addend = 0;
+ dre[0].dre_secname = NULL;
+ dre[1].dre_type = dwarf_drt_second_of_length_pair;
+ dre[1].dre_length = length;
+ dre[1].dre_offset = reloff;
+ dre[1].dre_symndx = esymndx;
+ dre[1].dre_addend = 0;
+ dre[1].dre_secname = NULL;
+ drs->drs_drecnt += 2;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_reloc_section_finalize(Dwarf_P_Debug dbg, Dwarf_Rel_Section drs,
+ Dwarf_Error *error)
+{
+ Dwarf_P_Section ds;
+ Dwarf_Unsigned unit;
+ int ret, size;
+
+ assert(dbg != NULL && drs != NULL && drs->drs_ds != NULL &&
+ drs->drs_ref != NULL);
+
+ ds = drs->drs_ds;
+
+ /*
+ * Calculate the size (in bytes) of the relocation section.
+ */
+ if (dbg->dbgp_flags & DW_DLC_SIZE_64)
+ unit = drs->drs_addend ? sizeof(Elf64_Rela) : sizeof(Elf64_Rel);
+ else
+ unit = drs->drs_addend ? sizeof(Elf32_Rela) : sizeof(Elf32_Rel);
+ assert(ds->ds_size == 0);
+ size = drs->drs_drecnt * unit;
+
+ /*
+ * Discard this relocation section if there is no entry in it.
+ */
+ if (size == 0) {
+ _dwarf_reloc_section_free(dbg, &drs);
+ return (DW_DLE_NONE);
+ }
+
+ /*
+ * If we are under stream mode, realloc the section data block to
+ * this size.
+ */
+ if ((dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS) == 0) {
+ ds->ds_cap = size;
+ if ((ds->ds_data = realloc(ds->ds_data, (size_t) ds->ds_cap)) ==
+ NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ }
+
+ /*
+ * Notify the application the creation of this relocation section.
+ * Note that the section link here should point to the .symtab
+ * section, we set it to 0 since we have no way to know .symtab
+ * section index.
+ */
+ ret = _dwarf_pro_callback(dbg, ds->ds_name, size,
+ drs->drs_addend ? SHT_RELA : SHT_REL, 0, 0, drs->drs_ref->ds_ndx,
+ &ds->ds_symndx, NULL);
+ if (ret < 0) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_ELF_SECT_ERR);
+ return (DW_DLE_ELF_SECT_ERR);
+ }
+ ds->ds_ndx = ret;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_reloc_section_gen(Dwarf_P_Debug dbg, Dwarf_Rel_Section drs,
+ Dwarf_Error *error)
+{
+ Dwarf_Rel_Entry dre;
+ Dwarf_P_Section ds;
+ Dwarf_Unsigned type;
+ int ret;
+
+ assert((dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS) == 0);
+ assert(drs->drs_ds != NULL && drs->drs_ds->ds_size == 0);
+ assert(!STAILQ_EMPTY(&drs->drs_dre));
+ ds = drs->drs_ds;
+
+ STAILQ_FOREACH(dre, &drs->drs_dre, dre_next) {
+ assert(dre->dre_length == 4 || dre->dre_length == 8);
+ type = _dwarf_get_reloc_type(dbg, dre->dre_length == 8);
+ if (dbg->dbgp_flags & DW_DLC_SIZE_64) {
+ /* Write r_offset (8 bytes) */
+ ret = dbg->write_alloc(&ds->ds_data, &ds->ds_cap,
+ &ds->ds_size, dre->dre_offset, 8, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ /* Write r_info (8 bytes) */
+ ret = dbg->write_alloc(&ds->ds_data, &ds->ds_cap,
+ &ds->ds_size, ELF64_R_INFO(dre->dre_symndx, type),
+ 8, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ /* Write r_addend (8 bytes) */
+ if (drs->drs_addend) {
+ ret = dbg->write_alloc(&ds->ds_data,
+ &ds->ds_cap, &ds->ds_size, dre->dre_addend,
+ 8, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+ } else {
+ /* Write r_offset (4 bytes) */
+ ret = dbg->write_alloc(&ds->ds_data, &ds->ds_cap,
+ &ds->ds_size, dre->dre_offset, 4, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ /* Write r_info (4 bytes) */
+ ret = dbg->write_alloc(&ds->ds_data, &ds->ds_cap,
+ &ds->ds_size, ELF32_R_INFO(dre->dre_symndx, type),
+ 4, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ /* Write r_addend (4 bytes) */
+ if (drs->drs_addend) {
+ ret = dbg->write_alloc(&ds->ds_data,
+ &ds->ds_cap, &ds->ds_size, dre->dre_addend,
+ 4, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+ }
+ }
+ assert(ds->ds_size == ds->ds_cap);
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_reloc_gen(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_Rel_Section drs;
+ Dwarf_Rel_Entry dre;
+ Dwarf_P_Section ds;
+ int ret;
+
+ STAILQ_FOREACH(drs, &dbg->dbgp_drslist, drs_next) {
+ /*
+ * Update relocation entries: translate any section name
+ * reference to section symbol index.
+ */
+ STAILQ_FOREACH(dre, &drs->drs_dre, dre_next) {
+ if (dre->dre_secname == NULL)
+ continue;
+ ds = _dwarf_pro_find_section(dbg, dre->dre_secname);
+ assert(ds != NULL && ds->ds_symndx != 0);
+ dre->dre_symndx = ds->ds_symndx;
+ }
+
+ /*
+ * Generate ELF relocation section if we are under stream
+ * mode.
+ */
+ if ((dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS) == 0) {
+ ret = _dwarf_reloc_section_gen(dbg, drs, error);
+ if (ret != DW_DLE_NONE)
+ return (ret);
+ }
+ }
+
+ return (DW_DLE_NONE);
+}
+
+void
+_dwarf_reloc_cleanup(Dwarf_P_Debug dbg)
+{
+ Dwarf_Rel_Section drs, tdrs;
+ Dwarf_Rel_Entry dre, tdre;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_WRITE);
+
+ STAILQ_FOREACH_SAFE(drs, &dbg->dbgp_drslist, drs_next, tdrs) {
+ STAILQ_REMOVE(&dbg->dbgp_drslist, drs, _Dwarf_Rel_Section,
+ drs_next);
+ free(drs->drs_drd);
+ STAILQ_FOREACH_SAFE(dre, &drs->drs_dre, dre_next, tdre) {
+ STAILQ_REMOVE(&drs->drs_dre, dre, _Dwarf_Rel_Entry,
+ dre_next);
+ free(dre);
+ }
+ if (dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS) {
+ if (drs->drs_ds) {
+ if (drs->drs_ds->ds_name)
+ free(drs->drs_ds->ds_name);
+ free(drs->drs_ds);
+ }
+ }
+ free(drs);
+ }
+ dbg->dbgp_drscnt = 0;
+ dbg->dbgp_drspos = NULL;
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_rw.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_rw.c
new file mode 100644
index 0000000..f0286d5
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_rw.c
@@ -0,0 +1,574 @@
+/*-
+ * Copyright (c) 2007 John Birrell (jb@freebsd.org)
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_rw.c 3286 2015-12-31 16:45:46Z emaste $");
+
+uint64_t
+_dwarf_read_lsb(uint8_t *data, uint64_t *offsetp, int bytes_to_read)
+{
+ uint64_t ret;
+ uint8_t *src;
+
+ src = data + *offsetp;
+
+ ret = 0;
+ switch (bytes_to_read) {
+ case 8:
+ ret |= ((uint64_t) src[4]) << 32 | ((uint64_t) src[5]) << 40;
+ ret |= ((uint64_t) src[6]) << 48 | ((uint64_t) src[7]) << 56;
+ /* FALLTHROUGH */
+ case 4:
+ ret |= ((uint64_t) src[2]) << 16 | ((uint64_t) src[3]) << 24;
+ /* FALLTHROUGH */
+ case 2:
+ ret |= ((uint64_t) src[1]) << 8;
+ /* FALLTHROUGH */
+ case 1:
+ ret |= src[0];
+ break;
+ default:
+ return (0);
+ }
+
+ *offsetp += bytes_to_read;
+
+ return (ret);
+}
+
+uint64_t
+_dwarf_decode_lsb(uint8_t **data, int bytes_to_read)
+{
+ uint64_t ret;
+ uint8_t *src;
+
+ src = *data;
+
+ ret = 0;
+ switch (bytes_to_read) {
+ case 8:
+ ret |= ((uint64_t) src[4]) << 32 | ((uint64_t) src[5]) << 40;
+ ret |= ((uint64_t) src[6]) << 48 | ((uint64_t) src[7]) << 56;
+ /* FALLTHROUGH */
+ case 4:
+ ret |= ((uint64_t) src[2]) << 16 | ((uint64_t) src[3]) << 24;
+ /* FALLTHROUGH */
+ case 2:
+ ret |= ((uint64_t) src[1]) << 8;
+ /* FALLTHROUGH */
+ case 1:
+ ret |= src[0];
+ break;
+ default:
+ return (0);
+ }
+
+ *data += bytes_to_read;
+
+ return (ret);
+}
+
+uint64_t
+_dwarf_read_msb(uint8_t *data, uint64_t *offsetp, int bytes_to_read)
+{
+ uint64_t ret;
+ uint8_t *src;
+
+ src = data + *offsetp;
+
+ switch (bytes_to_read) {
+ case 1:
+ ret = src[0];
+ break;
+ case 2:
+ ret = src[1] | ((uint64_t) src[0]) << 8;
+ break;
+ case 4:
+ ret = src[3] | ((uint64_t) src[2]) << 8;
+ ret |= ((uint64_t) src[1]) << 16 | ((uint64_t) src[0]) << 24;
+ break;
+ case 8:
+ ret = src[7] | ((uint64_t) src[6]) << 8;
+ ret |= ((uint64_t) src[5]) << 16 | ((uint64_t) src[4]) << 24;
+ ret |= ((uint64_t) src[3]) << 32 | ((uint64_t) src[2]) << 40;
+ ret |= ((uint64_t) src[1]) << 48 | ((uint64_t) src[0]) << 56;
+ break;
+ default:
+ return (0);
+ }
+
+ *offsetp += bytes_to_read;
+
+ return (ret);
+}
+
+uint64_t
+_dwarf_decode_msb(uint8_t **data, int bytes_to_read)
+{
+ uint64_t ret;
+ uint8_t *src;
+
+ src = *data;
+
+ ret = 0;
+ switch (bytes_to_read) {
+ case 1:
+ ret = src[0];
+ break;
+ case 2:
+ ret = src[1] | ((uint64_t) src[0]) << 8;
+ break;
+ case 4:
+ ret = src[3] | ((uint64_t) src[2]) << 8;
+ ret |= ((uint64_t) src[1]) << 16 | ((uint64_t) src[0]) << 24;
+ break;
+ case 8:
+ ret = src[7] | ((uint64_t) src[6]) << 8;
+ ret |= ((uint64_t) src[5]) << 16 | ((uint64_t) src[4]) << 24;
+ ret |= ((uint64_t) src[3]) << 32 | ((uint64_t) src[2]) << 40;
+ ret |= ((uint64_t) src[1]) << 48 | ((uint64_t) src[0]) << 56;
+ break;
+ default:
+ return (0);
+ break;
+ }
+
+ *data += bytes_to_read;
+
+ return (ret);
+}
+
+void
+_dwarf_write_lsb(uint8_t *data, uint64_t *offsetp, uint64_t value,
+ int bytes_to_write)
+{
+ uint8_t *dst;
+
+ dst = data + *offsetp;
+
+ switch (bytes_to_write) {
+ case 8:
+ dst[7] = (value >> 56) & 0xff;
+ dst[6] = (value >> 48) & 0xff;
+ dst[5] = (value >> 40) & 0xff;
+ dst[4] = (value >> 32) & 0xff;
+ /* FALLTHROUGH */
+ case 4:
+ dst[3] = (value >> 24) & 0xff;
+ dst[2] = (value >> 16) & 0xff;
+ /* FALLTHROUGH */
+ case 2:
+ dst[1] = (value >> 8) & 0xff;
+ /* FALLTHROUGH */
+ case 1:
+ dst[0] = value & 0xff;
+ break;
+ default:
+ return;
+ }
+
+ *offsetp += bytes_to_write;
+}
+
+int
+_dwarf_write_lsb_alloc(uint8_t **block, uint64_t *size, uint64_t *offsetp,
+ uint64_t value, int bytes_to_write, Dwarf_Error *error)
+{
+
+ assert(*size > 0);
+
+ while (*offsetp + bytes_to_write > *size) {
+ *size *= 2;
+ *block = realloc(*block, (size_t) *size);
+ if (*block == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ }
+
+ _dwarf_write_lsb(*block, offsetp, value, bytes_to_write);
+
+ return (DW_DLE_NONE);
+}
+
+void
+_dwarf_write_msb(uint8_t *data, uint64_t *offsetp, uint64_t value,
+ int bytes_to_write)
+{
+ uint8_t *dst;
+
+ dst = data + *offsetp;
+
+ switch (bytes_to_write) {
+ case 8:
+ dst[7] = value & 0xff;
+ dst[6] = (value >> 8) & 0xff;
+ dst[5] = (value >> 16) & 0xff;
+ dst[4] = (value >> 24) & 0xff;
+ value >>= 32;
+ /* FALLTHROUGH */
+ case 4:
+ dst[3] = value & 0xff;
+ dst[2] = (value >> 8) & 0xff;
+ value >>= 16;
+ /* FALLTHROUGH */
+ case 2:
+ dst[1] = value & 0xff;
+ value >>= 8;
+ /* FALLTHROUGH */
+ case 1:
+ dst[0] = value & 0xff;
+ break;
+ default:
+ return;
+ }
+
+ *offsetp += bytes_to_write;
+}
+
+int
+_dwarf_write_msb_alloc(uint8_t **block, uint64_t *size, uint64_t *offsetp,
+ uint64_t value, int bytes_to_write, Dwarf_Error *error)
+{
+
+ assert(*size > 0);
+
+ while (*offsetp + bytes_to_write > *size) {
+ *size *= 2;
+ *block = realloc(*block, (size_t) *size);
+ if (*block == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ }
+
+ _dwarf_write_msb(*block, offsetp, value, bytes_to_write);
+
+ return (DW_DLE_NONE);
+}
+
+int64_t
+_dwarf_read_sleb128(uint8_t *data, uint64_t *offsetp)
+{
+ int64_t ret = 0;
+ uint8_t b;
+ int shift = 0;
+ uint8_t *src;
+
+ src = data + *offsetp;
+
+ do {
+ b = *src++;
+ ret |= ((b & 0x7f) << shift);
+ (*offsetp)++;
+ shift += 7;
+ } while ((b & 0x80) != 0);
+
+ if (shift < 64 && (b & 0x40) != 0)
+ ret |= (-1 << shift);
+
+ return (ret);
+}
+
+int
+_dwarf_write_sleb128(uint8_t *data, uint8_t *end, int64_t val)
+{
+ uint8_t *p;
+
+ p = data;
+
+ for (;;) {
+ if (p >= end)
+ return (-1);
+ *p = val & 0x7f;
+ val >>= 7;
+ if ((val == 0 && (*p & 0x40) == 0) ||
+ (val == -1 && (*p & 0x40) != 0)) {
+ p++;
+ break;
+ }
+ *p++ |= 0x80;
+ }
+
+ return (p - data);
+}
+
+int
+_dwarf_write_sleb128_alloc(uint8_t **block, uint64_t *size, uint64_t *offsetp,
+ int64_t val, Dwarf_Error *error)
+{
+ int len;
+
+ assert(*size > 0);
+
+ while ((len = _dwarf_write_sleb128(*block + *offsetp, *block + *size,
+ val)) < 0) {
+ *size *= 2;
+ *block = realloc(*block, (size_t) *size);
+ if (*block == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ }
+
+ *offsetp += len;
+
+ return (DW_DLE_NONE);
+}
+
+uint64_t
+_dwarf_read_uleb128(uint8_t *data, uint64_t *offsetp)
+{
+ uint64_t ret = 0;
+ uint8_t b;
+ int shift = 0;
+ uint8_t *src;
+
+ src = data + *offsetp;
+
+ do {
+ b = *src++;
+ ret |= ((b & 0x7f) << shift);
+ (*offsetp)++;
+ shift += 7;
+ } while ((b & 0x80) != 0);
+
+ return (ret);
+}
+
+int
+_dwarf_write_uleb128(uint8_t *data, uint8_t *end, uint64_t val)
+{
+ uint8_t *p;
+
+ p = data;
+
+ do {
+ if (p >= end)
+ return (-1);
+ *p = val & 0x7f;
+ val >>= 7;
+ if (val > 0)
+ *p |= 0x80;
+ p++;
+ } while (val > 0);
+
+ return (p - data);
+}
+
+int
+_dwarf_write_uleb128_alloc(uint8_t **block, uint64_t *size, uint64_t *offsetp,
+ uint64_t val, Dwarf_Error *error)
+{
+ int len;
+
+ assert(*size > 0);
+
+ while ((len = _dwarf_write_uleb128(*block + *offsetp, *block + *size,
+ val)) < 0) {
+ *size *= 2;
+ *block = realloc(*block, (size_t) *size);
+ if (*block == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ }
+
+ *offsetp += len;
+
+ return (DW_DLE_NONE);
+}
+
+int64_t
+_dwarf_decode_sleb128(uint8_t **dp)
+{
+ int64_t ret = 0;
+ uint8_t b;
+ int shift = 0;
+
+ uint8_t *src = *dp;
+
+ do {
+ b = *src++;
+ ret |= ((b & 0x7f) << shift);
+ shift += 7;
+ } while ((b & 0x80) != 0);
+
+ if (shift < 64 && (b & 0x40) != 0)
+ ret |= (-1 << shift);
+
+ *dp = src;
+
+ return (ret);
+}
+
+uint64_t
+_dwarf_decode_uleb128(uint8_t **dp)
+{
+ uint64_t ret = 0;
+ uint8_t b;
+ int shift = 0;
+
+ uint8_t *src = *dp;
+
+ do {
+ b = *src++;
+ ret |= ((b & 0x7f) << shift);
+ shift += 7;
+ } while ((b & 0x80) != 0);
+
+ *dp = src;
+
+ return (ret);
+}
+
+char *
+_dwarf_read_string(void *data, Dwarf_Unsigned size, uint64_t *offsetp)
+{
+ char *ret, *src;
+
+ ret = src = (char *) data + *offsetp;
+
+ while (*src != '\0' && *offsetp < size) {
+ src++;
+ (*offsetp)++;
+ }
+
+ if (*src == '\0' && *offsetp < size)
+ (*offsetp)++;
+
+ return (ret);
+}
+
+void
+_dwarf_write_string(void *data, uint64_t *offsetp, char *string)
+{
+ char *dst;
+
+ dst = (char *) data + *offsetp;
+ strcpy(dst, string);
+ (*offsetp) += strlen(string) + 1;
+}
+
+int
+_dwarf_write_string_alloc(uint8_t **block, uint64_t *size, uint64_t *offsetp,
+ char *string, Dwarf_Error *error)
+{
+ size_t len;
+
+ assert(*size > 0);
+
+ len = strlen(string) + 1;
+ while (*offsetp + len > *size) {
+ *size *= 2;
+ *block = realloc(*block, (size_t) *size);
+ if (*block == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ }
+
+ _dwarf_write_string(*block, offsetp, string);
+
+ return (DW_DLE_NONE);
+}
+
+uint8_t *
+_dwarf_read_block(void *data, uint64_t *offsetp, uint64_t length)
+{
+ uint8_t *ret, *src;
+
+ ret = src = (uint8_t *) data + *offsetp;
+
+ (*offsetp) += length;
+
+ return (ret);
+}
+
+void
+_dwarf_write_block(void *data, uint64_t *offsetp, uint8_t *blk,
+ uint64_t length)
+{
+ uint8_t *dst;
+
+ dst = (uint8_t *) data + *offsetp;
+ memcpy(dst, blk, length);
+ (*offsetp) += length;
+}
+
+int
+_dwarf_write_block_alloc(uint8_t **block, uint64_t *size, uint64_t *offsetp,
+ uint8_t *blk, uint64_t length, Dwarf_Error *error)
+{
+
+ assert(*size > 0);
+
+ while (*offsetp + length > *size) {
+ *size *= 2;
+ *block = realloc(*block, (size_t) *size);
+ if (*block == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ }
+
+ _dwarf_write_block(*block, offsetp, blk, length);
+
+ return (DW_DLE_NONE);
+}
+
+void
+_dwarf_write_padding(void *data, uint64_t *offsetp, uint8_t byte,
+ uint64_t length)
+{
+ uint8_t *dst;
+
+ dst = (uint8_t *) data + *offsetp;
+ memset(dst, byte, length);
+ (*offsetp) += length;
+}
+
+int
+_dwarf_write_padding_alloc(uint8_t **block, uint64_t *size, uint64_t *offsetp,
+ uint8_t byte, uint64_t cnt, Dwarf_Error *error)
+{
+ assert(*size > 0);
+
+ while (*offsetp + cnt > *size) {
+ *size *= 2;
+ *block = realloc(*block, (size_t) *size);
+ if (*block == NULL) {
+ DWARF_SET_ERROR(NULL, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ }
+
+ _dwarf_write_padding(*block, offsetp, byte, cnt);
+
+ return (DW_DLE_NONE);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_sections.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_sections.c
new file mode 100644
index 0000000..24d5db8
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_sections.c
@@ -0,0 +1,280 @@
+/*-
+ * Copyright (c) 2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_sections.c 3041 2014-05-18 15:11:03Z kaiwang27 $");
+
+#define _SECTION_INIT_SIZE 128
+
+int
+_dwarf_section_init(Dwarf_P_Debug dbg, Dwarf_P_Section *dsp, const char *name,
+ int pseudo, Dwarf_Error *error)
+{
+ Dwarf_P_Section ds;
+
+ assert(dbg != NULL && dsp != NULL && name != NULL);
+
+ if ((ds = calloc(1, sizeof(struct _Dwarf_P_Section))) == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ if ((ds->ds_name = strdup(name)) == NULL) {
+ free(ds);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ if (!pseudo) {
+ ds->ds_cap = _SECTION_INIT_SIZE;
+ if ((ds->ds_data = malloc((size_t) ds->ds_cap)) == NULL) {
+ free(ds->ds_name);
+ free(ds);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ STAILQ_INSERT_TAIL(&dbg->dbgp_seclist, ds, ds_next);
+ dbg->dbgp_seccnt++;
+ }
+
+ *dsp = ds;
+
+ return (DW_DLE_NONE);
+}
+
+void
+_dwarf_section_free(Dwarf_P_Debug dbg, Dwarf_P_Section *dsp)
+{
+ Dwarf_P_Section ds, tds;
+
+ assert(dbg != NULL && dsp != NULL);
+
+ if (*dsp == NULL)
+ return;
+
+ STAILQ_FOREACH_SAFE(ds, &dbg->dbgp_seclist, ds_next, tds) {
+ if (ds == *dsp) {
+ STAILQ_REMOVE(&dbg->dbgp_seclist, ds, _Dwarf_P_Section,
+ ds_next);
+ dbg->dbgp_seccnt--;
+ break;
+ }
+ }
+ ds = *dsp;
+ if (ds->ds_name)
+ free(ds->ds_name);
+ if (ds->ds_data)
+ free(ds->ds_data);
+ free(ds);
+ *dsp = NULL;
+}
+
+int
+_dwarf_pro_callback(Dwarf_P_Debug dbg, char *name, int size,
+ Dwarf_Unsigned type, Dwarf_Unsigned flags, Dwarf_Unsigned link,
+ Dwarf_Unsigned info, Dwarf_Unsigned *symndx, int *error)
+{
+ int e, ret, isymndx;
+
+ assert(dbg != NULL && name != NULL && symndx != NULL);
+
+ if (dbg->dbgp_func_b)
+ ret = dbg->dbgp_func_b(name, size, type, flags, link, info,
+ symndx, &e);
+ else {
+ ret = dbg->dbgp_func(name, size, type, flags, link, info,
+ &isymndx, &e);
+ *symndx = isymndx;
+ }
+ if (ret < 0) {
+ if (error)
+ *error = e;
+ }
+
+ return (ret);
+}
+
+int
+_dwarf_section_callback(Dwarf_P_Debug dbg, Dwarf_P_Section ds,
+ Dwarf_Unsigned type, Dwarf_Unsigned flags, Dwarf_Unsigned link,
+ Dwarf_Unsigned info, Dwarf_Error *error)
+{
+ int ret, ndx;
+
+ ndx = _dwarf_pro_callback(dbg, ds->ds_name, (int) ds->ds_size,
+ type, flags, link, info, &ds->ds_symndx, NULL);
+ if (ndx < 0) {
+ ret = DW_DLE_ELF_SECT_ERR;
+ DWARF_SET_ERROR(dbg, error, ret);
+ return (ret);
+ }
+ ds->ds_ndx = ndx;
+
+ return (DW_DLE_NONE);
+}
+
+int
+_dwarf_generate_sections(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+ int ret;
+
+ /* Produce .debug_info section. */
+ if ((ret = _dwarf_info_gen(dbg, error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Produce .debug_abbrev section. */
+ if ((ret = _dwarf_abbrev_gen(dbg, error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Produce .debug_line section. */
+ if ((ret = _dwarf_lineno_gen(dbg, error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Produce .debug_frame section. */
+ if ((ret = _dwarf_frame_gen(dbg, error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Produce .debug_aranges section. */
+ if ((ret = _dwarf_arange_gen(dbg, error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Produce .debug_macinfo section. */
+ if ((ret = _dwarf_macinfo_gen(dbg, error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Produce .debug_pubnames section. */
+ if ((ret = _dwarf_nametbl_gen(dbg, ".debug_pubnames", dbg->dbgp_pubs,
+ error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Produce .debug_weaknames section. */
+ if ((ret = _dwarf_nametbl_gen(dbg, ".debug_weaknames", dbg->dbgp_weaks,
+ error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Produce .debug_funcnames section. */
+ if ((ret = _dwarf_nametbl_gen(dbg, ".debug_funcnames", dbg->dbgp_funcs,
+ error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Produce .debug_typenames section. */
+ if ((ret = _dwarf_nametbl_gen(dbg, ".debug_typenames", dbg->dbgp_types,
+ error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Produce .debug_varnames section. */
+ if ((ret = _dwarf_nametbl_gen(dbg, ".debug_varnames", dbg->dbgp_vars,
+ error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Produce .debug_str section. */
+ if ((ret = _dwarf_strtab_gen(dbg, error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Finally, update and generate all relocation sections. */
+ if ((ret = _dwarf_reloc_gen(dbg, error)) != DW_DLE_NONE)
+ return (ret);
+
+ /* Set section/relocation iterator to the first element. */
+ dbg->dbgp_secpos = STAILQ_FIRST(&dbg->dbgp_seclist);
+ dbg->dbgp_drspos = STAILQ_FIRST(&dbg->dbgp_drslist);
+
+ return (DW_DLE_NONE);
+}
+
+Dwarf_Section *
+_dwarf_find_section(Dwarf_Debug dbg, const char *name)
+{
+ Dwarf_Section *ds;
+ Dwarf_Half i;
+
+ assert(dbg != NULL && name != NULL);
+
+ for (i = 0; i < dbg->dbg_seccnt; i++) {
+ ds = &dbg->dbg_section[i];
+ if (ds->ds_name != NULL && !strcmp(ds->ds_name, name))
+ return (ds);
+ }
+
+ return (NULL);
+}
+
+Dwarf_Section *
+_dwarf_find_next_types_section(Dwarf_Debug dbg, Dwarf_Section *ds)
+{
+
+ assert(dbg != NULL);
+
+ if (ds == NULL)
+ return (_dwarf_find_section(dbg, ".debug_types"));
+
+ assert(ds->ds_name != NULL);
+
+ do {
+ ds++;
+ if (ds->ds_name != NULL &&
+ !strcmp(ds->ds_name, ".debug_types"))
+ return (ds);
+ } while (ds->ds_name != NULL);
+
+ return (NULL);
+}
+
+Dwarf_P_Section
+_dwarf_pro_find_section(Dwarf_P_Debug dbg, const char *name)
+{
+ Dwarf_P_Section ds;
+
+ assert(dbg != NULL && name != NULL);
+
+ STAILQ_FOREACH(ds, &dbg->dbgp_seclist, ds_next) {
+ if (ds->ds_name != NULL && !strcmp(ds->ds_name ,name))
+ return (ds);
+ }
+
+ return (NULL);
+}
+
+void
+_dwarf_section_cleanup(Dwarf_P_Debug dbg)
+{
+ Dwarf_P_Section ds, tds;
+
+ assert(dbg != NULL && dbg->dbg_mode == DW_DLC_WRITE);
+
+ STAILQ_FOREACH_SAFE(ds, &dbg->dbgp_seclist, ds_next, tds) {
+ STAILQ_REMOVE(&dbg->dbgp_seclist, ds, _Dwarf_P_Section,
+ ds_next);
+ if (ds->ds_name)
+ free(ds->ds_name);
+ if (ds->ds_data)
+ free(ds->ds_data);
+ free(ds);
+ }
+ dbg->dbgp_seccnt = 0;
+ dbg->dbgp_secpos = 0;
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/libdwarf_str.c b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_str.c
new file mode 100644
index 0000000..0c1ccac
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/libdwarf_str.c
@@ -0,0 +1,159 @@
+/*-
+ * Copyright (c) 2009,2010 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "_libdwarf.h"
+
+ELFTC_VCSID("$Id: libdwarf_str.c 2070 2011-10-27 03:05:32Z jkoshy $");
+
+#define _INIT_DWARF_STRTAB_SIZE 1024
+
+int
+_dwarf_strtab_add(Dwarf_Debug dbg, char *string, uint64_t *off,
+ Dwarf_Error *error)
+{
+ size_t len;
+
+ assert(dbg != NULL && string != NULL);
+
+ len = strlen(string) + 1;
+ while (dbg->dbg_strtab_size + len > dbg->dbg_strtab_cap) {
+ dbg->dbg_strtab_cap *= 2;
+ dbg->dbg_strtab = realloc(dbg->dbg_strtab,
+ (size_t) dbg->dbg_strtab_cap);
+ if (dbg->dbg_strtab == NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ }
+
+ if (off != NULL)
+ *off = dbg->dbg_strtab_size;
+
+ strncpy(&dbg->dbg_strtab[dbg->dbg_strtab_size], string, len - 1);
+ dbg->dbg_strtab_size += len;
+ dbg->dbg_strtab[dbg->dbg_strtab_size - 1] = '\0';
+
+ return (DW_DLE_NONE);
+}
+
+char *
+_dwarf_strtab_get_table(Dwarf_Debug dbg)
+{
+
+ assert(dbg != NULL);
+
+ return (dbg->dbg_strtab);
+}
+
+int
+_dwarf_strtab_init(Dwarf_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_Section *ds;
+
+ assert(dbg != NULL);
+
+ if (dbg->dbg_mode == DW_DLC_READ || dbg->dbg_mode == DW_DLC_RDWR) {
+ ds = _dwarf_find_section(dbg, ".debug_str");
+ if (ds == NULL) {
+ dbg->dbg_strtab = NULL;
+ dbg->dbg_strtab_cap = dbg->dbg_strtab_size = 0;
+ return (DW_DLE_NONE);
+ }
+
+ dbg->dbg_strtab_cap = dbg->dbg_strtab_size = ds->ds_size;
+
+ if (dbg->dbg_mode == DW_DLC_RDWR) {
+ if ((dbg->dbg_strtab = malloc((size_t) ds->ds_size)) ==
+ NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ memcpy(dbg->dbg_strtab, ds->ds_data, ds->ds_size);
+ } else
+ dbg->dbg_strtab = (char *) ds->ds_data;
+ } else {
+ /* DW_DLC_WRITE */
+
+ dbg->dbg_strtab_cap = _INIT_DWARF_STRTAB_SIZE;
+ dbg->dbg_strtab_size = 0;
+
+ if ((dbg->dbg_strtab = malloc((size_t) dbg->dbg_strtab_cap)) ==
+ NULL) {
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+
+ dbg->dbg_strtab[0] = '\0';
+ }
+
+ return (DW_DLE_NONE);
+}
+
+void
+_dwarf_strtab_cleanup(Dwarf_Debug dbg)
+{
+
+ assert(dbg != NULL);
+
+ if (dbg->dbg_mode == DW_DLC_RDWR || dbg->dbg_mode == DW_DLC_WRITE)
+ free(dbg->dbg_strtab);
+}
+
+int
+_dwarf_strtab_gen(Dwarf_P_Debug dbg, Dwarf_Error *error)
+{
+ Dwarf_P_Section ds;
+ int ret;
+
+ assert(dbg != NULL);
+
+ if ((ret = _dwarf_section_init(dbg, &ds, ".debug_str", 0, error)) !=
+ DW_DLE_NONE)
+ return (ret);
+
+ if (dbg->dbg_strtab_size > ds->ds_cap) {
+ ds->ds_data = realloc(ds->ds_data,
+ (size_t) dbg->dbg_strtab_size);
+ if (ds->ds_data == NULL) {
+ _dwarf_section_free(dbg, &ds);
+ DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
+ return (DW_DLE_MEMORY);
+ }
+ ds->ds_cap = dbg->dbg_strtab_size;
+ }
+
+ memcpy(ds->ds_data, dbg->dbg_strtab, dbg->dbg_strtab_size);
+ ds->ds_size = dbg->dbg_strtab_size;
+
+ /*
+ * Inform application the creation of .debug_str ELF section.
+ * Note that .debug_str use a different format than usual ELF
+ * string table, so it should not have SHT_STRTAB as its type.
+ */
+ ret = _dwarf_section_callback(dbg, ds, SHT_PROGBITS, 0, 0, 0, error);
+
+ return (ret);
+}
diff --git a/rtemstoolkit/elftoolchain/libdwarf/os.NetBSD.mk b/rtemstoolkit/elftoolchain/libdwarf/os.NetBSD.mk
new file mode 100644
index 0000000..ae214e3
--- /dev/null
+++ b/rtemstoolkit/elftoolchain/libdwarf/os.NetBSD.mk
@@ -0,0 +1,2 @@
+# TODO(#511): Revert after the source tree is -Wconversion clean.
+WARNS=5
diff --git a/rtemstoolkit/wscript b/rtemstoolkit/wscript
index f4e46b4..808d974 100644
--- a/rtemstoolkit/wscript
+++ b/rtemstoolkit/wscript
@@ -59,6 +59,7 @@ def build(bld):
# The include paths.
#
conf['includes'] = ['elftoolchain/libelf',
+ 'elftoolchain/libdwarf',
'elftoolchain/common',
'libiberty']
if bld.env.DEST_OS == 'win32':
@@ -168,7 +169,9 @@ def conf_elftoolchain(conf):
def bld_elftoolchain(bld, conf):
libelf = 'elftoolchain/libelf/'
+ libdwarf = 'elftoolchain/libdwarf/'
libelf_m4_rule = '${M4} -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + ' ${SRC} > ${TGT}'
+ libdwarf_m4_rule = '${M4} -D SRCDIR=../rtemstoolkit/' + libdwarf[:-1] + ' ${SRC} > ${TGT}'
if bld.env.DEST_OS == 'win32':
includes = ['win32']
else:
@@ -255,6 +258,81 @@ def bld_elftoolchain(bld, conf):
libelf + 'libelf_shdr.c',
libelf + 'libelf_xlate.c'] + libelf_m4_source + host_source)
+ libdwarf_m4_source = ['dwarf_funcs.c',
+ 'dwarf_pro_funcs.c',
+ 'dwarf_pro_pubnames.c',
+ 'dwarf_pro_types.c',
+ 'dwarf_pro_vars.c',
+ 'dwarf_pro_weaks.c',
+ 'dwarf_pubnames.c',
+ 'dwarf_pubtypes.c',
+ 'dwarf_types.c',
+ 'dwarf_vars.c',
+ 'dwarf_weaks.c']
+ for s in libdwarf_m4_source:
+ bld(target = s, source = libdwarf + s[:-2] + '.m4', rule = libdwarf_m4_rule)
+
+ bld.stlib(target = 'dwarf',
+ features = 'c',
+ install_path = None,
+ includes = [bld.bldnode.abspath(),
+ 'elftoolchain/libelf',
+ 'elftoolchain/libdwarf',
+ 'elftoolchain/common'] + includes,
+ cflags = conf['cflags'],
+ source =[libdwarf + 'dwarf_abbrev.c',
+ libdwarf + 'dwarf_arange.c',
+ libdwarf + 'dwarf_attr.c',
+ libdwarf + 'dwarf_attrval.c',
+ libdwarf + 'dwarf_cu.c',
+ libdwarf + 'dwarf_dealloc.c',
+ libdwarf + 'dwarf_die.c',
+ libdwarf + 'dwarf_dump.c',
+ libdwarf + 'dwarf_errmsg.c',
+ libdwarf + 'dwarf_finish.c',
+ libdwarf + 'dwarf_form.c',
+ libdwarf + 'dwarf_frame.c',
+ libdwarf + 'dwarf_init.c',
+ libdwarf + 'dwarf_lineno.c',
+ libdwarf + 'dwarf_loclist.c',
+ libdwarf + 'dwarf_macinfo.c',
+ libdwarf + 'dwarf_pro_arange.c',
+ libdwarf + 'dwarf_pro_attr.c',
+ libdwarf + 'dwarf_pro_die.c',
+ libdwarf + 'dwarf_pro_expr.c',
+ libdwarf + 'dwarf_pro_finish.c',
+ libdwarf + 'dwarf_pro_frame.c',
+ libdwarf + 'dwarf_pro_init.c',
+ libdwarf + 'dwarf_pro_lineno.c',
+ libdwarf + 'dwarf_pro_macinfo.c',
+ libdwarf + 'dwarf_pro_reloc.c',
+ libdwarf + 'dwarf_pro_sections.c',
+ libdwarf + 'dwarf_ranges.c',
+ libdwarf + 'dwarf_reloc.c',
+ libdwarf + 'dwarf_seterror.c',
+ libdwarf + 'dwarf_str.c',
+ libdwarf + 'libdwarf.c',
+ libdwarf + 'libdwarf_abbrev.c',
+ libdwarf + 'libdwarf_arange.c',
+ libdwarf + 'libdwarf_attr.c',
+ libdwarf + 'libdwarf_die.c',
+ libdwarf + 'libdwarf_error.c',
+ libdwarf + 'libdwarf_elf_access.c',
+ libdwarf + 'libdwarf_elf_init.c',
+ libdwarf + 'libdwarf_frame.c',
+ libdwarf + 'libdwarf_info.c',
+ libdwarf + 'libdwarf_init.c',
+ libdwarf + 'libdwarf_lineno.c',
+ libdwarf + 'libdwarf_loc.c',
+ libdwarf + 'libdwarf_loclist.c',
+ libdwarf + 'libdwarf_macinfo.c',
+ libdwarf + 'libdwarf_nametbl.c',
+ libdwarf + 'libdwarf_ranges.c',
+ libdwarf + 'libdwarf_reloc.c',
+ libdwarf + 'libdwarf_rw.c',
+ libdwarf + 'libdwarf_sections.c',
+ libdwarf + 'libdwarf_str.c'] + libdwarf_m4_source)
+
#
# Libiberty module.
#