C Programming Language
It is a simple language with basic data structures. There are functions and pointers for abstraction. A program in C is close to the assembler and machine code. The C programming language is often used for operating systems. The Linux kernel, drivers, shells and programs with many system calls are preferably written in C. Applications with graphical user interface often use more complex languages with polymorphic types.
Dynamic Libraries
The manpage ld-linux.8 describes the linux dynamic linker/loader.
Example to trace SQLite with a dynamic library
/* This library overrides sqlite3_open with a trace function for preloading See also ld-linux.8 cc sqlite3_trace.c \ -shared \ -fPIC \ -lsqlite3 \ -ldl \ -o sqlite3_trace.so \ -Wl,-init=lib_init */ #define _GNU_SOURCE // RTLD_NEXT #include <assert.h> #include <dlfcn.h> #include <sqlite3.h> #include <stdio.h> /** * Log database queries. */ void trace(void * a, const char * sql) { printf("-- %s\n", sql); fflush(stdout); } /** * Log sql time. */ void profile(void* a, const char* b, sqlite3_uint64 time) { printf( "-- SQL finished in %u ms\n", (unsigned int) time / 1000000); fflush(stdout); } typedef SQLITE_API int (*sqlite3_open_fp)( const char *filename, sqlite3 **ppDb); sqlite3_open_fp fun; void lib_init (void) { assert(RTLD_NEXT); void* original_sqlite3_open = dlsym(RTLD_NEXT, "sqlite3_open"); assert(original_sqlite3_open); fun=(sqlite3_open_fp)original_sqlite3_open; } SQLITE_API int sqlite3_open ( const char *filename, sqlite3 **ppDb) { int ret=fun(filename, ppDb); sqlite3_trace((sqlite3*) *ppDb, trace, NULL); //sqlite3_profile((sqlite3*) *ppDb, profile, NULL); return ret; }