From mboxrd@z Thu Jan 1 00:00:00 1970 From: andi.platschek@gmail.com (Andreas Platschek) Date: Tue, 06 Aug 2013 16:13:19 +0200 Subject: Fwd: Understanding disassembly x86 + understanding function call + parameter pass and stack frame In-Reply-To: References: Message-ID: <5201047F.6070405@gmail.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org > c)lets say for a program a.c i use gcc -S a.c ...do we have some other > command to generate > somewhat more clear assembly code, may be with some comments in english > Not sure if this is of any help, but the kernel build system (no idea how to do this for user space programs) offers to generate a listing that interleaves the c code into assembly making it better readable. So if your function is e.g. in kernel/rtmutex.c you could do the following: andi at PC63:~/working_git/linux-next$ make kernel/rtmutex.lst SYSHDR arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h SYSHDR arch/x86/syscalls/../include/generated/uapi/asm/unistd_64.h HOSTCC scripts/asn1_compiler MKLST kernel/rtmutex.lst No System.map andi at PC63:~/working_git/linux-next$ here is one function from the resulting rtmutex.lst file: static void fixup_rt_mutex_waiters(struct rt_mutex *lock) { 70: e8 00 00 00 00 callq 75 71: R_X86_64_PC32 __fentry__+0xfffffffffffffffc 75: 55 push %rbp 76: 48 ff 05 00 00 00 00 incq 0x0(%rip) # 7d 79: R_X86_64_PC32 .bss+0x6fc 7d: 48 89 e5 mov %rsp,%rbp 80: 53 push %rbx 81: 48 89 fb mov %rdi,%rbx if (!rt_mutex_has_waiters(lock)) 84: e8 8e ff ff ff callq 17 89: 48 ff 05 00 00 00 00 incq 0x0(%rip) # 90 8c: R_X86_64_PC32 .bss+0x704 90: 85 c0 test %eax,%eax 92: 75 0c jne a0 } btw. you can for example generate the pre-processed code in the same way: andi at PC63:~/working_git/linux-next$ make kernel/rtmutex.i or the assembly code: andi at PC63:~/working_git/linux-next$ make kernel/rtmutex.s this is especially helpful, as it also contains a list of all the flags used for compiling. regards, andi > Any kind of help in understanding this will be appreciated .. > > Thanks > Nidhi > > > > > > -- > Thanks & Regards > Nidhi Mittal Hada > > http://nidhi-searchingmyself.blogspot.com/ > > > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130806/25fc4a97/attachment-0001.html