Ubuntu 16.04 uses the GCC output to assemble the. 0 file as an executable when it appears: ' _start ' is defined multiple times

Source: Internet
Author: User
Tags stdin

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.


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.