Relationship between GCC, glibc, and binutils modules

Source: Internet
Author: User

From: http://www.mike.org.cn/articles/linux-about-gcc-glibc-and-binutils-the-relationship-between-modules/

 

1. Relations between GCC, glibc, and binutils modules 1. GCC (GNU collect compiler) is a general term for a group of compilation tools. It mainly completes "preprocessing" and "Compilation" tasks, and provides support for runtime libraries closely related to compilers, such as libgcc_s.so and libstdc ++. So. 2. binutils provides a series of tools for creating, managing, and maintaining binary target files. Program Such as assembly (AS), connection (LD), static library archiving (AR), disassembly (objdump), and elf Structure Analysis Tool (readelf) tool (strip) for invalid debugging information and symbols. Usually, binutils and GCC are tightly integrated. Without binutils, GCC cannot work normally. 3. glibc is the libc library released by GNU, that is, the C Runtime Library. Glibc is the most underlying API (Application Development Interface) in Linux. almost any other Runtime Library relies on glibc. Glibc not only encapsulates the system services provided by the Linux operating system, but also provides implementation of many other necessary functional services, mainly as follows: (1) string, string processing (2) signal, signal processing (3) dlfcn, managing dynamic loading of shared libraries (4) Direct, file directory operations (5) Elf, dynamic loaders of shared libraries, that is, Interpreter (6) iconv, encoding conversion of different character sets (7) Inet, socket interface implementation (8) Intl, internationalization, that is, gettext implementation (9) io (10) linuxthreads (11) locale, localization (12) login, virtual terminal device management, and secure system access (13) malloc, dynamic Memory Allocation and Management (14) NIS (15) stdlib. Other basic functions 2. How to upgrade existing systems 1. When upgrading these libraries, it is best not to override the default ones in the system. Because these libraries, especially glibc libraries, are the core shared libraries and workers in the system. If it is blindly covered, the entire system may be paralyzed, because when the glibc library is updated, all other shared libraries of the libc library need to be re-compiled. Therefore, to debug a program into glibc, it is best to install glibc under/usr/local/lib. 2. Compile the glibc Library first. Note that it is best to create a glibc-build directory and add the-enable-add-ons = linuxthreads option to configure. Install make install to/usr/local. 3. Modify the GCC spec file (/usr/lib/GCC-lib/i386-redhat-linux/3.2.2/specs ), change the ld-linux.so.2 to a new shared library loader under/usr/local/lib. 4. Compile the binutils library. The compiled program will be connected to the new libc library under/usr/local/lib. Note: Before configure, you need to set the path of the LD default connection (LIBRARY_PATH =/usr/local/lib:/usr/lib). Otherwise, binutils will configure errors, some symbols in libc cannot be found. The procedure is as follows: (1) Export LIBRARY_PATH =/usr/local/lib:/usr/lib (2) mkdir binutils-build & CD binutils-build (3 ).. /binutils-2.13.90.0.18/configure (4) Make (5) Make-c ld clean (6) Make-c ld lib_path =/usr/lib: /usr/local/bin (set the default library search path for the compiled lD, which is later higher than the previous one) (7) make install III. Summary 1. runtime, the loading of a dynamic library depends on the implementation of the ld-linux.so.6, which looks for the shared library in the following order: (1) the ld-linux.so.6 is specified in the executable target file and can be viewed with the readelf command (2) ld-linux.so.6 is searched by default in/usr/lib and LIB; When GL When IBC is installed in/usr/local, it looks for the path (4)/etc/LD set in the/usr/local/lib (3) LD_LIBRARY_PATH environment variable. so. conf (or/usr/local/etc/lD. so. the path specified in Conf. ldconfig generates the binary lD. so. cache 2. When compiling, the path order of the Search Library is as follows: (1) the ld-linux.so.6 is set by the GCC spec file (2) the path printed by GCC-print-search-dirs is mainly libgcc_s.so and other libraries. You can use gcc_exec_prefix to set (3) the path set in the LIBRARY_PATH environment variable or-L/usr/local/lib (4) specified in the compiled command line) the default search path sequence set by LD in binutils, which is specified when binutils is compiled. (You can view it through "LD-verbose | grep search") 3. the binary program's search path sequence is set in the PATH environment variable. Generally,/usr/local/bin is higher than/usr/bin 4. The search path sequence of the header files during compilation is similar to that of the library. Generally,/usr/local/include is higher than/usr/include.

 

Complete!

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.