Exercise 1.2

The following is the assembly program written for Exercise 1.1, except that it defines the symbol "main" instead of "_start".

write "exit_main.asm"
segment .text global main main: mov eax,60 mov edi,5 syscall end

In order to make an executable from this, we'll have to assemble the file using Yasm and then link it using the C compiler gcc instead of using ld directly.

build exit_main exit_main.asm
yasm -f elf64 -g dwarf2 exit_main.asm && gcc -o exit_main exit_main.o

In order to check the difference in size when using "main" instead of "_start", we can use the following command.

du -BK ../exercise_1_2/exit_main $ 20K exercise_1_2/exit_main du -BK ../exercise_1_1/exit $ 8K exercise_1_1/exit

On my machine, the difference turns out to be around 12KB.