Analysis of GCC, ARM-LINUX-GCC and ARM-ELF-GCC

Source: Internet
Author: User

I. INTRODUCTION of GCC:

The GNU Compiler Collection, often referred to as GCC, is a set of compilers developed by GNU, and why is it an editor set instead of a compiler? That's because it not only supports C language compilation, but also supports C + +, Ada, Objective C and many other languages. In addition, GCC support for the hardware platform can be ubiquitous, it not only supports the X86 processor architecture, but also supports arm, Motorola 68000, Motorola 8800, Atmel AVR, MIPS and other processor architectures.

Second, GCC internal structure:

The internal structure of GCC is mainly composed of Binutils, Gcc-core, glibc and other software packages.

1. Binutils: It is a set of development tools, including connectors, assemblers and other tools for target files and archives. The introduction of Binutils can be referred to binutils Brief introduction . "This package depends on the platform of the different target machines. Because the instruction sets of different target machines are not the same, such as arm and x86 are not the same "

2. Gcc-core: Gu Ming is the core of GCC, which contains only C compilers and public parts, while support packages for other languages such as "C + +, ADA, etc." need to be installed separately, which is why GCC is so powerful. "It relies on binutils and can refer to installing GCC"

3. GLIBC: Contains the main C library, which provides basic routines for allocating memory, searching directories, reading and writing files, string processing, and so on. "This package gcc compiled the generated library, the predecessors in order to facilitate the development of people, put glibc into GCC"

For example, describe how the above 3 packages work. There is a C source file test.c source code as follows:

#include <stdio.h>int main (intChar *argv[]) {printf ("Hello Linux!! \ n"return0;} /* */

$ gcc-o Test test.c compile to generate the test executable file. The GCC compilation process consists of four steps: preprocessing, compiling, compiling, linking. The individual thinks that preprocessing and compiling are mainly done by Gcc-core, and the assembly and link are mainly done by binutils. So when do we use the glibc? See the printf function in the source code is not, this function in GCC is in the form of a library function, the library function in the GLIBC library, in the stdio.h header file is declared.

In general, if you really understand the role of the 3 packages above, you will naturally understand how GCC works.

Third, the installation of GCC:

Since GCC itself is a collection of software, then how to install these software collections, because this process is very complex, I have not installed, but this is not the focus of this article, do not say. However, the online "Linux thorough customization Guide" is very detailed, interested can take a look.

Four, cross-compiling:

Cross-compilation (or cross-build) is a process in which software compiled under a machine structure executes under a completely different machine structure. A common example is the build software on a PC that runs on a target machine based on ARM, PowerPC, or MIPS. Fortunately, GCC makes the process much less difficult than it sounds.

The general tools in GCC are usually executed by invoking commands (such as GCC) on the command line. In the case of cross-compilation, these tools are named according to the target that it compiles. For example, to compile a simple Hello World program for ARM machines using the cross toolchain, you can run a command like this:

Compile and test the code using the following command:

$ arm-linux-gcc-o Hello hello.c

Five, ARM-LINUX-GCC:

ARM-LINUX-GCC is a cross-compiling software based on an arm target, and installing ARM-LINUX-GCC cross-compiling software in previous years is particularly tricky for a primary embedded engineer, because it requires multiple packages to be installed, and there is no error in the installation process. Because each package has its dependencies "in other words, if a package is installed, it will fail to install if its dependent software version is too low or not installed"; Well, nonsense, let's get to the point. The practice of creating a Armlinux cross-compilation environment , please refer to the original text or Google search for detailed installation procedures.

......

1. source File Preparation
Binutils-2.14.tar.gz
Ftp://ftp.gnu.org/gnu/binutils/binutils-2.14.tar.gz
Gcc-core-2.95.3.tar.gz
Ftp://ftp.gnu.org/gnu/gcc/gcc-2.95.3/gcc-core-2.95.3.tar.gz
Gcc-g++2.95.3.tar.gz
Ftp://ftp.gnu.org/gnu/gcc/gcc-2.95.3/gcc-g++-2.95.3.tar.gz
Glibc-2.2.4.tar.gz
Ftp://ftp.gnu.org/gnu/glibc/glibc-2.2.4.tar.gz
Glibc-linuxthreads-2.2.4.tar.gz
Ftp://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-2.2.4.tar.gz
Linux-2.4.21.tar.gz
Ftp://ftp.kernle.org/pub/linux/kernel/v2.4/linux-2.4.21.tar.gz
patch-2.4.21-rmk1.gz # Linux Kernel patch for ARM
FTP://FTP.ARM.LINUX.ORG.UK/PUB/L ... atch-2.4.21-rmk1.gz

Binutils-2.14.tar.gz This compression package contains ld,ar,as and other tools that produce or process binary files.
Gcc-core-2.95.3.tar.gz This is the main part of GCC, GCC is the GNU Compiler collection abbreviation, as the name implies, it can compile many kinds of high-level languages, such as C, C++,java, etc., This package contains the C compiler, and the public part, and other language support, the use of additional compression package released separately.
Gcc-g++2.95.3.tar.gz, this compression package is published separately for GCC to compile C + + programs.
GLIBC-2.2.4.TAR.GZ,LIBC is a library that is used by many user-level applications, kernel and bootloader do not need the support of this library, which is encapsulated within this compact package.
Glibc-linuxthreads-2.2.4.tar.gz, which is a single compressed package that LIBC uses to support POSIX threads.
Linux-2.4.21.tar.gz, this compression package is the kernel of Linux.
Patch-2.4.21-rmk1.gz, this compression package is used to patch the Linux kernel so that it can support arm's hardware platform.

......

It can be seen that ARM-LINUX-GCC and GCC need the name of the installation package Datong small easy, but this is why? Do not know that the netizen did not think of this problem, may netizens know that these packages and GCC used by the package is not the same, only the name is not the same, but know why is not the same as I am afraid there are quite a lot of people are not clear. Personally, the question is the key to understanding the relationship and difference between ARM-LINUX-GCC and GCC. Well, not suspense, into the point, because we know that X86 and arm use of the instruction set is not the same, so the need for binutils certainly different, the above mentioned Gcc-core is dependent on binutils, Natural arm and X86 use of the Gcc-core package is not the same, glibc a C library, the end is in the form of libraries in the compiler, natural arm used by the GLIBC library and X86 is also different, and so on.

Vi. ARM-LINUX-GCC and ARM-ELF-GCC:

ARM-ELF-GCC, like ARM-LINUX-GCC, is also a cross-compiling software based on an arm target machine. But they are not the same cross-compiler software, there are differences between the two, the main difference is the use of different C library files. ARM-LINUX-GCC uses the GNU glibc, while ARM-ELF-GCC generally uses UCLIBC/UC-LIBC or the C library Redhat specifically developed for embedded systems using NEWLIB. For the difference between the two, please refer to the arm-linux-gcc arm-elf-gcc difference .

Analysis of GCC, ARM-LINUX-GCC and ARM-ELF-GCC

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.