Skip to content

RED HAT Linux & GCC – How to Compile a C program into Assembly code


There is a correlation between C code and Assembly code, that shows what exactly is happening on the machine.  Assembly code is seriously enjoyable to read.

Step 1 – Create the C code.  (Pico/Gedit/Nano).

Create a program called main.c


Step 2 – Compile into an executable.

gcc main.c -o userid


main.c compiled

Step 3 – Compile into Assembly code

gcc -S main.c -o userassembly

main assembly

cat userassembly | more



assembly more


nm to obtain Memory locations (nod to Xerocrypt)

nm userid | more

nm userid

Objdump -D userid  (nod to Xerocrypt)

objdump -D

Love those opcodes 🙂


objdump -S userid | more

objdump -S

To display the Symbol table

objdump -t ./userid | more

objdump -t symbol table

Objdump Options – Happy reading 🙂

objdump options


How to use objdump – Intel Syntax – The Visual Guide

  1. You know, if you run the compiled program through objdump (or was it nm?), you get the assembly aongside the opcodes for the program, which could then be used as a payload in an exploit.


Trackbacks & Pingbacks

  1. How to use Objdump – Intel Syntax – The Visual Guide | University of South Wales: Information Security and Privacy

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: