| @@ -431,7 +431,7 @@ struct _tccdbg { · 430 unmodified lines |
| 431 | 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 | 435 | int desc, unsigned long value); |
| 436 | 436 | |
| 437 | 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 | 449 | #endif |
| 450 | 450 | |
| 451 | 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 | 465 | s1->dwlo = s1->nb_sections; |
| 453 | 466 | dwarf_info_section = |
| 454 | 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 | 471 | new_section(s1, ".debug_line", SHT_PROGBITS, shf); |
| 459 | 472 | dwarf_aranges_section = |
| 460 | 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 | 476 | shf |= SHF_MERGE | SHF_STRINGS; |
| 462 | 477 | dwarf_str_section = |
| 463 | 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 | 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 | 506 | unsigned long value) |
| 492 | 507 | { |
| 493 | 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 | 515 | && sym->n_value == value) { |
| 501 | 516 | /* just update line_number in previous entry */ |
| 502 | 517 | sym->n_desc = desc; |
| 503 | | − return; |
| 518 | + return 0; |
| 504 | 519 | } |
| 505 | 520 | |
| 506 | 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 | 528 | sym->n_other = other; |
| 514 | 529 | sym->n_desc = desc; |
| 515 | 530 | sym->n_value = value; |
| 531 | + return 1; |
| 516 | 532 | } |
| 517 | 533 | |
| 518 | 534 | static void put_stabs_r(TCCState *s1, const char *str, int type, int other, int desc, |
| 519 | 535 | unsigned long value, Section *sec, int sym_index) |
| 520 | 536 | { |
| 521 | | − put_elf_reloc(symtab_section, stab_section, |
| 522 | | − stab_section->data_offset + 8, |
| 523 | | − sizeof ((Stab_Sym*)0)->n_value == PTR_SIZE ? R_DATA_PTR : R_DATA_32, |
| 524 | | − sym_index); |
| 525 | | − put_stabs(s1, str, type, other, desc, value); |
| 537 | + if (put_stabs(s1, str, type, other, desc, value)) |
| 538 | + put_elf_reloc(symtab_section, stab_section, |
| 539 | + stab_section->data_offset - 4, |
| 540 | + sizeof ((Stab_Sym*)0)->n_value == PTR_SIZE ? R_DATA_PTR : R_DATA_32, |
| 541 | + sym_index); |
| 526 | 542 | } |
| 527 | 543 | |
| 528 | 544 | static void put_stabn(TCCState *s1, int type, int other, int desc, int value) |