user9623401
user9623401

Reputation:

what's the relationship between dlfcn.c, ld-linux.so and libdl.so?

I'm new to C and linker, sorry if my question sounds weird.

I check online and found dlfcn.c, ld-linux.so are both called dynamic linker, then comes the libdl.so which is dynamic linker library by its name, so what's the relationsip between them?

does dlfcn.c and other essentiaL .C files used to generate ld-linux.so? if yes then what's the difference between ld-linux.so and libdl.so?

Upvotes: 1

Views: 1758

Answers (1)

Martin Rosenau
Martin Rosenau

Reputation: 18493

ld-linux.so

... is what I call "the dynamic linker":

This file is loaded by the Linux kernel together with an ELF file when the ELF file requires dynamic libraries.

The file ld-linux.so contains the code that loads the dynamic libraries (for example libc.so) needed by the ELF file from the disk to memory.

libdl.so

This file is a dynamic library that contains functions like dlopen() or dlsym():

These functions allow a program to "dynamically" load dynamic libraries - this means the program can call a function to load a dynamic library.

One of many use-cases are plug-ins that the user may configure in some configuration dialog (so these plug-ins do not appear in the list of required files stored inside the executable file).

dlfcn.c

I'm not absolutely sure, but this file seems to be part of the source code of libdl.so.

Upvotes: 3

Related Questions