Abstract
- We can’t directly make System Call (系统调用) in the same way that we call functions in a program, different Instruction Set Architecture (ISA) has a different implementation of System Calls. So we have Library call that is built on top of system calls to abstract this complexity away from the application programmers
Abstraction
Make it possible to make System Call (系统调用) from user program written in languages like Java and C via an unified interface like POSIX without considering the underlying ISA.
For example, when the C program makes a
malloc()
library call, themalloc()
library call uses corresponding Assembly language to complete the memory allocation on the Heap Segment.
Tip
Library calls can be traced with
lstrace
.
Attention
Library Procedure
- The underlying codes that carry out Library Call, usually written in Assembly language
libc
- Short for C standard library
- Library Call that is implemented in the form of standard C functions like
strcpy()
and POSIX functions (which may be System Call (系统调用)) likegetpid()
Attention
Not all standard C functions are in
libc
- most math functions are inlibm
.
Tip
glibc
- glibc (GNU libc) provides more than just libc, it also provides the
libm
, and other core libraries likelibpthread
in separate files - For ubuntu, you can find all the glibc files under
/lib/x86_64-linux-gnu
and/usr/lib/x86_64-linux-gnu
musl libc
- A lightweight implementation of libc with
libpthread
,libm
,librt
, etc united into one single filelibc.so
- For ubuntu, you can find all the musl libc files under
/lib/x86_64-linux-musl
and/usr/lib/x86_64-linux-musl
Quote
musl’s efficiency is unparalleled in Linux libc implementations. Designed from the ground up for static linking, musl carefully avoids pulling in large amounts of code or data that the application will not use. Dynamic linking is also efficient; by integrating the entire standard library implementation, including threads, math, and even the dynamic linker itself into a single shared object, most of the startup time and memory overhead of dynamic linking have been eliminated.
Info
musleabi - targets systems using the standard ARM EABI (Embedded Application Binary Interface).
musleabihf - targets systems using the ARM EABI with hard-float support (hardware-accelerated floating-point operations).