<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 8, 2019 at 4:53 AM wuzhouhui <<a href="mailto:wuzhouhui14@mails.ucas.ac.cn">wuzhouhui14@mails.ucas.ac.cn</a>> wrote:</div><div dir="ltr" class="gmail_attr">> Hi,</div><div><br></div><div>> Suppose I have two kernels, one is A.B.C build by people Tom. And</div><div>> the other is A.B.C build by Jerry. The source code have been deleted</div><div>> after kernel is build and installed. Now I want to know whether the</div><div>> source code of these two kernel is the same (even if they have the same</div><div>> name). All I have is binaries (e.g. vmlinux, config, *.ko, System.map).</div><div><br></div><div>> Is it possible?</div>Within sane defaults yes it is possible. Think of it this way, if the source code is <br></div><div class="gmail_quote">the 'same'  we can safely assume that the kernel built by Tom will function and behave <br></div><div class="gmail_quote">'exactly' the same as the kernel built by Jerry. Behavior can be traced and analyzed.<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">diff, dmesg, lsmod, tree and objdump are your friends :-)</div><div class="gmail_quote"><br></div><div class="gmail_quote">Run diff vmlinuz-Tom vmlinuz-Jerry and see if they differ. Then just  to make</div><div class="gmail_quote">sure follow below steps:<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">1 - Boot kernel-Tom and  redirect dmesg output to file(s)</div><div class="gmail_quote">2 - dmesg -k > kernel-Tom.txt    <br></div><div class="gmail_quote">3 - dmesg -u > userspace-Tom.txt</div><div class="gmail_quote">4 - lsmod > modules-Tom.txt</div><div class="gmail_quote">5 - tree / > fs-Tom.txt</div><div class="gmail_quote"><br></div><div class="gmail_quote">Now we have what the kernel prints while booting in kernel-Tom.txt and what userspace prints <br></div><div class="gmail_quote">in userspace-Tom.txt and loaded modules in modules-Tom.txt and the folder structure under root</div><div class="gmail_quote">in fs-Tom.txt.</div><div class="gmail_quote"><br></div><div class="gmail_quote">Now repeat the same process with kernel-Jerry<br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><div class="gmail_quote">1 - Boot kernel-Jerry</div><div class="gmail_quote">2 - dmesg -k > kernel-Jerry.txt</div><div class="gmail_quote">3 - dmesg -u > userspace-Jerry.txt</div><div class="gmail_quote">4 - lsmod > modules-Jerry.txt</div><div class="gmail_quote">5 - tree / > fs-Jerry.txt</div><div class="gmail_quote"><br></div><div class="gmail_quote">Then run diff on those files..<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">1 - diff kernel-Tom.txt kernel-Jerry.txt   <br></div><div class="gmail_quote">2 - diff userspace-Tom userspace-Jerry</div><div class="gmail_quote">3 - diff modules-Tom modules-Jerry</div><div class="gmail_quote">4 - diff fs-Tom fs-Jerry<br></div><div class="gmail_quote"><br></div></div><div class="gmail_quote">if you want to dig deeper use objdump -d vmlinuz-Tom then objdump -d vmlinuz-Jerry</div><div class="gmail_quote">which is really overkill unless there is output from diff that says the file(s) differ.<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">If you really really need the source there are decompilers :</div><div class="gmail_quote"><a href="https://www.hex-rays.com/products/ida/">IDA</a></div><div class="gmail_quote"><a href="https://ghidra-sre.org/">ghidra</a></div><div class="gmail_quote"><a href="https://derevenets.com/">snowman</a></div><div class="gmail_quote"><a href="https://www.hopperapp.com/">hopper</a><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">Keep in mind what Valdis pointed out that though the source may be exactly the same,</div><div class="gmail_quote">depending on what compiler flags were used the binaries may differ. <br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><div>You had asked..</div><div>> Is it possible?</div><div>Simple answer: In the Linux world the impossible becomes very possible :)</div><div><br></div><div>Good luck - Aruna<br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div></div>