1 00:00:00,820 --> 00:00:08,140 Welcome to the fascinating assembly phase where the magic of generating real machine code unfolds in 2 00:00:08,140 --> 00:00:09,310 this pivotal stage. 3 00:00:09,310 --> 00:00:15,550 The assembly language files generated during the compilation phase take center stage as the input. 4 00:00:15,550 --> 00:00:21,700 So the output of this phase is a collection of object files also referred to as modules. 5 00:00:21,700 --> 00:00:28,150 So these object files encapsulate the machine instructions that hold the potential to be executed by 6 00:00:28,150 --> 00:00:29,380 the processor. 7 00:00:29,380 --> 00:00:37,510 However, before we can revel in the glory of fully operational binary executable, there are three 8 00:00:37,510 --> 00:00:40,060 more essential steps to undertake. 9 00:00:40,060 --> 00:00:46,390 So it's important to note that each source file typically corresponds to an assembly file, and in turn 10 00:00:46,390 --> 00:00:50,380 each assembly file corresponds to an object file. 11 00:00:50,380 --> 00:00:59,950 So to generate an object file, you can simply append the C flag to your GCC here. 12 00:00:59,950 --> 00:01:08,360 So in order to do that, we will again use the My app dot C and GCC here. 13 00:01:08,360 --> 00:01:14,990 And after that C parameter C flag and I'm sorry here. 14 00:01:14,990 --> 00:01:15,560 Yeah. 15 00:01:15,560 --> 00:01:24,950 And after that we will enter our my app dot C and here we created a new file and now we're going to 16 00:01:24,950 --> 00:01:25,880 open it. 17 00:01:26,360 --> 00:01:32,210 Mouse pad my app dot Oh here. 18 00:01:32,870 --> 00:01:38,390 And as you can see, this document is not UTF eight valid, but we will still going to open it. 19 00:01:38,390 --> 00:01:38,840 But. 20 00:01:38,960 --> 00:01:42,020 And as you can see, we are seeing nothing here. 21 00:01:42,020 --> 00:01:46,220 So you can use the you can also use the file utility here. 22 00:01:46,580 --> 00:01:50,300 File my app dot. 23 00:01:51,240 --> 00:01:51,990 All here. 24 00:01:52,170 --> 00:02:00,330 And with this file utility, this is a handy utility that it will return, that it will return some 25 00:02:00,330 --> 00:02:02,310 of the information about this here. 26 00:02:02,310 --> 00:02:04,950 And we will also learn that in next lectures. 27 00:02:05,130 --> 00:02:15,150 And here with this file here, we are confirming that the produced file, my app, that all here is 28 00:02:15,150 --> 00:02:16,860 indeed an object file. 29 00:02:16,860 --> 00:02:25,110 So as you can see here, the file shows up as Elf 64 bit LSB relocatable file. 30 00:02:25,260 --> 00:02:27,680 And what exactly does this mean? 31 00:02:27,690 --> 00:02:35,430 So this the first part of the file output shows that the file conforms to the Elf specifications for 32 00:02:35,430 --> 00:02:39,540 binary executables, which we will learn later in this course. 33 00:02:39,540 --> 00:02:49,620 And more specifically, it's a 64 bit Elf file since you are compiling for x86 and 64 in this example 34 00:02:49,620 --> 00:02:58,420 here and it is LSB meaning that numbers are ordered in memory with their least significant byte first. 35 00:02:58,420 --> 00:03:06,790 So but most important, you can see that this file is relocatable and Relocatable files don't rely on 36 00:03:06,790 --> 00:03:10,030 being placed at any particular address in memory. 37 00:03:10,030 --> 00:03:15,730 Rather, they can be moved around and it will without breaking any assumptions in the code. 38 00:03:15,730 --> 00:03:23,650 So when you see the term relocatable in the file output, you know you are dealing with an object file 39 00:03:23,650 --> 00:03:26,530 and not with an executable. 40 00:03:26,710 --> 00:03:36,160 And there are also position independent relocatable executables, but these show up in file as shared 41 00:03:36,160 --> 00:03:38,230 objects rather than relocatable files. 42 00:03:38,230 --> 00:03:44,650 So you can tell them apart from ordinary shared libraries because they have an entry point addresses 43 00:03:44,650 --> 00:03:45,160 here. 44 00:03:45,370 --> 00:03:46,270 So. 45 00:03:48,210 --> 00:03:54,750 Object files are compiled independently from each other, so the assembler has no way of knowing the 46 00:03:54,750 --> 00:03:59,370 memory addresses of the other object files when assembling an object file. 47 00:03:59,370 --> 00:04:03,000 So that's why object files need to be relocatable. 48 00:04:03,000 --> 00:04:03,450 Right. 49 00:04:03,450 --> 00:04:09,620 So that way you can link them together in any order to form a complete binary executable. 50 00:04:09,630 --> 00:04:14,820 So if object files were not relocatable, this would not possible. 51 00:04:14,820 --> 00:04:19,140 So you will see the contents of the object files later in this course. 52 00:04:19,140 --> 00:04:23,010 So when you are ready to disassemble a file for the first time.