Artificial intelligent assistant

Is the dynamic linker automatically invoked by the operating system or by code embedded in the ELF file? I'm not sure, whether the dynamic linker `/usr/bin/ld` is automatically invoked by the operating system, when the ELF file is loaded, or whether it's invoked by code embedded in the ELF file? When I use `r2` to debug an ELF file, it stops at first instruction to be executed, which should be dynamic linker code, but I don't know if this code is part of the ELF file.

The kernel loads the dynamic loader (which isn’t `/usr/bin/ld`; see what are the executable ELF files respectively for static linker, dynamic linker, loader and dynamic loader?).

When you run an ELF binary, the kernel uses its specific ELF binary loader; for dynamically-linked binaries, this looks for the interpreter specified in the ELF headers, loads that and instructs it to run the target binary. The interpreter is the dynamic loader, which loads any required libraries, resolves the undefined symbols, and jumps to the programs start address. (See What types of executable files exist on Linux? for details of the binary loads in the kernel.)

LWN has an article which goes into the details, How programs get run: ELF binaries.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 287f653251fa39b03af0db32ccd5f424