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 #ifdef _KEEP_RCS_ID
00041 static const char source_file[] = __FILE__;
00042 static const char rcs_id[] = "$Source: common/com/SCCS/s.em_dwarf.cxx $ $Revision: 1.21 $";
00043 #endif
00044
00045 #include <stdio.h>
00046
00047 #include "libelf/libelf.h"
00048 #include "elf_stuff.h"
00049
00050 #define USE_STANDARD_TYPES 1
00051 #include "defs.h"
00052 #include "erglob.h"
00053 #include "srcpos.h"
00054 #include "em_elf.h"
00055 #include "em_dwarf.h"
00056 #include "config_elf_targ.h"
00057 #include "targ_em_dwarf.h"
00058 #ifdef KEY
00059 #include "config_targ.h"
00060 #include "config_debug.h"
00061 #endif
00062
00063
00064 INT data_alignment_factor;
00065
00066 static Dwarf_P_Debug dw_dbg;
00067 static Dwarf_Error dw_error;
00068
00069 #define MAX_DWARF_SECTIONS 20
00070 static pSCNINFO dwarf_scn[MAX_DWARF_SECTIONS];
00071 static size_t num_dwarf_scns = 0;
00072
00073 static Dwarf_Unsigned cie_index;
00074 #ifdef KEY
00075 static Dwarf_Unsigned eh_cie_index;
00076 #endif
00077
00078 typedef struct {
00079 UINT16 dwarf_idx;
00080 const char *path;
00081 } INCL;
00082
00083 typedef struct {
00084 UINT16 dwarf_idx;
00085 UINT16 incl_idx;
00086 const char *filename;
00087 } FNAME;
00088
00089 static INCL *incl_table;
00090 static INT incl_table_size;
00091 static FNAME *file_table;
00092 static INT file_table_size;
00093
00094 static void
00095 identity_function(Dwarf_Unsigned symidx,
00096 Dwarf_Unsigned *elf_symidx,
00097 Dwarf_Unsigned *elf_symoff)
00098 {
00099 *elf_symidx = symidx;
00100 *elf_symoff = 0;
00101 }
00102
00103 static Dwarf_Unsigned
00104 another_identity_function(Elf64_Word x)
00105 {
00106 return x;
00107 }
00108
00109 static symbol_index_recorder Record_Symidx;
00110
00111 static int
00112 setup_new_section_for_dwarf (
00113 char *name,
00114 int is_64bit,
00115 Dwarf_Unsigned type,
00116 Dwarf_Unsigned flags,
00117 Dwarf_Unsigned link,
00118 Dwarf_Unsigned info,
00119 Dwarf_Unsigned *name_idx,
00120 int *error)
00121 {
00122 pSCNINFO newscn;
00123 BOOL is_reloc;
00124 INT scnalign;
00125
00126 if (num_dwarf_scns >= MAX_DWARF_SECTIONS) {
00127 fprintf (stderr, "ERROR: setup_new_section_for_dwarf: too many dwarf sections\n");
00128 exit(-1);
00129 }
00130
00131 is_reloc = (type == SHT_REL) || (type == SHT_RELA);
00132 scnalign = (is_reloc) ? (is_64bit ? ELF64_FSZ_XWORD : ELF32_FSZ_WORD) : 1;
00133 newscn = Em_New_Section (name, type, flags, 0, scnalign);
00134
00135
00136
00137
00138
00139 if (is_reloc) {
00140 Em_Set_sh_link (newscn, Em_Get_Section_Index (Symtab_Info));
00141 }
00142 else {
00143 Em_Set_sh_link (newscn, link);
00144 }
00145 Em_Set_sh_info (newscn, info);
00146 dwarf_scn[num_dwarf_scns] = newscn;
00147 num_dwarf_scns++;
00148 *name_idx = (Dwarf_Unsigned) Record_Symidx(Em_Create_Section_Symbol(newscn));
00149 return Em_Get_Section_Index (newscn);
00150 }
00151
00152 pSCNINFO
00153 Em_Dwarf_Find_Dwarf_Scn (size_t scndx)
00154 {
00155 size_t i;
00156
00157 for (i = 0; i < num_dwarf_scns; i++) {
00158 if (Em_Get_Section_Index (dwarf_scn[i]) == scndx) return dwarf_scn[i];
00159 }
00160 return NULL;
00161 }
00162
00163 pSCNINFO
00164 Em_Dwarf_Find_Dwarf_Scn_By_Name (char *name)
00165 {
00166 size_t i;
00167 char *scnname;
00168
00169 for (i = 0; i < num_dwarf_scns; i++) {
00170 scnname = Em_Get_Section_Name(dwarf_scn[i]);
00171 if (0 == strcmp(scnname, name)) return dwarf_scn[i];
00172 }
00173 return NULL;
00174 }
00175
00176
00177
00178 static void
00179 Increase_Incl_Table_Size (UINT16 incl_idx)
00180 {
00181 UINT16 new_idx;
00182
00183
00184 if (incl_idx >= incl_table_size) {
00185 new_idx = incl_idx + 5;
00186 if (incl_table == NULL) {
00187 incl_table = (INCL *) malloc (new_idx * sizeof (INCL));
00188 }
00189 else {
00190 incl_table = (INCL *) realloc (incl_table, new_idx * sizeof(INCL));
00191 }
00192 if (incl_table == NULL) {
00193 ErrMsg ( EC_No_Mem, "Increase_Incl_Table_Size" );
00194 }
00195 BZERO (&incl_table[incl_table_size], new_idx - incl_table_size);
00196 incl_table_size = new_idx;
00197 }
00198 }
00199
00200 void
00201 Em_Dwarf_Add_Include (UINT16 incl_idx, const char *name)
00202 {
00203 Dwarf_Unsigned dwarf_idx;
00204
00205 Increase_Incl_Table_Size (incl_idx);
00206 dwarf_idx = dwarf_add_directory_decl (dw_dbg, name, &dw_error);
00207 incl_table[incl_idx].dwarf_idx = dwarf_idx;
00208 incl_table[incl_idx].path = name;
00209 }
00210
00211
00212 static void
00213 Increase_File_Table_Size (UINT16 file_idx)
00214 {
00215 UINT16 new_idx;
00216
00217
00218 if (file_idx >= file_table_size) {
00219 new_idx = file_idx + 5;
00220 if (file_table == NULL) {
00221 file_table = (FNAME *) malloc (new_idx * sizeof (FNAME));
00222 }
00223 else {
00224 file_table = (FNAME *) realloc (file_table, new_idx * sizeof(FNAME));
00225 }
00226 if (file_table == NULL) {
00227 ErrMsg ( EC_No_Mem, "Increase_File_Table_Size" );
00228 }
00229 BZERO (&file_table[file_table_size], new_idx - file_table_size);
00230 file_table_size = new_idx;
00231 }
00232 }
00233
00234
00235 void
00236 Em_Dwarf_Add_File (
00237 UINT16 file_idx,
00238 const char *name,
00239 UINT16 incl_idx,
00240 Dwarf_Unsigned modification_time,
00241 Dwarf_Unsigned file_size)
00242 {
00243 Dwarf_Unsigned dwarf_idx;
00244
00245 Increase_File_Table_Size (file_idx);
00246 dwarf_idx = dwarf_add_file_decl (
00247 dw_dbg,
00248 name,
00249 incl_table[incl_idx].dwarf_idx,
00250 modification_time,
00251 file_size,
00252 &dw_error);
00253 file_table[file_idx].dwarf_idx = dwarf_idx;
00254 file_table[file_idx].filename = name;
00255 file_table[file_idx].incl_idx = incl_idx;
00256 }
00257
00258 #ifdef KEY
00259 #include "strtab.h"
00260 #include "symtab.h"
00261 #include "irbdata.h"
00262 #endif // KEY
00263 extern "C" void Assign_ST_To_Named_Section (ST *, STR_IDX);
00264
00265 Dwarf_P_Debug
00266 Em_Dwarf_Begin (BOOL is_64bit, BOOL dwarf_trace, BOOL is_cplus,
00267 symbol_index_recorder record_symidx)
00268 {
00269 Dwarf_Unsigned flags;
00270 const char *augmenter;
00271 Dwarf_Unsigned personality=0;
00272
00273 #define EXT_OP(v) (DW_CFA_extended | v)
00274 static unsigned char init_bytes[] = TARG_INIT_BYTES;
00275 #ifdef TARG_X8664
00276 static unsigned char init_x86_bytes[] = TARG_INIT_X86_BYTES;
00277 #endif
00278
00279 if (record_symidx == NULL) {
00280 record_symidx = another_identity_function;
00281 }
00282
00283 Record_Symidx = record_symidx;
00284
00285
00286 Increase_Incl_Table_Size (0);
00287 Increase_File_Table_Size (0);
00288
00289 data_alignment_factor = is_64bit ? -8 : -4;
00290 flags = DW_DLC_WRITE | ((is_64bit) ? DW_DLC_SIZE_64 : DW_DLC_SIZE_32);
00291 flags |= DWARF_TARGET_FLAG;
00292 flags |= DW_DLC_SYMBOLIC_RELOCATIONS;
00293 dw_dbg = dwarf_producer_init_b (flags, setup_new_section_for_dwarf,
00294 0, 0, &dw_error);
00295
00296
00297
00298 if (is_cplus)
00299 {
00300 if (Gen_PIC_Call_Shared || Gen_PIC_Shared)
00301 augmenter = PIC_DW_CIE_AUGMENTER_STRING_V0;
00302 else
00303 augmenter = DW_CIE_AUGMENTER_STRING_V0;
00304 personality = Save_Str ("__gxx_personality_v0");
00305 if (Gen_PIC_Call_Shared || Gen_PIC_Shared)
00306 {
00307 ST * pic_personality_st = New_ST (GLOBAL_SYMTAB);
00308 STR_IDX name = Save_Str ("DW.ref.__gxx_personality_v0");
00309 ST_Init(pic_personality_st, name, CLASS_VAR, SCLASS_DGLOBAL, EXPORT_HIDDEN, MTYPE_TO_TY_array[MTYPE_U8]);
00310 Set_ST_is_weak_symbol (pic_personality_st);
00311 Set_ST_is_initialized (pic_personality_st);
00312 ST_ATTR_IDX st_attr_idx;
00313 ST_ATTR& st_attr = New_ST_ATTR (GLOBAL_SYMTAB, st_attr_idx);
00314 ST_ATTR_Init (st_attr, ST_st_idx (pic_personality_st), ST_ATTR_SECTION_NAME, Save_Str (".gnu.linkonce.d.DW.ref.__gxx_personality_v0"));
00315
00316 ST * personality_st = New_ST (GLOBAL_SYMTAB);
00317 ST_Init (personality_st, Save_Str("__gxx_personality_v0"), CLASS_VAR, SCLASS_EXTERN, EXPORT_PREEMPTIBLE, MTYPE_TO_TY_array[MTYPE_U8]);
00318 INITV_IDX iv = New_INITV();
00319 INITV_Init_Symoff (iv, personality_st, 0, 1);
00320 New_INITO (ST_st_idx (pic_personality_st), iv);
00321
00322
00323
00324
00325
00326
00327 if (Read_Global_Data)
00328 Assign_ST_To_Named_Section (pic_personality_st,
00329 ST_ATTR_section_name (st_attr));
00330 }
00331 }
00332 else
00333
00334 if (Gen_PIC_Call_Shared || Gen_PIC_Shared)
00335 augmenter = PIC_NONCPLUS_DW_CIE_AUGMENTER_STRING_V0;
00336 else
00337 augmenter = "";
00338
00339 const char *cie_augmenter;
00340 Dwarf_Small code_alignent_factor;
00341 Dwarf_Small return_reg;
00342 Dwarf_Ptr cie_init_bytes;
00343 Dwarf_Unsigned cie_init_byte_len;
00344
00345 #ifdef TARG_X8664
00346 code_alignent_factor = 1;
00347 cie_augmenter = "";
00348 return_reg = Is_Target_64bit() ? DW_FRAME_RA_COL : 0x8;
00349
00350
00351 cie_init_bytes = Is_Target_64bit() ? init_bytes : init_x86_bytes;
00352 cie_init_byte_len = Is_Target_64bit()
00353 ? sizeof(init_bytes) : sizeof(init_x86_bytes);
00354 #else
00355 code_alignent_factor = 4;
00356 cie_augmenter = augmenter;
00357 return_reg = DW_FRAME_RA_COL;
00358 cie_init_bytes = init_bytes;
00359 cie_init_byte_len = sizeof(init_bytes);
00360 #endif
00361
00362 cie_index = dwf_add_frame_cie (dw_dbg,
00363 cie_augmenter,
00364 code_alignent_factor,
00365 data_alignment_factor,
00366 return_reg,
00367 0,
00368 (Gen_PIC_Call_Shared || Gen_PIC_Shared),
00369 is_64bit,
00370 cie_init_bytes,
00371 cie_init_byte_len,
00372 &dw_error);
00373
00374 #if defined(KEY) && !defined(TARG_SL) && !defined(TARG_MIPS)
00375
00376 if (is_cplus || DEBUG_Emit_Ehframe)
00377 eh_cie_index = dwf_add_ehframe_cie (dw_dbg, augmenter,
00378 1, data_alignment_factor,
00379
00380
00381
00382 Is_Target_64bit() ? DW_FRAME_RA_COL: 0x8,
00383 personality,
00384 (Gen_PIC_Call_Shared || Gen_PIC_Shared),
00385 is_64bit,
00386 #ifdef TARG_X8664
00387 Is_Target_64bit() ? init_bytes : init_x86_bytes,
00388 Is_Target_64bit() ? sizeof(init_bytes) : sizeof(init_x86_bytes),
00389 #else
00390 init_bytes, sizeof(init_bytes),
00391 #endif
00392 &dw_error);
00393 #endif // KEY
00394
00395 return dw_dbg;
00396 }
00397
00398 extern "C" Dwarf_P_Debug
00399 Em_Dwarf_Begin (BOOL is_64bit, BOOL dwarf_trace, BOOL is_cplus)
00400 {
00401 return Em_Dwarf_Begin(is_64bit, dwarf_trace, is_cplus, NULL);
00402 }
00403
00404 static Dwarf_Signed section_count = DW_DLV_NOCOUNT;
00405 static Dwarf_Unsigned relocation_section_count = DW_DLV_NOCOUNT;
00406
00407 struct index_to_buffer_map_entry {
00408 pSCNINFO cursection;
00409 Dwarf_Signed scndx;
00410 Dwarf_Ptr buffer;
00411 Dwarf_Unsigned bufsize;
00412 };
00413
00414 index_to_buffer_map_entry *index_to_buffer_map;
00415
00416 static inline int
00417 find_indexed_section( int i,
00418 const Dwarf_Signed scn)
00419 {
00420 for (; i < section_count; ++i) {
00421 if (index_to_buffer_map[i].scndx == scn) {
00422 return i;
00423 }
00424 }
00425 return -1;
00426 }
00427
00428 static int current_scn;
00429
00430 static int
00431 advance_to_next_stream_buffer(const Dwarf_Signed scndx)
00432 {
00433 if (current_scn >= section_count) {
00434 fprintf(stderr, "Too many calls to advance_to_next_stream_buffer");
00435 exit(-1);
00436 }
00437 current_scn =
00438 find_indexed_section(current_scn + 1, scndx);
00439 return current_scn != -1;
00440 }
00441
00442 static Dwarf_Ptr
00443 get_current_buffer(void)
00444 {
00445 return index_to_buffer_map[current_scn].buffer;
00446 }
00447
00448 static Dwarf_Unsigned
00449 get_current_bufsize(void)
00450 {
00451 return index_to_buffer_map[current_scn].bufsize;
00452 }
00453
00454 void
00455 Em_Dwarf_Write_Scns (Cg_Dwarf_Sym_To_Elfsym_Ofst translate_dwarf_sym)
00456 {
00457 Dwarf_Signed i;
00458 Dwarf_Ptr buffer;
00459 Dwarf_Signed scndx;
00460 Dwarf_Unsigned bufsize;
00461 int result;
00462 int reloc_buffer_version;
00463 pSCNINFO cursection;
00464
00465 if (translate_dwarf_sym == NULL) {
00466 translate_dwarf_sym = identity_function;
00467 }
00468
00469 index_to_buffer_map =
00470 (index_to_buffer_map_entry *) malloc(section_count *
00471 sizeof(index_to_buffer_map_entry));
00472
00473 dwarf_reset_section_bytes(dw_dbg);
00474
00475 for (i = 0; i < section_count; i++) {
00476 buffer = dwarf_get_section_bytes (dw_dbg, i, &scndx, &bufsize, &dw_error);
00477 cursection = Em_Dwarf_Find_Dwarf_Scn (scndx);
00478 if (cursection != NULL) {
00479 index_to_buffer_map[i].cursection = cursection;
00480 index_to_buffer_map[i].scndx = scndx;
00481 index_to_buffer_map[i].buffer = buffer;
00482 index_to_buffer_map[i].bufsize = bufsize;
00483 }
00484 else {
00485 fprintf (stderr, "ERROR No such section index: %d\n", (int)scndx);
00486 exit(-1);
00487 }
00488 }
00489
00490
00491
00492 result = dwarf_get_relocation_info_count(dw_dbg,
00493 &relocation_section_count,
00494 &reloc_buffer_version,
00495 &dw_error);
00496 if (result != DW_DLV_OK) {
00497 fprintf(stderr, "ERROR Couldn't get relocation buffer count\n");
00498 exit(-1);
00499 }
00500 if (reloc_buffer_version != 2 ) {
00501 fprintf(stderr,
00502 "ERROR Relocation buffer format unrecognized "
00503 "(version %d)\n", reloc_buffer_version);
00504 exit(-1);
00505 }
00506
00507 for (i = 0; i < relocation_section_count; i++) {
00508 Dwarf_Relocation_Data reloc_buf;
00509 Dwarf_Unsigned entry_count;
00510 Dwarf_Signed link_scn;
00511
00512 result = dwarf_get_relocation_info(dw_dbg, &scndx, &link_scn,
00513 &entry_count, &reloc_buf,
00514 &dw_error);
00515 if (result != DW_DLV_OK) {
00516 fprintf(stderr, "ERROR dwarf_get_relocation_info failed\n");
00517 exit(-1);
00518 }
00519
00520 current_scn = -1;
00521
00522 Dwarf_Signed j = find_indexed_section(current_scn + 1, link_scn);
00523
00524 BOOL is_debug_line =
00525 (strcmp(
00526 #ifdef KEY
00527 DEBUG_LINE_SECTNAME,
00528 #else
00529 ".debug_line",
00530 #endif
00531 Em_Get_Section_Name(index_to_buffer_map[j].cursection)) == 0);
00532
00533 buffer =
00534 Em_Dwarf_Symbolic_Relocs_To_Elf(get_current_buffer,
00535 get_current_bufsize,
00536 advance_to_next_stream_buffer,
00537 link_scn,
00538 reloc_buf, entry_count,
00539
00540
00541 data_alignment_factor == -8,
00542 (is_debug_line ?
00543 identity_function :
00544 translate_dwarf_sym),
00545 &bufsize);
00546 cursection = Em_Dwarf_Find_Dwarf_Scn(scndx);
00547 if (cursection != NULL) {
00548 Em_Add_Bytes_To_Scn(cursection, buffer, bufsize, 1);
00549 }
00550 else {
00551 fprintf (stderr, "ERROR No such section index: %d\n", (int)scndx);
00552 exit(-1);
00553 }
00554 free((void *) buffer);
00555 }
00556
00557 for (i = 0; i < section_count; ++i) {
00558 Em_Add_Bytes_To_Scn (index_to_buffer_map[i].cursection,
00559 index_to_buffer_map[i].buffer,
00560 index_to_buffer_map[i].bufsize,
00561 1);
00562 }
00563
00564 free(index_to_buffer_map);
00565
00566 for (i = 0; i < num_dwarf_scns; i++) {
00567 Em_End_Section (dwarf_scn[i]);
00568 }
00569 }
00570
00571 extern "C" void
00572 Em_Dwarf_Write_Scns (void)
00573 {
00574 Em_Dwarf_Write_Scns(NULL);
00575 }
00576
00577 INT
00578 Em_Dwarf_Prepare_Output(void)
00579 {
00580 section_count = dwarf_transform_to_disk_form (dw_dbg, &dw_error);
00581 if (section_count == DW_DLV_NOCOUNT) {
00582 fprintf(stderr, "ERROR in dwarf_transform_to_disk_form\n");
00583 exit(-1);
00584 }
00585 return (INT) section_count;
00586 }
00587
00588 void
00589 Em_Dwarf_End (void)
00590 {
00591 dwarf_producer_finish (dw_dbg, &dw_error);
00592 }
00593
00594
00595 void
00596 Em_Dwarf_Add_Line_Entry ( INT code_address, SRCPOS srcpos)
00597 {
00598 USRCPOS usrcpos;
00599
00600 USRCPOS_srcpos(usrcpos) = srcpos;
00601
00602 dwarf_add_line_entry (dw_dbg,
00603 file_table[USRCPOS_filenum(usrcpos)].dwarf_idx,
00604 code_address,
00605 USRCPOS_linenum(usrcpos),
00606 USRCPOS_column(usrcpos),
00607 USRCPOS_stmt_begin(usrcpos),
00608 USRCPOS_bb_begin(usrcpos),
00609 &dw_error);
00610 }
00611
00612
00613 #ifndef MONGOOSE_BE
00614
00615 void
00616 Em_Dwarf_File_Index_To_Name (INT file_index, char **filename, char **path)
00617 {
00618 *filename = file_table[file_index].filename;
00619 *path = incl_table[file_table[file_index].incl_idx].path;
00620 }
00621 #endif
00622
00623
00624
00625 static INT Text_Start_Offset;
00626 static Dwarf_Unsigned Text_Start_Label;
00627 static Dwarf_Addr Offset_From_Text_Start_Label;
00628
00629 void
00630 Em_Dwarf_Start_Text_Lines (pSCNINFO scninfo, INT start_offset)
00631 {
00632 Text_Start_Offset = start_offset;
00633 dwarf_lne_set_address (dw_dbg, start_offset,
00634 Em_Create_Section_Symbol(scninfo), &dw_error);
00635 }
00636
00637 void
00638 Em_Dwarf_Start_Text_Region (pSCNINFO scninfo, INT start_offset)
00639 {
00640 Em_Dwarf_Start_Text_Lines (scninfo, start_offset);
00641 }
00642
00643 void
00644 Em_Dwarf_Start_Text_Region_Semi_Symbolic (pSCNINFO scninfo,
00645 INT start_offset,
00646 Dwarf_Unsigned first_label,
00647 Dwarf_Addr offset_from_first_label)
00648 {
00649 Text_Start_Offset = start_offset;
00650 Text_Start_Label = first_label;
00651 Offset_From_Text_Start_Label = offset_from_first_label;
00652 }
00653
00654 void
00655 Em_Dwarf_End_Text_Lines (pSCNINFO scninfo, INT end_offset)
00656 {
00657 dwarf_lne_end_sequence (dw_dbg, end_offset, &dw_error);
00658 }
00659
00660 void
00661 Em_Dwarf_End_Text_Arange (pSCNINFO scninfo, INT end_offset)
00662 {
00663 INT region_size = end_offset - Text_Start_Offset;
00664
00665 dwarf_add_arange (dw_dbg, Text_Start_Offset, region_size,
00666 Em_Create_Section_Symbol(scninfo), &dw_error);
00667 }
00668
00669 void
00670 Em_Dwarf_End_Text_Arange_Symbolic(Dwarf_Unsigned last_label,
00671 Dwarf_Addr offset_from_last_label)
00672 {
00673 dwarf_add_arange_b (dw_dbg,
00674 Offset_From_Text_Start_Label,
00675 0 ,
00676 Text_Start_Label,
00677 last_label,
00678 offset_from_last_label,
00679 &dw_error);
00680 }
00681
00682 void
00683 Em_Dwarf_End_Text_Region (pSCNINFO scninfo, INT end_offset)
00684 {
00685 Em_Dwarf_End_Text_Arange (scninfo, end_offset);
00686 Em_Dwarf_End_Text_Lines (scninfo, end_offset);
00687 }
00688
00689 void
00690 Em_Dwarf_End_Text_Region_Semi_Symbolic(pSCNINFO scninfo,
00691 INT end_offset,
00692 Dwarf_Unsigned last_label,
00693 Dwarf_Addr offset_from_last_label)
00694 {
00695 Em_Dwarf_End_Text_Arange_Symbolic(last_label,
00696 offset_from_last_label);
00697 Em_Dwarf_End_Text_Lines(scninfo, end_offset);
00698 }
00699
00700 void Em_Dwarf_Process_PU (Dwarf_Unsigned begin_label,
00701 Dwarf_Unsigned end_label,
00702 INT32 begin_offset,
00703 INT32 end_offset,
00704 Dwarf_P_Die PU_die,
00705 Dwarf_P_Fde fde,
00706 #ifdef TARG_X8664
00707 Dwarf_P_Fde eh_fde,
00708 #endif
00709 Elf64_Word eh_symindex,
00710 INT eh_offset)
00711 {
00712
00713 dwarf_add_AT_targ_address_b (dw_dbg, PU_die, DW_AT_low_pc,
00714 begin_offset,
00715 (Dwarf_Unsigned) begin_label,
00716 &dw_error);
00717 dwarf_add_AT_targ_address_b (dw_dbg, PU_die, DW_AT_high_pc,
00718 end_offset, (Dwarf_Unsigned) end_label,
00719 &dw_error);
00720
00721 if (fde == NULL)
00722 return;
00723
00724 if (eh_offset == DW_DLX_NO_EH_OFFSET)
00725 dwarf_add_frame_fde_b (dw_dbg, fde, PU_die, cie_index,
00726 begin_offset,
00727 0 ,
00728 (Dwarf_Unsigned) begin_label,
00729 (Dwarf_Unsigned) end_label,
00730 end_offset,
00731 &dw_error);
00732 else
00733 dwarf_add_frame_info_b (dw_dbg, fde, PU_die, cie_index,
00734 begin_offset,
00735 0 ,
00736 (Dwarf_Unsigned) begin_label,
00737 (Dwarf_Unsigned) end_label,
00738 end_offset,
00739 eh_offset, eh_symindex, &dw_error);
00740
00741 #ifdef TARG_X8664
00742 if (eh_fde == NULL)
00743 return;
00744
00745 if (eh_offset == DW_DLX_NO_EH_OFFSET)
00746 dwf_add_ehframe_fde_b (dw_dbg, eh_fde, PU_die, eh_cie_index,
00747 begin_offset,
00748 0 ,
00749 (Dwarf_Unsigned) begin_label,
00750 (Dwarf_Unsigned) end_label,
00751 end_offset,
00752 &dw_error);
00753 else
00754 dwf_add_ehframe_info_b (dw_dbg, eh_fde, PU_die, eh_cie_index,
00755 begin_offset,
00756 0 ,
00757 (Dwarf_Unsigned) begin_label,
00758 (Dwarf_Unsigned) end_label,
00759 end_offset,
00760 eh_offset, eh_symindex, &dw_error);
00761 #endif
00762 }
00763 #ifdef TARG_X8664
00764 void Em_Dwarf_Add_PU_Entries (Dwarf_Unsigned begin_label,
00765 Dwarf_Unsigned end_label,
00766 INT32 begin_offset,
00767 INT32 end_offset,
00768 Dwarf_P_Die PU_die,
00769 Dwarf_P_Fde fde)
00770 {
00771 dwarf_add_AT_targ_address_b (dw_dbg, PU_die, DW_AT_low_pc,
00772 begin_offset,
00773 (Dwarf_Unsigned) begin_label,
00774 &dw_error);
00775 dwarf_add_AT_targ_address_b (dw_dbg, PU_die, DW_AT_high_pc,
00776 end_offset, (Dwarf_Unsigned) end_label,
00777 &dw_error);
00778
00779 if (fde == NULL)
00780 return;
00781
00782 dwarf_add_frame_fde_b (dw_dbg, fde, PU_die, cie_index,
00783 begin_offset,
00784 0 ,
00785 (Dwarf_Unsigned) begin_label,
00786 (Dwarf_Unsigned) end_label,
00787 end_offset,
00788 &dw_error);
00789 }
00790 #endif