If you're getting this error on compiling and linking phase :


nasm -f elf64 -g -F dwarf project.asm -l project.lst

gcc -o project project.o -no-pie

/usr/bin/ld: project.o: in function `_start':

/home/typhon/assembly/instruction_flags_and_jumps//project.asm:9: multiple definition of `_start'; /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here

/usr/bin/ld: warning: project.o: missing .note.GNU-stack section implies executable stack

/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/crt1.o: in function `_start':

(.text+0x17): undefined reference to `main'

collect2: error: ld returned 1 exit status

make: *** [makefile:3: project] Error 1



The issue you're facing seems to be related to how you're compiling and linking your assembly code with GCC. The error message indicates that there's a multiple definition of _start, which typically occurs when you're linking an object file that already contains a definition of _start with the standard C runtime.


Here's how you can compile and link your assembly code correctly using GCC:


Assemble the assembly code into an object file:


nasm -f elf64 -g -F dwarf project.asm -o project.o

Link the object file with GCC to create the final executable:


gcc -nostartfiles -o project project.o

The -nostartfiles flag tells GCC not to include the standard startup files like crt1.o, which are causing the multiple definition of _start issue.


Additionally, the -no-pie flag might be needed to disable Position Independent Executable (PIE) mode, which can sometimes lead to issues in assembly programs. If you still encounter problems, try adding that flag as well:


gcc -nostartfiles -no-pie -o project project.o

After running these commands, you should have an executable named project that you can run to test your assembly program.


If you're still experiencing issues, please provide the contents of your project.asm file so I can take a closer look and help you further troubleshoot the problem.