00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <stddef.h>
00042
00043
00044
00045
00046
00047 #include "libdwarfdefs.h"
00048
00049 #define true 1
00050 #define false 0
00051
00052
00053 #define DW_CIE_ID ~(0x0)
00054 #define DW_CIE_VERSION 1
00055
00056
00057
00058
00059
00060
00061
00062
00063 typedef unsigned long Dwarf_Word;
00064 typedef long Dwarf_Sword;
00065
00066
00067 typedef signed char Dwarf_Sbyte;
00068 typedef unsigned char Dwarf_Ubyte;
00069 typedef signed short Dwarf_Shalf;
00070
00071
00072
00073
00074
00075
00076
00077 #define PRO_VERSION_MAGIC 0xdead1
00078
00079
00080
00081
00082
00083 typedef __uint32_t Dwarf_ufixed;
00084 typedef __int32_t Dwarf_sfixed;
00085
00086
00087
00088
00089
00090
00091
00092
00093 typedef struct Dwarf_P_Section_Data_s *Dwarf_P_Section_Data;
00094
00095
00096
00097
00098
00099
00100 typedef struct Dwarf_P_Inc_Dir_s *Dwarf_P_Inc_Dir;
00101
00102
00103
00104
00105
00106
00107 typedef struct Dwarf_P_F_Entry_s *Dwarf_P_F_Entry;
00108
00109
00110
00111
00112
00113 typedef struct Dwarf_P_Cie_s *Dwarf_P_Cie;
00114
00115
00116
00117
00118
00119
00120 typedef struct Dwarf_P_Line_s *Dwarf_P_Line;
00121
00122
00123
00124
00125
00126 typedef struct Dwarf_P_Simple_nameentry_s *Dwarf_P_Simple_nameentry;
00127 typedef struct Dwarf_P_Simple_name_header_s *Dwarf_P_Simple_name_header;
00128 typedef struct Dwarf_P_Arange_s *Dwarf_P_Arange;
00129 typedef struct Dwarf_P_Per_Reloc_Sect_s *Dwarf_P_Per_Reloc_Sect;
00130
00131
00132
00133
00134
00135
00136 #define DEBUG_INFO 0
00137 #define DEBUG_LINE 1
00138 #define DEBUG_ABBREV 2
00139 #define DEBUG_FRAME 3
00140 #define DEBUG_ARANGES 4
00141 #define DEBUG_PUBNAMES 5
00142 #define DEBUG_STR 6
00143 #define DEBUG_FUNCNAMES 7
00144 #define DEBUG_TYPENAMES 8
00145 #define DEBUG_VARNAMES 9
00146 #define DEBUG_WEAKNAMES 10
00147 #define DEBUG_MACINFO 11
00148 #define DEBUG_LOC 12
00149 #define EH_FRAME 13
00150
00151
00152 #define NUM_DEBUG_SECTIONS EH_FRAME + 1
00153
00154
00155 struct Dwarf_P_Die_s {
00156 Dwarf_Unsigned di_offset;
00157 char *di_abbrev;
00158 Dwarf_Word di_abbrev_nbytes;
00159 Dwarf_Tag di_tag;
00160 Dwarf_P_Die di_parent;
00161 Dwarf_P_Die di_child;
00162 Dwarf_P_Die di_left;
00163 Dwarf_P_Die di_right;
00164 Dwarf_P_Die di_last_child;
00165 Dwarf_P_Attribute di_attrs;
00166 Dwarf_P_Attribute di_last_attr;
00167 int di_n_attr;
00168 };
00169
00170
00171
00172 struct Dwarf_P_Attribute_s {
00173 Dwarf_Half ar_attribute;
00174 Dwarf_Half ar_attribute_form;
00175 Dwarf_P_Die ar_ref_die;
00176 char *ar_data;
00177 Dwarf_Unsigned ar_nbytes;
00178 Dwarf_Unsigned ar_rel_symidx;
00179
00180
00181 Dwarf_Ubyte ar_rel_type;
00182 Dwarf_Word ar_rel_offset;
00183 char ar_reloc_len;
00184
00185
00186
00187 Dwarf_P_Attribute ar_next;
00188 };
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 struct dw_macinfo_block_s {
00199 struct dw_macinfo_block_s *mb_next;
00200 unsigned long mb_avail_len;
00201 unsigned long mb_used_len;
00202 unsigned long mb_macinfo_data_space_len;
00203 char *mb_data;
00204 };
00205
00206
00207
00208
00209 enum dwarf_sn_kind { dwarf_snk_pubname, dwarf_snk_funcname,
00210 dwarf_snk_weakname, dwarf_snk_typename,
00211 dwarf_snk_varname,
00212 dwarf_snk_entrycount
00213 };
00214
00215
00216
00217
00218
00219
00220 struct Dwarf_P_Simple_nameentry_s {
00221 Dwarf_P_Die sne_die;
00222 char *sne_name;
00223 int sne_name_len;
00224 Dwarf_P_Simple_nameentry sne_next;
00225 };
00226
00227
00228
00229
00230 struct Dwarf_P_Simple_name_header_s {
00231 Dwarf_P_Simple_nameentry sn_head;
00232 Dwarf_P_Simple_nameentry sn_tail;
00233 Dwarf_Signed sn_count;
00234
00235
00236
00237 Dwarf_Signed sn_net_len;
00238 };
00239 typedef int (*_dwarf_pro_reloc_name_func_ptr) (Dwarf_P_Debug dbg, int sec_index, Dwarf_Unsigned offset,
00240
00241 Dwarf_Unsigned symidx,
00242 enum Dwarf_Rel_Type type,
00243 int reltarget_length);
00244
00245 typedef int (*_dwarf_pro_reloc_length_func_ptr) (Dwarf_P_Debug dbg, int sec_index, Dwarf_Unsigned offset,
00246
00247 Dwarf_Unsigned
00248 start_symidx,
00249 Dwarf_Unsigned
00250 end_symidx,
00251 enum Dwarf_Rel_Type
00252 type,
00253 int reltarget_length);
00254 typedef int (*_dwarf_pro_transform_relocs_func_ptr) (Dwarf_P_Debug dbg,
00255 Dwarf_Signed *
00256 new_sec_count);
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275 struct Dwarf_P_Relocation_Block_s {
00276 Dwarf_Unsigned rb_slots_in_block;
00277 Dwarf_Unsigned rb_next_slot_to_use;
00278 struct Dwarf_P_Relocation_Block_s *rb_next;
00279 char *rb_where_to_add_next;
00280
00281
00282 char *rb_data;
00283 };
00284
00285
00286
00287
00288
00289
00290 struct Dwarf_P_Per_Reloc_Sect_s {
00291
00292
00293 unsigned long pr_reloc_total_count;
00294
00295
00296 unsigned long pr_slots_per_block_to_alloc;
00297
00298
00299
00300
00301 int pr_sect_num_of_reloc_sect;
00302
00303
00304
00305
00306
00307
00308
00309 struct Dwarf_P_Relocation_Block_s *pr_first_block;
00310 struct Dwarf_P_Relocation_Block_s *pr_last_block;
00311 unsigned long pr_block_count;
00312 };
00313
00314 #define DEFAULT_SLOTS_PER_BLOCK 3
00315
00316
00317
00318 struct Dwarf_P_Debug_s {
00319
00320
00321 int de_version_magic_number;
00322
00323 Dwarf_Unsigned de_access;
00324 Dwarf_Handler de_errhand;
00325 Dwarf_Ptr de_errarg;
00326
00327
00328
00329
00330 Dwarf_Callback_Func de_func;
00331 Dwarf_Callback_Func_b de_func_b;
00332
00333
00334 Dwarf_Unsigned de_flags;
00335
00336
00337
00338 Dwarf_P_Section_Data de_debug_sects;
00339
00340
00341 Dwarf_P_Section_Data de_current_active_section;
00342
00343
00344 Dwarf_Word de_n_debug_sect;
00345
00346
00347 Dwarf_P_F_Entry de_file_entries;
00348 Dwarf_P_F_Entry de_last_file_entry;
00349 Dwarf_Unsigned de_n_file_entries;
00350
00351
00352 Dwarf_P_Inc_Dir de_inc_dirs;
00353 Dwarf_P_Inc_Dir de_last_inc_dir;
00354 Dwarf_Unsigned de_n_inc_dirs;
00355
00356
00357 Dwarf_P_Line de_lines;
00358 Dwarf_P_Line de_last_line;
00359
00360
00361 Dwarf_P_Cie de_frame_cies;
00362 Dwarf_P_Cie de_last_cie;
00363 Dwarf_Unsigned de_n_cie;
00364
00365
00366
00367 Dwarf_P_Fde de_frame_fdes;
00368 Dwarf_P_Fde de_last_fde;
00369 Dwarf_Unsigned de_n_fde;
00370
00371
00372 Dwarf_P_Cie de_eh_frame_cies;
00373 Dwarf_P_Cie de_eh_last_cie;
00374 Dwarf_Unsigned de_eh_n_cie;
00375
00376
00377 Dwarf_P_Fde de_eh_frame_fdes;
00378 Dwarf_P_Fde de_eh_last_fde;
00379 Dwarf_Unsigned de_eh_n_fde;
00380
00381
00382 Dwarf_P_Die de_dies;
00383
00384
00385 char *de_strings;
00386
00387
00388 Dwarf_P_Arange de_arange;
00389 Dwarf_P_Arange de_last_arange;
00390 Dwarf_Sword de_arange_count;
00391
00392
00393
00394 struct dw_macinfo_block_s *de_first_macinfo;
00395
00396
00397 struct dw_macinfo_block_s *de_current_macinfo;
00398
00399
00400
00401 Dwarf_P_Section_Data de_first_debug_sect;
00402
00403
00404
00405 struct Dwarf_P_Simple_name_header_s
00406 de_simple_name_headers[dwarf_snk_entrycount];
00407
00408
00409
00410 struct Dwarf_P_Per_Reloc_Sect_s de_reloc_sect[NUM_DEBUG_SECTIONS];
00411 int de_reloc_next_to_return;
00412
00413
00414
00415 int de_elf_sects[NUM_DEBUG_SECTIONS];
00416
00417
00418
00419
00420
00421 Dwarf_Unsigned de_sect_name_idx[NUM_DEBUG_SECTIONS];
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440 int de_offset_reloc;
00441
00442
00443
00444 int de_exc_reloc;
00445
00446 int de_ptr_reloc;
00447
00448
00449
00450
00451 unsigned char de_offset_size;
00452
00453
00454
00455
00456 unsigned char de_pointer_size;
00457
00458
00459
00460
00461 unsigned char de_is_64bit;
00462
00463
00464 unsigned char de_relocation_record_size;
00465
00466
00467
00468
00469
00470 unsigned char de_64bit_extension;
00471
00472
00473
00474 int de_ar_data_attribute_form;
00475 int de_ar_ref_attr_form;
00476
00477
00478 _dwarf_pro_reloc_name_func_ptr de_reloc_name;
00479
00480
00481 _dwarf_pro_reloc_length_func_ptr de_reloc_pair;
00482
00483 _dwarf_pro_transform_relocs_func_ptr de_transform_relocs_to_disk;
00484
00485
00486 unsigned long de_compose_avail;
00487 unsigned long de_compose_used_len;
00488
00489 unsigned char de_same_endian;
00490 void *(*de_copy_word) (void *, const void *, size_t);
00491
00492
00493
00494
00495
00496 };
00497
00498
00499 #define CURRENT_VERSION_STAMP 2
00500
00501 Dwarf_Unsigned _dwarf_add_simple_name_entry(Dwarf_P_Debug dbg,
00502 Dwarf_P_Die die,
00503 char *entry_name,
00504 enum dwarf_sn_kind
00505 entrykind,
00506 Dwarf_Error * error);
00507
00508
00509 #define DISTINGUISHED_VALUE 0xffffffff