Summary of the relationships between gcc, glibc, and binutils modules and how to upgrade existing systems

Source: Internet
Author: User

Summary of the relationships between gcc, glibc, and binutils modules and how to upgrade existing systems

1. Relationship between gcc, glibc, and binutils modules

1. gcc (gnu collect compiler) is 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 tool programs used to create, manage, and maintain binary target files, such as assembly (as), connection (ld), static library archiving (ar), and disassembly.
(Objdump), elf Structure Analysis Tool (readelf), tool with invalid debugging information and symbols (strip), etc. 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, and almost any other Runtime Library
It depends 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) manage dynamic loading of shared libraries in dlfcn
(4) direct, file directory operations
(5) elf, the dynamic loader of the shared library, that is, interpreter
(6) iconv, encoding conversion of different character sets
(7) Implementation of inet and socket Interfaces
(8) intl, international, that is, the implementation of gettext
(9) io
(10) linuxthreads
(11) locale, Localization
(12) login, virtual terminal device management, and secure system access
(13) malloc: Allocation and Management of dynamic memory
(14) nis
(15) stdlib, other basic functions

Ii. How to upgrade existing systems (practice on redhat9)

1. When upgrading these libraries, it is best not to overwrite the default ones in the system. Because these libraries, especially glibc libraries, are the core shared libraries and tools in the system. If they are blindly overwritten, it is likely that the entire system
Paralysis, because when the glibc library is updated, all other libc library shared libraries need to be re-compiled. Therefore, to debug a program into glibc, it is best to install glibc
To/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 configuring configure, you must set
Set the default ld connection path (LIBRARY_PATH =/usr/local/lib:/usr/lib); otherwise, binutils will
Configure error. 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 of the compiled ld, the latter is higher than the previous one)
(7) make install

Iii. Summary

1. At runtime, the loading of dynamic library depends on the implementation of ld-linux.so.6, and the order of searching shared library is as follows:
(1) The ld-linux.so.6 is specified in the executable target file and can be viewed with the readelf command
(2) The ld-linux.so.6 is searched by default in/usr/lib and lib; When glibc is installed under/usr/local, it looks for/usr/local/lib
(3) path set in environment variable LD_LIBRARY_PATH
(4)/etc/ld. so. conf (or/usr/local/etc/ld. so. the path specified in conf. ldconfig generates the binary ld. so. cache in progress

2. The path sequence of the database to be searched during compilation is as follows:
(1) The ld-linux.so.6 is set in 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 specified in the compiled command line
(2) 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 file during compilation is similar to that of the library. Generally,/usr/local/include is higher than/usr/include.

Http://blog.csai.cn/user1/265/archives/2005/2465.html

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.