The error is as follows:
' _start ' has been defined several times /usr/lib/gcc/x86_64-linux-gnu/5/. /.. /.. /X86_64-LINUX-GNU/CRT1.O: (. text+0x0): For the first time in this definition /usr/lib/gcc/x86_64-linux-gnu/5/. /.. /.. /x86_64-linux-gnu/crt1. o: In function ' _start ': (. text+0x20) exit Status
Problem Analysis:
Can see the error message prompt, mentioned a "crt1.o" This file, wherein the CRT is "C Runtime Library" abbreviation, meaning is "C Operation Time Library".
In addition to providing us with the necessary library function calls (such as memcpy, printf, malloc, and so on), the C run-time library provides another of the most important features to add startup functions to your application. The main function of the C run-time library startup function is to initialize the program, assign the initial value to the global variable, and load the entry function of the user program.
As you can tell from the error message given, there is a function named "_start" in CRT1.O. Now find a copy of CRT1.O's pseudo-code online:
Section. text: __start:: Init stack; init heap; Open stdin; Open stdout; Open stderr; : Push argv; Push ARGC call _main; (Call Main) : Destory heap; close stdin; Close stdout; close stderr; call __exit;
As can be seen from the pseudo-code, in this _start function, the main function is called. Then we can modify the entry function to change the entry function to Junco.
Execute the following command:
GCC 1.c-e junco-nostartfiles
Where the-e option is the entry address of the modified function. E refers to the entrance. This specifies the entrance as the Junco function. The purpose of the-nostartfiles option is to inform the compiler not to automatically join the startup function and other library-level initializations so that the _start function in the CRT1.O is not called.
Reference:
Http://blog.sina.com.cn/s/blog_76a864e20101ehtp.html (The above analysis is from this article, but the C language, and the above method also applies to the Assembly)
Ubuntu 16.04 uses the GCC output to assemble the. 0 file as an executable when it appears: ' _start ' is defined multiple times