* Build the set of labels. */
| 625 | * Build the set of labels. |
| 626 | */ |
| 627 | static intptr_t buildLabelSet(const Binary *B, const Trampoline *T, |
| 628 | const Instr *I, intptr_t addr, bool last, BreakInfo &breaks, |
| 629 | LabelSet &labels) |
| 630 | { |
| 631 | for (unsigned i = 0; i < T->num_entries; i++) |
| 632 | { |
| 633 | const Entry &entry = T->entries[i]; |
| 634 | switch (entry.kind) |
| 635 | { |
| 636 | case ENTRY_DEBUG: |
| 637 | addr += (I != nullptr && I->debug? /*sizeof(int3)=*/1: 0); |
| 638 | case ENTRY_BYTES: |
| 639 | case ENTRY_ZEROES: |
| 640 | addr += entry.length; |
| 641 | continue; |
| 642 | case ENTRY_INT8: |
| 643 | addr += sizeof(uint8_t); |
| 644 | continue; |
| 645 | case ENTRY_INT16: |
| 646 | addr += sizeof(uint16_t); |
| 647 | continue; |
| 648 | case ENTRY_INT32: |
| 649 | addr += sizeof(uint32_t); |
| 650 | continue; |
| 651 | case ENTRY_INT64: |
| 652 | addr += sizeof(uint64_t); |
| 653 | continue; |
| 654 | case ENTRY_LABEL: |
| 655 | { |
| 656 | Label L(I, entry.label); |
| 657 | auto i = labels.insert(std::make_pair(L, addr)); |
| 658 | if (!i.second) |
| 659 | error("failed to build trampoline; duplicate label " |
| 660 | "\"%s\"", entry.label); |
| 661 | continue; |
| 662 | } |
| 663 | case ENTRY_MACRO: |
| 664 | { |
| 665 | const Trampoline *U = expandMacro(B, I->metadata, entry.macro); |
| 666 | if (U == nullptr) |
| 667 | error("failed to build trampoline; metadata for macro " |
| 668 | "\"%s\" is missing", entry.macro); |
| 669 | addr = buildLabelSet(B, U, I, addr, last, breaks, labels); |
| 670 | continue; |
| 671 | } |
| 672 | case ENTRY_REL8: |
| 673 | addr += sizeof(int8_t); |
| 674 | continue; |
| 675 | case ENTRY_REL32: |
| 676 | addr += sizeof(int32_t); |
| 677 | continue; |
| 678 | case ENTRY_INSTR: |
| 679 | addr += relocateInstr(I, addr); |
| 680 | continue; |
| 681 | case ENTRY_INSTR_BYTES: |
| 682 | addr += I->size; |
| 683 | continue; |
| 684 | case ENTRY_BREAK: |
no test coverage detected