Skip to content

Instantly share code, notes, and snippets.

@Manu343726
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Manu343726/6ea94a10330fc3554bb5 to your computer and use it in GitHub Desktop.
Save Manu343726/6ea94a10330fc3554bb5 to your computer and use it in GitHub Desktop.
ctti example 1
g++ main.cpp -o ctti.s -S -O3 -Wno-unused-value -ftemplate-depth=2048 -DCTTI_MAX_STRING_LENGTH=128
.file "main.cpp"
.section .rodata.str1.1,"aMS",@progbits,1
.LC3:
.string "\n"
.section .text.unlikely,"ax",@progbits
.LCOLDB4:
.section .text.startup,"ax",@progbits
.LHOTB4:
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB1828:
.cfi_startproc
subq $328, %rsp
.cfi_def_cfa_offset 336
movabsq $-3750763034362895579, %rax
movabsq $109951162821, %rdi
leaq 34(%rsp), %rsi
movb $109, (%rsp)
movb $97, 1(%rsp)
movb $105, 2(%rsp)
movb $110, 3(%rsp)
movq %rsp, %rdx
movb $40, 4(%rsp)
movb $41, 5(%rsp)
movb $58, 6(%rsp)
movb $58, 7(%rsp)
movb $70, 8(%rsp)
movb $73, 9(%rsp)
movb $78, 10(%rsp)
movb $68, 11(%rsp)
movb $95, 12(%rsp)
movb $77, 13(%rsp)
movb $69, 14(%rsp)
movb $95, 15(%rsp)
movb $73, 16(%rsp)
movb $78, 17(%rsp)
movb $95, 18(%rsp)
movb $84, 19(%rsp)
movb $72, 20(%rsp)
movb $69, 21(%rsp)
movb $95, 22(%rsp)
movb $68, 23(%rsp)
movb $73, 24(%rsp)
movb $83, 25(%rsp)
movb $65, 26(%rsp)
movb $83, 27(%rsp)
movb $83, 28(%rsp)
movb $69, 29(%rsp)
movb $77, 30(%rsp)
movb $66, 31(%rsp)
movb $76, 32(%rsp)
movb $89, 33(%rsp)
.p2align 4,,10
.p2align 3
.L2:
movsbq (%rdx), %rcx
addq $1, %rdx
xorq %rcx, %rax
imulq %rdi, %rax
cmpq %rsi, %rdx
jne .L2
movdqa .LC0(%rip), %xmm0
leaq 48(%rsp), %rsi
movl std::cout, %edi
movq $34, 304(%rsp)
movq %rax, 312(%rsp)
movaps %xmm0, 48(%rsp)
movdqa .LC1(%rip), %xmm0
movaps %xmm0, 64(%rsp)
movdqa .LC2(%rip), %xmm0
movaps %xmm0, 80(%rsp)
pxor %xmm0, %xmm0
movaps %xmm0, 96(%rsp)
movaps %xmm0, 112(%rsp)
movaps %xmm0, 128(%rsp)
movaps %xmm0, 144(%rsp)
movaps %xmm0, 160(%rsp)
movaps %xmm0, 176(%rsp)
movaps %xmm0, 192(%rsp)
movaps %xmm0, 208(%rsp)
movaps %xmm0, 224(%rsp)
movaps %xmm0, 240(%rsp)
movaps %xmm0, 256(%rsp)
movaps %xmm0, 272(%rsp)
movaps %xmm0, 288(%rsp)
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
movl $.LC3, %esi
movq %rax, %rdi
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
xorl %eax, %eax
addq $328, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE1828:
.size main, .-main
.section .text.unlikely
.LCOLDE4:
.section .text.startup
.LHOTE4:
.section .text.unlikely
.LCOLDB5:
.section .text.startup
.LHOTB5:
.p2align 4,,15
.type _GLOBAL__sub_I_main, @function
_GLOBAL__sub_I_main:
.LFB2138:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
movl std::__ioinit, %edi
call std::ios_base::Init::Init()
movl $__dso_handle, %edx
movl std::__ioinit, %esi
movl std::ios_base::Init::~Init(), %edi
addq $8, %rsp
.cfi_def_cfa_offset 8
jmp __cxa_atexit
.cfi_endproc
.LFE2138:
.size _GLOBAL__sub_I_main, .-_GLOBAL__sub_I_main
.section .text.unlikely
.LCOLDE5:
.section .text.startup
.LHOTE5:
.section .init_array,"aw"
.align 8
.quad _GLOBAL__sub_I_main
.local std::__ioinit
.comm std::__ioinit,1,1
.section .rodata.cst16,"aM",@progbits,16
.align 16
.LC0:
.byte 109
.byte 97
.byte 105
.byte 110
.byte 40
.byte 41
.byte 58
.byte 58
.byte 70
.byte 73
.byte 78
.byte 68
.byte 95
.byte 77
.byte 69
.byte 95
.align 16
.LC1:
.byte 73
.byte 78
.byte 95
.byte 84
.byte 72
.byte 69
.byte 95
.byte 68
.byte 73
.byte 83
.byte 65
.byte 83
.byte 83
.byte 69
.byte 77
.byte 66
.align 16
.LC2:
.byte 76
.byte 89
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.hidden __dso_handle
.ident "GCC: (GNU) 5.2.0"
.section .note.GNU-stack,"",@progbits
#include "type_id.hpp"
#include <iostream>
int main()
{
std::cout << ctti::type_id<struct FIND_ME_IN_THE_DISASSEMBLY>().name().c_str() << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment