Library Calling in C

In this post we are exploring how different types of binaries are generated, how function calls work when code is split across multiple files, and how the toolchain (compiler, linker, loader) helps. We’ll also cover how to build and install a custom libc for testing and debugging purposes. File Types and High-Level Flow Difference in types of files: .c / .cpp: source files .o: object files (compiled but not yet linked) .a: static library (archive of .o files) .so: shared library (dynamically linked at runtime) Typical build pipeline: ...

May 1, 2019 · 9 min · Sandeep Kumar

Installing custom LibC

Glibc is the standard library that is linked against all the linux applications. It provides the necessary functionality like printf. It also provides wrappers for most used system calls like open, read, write, close. Manually building and installing libc. Example from a StackOverflow answer export glibc_install="$(pwd)/glibc/build/install" git clone git://sourceware.org/git/glibc.git cd glibc git checkout glibc-2.28 mkdir build cd build ../configure --prefix "$glibc_install" make make install Followed by a test c code ...

March 9, 2020 · 4 min · Sandeep Kumar