Object code is a generated assembly binary that is typically not [[../../../02 Areas/Computer Science/Executable|executable]] by itself, and has "hooks" left undone - which requires the [[Linker]] to clear ambiguity.
## Viewing Object Files
A way you can view object code yourself is by compiling your code in a certain way. Take the following file:
```c
/* main.c */
#include <stdio.h>
int main() {
prinf("bruh\n");
}
```
Normally when using a [[Compiler]], the compiler will both compile you code as well as [[Linker|link]] your code. You can bypass it by compiling your code in the terminal as such:
```sh
clang -c main.c -o main.o # for use with the clang compiler
gcc -c main.c -o main.o # for use with the GCC compiler
```
Doing this will create an object file `main.o` that is normally kept in memory when the compiler is in between compilation and linking. To view this file, you can use the `objdump` command.
```sh
objdump -d main.o
```
This command will then give us the following output (some things may be different depending on whether you are on a 32 bit machine or on another operating system):
```nasm
main.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <main>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 83 ec 10 sub $0x10,%rsp
8: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
f: 48 8d 3d 00 00 00 00 lea 0x0(%rip),%rdi #16 <main+0x16>
16: b0 00 mov $0x0,%al
18: e8 00 00 00 00 call 1d <main+0x1d>
1d: 31 c0 xor %eax,%eax
1f: 48 83 c4 10 add $0x10,%rsp
23: 5d pop %rbp
24: c3 ret
```
If you are unfamiliar to assembly this can look intimidating, but something to note is that this is real assembly code being generated before linking. The reason why this code would not run by itself, however, can be seen when you look at the line:
```nasm
call 1d <main+0x1d>
```
What this line is saying is call a method, in this case
`printf`, with this id. This, however, is not an exact
location for where this function, all this tells the
assembler is it wants to call a function with this ID.
The use of the [[Linker]] is to resolve these references and
connect `<main+0x1d>` to `printf`, allowing the code to
be run properly.