Last active
August 29, 2015 14:05
-
-
Save LuminousMonkey/d2ecacc615cb798a8f16 to your computer and use it in GitHub Desktop.
Contrived Activation Record Experiment - Assembly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "activerecords.c" | |
.text | |
.Ltext0: | |
.section .rodata | |
.LC0: | |
.string "outerFunction z: %d\n" | |
.text | |
.globl outerFunction | |
.type outerFunction, @function | |
outerFunction: | |
.LFB0: | |
.file 1 "activerecords.c" | |
.loc 1 3 0 | |
.cfi_startproc | |
pushq %rbp | |
.cfi_def_cfa_offset 16 | |
.cfi_offset 6, -16 | |
movq %rsp, %rbp | |
.cfi_def_cfa_register 6 | |
subq $16, %rsp | |
.loc 1 4 0 | |
movl $88, -4(%rbp) | |
.loc 1 6 0 | |
movl -4(%rbp), %eax | |
movl %eax, %esi | |
movl $.LC0, %edi | |
movl $0, %eax | |
call printf | |
.loc 1 7 0 | |
leave | |
.cfi_def_cfa 7, 8 | |
ret | |
.cfi_endproc | |
.LFE0: | |
.size outerFunction, .-outerFunction | |
.section .rodata | |
.LC1: | |
.string "Inner function z: %d\n" | |
.text | |
.type innerFunction.2206, @function | |
innerFunction.2206: | |
.LFB2: | |
.loc 1 28 0 | |
.cfi_startproc | |
pushq %rbp | |
.cfi_def_cfa_offset 16 | |
.cfi_offset 6, -16 | |
movq %rsp, %rbp | |
.cfi_def_cfa_register 6 | |
movq %r10, %rax | |
.loc 1 29 0 | |
movl (%rax), %eax | |
movl %eax, %esi | |
movl $.LC1, %edi | |
movl $0, %eax | |
call printf | |
.loc 1 30 0 | |
popq %rbp | |
.cfi_def_cfa 7, 8 | |
ret | |
.cfi_endproc | |
.LFE2: | |
.size innerFunction.2206, .-innerFunction.2206 | |
.section .rodata | |
.LC2: | |
.string "main x: %d\n" | |
.LC3: | |
.string "main inner block x: %d\n" | |
.LC4: | |
.string "main inner block y: %d\n" | |
.align 8 | |
.LC5: | |
.string "main inner block x after z added: %d\n" | |
.text | |
.globl main | |
.type main, @function | |
main: | |
.LFB1: | |
.loc 1 9 0 | |
.cfi_startproc | |
pushq %rbp | |
.cfi_def_cfa_offset 16 | |
.cfi_offset 6, -16 | |
movq %rsp, %rbp | |
.cfi_def_cfa_register 6 | |
subq $16, %rsp | |
.loc 1 10 0 | |
movl $11, -4(%rbp) | |
.loc 1 11 0 | |
movl $55, -8(%rbp) | |
.loc 1 13 0 | |
movl -8(%rbp), %eax | |
movl %eax, -16(%rbp) | |
.loc 1 15 0 | |
movl -4(%rbp), %eax | |
movl %eax, %esi | |
movl $.LC2, %edi | |
movl $0, %eax | |
call printf | |
.LBB2: | |
.loc 1 18 0 | |
movl $22, -12(%rbp) | |
.loc 1 19 0 | |
movl -12(%rbp), %eax | |
movl %eax, %esi | |
movl $.LC3, %edi | |
movl $0, %eax | |
call printf | |
.loc 1 20 0 | |
movl -8(%rbp), %eax | |
movl %eax, %esi | |
movl $.LC4, %edi | |
movl $0, %eax | |
call printf | |
.loc 1 21 0 | |
movl -16(%rbp), %eax | |
addl %eax, -12(%rbp) | |
.loc 1 23 0 | |
movl -12(%rbp), %eax | |
movl %eax, %esi | |
movl $.LC5, %edi | |
movl $0, %eax | |
call printf | |
.LBE2: | |
.loc 1 26 0 | |
movl $0, %eax | |
call outerFunction | |
.loc 1 32 0 | |
leaq -16(%rbp), %rax | |
movq %rax, %r10 | |
movl $0, %eax | |
call innerFunction.2206 | |
.loc 1 34 0 | |
movl -4(%rbp), %eax | |
movl %eax, %esi | |
movl $.LC2, %edi | |
movl $0, %eax | |
call printf | |
.loc 1 35 0 | |
movl $0, %eax | |
.loc 1 36 0 | |
leave | |
.cfi_def_cfa 7, 8 | |
ret | |
.cfi_endproc | |
.LFE1: | |
.size main, .-main | |
.Letext0: | |
.section .debug_info,"",@progbits | |
.Ldebug_info0: | |
.long 0x126 | |
.value 0x4 | |
.long .Ldebug_abbrev0 | |
.byte 0x8 | |
.uleb128 0x1 | |
.long .LASF11 | |
.byte 0x1 | |
.long .LASF12 | |
.long .LASF13 | |
.quad .Ltext0 | |
.quad .Letext0-.Ltext0 | |
.long .Ldebug_line0 | |
.uleb128 0x2 | |
.byte 0x8 | |
.byte 0x7 | |
.long .LASF0 | |
.uleb128 0x2 | |
.byte 0x1 | |
.byte 0x8 | |
.long .LASF1 | |
.uleb128 0x2 | |
.byte 0x2 | |
.byte 0x7 | |
.long .LASF2 | |
.uleb128 0x2 | |
.byte 0x4 | |
.byte 0x7 | |
.long .LASF3 | |
.uleb128 0x2 | |
.byte 0x1 | |
.byte 0x6 | |
.long .LASF4 | |
.uleb128 0x2 | |
.byte 0x2 | |
.byte 0x5 | |
.long .LASF5 | |
.uleb128 0x3 | |
.byte 0x4 | |
.byte 0x5 | |
.string "int" | |
.uleb128 0x2 | |
.byte 0x8 | |
.byte 0x5 | |
.long .LASF6 | |
.uleb128 0x2 | |
.byte 0x8 | |
.byte 0x7 | |
.long .LASF7 | |
.uleb128 0x2 | |
.byte 0x1 | |
.byte 0x6 | |
.long .LASF8 | |
.uleb128 0x4 | |
.long .LASF9 | |
.byte 0x1 | |
.byte 0x3 | |
.quad .LFB0 | |
.quad .LFE0-.LFB0 | |
.uleb128 0x1 | |
.byte 0x9c | |
.long 0x9d | |
.uleb128 0x5 | |
.string "z" | |
.byte 0x1 | |
.byte 0x4 | |
.long 0x57 | |
.uleb128 0x2 | |
.byte 0x91 | |
.sleb128 -20 | |
.byte 0 | |
.uleb128 0x6 | |
.long .LASF10 | |
.byte 0x1 | |
.byte 0x9 | |
.long 0x57 | |
.quad .LFB1 | |
.quad .LFE1-.LFB1 | |
.uleb128 0x1 | |
.byte 0x9c | |
.uleb128 0x5 | |
.string "x" | |
.byte 0x1 | |
.byte 0xa | |
.long 0x57 | |
.uleb128 0x2 | |
.byte 0x91 | |
.sleb128 -20 | |
.uleb128 0x5 | |
.string "y" | |
.byte 0x1 | |
.byte 0xb | |
.long 0x57 | |
.uleb128 0x2 | |
.byte 0x91 | |
.sleb128 -24 | |
.uleb128 0x7 | |
.long .LASF14 | |
.byte 0x1 | |
.byte 0x1c | |
.quad .LFB2 | |
.quad .LFE2-.LFB2 | |
.uleb128 0x1 | |
.byte 0x9c | |
.uleb128 0x1 | |
.byte 0x50 | |
.long 0xfe | |
.uleb128 0x5 | |
.string "z" | |
.byte 0x1 | |
.byte 0xd | |
.long 0x57 | |
.uleb128 0x2 | |
.byte 0x70 | |
.sleb128 0 | |
.byte 0 | |
.uleb128 0x5 | |
.string "z" | |
.byte 0x1 | |
.byte 0xd | |
.long 0x57 | |
.uleb128 0x2 | |
.byte 0x91 | |
.sleb128 -32 | |
.uleb128 0x8 | |
.quad .LBB2 | |
.quad .LBE2-.LBB2 | |
.uleb128 0x5 | |
.string "x" | |
.byte 0x1 | |
.byte 0x12 | |
.long 0x57 | |
.uleb128 0x2 | |
.byte 0x91 | |
.sleb128 -28 | |
.byte 0 | |
.byte 0 | |
.byte 0 | |
.section .debug_abbrev,"",@progbits | |
.Ldebug_abbrev0: | |
.uleb128 0x1 | |
.uleb128 0x11 | |
.byte 0x1 | |
.uleb128 0x25 | |
.uleb128 0xe | |
.uleb128 0x13 | |
.uleb128 0xb | |
.uleb128 0x3 | |
.uleb128 0xe | |
.uleb128 0x1b | |
.uleb128 0xe | |
.uleb128 0x11 | |
.uleb128 0x1 | |
.uleb128 0x12 | |
.uleb128 0x7 | |
.uleb128 0x10 | |
.uleb128 0x17 | |
.byte 0 | |
.byte 0 | |
.uleb128 0x2 | |
.uleb128 0x24 | |
.byte 0 | |
.uleb128 0xb | |
.uleb128 0xb | |
.uleb128 0x3e | |
.uleb128 0xb | |
.uleb128 0x3 | |
.uleb128 0xe | |
.byte 0 | |
.byte 0 | |
.uleb128 0x3 | |
.uleb128 0x24 | |
.byte 0 | |
.uleb128 0xb | |
.uleb128 0xb | |
.uleb128 0x3e | |
.uleb128 0xb | |
.uleb128 0x3 | |
.uleb128 0x8 | |
.byte 0 | |
.byte 0 | |
.uleb128 0x4 | |
.uleb128 0x2e | |
.byte 0x1 | |
.uleb128 0x3f | |
.uleb128 0x19 | |
.uleb128 0x3 | |
.uleb128 0xe | |
.uleb128 0x3a | |
.uleb128 0xb | |
.uleb128 0x3b | |
.uleb128 0xb | |
.uleb128 0x11 | |
.uleb128 0x1 | |
.uleb128 0x12 | |
.uleb128 0x7 | |
.uleb128 0x40 | |
.uleb128 0x18 | |
.uleb128 0x2116 | |
.uleb128 0x19 | |
.uleb128 0x1 | |
.uleb128 0x13 | |
.byte 0 | |
.byte 0 | |
.uleb128 0x5 | |
.uleb128 0x34 | |
.byte 0 | |
.uleb128 0x3 | |
.uleb128 0x8 | |
.uleb128 0x3a | |
.uleb128 0xb | |
.uleb128 0x3b | |
.uleb128 0xb | |
.uleb128 0x49 | |
.uleb128 0x13 | |
.uleb128 0x2 | |
.uleb128 0x18 | |
.byte 0 | |
.byte 0 | |
.uleb128 0x6 | |
.uleb128 0x2e | |
.byte 0x1 | |
.uleb128 0x3f | |
.uleb128 0x19 | |
.uleb128 0x3 | |
.uleb128 0xe | |
.uleb128 0x3a | |
.uleb128 0xb | |
.uleb128 0x3b | |
.uleb128 0xb | |
.uleb128 0x49 | |
.uleb128 0x13 | |
.uleb128 0x11 | |
.uleb128 0x1 | |
.uleb128 0x12 | |
.uleb128 0x7 | |
.uleb128 0x40 | |
.uleb128 0x18 | |
.uleb128 0x2116 | |
.uleb128 0x19 | |
.byte 0 | |
.byte 0 | |
.uleb128 0x7 | |
.uleb128 0x2e | |
.byte 0x1 | |
.uleb128 0x3 | |
.uleb128 0xe | |
.uleb128 0x3a | |
.uleb128 0xb | |
.uleb128 0x3b | |
.uleb128 0xb | |
.uleb128 0x11 | |
.uleb128 0x1 | |
.uleb128 0x12 | |
.uleb128 0x7 | |
.uleb128 0x40 | |
.uleb128 0x18 | |
.uleb128 0x48 | |
.uleb128 0x18 | |
.uleb128 0x2116 | |
.uleb128 0x19 | |
.uleb128 0x1 | |
.uleb128 0x13 | |
.byte 0 | |
.byte 0 | |
.uleb128 0x8 | |
.uleb128 0xb | |
.byte 0x1 | |
.uleb128 0x11 | |
.uleb128 0x1 | |
.uleb128 0x12 | |
.uleb128 0x7 | |
.byte 0 | |
.byte 0 | |
.byte 0 | |
.section .debug_aranges,"",@progbits | |
.long 0x2c | |
.value 0x2 | |
.long .Ldebug_info0 | |
.byte 0x8 | |
.byte 0 | |
.value 0 | |
.value 0 | |
.quad .Ltext0 | |
.quad .Letext0-.Ltext0 | |
.quad 0 | |
.quad 0 | |
.section .debug_line,"",@progbits | |
.Ldebug_line0: | |
.section .debug_str,"MS",@progbits,1 | |
.LASF3: | |
.string "unsigned int" | |
.LASF0: | |
.string "long unsigned int" | |
.LASF11: | |
.string "GNU C 4.9.1 -mtune=generic -march=x86-64 -g" | |
.LASF8: | |
.string "char" | |
.LASF12: | |
.string "activerecords.c" | |
.LASF1: | |
.string "unsigned char" | |
.LASF9: | |
.string "outerFunction" | |
.LASF10: | |
.string "main" | |
.LASF6: | |
.string "long int" | |
.LASF2: | |
.string "short unsigned int" | |
.LASF4: | |
.string "signed char" | |
.LASF14: | |
.string "innerFunction" | |
.LASF13: | |
.string "/home/aldredmr/Dropbox/Blog" | |
.LASF5: | |
.string "short int" | |
.LASF7: | |
.string "sizetype" | |
.ident "GCC: (GNU) 4.9.1" | |
.section .note.GNU-stack,"",@progbits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment