|
| 1 | +; The assembly below corresponds to this program: |
| 2 | +; __attribute__((nodebug)) |
| 3 | +; int foo() { |
| 4 | +; return 10; |
| 5 | +; } |
| 6 | +; int main(int argc, char **argv) { |
| 7 | +; foo(); |
| 8 | +; return 0; |
| 9 | +; } |
| 10 | +; |
| 11 | +; The assembly was edited in two places (search for "EDIT"): |
| 12 | +; 1. A "orr x29, x29, #0x1000000000000000" instruction was added in foo. This |
| 13 | +; effectively changes the CFA value of the frame above foo (i.e. main). |
| 14 | +; 2. In main, the DWARF location of `argv` was changed to DW_AT_call_frame_cfa. |
| 15 | +; |
| 16 | +; This allows us to stop in foo, go to frame 1 (main) and do `v &argv`, |
| 17 | +; obtaining the result of evaluating DW_AT_call_frame_cfa. |
| 18 | + |
| 19 | + .section __TEXT,__text,regular,pure_instructions |
| 20 | + .globl _foo ; -- Begin function foo |
| 21 | + .p2align 2 |
| 22 | +_foo: ; @foo |
| 23 | +Lfunc_begin0: |
| 24 | + .cfi_startproc |
| 25 | + orr x29, x29, #0x1000000000000000 ; EDIT: Set top byte of fp. |
| 26 | + stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill |
| 27 | + mov x29, sp |
| 28 | + .cfi_def_cfa w29, 16 |
| 29 | + .cfi_offset w30, -8 |
| 30 | + .cfi_offset w29, -16 |
| 31 | + mov w0, #10 ; =0xa |
| 32 | + ldp x29, x30, [sp], #16 ; 16-byte Folded Reload |
| 33 | + ret |
| 34 | +Lfunc_end0: |
| 35 | + .cfi_endproc |
| 36 | + ; -- End function |
| 37 | + .globl _main ; -- Begin function main |
| 38 | + .p2align 2 |
| 39 | +_main: ; @main |
| 40 | +Lfunc_begin1: |
| 41 | + .file 1 "/test" "test.c" |
| 42 | + .loc 1 6 0 ; test.c:6:0 |
| 43 | + .cfi_startproc |
| 44 | + sub sp, sp, #48 |
| 45 | + stp x29, x30, [sp, #32] ; 16-byte Folded Spill |
| 46 | + add x29, sp, #32 |
| 47 | + .cfi_def_cfa w29, 16 |
| 48 | + .cfi_offset w30, -8 |
| 49 | + .cfi_offset w29, -16 |
| 50 | + mov w8, #0 ; =0x0 |
| 51 | + str w8, [sp, #12] ; 4-byte Folded Spill |
| 52 | + stur wzr, [x29, #-4] |
| 53 | + stur w0, [x29, #-8] |
| 54 | + str x1, [sp, #16] |
| 55 | +Ltmp0: |
| 56 | + bl _foo |
| 57 | + ldr w0, [sp, #12] ; 4-byte Folded Reload |
| 58 | + ldp x29, x30, [sp, #32] ; 16-byte Folded Reload |
| 59 | + add sp, sp, #48 |
| 60 | + ret |
| 61 | +Ltmp1: |
| 62 | +Lfunc_end1: |
| 63 | + .cfi_endproc |
| 64 | + ; -- End function |
| 65 | + .section __DWARF,__debug_abbrev,regular,debug |
| 66 | +Lsection_abbrev: |
| 67 | + .byte 1 ; Abbreviation Code |
| 68 | + .byte 17 ; DW_TAG_compile_unit |
| 69 | + .byte 1 ; DW_CHILDREN_yes |
| 70 | + .byte 37 ; DW_AT_producer |
| 71 | + .byte 14 ; DW_FORM_strp |
| 72 | + .byte 19 ; DW_AT_language |
| 73 | + .byte 5 ; DW_FORM_data2 |
| 74 | + .byte 3 ; DW_AT_name |
| 75 | + .byte 14 ; DW_FORM_strp |
| 76 | + .ascii "\202|" ; DW_AT_LLVM_sysroot |
| 77 | + .byte 14 ; DW_FORM_strp |
| 78 | + .ascii "\357\177" ; DW_AT_APPLE_sdk |
| 79 | + .byte 14 ; DW_FORM_strp |
| 80 | + .byte 16 ; DW_AT_stmt_list |
| 81 | + .byte 23 ; DW_FORM_sec_offset |
| 82 | + .byte 27 ; DW_AT_comp_dir |
| 83 | + .byte 14 ; DW_FORM_strp |
| 84 | + .byte 17 ; DW_AT_low_pc |
| 85 | + .byte 1 ; DW_FORM_addr |
| 86 | + .byte 18 ; DW_AT_high_pc |
| 87 | + .byte 6 ; DW_FORM_data4 |
| 88 | + .byte 0 ; EOM(1) |
| 89 | + .byte 0 ; EOM(2) |
| 90 | + .byte 2 ; Abbreviation Code |
| 91 | + .byte 46 ; DW_TAG_subprogram |
| 92 | + .byte 1 ; DW_CHILDREN_yes |
| 93 | + .byte 17 ; DW_AT_low_pc |
| 94 | + .byte 1 ; DW_FORM_addr |
| 95 | + .byte 18 ; DW_AT_high_pc |
| 96 | + .byte 6 ; DW_FORM_data4 |
| 97 | + .byte 64 ; DW_AT_frame_base |
| 98 | + .byte 24 ; DW_FORM_exprloc |
| 99 | + .byte 3 ; DW_AT_name |
| 100 | + .byte 14 ; DW_FORM_strp |
| 101 | + .byte 58 ; DW_AT_decl_file |
| 102 | + .byte 11 ; DW_FORM_data1 |
| 103 | + .byte 59 ; DW_AT_decl_line |
| 104 | + .byte 11 ; DW_FORM_data1 |
| 105 | + .byte 39 ; DW_AT_prototyped |
| 106 | + .byte 25 ; DW_FORM_flag_present |
| 107 | + .byte 73 ; DW_AT_type |
| 108 | + .byte 19 ; DW_FORM_ref4 |
| 109 | + .byte 63 ; DW_AT_external |
| 110 | + .byte 25 ; DW_FORM_flag_present |
| 111 | + .byte 0 ; EOM(1) |
| 112 | + .byte 0 ; EOM(2) |
| 113 | + .byte 3 ; Abbreviation Code |
| 114 | + .byte 5 ; DW_TAG_formal_parameter |
| 115 | + .byte 0 ; DW_CHILDREN_no |
| 116 | + .byte 2 ; DW_AT_location |
| 117 | + .byte 24 ; DW_FORM_exprloc |
| 118 | + .byte 3 ; DW_AT_name |
| 119 | + .byte 14 ; DW_FORM_strp |
| 120 | + .byte 58 ; DW_AT_decl_file |
| 121 | + .byte 11 ; DW_FORM_data1 |
| 122 | + .byte 59 ; DW_AT_decl_line |
| 123 | + .byte 11 ; DW_FORM_data1 |
| 124 | + .byte 73 ; DW_AT_type |
| 125 | + .byte 19 ; DW_FORM_ref4 |
| 126 | + .byte 0 ; EOM(1) |
| 127 | + .byte 0 ; EOM(2) |
| 128 | + .byte 4 ; Abbreviation Code |
| 129 | + .byte 36 ; DW_TAG_base_type |
| 130 | + .byte 0 ; DW_CHILDREN_no |
| 131 | + .byte 3 ; DW_AT_name |
| 132 | + .byte 14 ; DW_FORM_strp |
| 133 | + .byte 62 ; DW_AT_encoding |
| 134 | + .byte 11 ; DW_FORM_data1 |
| 135 | + .byte 11 ; DW_AT_byte_size |
| 136 | + .byte 11 ; DW_FORM_data1 |
| 137 | + .byte 0 ; EOM(1) |
| 138 | + .byte 0 ; EOM(2) |
| 139 | + .byte 5 ; Abbreviation Code |
| 140 | + .byte 15 ; DW_TAG_pointer_type |
| 141 | + .byte 0 ; DW_CHILDREN_no |
| 142 | + .byte 73 ; DW_AT_type |
| 143 | + .byte 19 ; DW_FORM_ref4 |
| 144 | + .byte 0 ; EOM(1) |
| 145 | + .byte 0 ; EOM(2) |
| 146 | + .byte 0 ; EOM(3) |
| 147 | + .section __DWARF,__debug_info,regular,debug |
| 148 | +Lsection_info: |
| 149 | +Lcu_begin0: |
| 150 | +.set Lset0, Ldebug_info_end0-Ldebug_info_start0 ; Length of Unit |
| 151 | + .long Lset0 |
| 152 | +Ldebug_info_start0: |
| 153 | + .short 4 ; DWARF version number |
| 154 | +.set Lset1, Lsection_abbrev-Lsection_abbrev ; Offset Into Abbrev. Section |
| 155 | + .long Lset1 |
| 156 | + .byte 8 ; Address Size (in bytes) |
| 157 | + .byte 1 ; Abbrev [1] 0xb:0x76 DW_TAG_compile_unit |
| 158 | + .long 0 ; DW_AT_producer |
| 159 | + .short 12 ; DW_AT_language |
| 160 | + .long 47 ; DW_AT_name |
| 161 | + .long 54 ; DW_AT_LLVM_sysroot |
| 162 | + .long 165 ; DW_AT_APPLE_sdk |
| 163 | +.set Lset2, Lline_table_start0-Lsection_line ; DW_AT_stmt_list |
| 164 | + .long Lset2 |
| 165 | + .long 180 ; DW_AT_comp_dir |
| 166 | + .quad Lfunc_begin1 ; DW_AT_low_pc |
| 167 | +.set Lset3, Lfunc_end1-Lfunc_begin1 ; DW_AT_high_pc |
| 168 | + .long Lset3 |
| 169 | + .byte 2 ; Abbrev [2] 0x32:0x36 DW_TAG_subprogram |
| 170 | + .quad Lfunc_begin1 ; DW_AT_low_pc |
| 171 | +.set Lset4, Lfunc_end1-Lfunc_begin1 ; DW_AT_high_pc |
| 172 | + .long Lset4 |
| 173 | + .byte 1 ; DW_AT_frame_base |
| 174 | + .byte 109 |
| 175 | + .long 247 ; DW_AT_name |
| 176 | + .byte 1 ; DW_AT_decl_file |
| 177 | + .byte 6 ; DW_AT_decl_line |
| 178 | + ; DW_AT_prototyped |
| 179 | + .long 107 ; DW_AT_type |
| 180 | + ; DW_AT_external |
| 181 | + .byte 3 ; Abbrev [3] 0x4b:0xe DW_TAG_formal_parameter |
| 182 | + .byte 2 ; DW_AT_location |
| 183 | + .byte 145 |
| 184 | + .byte 120 |
| 185 | + .long 256 ; DW_AT_name |
| 186 | + .byte 1 ; DW_AT_decl_file |
| 187 | + .byte 6 ; DW_AT_decl_line |
| 188 | + .long 103 ; DW_AT_type |
| 189 | + .byte 3 ; Abbrev [3] 0x59:0xe DW_TAG_formal_parameter |
| 190 | + .byte 1 ; DW_AT_location |
| 191 | + .byte 0x9c ; EDIT: DW_AT_call_frame_cfa |
| 192 | + .long 261 ; DW_AT_name |
| 193 | + .byte 1 ; DW_AT_decl_file |
| 194 | + .byte 6 ; DW_AT_decl_line |
| 195 | + .long 110 ; DW_AT_type |
| 196 | + .byte 0 ; End Of Children Mark |
| 197 | + .byte 4 ; Abbrev [4] 0x68:0x7 DW_TAG_base_type |
| 198 | + .long 252 ; DW_AT_name |
| 199 | + .byte 5 ; DW_AT_encoding |
| 200 | + .byte 4 ; DW_AT_byte_size |
| 201 | + .byte 5 ; Abbrev [5] 0x6f:0x5 DW_TAG_pointer_type |
| 202 | + .long 115 ; DW_AT_type |
| 203 | + .byte 5 ; Abbrev [5] 0x74:0x5 DW_TAG_pointer_type |
| 204 | + .long 120 ; DW_AT_type |
| 205 | + .byte 4 ; Abbrev [4] 0x79:0x7 DW_TAG_base_type |
| 206 | + .long 266 ; DW_AT_name |
| 207 | + .byte 6 ; DW_AT_encoding |
| 208 | + .byte 1 ; DW_AT_byte_size |
| 209 | + .byte 0 ; End Of Children Mark |
| 210 | +Ldebug_info_end0: |
| 211 | + .section __DWARF,__debug_str,regular,debug |
| 212 | +Linfo_string: |
| 213 | + .asciz "Apple clang " ; string offset=0 |
| 214 | + .asciz "test.c" ; string offset=47 |
| 215 | + .asciz "/Applications/Xcode..........................................................................................." ; string offset=54 |
| 216 | + .asciz ".............." ; string offset=165 |
| 217 | + .asciz "......................................................../llvm_src1" ; string offset=180 |
| 218 | + .asciz "main" ; string offset=247 |
| 219 | + .asciz "int" ; string offset=252 |
| 220 | + .asciz "argc" ; string offset=256 |
| 221 | + .asciz "argv" ; string offset=261 |
| 222 | + .asciz "char" ; string offset=266 |
| 223 | +.subsections_via_symbols |
| 224 | + .section __DWARF,__debug_line,regular,debug |
| 225 | +Lsection_line: |
| 226 | +Lline_table_start0: |
0 commit comments