|
| 1 | +## Test disassembling of functions which are spread over multiple sections (ELF |
| 2 | +## segments are modelled as LLDB sections). |
| 3 | + |
| 4 | + |
| 5 | +# REQUIRES: x86, lld |
| 6 | + |
| 7 | +# RUN: split-file %s %t |
| 8 | +# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %t/file.s -o %t/file.o |
| 9 | +# RUN: ld.lld %t/file.o -o %t/file.out -T %t/file.lds |
| 10 | +# RUN: %lldb %t/file.out -o "disassemble --name func1" -o exit | FileCheck %s |
| 11 | + |
| 12 | +# CHECK: (lldb) disassemble --name func1 |
| 13 | +# CHECK: file.out`func1: |
| 14 | +# CHECK-NEXT: file.out[0x0] <+0>: int $0x2a |
| 15 | +# CHECK: file.out`func1: |
| 16 | +# CHECK-NEXT: file.out[0x1000] <+4096>: int $0x2f |
| 17 | + |
| 18 | + |
| 19 | +#--- file.lds |
| 20 | +## Linker script placing the parts of the section into different segments |
| 21 | +## (typically one of these would be for the "hot" code). |
| 22 | +PHDRS { |
| 23 | + text1 PT_LOAD; |
| 24 | + text2 PT_LOAD; |
| 25 | +} |
| 26 | +SECTIONS { |
| 27 | + . = 0; |
| 28 | + .text.part1 : { *(.text.part1) } :text1 |
| 29 | + .text.part2 : { *(.text.part2) } :text2 |
| 30 | +} |
| 31 | + |
| 32 | +#--- file.s |
| 33 | +## A very simple function consisting of two parts and DWARF describing the |
| 34 | +## function. |
| 35 | + .section .text.part1,"ax",@progbits |
| 36 | + .p2align 12 |
| 37 | +func1: |
| 38 | + int $42 |
| 39 | +.Lfunc1_end: |
| 40 | + |
| 41 | + .section .text.part2,"ax",@progbits |
| 42 | + .p2align 12 |
| 43 | +func1.__part.1: |
| 44 | + int $47 |
| 45 | +.Lfunc1.__part.1_end: |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + .section .debug_abbrev,"",@progbits |
| 50 | + .byte 1 # Abbreviation Code |
| 51 | + .byte 17 # DW_TAG_compile_unit |
| 52 | + .byte 1 # DW_CHILDREN_yes |
| 53 | + .byte 37 # DW_AT_producer |
| 54 | + .byte 8 # DW_FORM_string |
| 55 | + .byte 19 # DW_AT_language |
| 56 | + .byte 5 # DW_FORM_data2 |
| 57 | + .byte 17 # DW_AT_low_pc |
| 58 | + .byte 1 # DW_FORM_addr |
| 59 | + .byte 85 # DW_AT_ranges |
| 60 | + .byte 23 # DW_FORM_sec_offset |
| 61 | + .byte 0 # EOM(1) |
| 62 | + .byte 0 # EOM(2) |
| 63 | + .byte 2 # Abbreviation Code |
| 64 | + .byte 46 # DW_TAG_subprogram |
| 65 | + .byte 0 # DW_CHILDREN_no |
| 66 | + .byte 85 # DW_AT_ranges |
| 67 | + .byte 23 # DW_FORM_sec_offset |
| 68 | + .byte 3 # DW_AT_name |
| 69 | + .byte 8 # DW_FORM_string |
| 70 | + .byte 0 # EOM(1) |
| 71 | + .byte 0 # EOM(2) |
| 72 | + .byte 0 # EOM(3) |
| 73 | + |
| 74 | + .section .debug_info,"",@progbits |
| 75 | +.Lcu_begin0: |
| 76 | + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit |
| 77 | +.Ldebug_info_start0: |
| 78 | + .short 5 # DWARF version number |
| 79 | + .byte 1 # DWARF Unit Type |
| 80 | + .byte 8 # Address Size (in bytes) |
| 81 | + .long .debug_abbrev # Offset Into Abbrev. Section |
| 82 | + .byte 1 # Abbrev DW_TAG_compile_unit |
| 83 | + .asciz "Hand-written DWARF" # DW_AT_producer |
| 84 | + .short 29 # DW_AT_language |
| 85 | + .quad 0 # DW_AT_low_pc |
| 86 | + .long .Ldebug_ranges0 # DW_AT_ranges |
| 87 | + .byte 2 # Abbrev DW_TAG_subprogram |
| 88 | + .long .Ldebug_ranges0 # DW_AT_ranges |
| 89 | + .asciz "func1" # DW_AT_name |
| 90 | + .byte 0 # End Of Children Mark |
| 91 | +.Ldebug_info_end0: |
| 92 | + |
| 93 | + .section .debug_rnglists,"",@progbits |
| 94 | + .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length |
| 95 | +.Ldebug_list_header_start0: |
| 96 | + .short 5 # Version |
| 97 | + .byte 8 # Address size |
| 98 | + .byte 0 # Segment selector size |
| 99 | + .long 1 # Offset entry count |
| 100 | +.Lrnglists_table_base0: |
| 101 | + .long .Ldebug_ranges0-.Lrnglists_table_base0 |
| 102 | +.Ldebug_ranges0: |
| 103 | + .byte 6 # DW_RLE_start_end |
| 104 | + .quad func1 |
| 105 | + .quad .Lfunc1_end |
| 106 | + .byte 6 # DW_RLE_start_end |
| 107 | + .quad func1.__part.1 |
| 108 | + .quad .Lfunc1.__part.1_end |
| 109 | + .byte 0 # DW_RLE_end_of_list |
| 110 | +.Ldebug_list_header_end0: |
0 commit comments