This article provides information on Linux Build Process , Tool chain , Naming convention etc.
I discussed about redirection related pipe,tee and grep commands in Linux File System . I strongly recommend you to read earlier blogs for better understanding . If you find something missing, Please provide feedback in comment box so that I can take corrective action.
Linux Build Process Components :
Terminology :
- Build System is the machine Which is building Tool chain components.
- Host System is the machine Where software development using tool chain being done.
- Target System is the machine where generated code to be executed.
- If all above are being done in a single machine, It is called native based development. For ex: x86
- If Build and Host systems are different but final Target is Host m/c itself ,It is called cross-native.
- If all above are being done in two or more machines, It is called cross tool chain based development. For ex code was generated in x86 but executed in PowerPC/ARM/MIPS/RISCV
If all above are being done in three different machines, It is called Canadian system. For ex: Tool chain was build in a fast x86 based m/c. The build tool chain binary was used in another x86 based m/c to generate code for the target x86 based system .
Tool chain Components :
Have you heard about Recursive Acronym ? If not , Look for same at the end of this blog.
The basic components of any tool chain are compiler, assembler and linker. Compiler parses the C language tokens to assembly, Assembly converts that to binary objects and finally Linker combines all these objects with pre-built libraries to generate the final executable file. GNU tool chain components are as follows :
GNU Compiler Collection(GCC) : A set of compilers for several programming languages
GNU Debugger (GDB) : Used for source level debugging of application at run time
GNU Binutils : A set of tools including Assembler, Linker , Strip utility and other tools to build target executable file.
GNU C Lbrary(glibc) : It is the implementation of standard C library and some other useful stuff related to kernel interface. i.e. printf(),malloc, system calls etc.
-
Static libraries: The static library object code is linked with the application. It is basically archive(.a) of objects.
- Shared libraries or Dynamically linked libraries(DLL) are libraries that are loaded by programs when they start. When a shared library is installed properly, all programs that start afterwards automatically use the new shared library.
- Dynamically linked shared object libraries (.so): It can be used in following ways. This gives flexibility to change a particular library version while program is running.
-
Dynamically linked at run time. The libraries must be available during compile/link phase. The application binary doesn’t include these shared objects but is aware of these..
-
Dynamically loaded/unloaded and linked during execution using the dynamic linking loader system functions.
-
gcc src-file.c -lm
Here Linker will use the math library. Math library is in /usr/lib/libm.a
Library naming conventions:
Every shared library has a special name called the “soname”. This follows a format .so.[major ABI version].[minor version1].[minor version2…]
sanjay@sanjay-VirtualBox:~/linux_day6$ ./hello &
Why there is a difference in name of library file shown by ldd and lsof ?
Every shared library also has a “real name”, which is the filename containing the actual library code. The real name adds to the soname .[minor number].[release number]. Linker will use only soname. You may use ldd (List Dynamic Dependencies) to find required shared libraries by an application.
References
- GNU is Not Unix : This is example of Recursive Acronym
- Anatomy of the Linux File System
This article is discussed at Linux Development Process video.
Thanks for reading till end. I am trying to improve usability of my site. Did you find this discussion helpful ? If so, Please subscribe to YouTube channel Embedkari as well for additional embedded related stuff.