I have the following test program to examine the code generated by GCC. rotlFixed
is provided in the header misc.h
, and its declared as inline. It also uses a template specialization to invoke GCC inline assembly:
int main(int argc, char* argv[])
{
byte r1 = rotlFixed(1, 1);
byte r2 = rotlFixed(1, 255);
word16 r3 = rotlFixed(1, 1);
word16 r4 = rotlFixed(1, 255);
word16 r5 = rotlFixed(1, 256);
word16 r6 = rotlFixed(1, 65535);
cout << r1 << "," << r2 << "," << r3 << "," << r4 << ",";
cout << r5 << "," << r6 << endl;
return 0;
}
According to How to get GCC to generate assembly code, I compiled the source file with:
g++ -O1 -S -c cryptopp-test.cxx
But when I cat, I don't see the call to the rotates:
$ cat cryptopp-test.s
.file "cryptopp-test.cxx"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "misc.h"
.LC1:
.string "y < THIS_SIZE"
.text
.globl main
.type main, @function
main:
.LFB2196:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
movl $_ZZN8CryptoPP9rotlFixedIiEET_S1_jE19__PRETTY_FUNCTION__, %ecx
movl $692, %edx
movl $.LC0, %esi
movl $.LC1, %edi
call __assert_fail
.cfi_endproc
.LFE2196:
.size main, .-main
.type _GLOBAL__sub_I_main, @function
_GLOBAL__sub_I_main:
.LFB2311:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
movl $_ZStL8__ioinit, %edi
call _ZNSt8ios_base4InitC1Ev
movl $__dso_handle, %edx
movl $_ZStL8__ioinit, %esi
movl $_ZNSt8ios_base4InitD1Ev, %edi
call __cxa_atexit
addq $8, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE2311:
.size _GLOBAL__sub_I_main, .-_GLOBAL__sub_I_main
.section .init_array,"aw"
.align 8
.quad _GLOBAL__sub_I_main
.section .rodata
.align 32
.type _ZZN8CryptoPP9rotlFixedIiEET_S1_jE19__PRETTY_FUNCTION__, @object
.size _ZZN8CryptoPP9rotlFixedIiEET_S1_jE19__PRETTY_FUNCTION__, 54
_ZZN8CryptoPP9rotlFixedIiEET_S1_jE19__PRETTY_FUNCTION__:
.string "T CryptoPP::rotlFixed(T, unsigned int) [with T = int]"
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.hidden __dso_handle
.ident "GCC: (GNU) 5.1.1 20150618 (Red Hat 5.1.1-4)"
.section .note.GNU-stack,"",@progbits
I'm obviously doing something wrong because the calls I want to inspect are missing.
How do I generate the listing? Or, if I am generating it, how do I display all relevant parts?
Thanks in advance.
In case it matters, the system is Fedora 22 x86_64, and GCC 5.1.1:
$ uname -a
Linux localhost.localdomain 4.0.4-301.fc22.x86_64 #1 SMP Thu May 21 13:10:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ gcc --version
gcc (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)
...
Related, here's the underlying question that's causing me to want to look at the generated code How to force const propagation through an inline function?