This preview shows page 1. Sign up to view the full content.
Unformatted text preview: unix> gcc -O2 -c code.c This will generate an object code ﬁle code.o that is in binary format and hence cannot be viewed directly. Embedded within the 852 bytes of the ﬁle code.o is a 19 byte sequence having hexadecimal representation:
55 89 e5 8b 45 0c 03 45 08 01 05 00 00 00 00 89 ec 5d c3 3.2. PROGRAM ENCODINGS 95 This is the object code corresponding to the assembly instructions listed above. A key lesson to learn from this is that the program actually executed by the machine is simply a sequence of bytes encoding a series of instructions. The machine has very little information about the source code from which these instructions were generated.
Aside: How do I ﬁnd the byte representation of a program? First we used a disassembler (to be described shortly) to determine that the code for sum is 19 bytes long. Then we ran the GNU debugging tool GDB on ﬁle code.o and gave it the command: (gdb) x/19xb sum telling it to examine (abbreviated ‘x’) 19 hex-formatted (also abbre...
View Full Document