266 lines · plain
1# An example of a function which has been split into two parts. Roughly2# corresponds to this C code.3# int baz() { return 47; }4# int bar() { return foo(0); }5# int foo(int flag) { return flag ? bar() : baz(); }6# int main() { return foo(1); }7# The function bar has been placed "in the middle" of foo. The functions are not8# using the frame pointer register and the are deliberately adjusting the stack9# pointer to test that we're using the correct unwind row.10 11 .text12 13 .type baz,@function14baz:15 .cfi_startproc16 movl $47, %eax17 retq18 .cfi_endproc19.Lbaz_end:20 .size baz, .Lbaz_end-baz21 22foo.__part.3:23 .cfi_startproc24 .cfi_def_cfa_offset 3225 .cfi_offset %rbx, -1626 addq $24, %rsp27 .cfi_def_cfa %rsp, 828 retq29.Lfoo.__part.3_end:30 .size foo.__part.3, .Lfoo.__part.3_end-foo.__part.331 .cfi_endproc32 33# NB: Deliberately inserting padding to separate the two parts of the function34# as we're currently only parsing a single FDE entry from a (coalesced) address35# range.36 nop37 38foo.__part.1:39 .cfi_startproc40 .cfi_def_cfa_offset 3241 .cfi_offset %rbx, -1642 subq $16, %rsp43 .cfi_def_cfa_offset 4844 callq bar45 addq $16, %rsp46 .cfi_def_cfa_offset 3247 jmp foo.__part.348.Lfoo.__part.1_end:49 .size foo.__part.1, .Lfoo.__part.1_end-foo.__part.150 .cfi_endproc51 52bar:53 .cfi_startproc54 subq $88, %rsp55 .cfi_def_cfa_offset 9656 xorl %edi, %edi57 callq foo58 addq $88, %rsp59 .cfi_def_cfa %rsp, 860 retq61 .cfi_endproc62.Lbar_end:63 .size bar, .Lbar_end-bar64 65 .type foo,@function66foo:67 .cfi_startproc68 pushq %rbx69 .cfi_def_cfa_offset 1670 .cfi_offset %rbx, -1671 movl %edi, %ebx72 cmpl $0, %ebx73 je foo.__part.274 subq $16, %rsp75 .cfi_def_cfa_offset 3276 jmp foo.__part.177 .cfi_endproc78.Lfoo_end:79 .size foo, .Lfoo_end-foo80 81# NB: Deliberately inserting padding to separate the two parts of the function82# as we're currently only parsing a single FDE entry from a (coalesced) address83# range.84 nop85 86foo.__part.2:87 .cfi_startproc88 .cfi_def_cfa_offset 1689 .cfi_offset %rbx, -1690 subq $16, %rsp91 .cfi_def_cfa_offset 3292 callq baz93 jmp foo.__part.394.Lfoo.__part.2_end:95 .size foo.__part.2, .Lfoo.__part.2_end-foo.__part.296 .cfi_endproc97 98 .globl main99 .type main,@function100main:101 .cfi_startproc102 movl $1, %edi103 callq foo104 retq105 .cfi_endproc106.Lmain_end:107 .size main, .Lmain_end-main108 109 .section .debug_abbrev,"",@progbits110 .byte 1 # Abbreviation Code111 .byte 17 # DW_TAG_compile_unit112 .byte 1 # DW_CHILDREN_yes113 .byte 37 # DW_AT_producer114 .byte 8 # DW_FORM_string115 .byte 19 # DW_AT_language116 .byte 5 # DW_FORM_data2117 .byte 17 # DW_AT_low_pc118 .byte 1 # DW_FORM_addr119 .byte 85 # DW_AT_ranges120 .byte 35 # DW_FORM_rnglistx121 .byte 116 # DW_AT_rnglists_base122 .byte 23 # DW_FORM_sec_offset123 .byte 0 # EOM(1)124 .byte 0 # EOM(2)125 .byte 2 # Abbreviation Code126 .byte 46 # DW_TAG_subprogram127 .byte 0 # DW_CHILDREN_no128 .byte 17 # DW_AT_low_pc129 .byte 1 # DW_FORM_addr130 .byte 18 # DW_AT_high_pc131 .byte 1 # DW_FORM_addr132 .byte 3 # DW_AT_name133 .byte 8 # DW_FORM_string134 .byte 0 # EOM(1)135 .byte 0 # EOM(2)136 .byte 3 # Abbreviation Code137 .byte 46 # DW_TAG_subprogram138 .byte 1 # DW_CHILDREN_yes139 .byte 85 # DW_AT_ranges140 .byte 35 # DW_FORM_rnglistx141 .byte 64 # DW_AT_frame_base142 .byte 24 # DW_FORM_exprloc143 .byte 3 # DW_AT_name144 .byte 8 # DW_FORM_string145 .byte 0 # EOM(1)146 .byte 0 # EOM(2)147 .byte 4 # Abbreviation Code148 .byte 5 # DW_TAG_formal_parameter149 .byte 0 # DW_CHILDREN_no150 .byte 2 # DW_AT_location151 .byte 24 # DW_FORM_exprloc152 .byte 3 # DW_AT_name153 .byte 8 # DW_FORM_string154 .byte 73 # DW_AT_type155 .byte 19 # DW_FORM_ref4156 .byte 0 # EOM(1)157 .byte 0 # EOM(2)158 .byte 5 # Abbreviation Code159 .byte 36 # DW_TAG_base_type160 .byte 0 # DW_CHILDREN_no161 .byte 3 # DW_AT_name162 .byte 8 # DW_FORM_string163 .byte 62 # DW_AT_encoding164 .byte 11 # DW_FORM_data1165 .byte 11 # DW_AT_byte_size166 .byte 11 # DW_FORM_data1167 .byte 0 # EOM(1)168 .byte 0 # EOM(2)169 .byte 0 # EOM(3)170 171 .section .debug_info,"",@progbits172.Lcu_begin0:173 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit174.Ldebug_info_start0:175 .short 5 # DWARF version number176 .byte 1 # DWARF Unit Type177 .byte 8 # Address Size (in bytes)178 .long .debug_abbrev # Offset Into Abbrev. Section179 .byte 1 # Abbrev [1] DW_TAG_compile_unit180 .asciz "Hand-written DWARF" # DW_AT_producer181 .short 29 # DW_AT_language182 .quad 0 # DW_AT_low_pc183 .byte 1 # DW_AT_ranges184 .long .Lrnglists_table_base0 # DW_AT_rnglists_base185 .byte 2 # Abbrev [2] DW_TAG_subprogram186 .quad baz # DW_AT_low_pc187 .quad .Lbaz_end # DW_AT_high_pc188 .asciz "baz" # DW_AT_name189 .byte 2 # Abbrev [2] DW_TAG_subprogram190 .quad bar # DW_AT_low_pc191 .quad .Lbar_end # DW_AT_high_pc192 .asciz "bar" # DW_AT_name193 .byte 3 # Abbrev [3] DW_TAG_subprogram194 .byte 0 # DW_AT_ranges195 .byte 1 # DW_AT_frame_base196 .byte 86197 .asciz "foo" # DW_AT_name198 .byte 4 # Abbrev [4] DW_TAG_formal_parameter199 .byte 1 # DW_AT_location200 .byte 0x53 # DW_OP_reg3201 .asciz "flag" # DW_AT_name202 .long .Lint-.Lcu_begin0 # DW_AT_type203 .byte 0 # End Of Children Mark204 .byte 2 # Abbrev [2] DW_TAG_subprogram205 .quad main # DW_AT_low_pc206 .quad .Lmain_end # DW_AT_high_pc207 .asciz "main" # DW_AT_name208.Lint:209 .byte 5 # Abbrev [5] DW_TAG_base_type210 .asciz "int" # DW_AT_name211 .byte 5 # DW_AT_encoding212 .byte 4 # DW_AT_byte_size213 .byte 0 # End Of Children Mark214.Ldebug_info_end0:215 216 .section .debug_rnglists,"",@progbits217 .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length218.Ldebug_list_header_start0:219 .short 5 # Version220 .byte 8 # Address size221 .byte 0 # Segment selector size222 .long 2 # Offset entry count223.Lrnglists_table_base0:224 .long .Ldebug_ranges0-.Lrnglists_table_base0225 .long .Ldebug_ranges1-.Lrnglists_table_base0226.Ldebug_ranges0:227 .byte 6 # DW_RLE_start_end228 .quad foo229 .quad .Lfoo_end230 .byte 6 # DW_RLE_start_end231 .quad foo.__part.1232 .quad .Lfoo.__part.1_end233 .byte 6 # DW_RLE_start_end234 .quad foo.__part.2235 .quad .Lfoo.__part.2_end236 .byte 6 # DW_RLE_start_end237 .quad foo.__part.3238 .quad .Lfoo.__part.3_end239 .byte 0 # DW_RLE_end_of_list240.Ldebug_ranges1:241 .byte 6 # DW_RLE_start_end242 .quad baz243 .quad .Lbaz_end244 .byte 6 # DW_RLE_start_end245 .quad bar246 .quad .Lbar_end247 .byte 6 # DW_RLE_start_end248 .quad foo.__part.1249 .quad .Lfoo.__part.1_end250 .byte 6 # DW_RLE_start_end251 .quad foo.__part.2252 .quad .Lfoo.__part.2_end253 .byte 6 # DW_RLE_start_end254 .quad foo.__part.3255 .quad .Lfoo.__part.3_end256 .byte 6 # DW_RLE_start_end257 .quad foo258 .quad .Lfoo_end259 .byte 6 # DW_RLE_start_end260 .quad main261 .quad .Lmain_end262 .byte 0 # DW_RLE_end_of_list263.Ldebug_list_header_end0:264 265 .section ".note.GNU-stack","",@progbits266