Assembly code for Sniper

215 views
Skip to first unread message

Newton

unread,
Aug 29, 2017, 7:15:53 AM8/29/17
to Sniper simulator
Dear all,

I wrote a small c program (attached also).

#include "stdio.h"
int main()
{
    unsigned short a = 12343, b = 234, c = 345, d = 456, e = 567, f = 678, g = 789, h = 890;

    f = g + h;
    e = f + g;
    d = e + f;
    c = d + e;
    b = c + d;
    a = b + c;
}

1) Using gcc, i compiled the code and generated object file.
gcc -c
2) and then used objdump to check the assembly code and got output
objdumpASM.txt

3) To check the assembly code being run by sniper, i modified the
InstructionModeling::handleInstruction in instruction_modeling.cc
   std::cout << instruction->getDisassembly() << std::endl;

From this step, i got the assembly code being run by sniper as output
sniperASM.txt
4) Then i compared the outputs from step 2 & 3 i.e.
objdumpASM.txt sniperASM.txt
5) I found a lot of extra assembly code in
sniperASM.txt which is not part of objdumpASM.txt.

Please, can anybody tell me the reason of this extra code
.

objdumpASM.txt
sniperASM.txt
c_x_86_sniper.c

Trevor E. Carlson

unread,
Aug 29, 2017, 10:20:40 PM8/29/17
to newto...@gmail.com, snip...@googlegroups.com
Newton,

What you are seeing is all of the setup code that starts before your main() function is actually called. If I remember correctly, Linux sets up an initial stack and calls _start() which then does some initialization before handing over control to main(). All of those instructions you are seeing is Pin capturing this process and feeding these instructions to Sniper.

Trevor

--
--
--
You received this message because you are subscribed to the Google
Groups "Sniper simulator" group.
To post to this group, send email to snip...@googlegroups.com
To unsubscribe from this group, send email to
snipersim+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/snipersim?hl=en

---
You received this message because you are subscribed to the Google Groups "Sniper simulator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snipersim+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<objdumpASM.txt><sniperASM.txt><c_x_86_sniper.c>

Newton

unread,
Aug 31, 2017, 4:28:43 AM8/31/17
to Trevor E. Carlson, snip...@googlegroups.com
Dear Trevor,

Thanks for your reply.

Is there any way i can log only the assembly code which
is relevant to my program and exclude all setup and exit code.

Will ROI markers be useful here?
SimRoiStart();
SimNamedMarker(4, "begin");



For more options, visit this group at
http://groups.google.com/group/snipersim?hl=en

---
You received this message because you are subscribed to the Google Groups "Sniper simulator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snipersim+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
<objdumpASM.txt><sniperASM.txt><c_x_86_sniper.c>




--
Thanks
Newton
Research Scholar, EE Dept.
IIT Bombay
Reply all
Reply to author
Forward
0 new messages