| @@ -431,7 +431,7 @@ struct _tccdbg { · 430 unmodified lines |
| 431 | #define FDE_ENCODING (DW_EH_PE_udata4 | DW_EH_PE_signed | DW_EH_PE_pcrel) | 431 | #define FDE_ENCODING (DW_EH_PE_udata4 | DW_EH_PE_signed | DW_EH_PE_pcrel) |
| 432 | | 432 | |
| 433 | /* ------------------------------------------------------------------------- */ | 433 | /* ------------------------------------------------------------------------- */ |
| 434 | static void put_stabs(TCCState *s1, const char *str, int type, int other, | 434 | static int put_stabs(TCCState *s1, const char *str, int type, int other, |
| 435 | int desc, unsigned long value); | 435 | int desc, unsigned long value); |
| 436 | | 436 | |
| 437 | ST_FUNC void tcc_debug_new(TCCState *s1) | 437 | ST_FUNC void tcc_debug_new(TCCState *s1) |
| @@ -449,6 +449,19 @@ ST_FUNC void tcc_debug_new(TCCState *s1) · 11 unmodified lines |
| 449 | #endif | 449 | #endif |
| 450 | | 450 | |
| 451 | if (s1->dwarf) { | 451 | if (s1->dwarf) { |
| | 452 | int i; |
| | 453 | /* The sections below are just to make reloctions with |
| | 454 | R_DATA_32DW work correctly. See tccelf.c */ |
| | 455 | static const char *const debug[] = { |
| | 456 | ".debug_macro", |
| | 457 | ".debug_loc", |
| | 458 | ".debug_ranges", |
| | 459 | ".debug_loclists", |
| | 460 | ".debug_rnglists", |
| | 461 | ".debug_str_offsets", |
| | 462 | ".debug_addr" |
| | 463 | }; |
| | 464 | |
| 452 | s1->dwlo = s1->nb_sections; | 465 | s1->dwlo = s1->nb_sections; |
| 453 | dwarf_info_section = | 466 | dwarf_info_section = |
| 454 | new_section(s1, ".debug_info", SHT_PROGBITS, shf); | 467 | new_section(s1, ".debug_info", SHT_PROGBITS, shf); |
| @@ -458,6 +471,8 @@ ST_FUNC void tcc_debug_new(TCCState *s1) · 3 unmodified lines |
| 458 | new_section(s1, ".debug_line", SHT_PROGBITS, shf); | 471 | new_section(s1, ".debug_line", SHT_PROGBITS, shf); |
| 459 | dwarf_aranges_section = | 472 | dwarf_aranges_section = |
| 460 | new_section(s1, ".debug_aranges", SHT_PROGBITS, shf); | 473 | new_section(s1, ".debug_aranges", SHT_PROGBITS, shf); |
| | 474 | for (i = 0; i < sizeof(debug)/sizeof(debug[0]); i++) |
| | 475 | new_section(s1, debug[i], SHT_PROGBITS, 0)->sh_addralign = 1; |
| 461 | shf |= SHF_MERGE | SHF_STRINGS; | 476 | shf |= SHF_MERGE | SHF_STRINGS; |
| 462 | dwarf_str_section = | 477 | dwarf_str_section = |
| 463 | new_section(s1, ".debug_str", SHT_PROGBITS, shf); | 478 | new_section(s1, ".debug_str", SHT_PROGBITS, shf); |
| @@ -487,7 +502,7 @@ ST_FUNC void tcc_debug_new(TCCState *s1) · 23 unmodified lines |
| 487 | } | 502 | } |
| 488 | | 503 | |
| 489 | /* put stab debug information */ | 504 | /* put stab debug information */ |
| 490 | static void put_stabs(TCCState *s1, const char *str, int type, int other, int desc, | 505 | static int put_stabs(TCCState *s1, const char *str, int type, int other, int desc, |
| 491 | unsigned long value) | 506 | unsigned long value) |
| 492 | { | 507 | { |
| 493 | Stab_Sym *sym; | 508 | Stab_Sym *sym; |
| @@ -500,7 +515,7 @@ static void put_stabs(TCCState *s1, const char *str, int type, int other, int de · 6 unmodified lines |
| 500 | && sym->n_value == value) { | 515 | && sym->n_value == value) { |
| 501 | /* just update line_number in previous entry */ | 516 | /* just update line_number in previous entry */ |
| 502 | sym->n_desc = desc; | 517 | sym->n_desc = desc; |
| 503 | return; | 518 | return 0; |
| 504 | } | 519 | } |
| 505 | | 520 | |
| 506 | sym = section_ptr_add(stab_section, sizeof(Stab_Sym)); | 521 | sym = section_ptr_add(stab_section, sizeof(Stab_Sym)); |
| @@ -513,16 +528,17 @@ static void put_stabs(TCCState *s1, const char *str, int type, int other, int de · 6 unmodified lines |
| 513 | sym->n_other = other; | 528 | sym->n_other = other; |
| 514 | sym->n_desc = desc; | 529 | sym->n_desc = desc; |
| 515 | sym->n_value = value; | 530 | sym->n_value = value; |
| | 531 | return 1; |
| 516 | } | 532 | } |
| 517 | | 533 | |
| 518 | static void put_stabs_r(TCCState *s1, const char *str, int type, int other, int desc, | 534 | static void put_stabs_r(TCCState *s1, const char *str, int type, int other, int desc, |
| 519 | unsigned long value, Section *sec, int sym_index) | 535 | unsigned long value, Section *sec, int sym_index) |
| 520 | { | 536 | { |
| 521 | put_elf_reloc(symtab_section, stab_section, | 537 | if (put_stabs(s1, str, type, other, desc, value)) |
| 522 | stab_section->data_offset + 8, | 538 | put_elf_reloc(symtab_section, stab_section, |
| 523 | sizeof ((Stab_Sym*)0)->n_value == PTR_SIZE ? R_DATA_PTR : R_DATA_32, | 539 | stab_section->data_offset - 4, |
| 524 | sym_index); | 540 | sizeof ((Stab_Sym*)0)->n_value == PTR_SIZE ? R_DATA_PTR : R_DATA_32, |
| 525 | put_stabs(s1, str, type, other, desc, value); | 541 | sym_index); |
| 526 | } | 542 | } |
| 527 | | 543 | |
| 528 | static void put_stabn(TCCState *s1, int type, int other, int desc, int value) | 544 | static void put_stabn(TCCState *s1, int type, int other, int desc, int value) |