Welcome to the fascinating assembly phase where the magic of generating real machine code unfolds in
this pivotal stage.
The assembly language files generated during the compilation phase take center stage as the input.
So the output of this phase is a collection of object files also referred to as modules.
So these object files encapsulate the machine instructions that hold the potential to be executed by
the processor.
However, before we can revel in the glory of fully operational binary executable, there are three
more essential steps to undertake.
So it's important to note that each source file typically corresponds to an assembly file, and in turn
each assembly file corresponds to an object file.
So to generate an object file, you can simply append the C flag to your GCC here.
So in order to do that, we will again use the My app dot C and GCC here.
And after that C parameter C flag and I'm sorry here.
Yeah.
And after that we will enter our my app dot C and here we created a new file and now we're going to
open it.
Mouse pad my app dot Oh here.
And as you can see, this document is not UTF eight valid, but we will still going to open it.
But.
And as you can see, we are seeing nothing here.
So you can use the you can also use the file utility here.
File my app dot.
All here.
And with this file utility, this is a handy utility that it will return, that it will return some
of the information about this here.
And we will also learn that in next lectures.
And here with this file here, we are confirming that the produced file, my app, that all here is
indeed an object file.
So as you can see here, the file shows up as Elf 64 bit LSB relocatable file.
And what exactly does this mean?
So this the first part of the file output shows that the file conforms to the Elf specifications for
binary executables, which we will learn later in this course.
And more specifically, it's a 64 bit Elf file since you are compiling for x86 and 64 in this example
here and it is LSB meaning that numbers are ordered in memory with their least significant byte first.
So but most important, you can see that this file is relocatable and Relocatable files don't rely on
being placed at any particular address in memory.
Rather, they can be moved around and it will without breaking any assumptions in the code.
So when you see the term relocatable in the file output, you know you are dealing with an object file
and not with an executable.
And there are also position independent relocatable executables, but these show up in file as shared
objects rather than relocatable files.
So you can tell them apart from ordinary shared libraries because they have an entry point addresses
here.
So.
Object files are compiled independently from each other, so the assembler has no way of knowing the
memory addresses of the other object files when assembling an object file.
So that's why object files need to be relocatable.
Right.
So that way you can link them together in any order to form a complete binary executable.
So if object files were not relocatable, this would not possible.
So you will see the contents of the object files later in this course.
So when you are ready to disassemble a file for the first time.