For those of you unfamiliar with it, GLIBC stands for the GNU C Library.
It's an open source library that takes the form of a shared object,
the Linux equivalent of a DLL.
And it's a fundamental part of many Linux operating systems.
Alternative C library implementations exist, such as musl and uclibc, but GLIBC has been around
for the past 30 years and is widely adopted.
It's used in both desktop and embedded systems, including popular distros like Ubuntu, Debian and Arch
Linux, to name just a few.
And all GLIBC does is provide boilerplate code, functions like memcpy() and printf(), to programs written
in C and C++ and by extension, higher level languages like Python, whose interpreters are often written
in C.
Put simply, on your average Linux distro, you'd be hard pushed to find a process that doesn't map
one of the GLIBC shared objects into memory.
On your screen now is an Ubuntu 18.04 long term support distro, which I'm going
to use to demonstrate where to find an operating system's GLIBC shared objects and how important
those shared objects are.
There's no need to follow along at this stage,
we'll be preparing our environment soon.
ldd, short for "list dynamic dependencies" lists the shared objects that a binary relies upon.
Running it against ls shows that ls loads libraries such as libselinux and libphread.
Amongst these libraries is one named libc.so.6,
this is the GLIBC shared object.
GLIBC is often shortened to libc and the .so part stands for shared object.
The 6 part is part of the Linux Library ABI versioning convention known as a
soname. A library maintainer increments the library's
soname when its ABI changes.
file shows us that libc.so.6 is just a symbolic link to libc-2.27.so
libc-2.27.so
This is the actual GLIBC shared object, 2.27 indicates the GLIBC version, which is
different to the soname.
Most Linux operating systems are distributed with a specific version of GLIBC, which often will not
change for its support period.
For example, we've seen that Ubuntu 18.04 long term support uses GLIBC version 2.27.
It was created with this version and will continue to use it throughout its five year support period.
The exceptions to this rule are rolling distros like Arch Linux, which do update their versions of GLIBC.
Running file on the actual GLIBC binary reveals that it's just a position independent ELF file,
much like how Windows DLLs are PE files.
The BuildID can be used to identify a specific build of GLIBC.
We can run the GLIBC shared object, and it will print information such as its version number and
what version of GCC it was compiled with.
If you're unsure of which version of GLIBC you're dealing with, running the shared object is a
quick way to find out.
du, short for "disk usage", shows us that the libc binary takes up just two megabytes of space on
disk.
So how important are these two megabytes?
Well, I'm going to remove them and find out. This command deletes the libc.so.6 symlink.
Now, when I tried to use simple programs such as ls or whoami
they're unable to run.
Closing the terminal emulator makes it unresponsive.
Programs like Firefox won't start and the OS can't even shut down.
That's how important GLIBC is to the integrity of a modern Linux operating system.
So in summary, GLIBC is a shared object or library that provides boilerplate code to nearly every
process on the operating systems that use it.
And it's so integral a part of these operating systems that even their most basic functionality requires
it.
In the next video, we'll learn about heaps and how they're related to GLIBC.