How can the dynamic linker/loader itself be dynamically linked as reported by `file`?Error Loading Shared Libraries when Installing Redhat Directory ServerWhy does ldd show this dynamic linker location?Cannot create root jailWhy does chroot get ENOENT on an existing file?9 Mb Slackware distro - possible?dynamic linker/loader libs - missing ld.soWhat is the order that Linux's dynamic linker searches paths in?How to run programs with ld-linux.so?Placed library in /usr/lib, but ldconfig doesn't put it in cache
How to prevent pickpocketing in busy bars?
How do we know neutrons have no charge?
How can I install Fritz 16 on a Mac running macOS Mojave?
"I will not" or "I don't" as an answer for negative orders?
Is determiner 'a' needed here?
Lost passport which have valid student visa but I make new passport unable paste
Why aren't faces sharp in my f/1.8 portraits even though I'm carefully using center-point autofocus?
Can someone give the intuition behind Mean Absolute Error and the Median?
Why is a road bike faster than a city bike with the same effort? How much faster it can be?
Create the same subfolders in another folder
Garage door sticks on a bolt
Windows 10 deletes lots of tiny files super slowly. Anything that can be done to speed it up?
Fix Ethernet 10/100 PoE cable with 7 out of 8 wires alive
is there a relationship between prime numbers and music?
Calculate the Ultraradical
How can I find Marin?
MaxDetect speed
What makes learning more difficult as we age?
Is there any exception that proves or suggests that the law of non-contradiction does not always apply?
Do interval ratios take overtones into account or solely the fundamental frequency?
お仕事に学校頑張って meaning
What can Thomas Cook customers who have not yet departed do now it has stopped operating?
One-digit products in a row of numbers
Convert a string of digits from words to an integer
How can the dynamic linker/loader itself be dynamically linked as reported by `file`?
Error Loading Shared Libraries when Installing Redhat Directory ServerWhy does ldd show this dynamic linker location?Cannot create root jailWhy does chroot get ENOENT on an existing file?9 Mb Slackware distro - possible?dynamic linker/loader libs - missing ld.soWhat is the order that Linux's dynamic linker searches paths in?How to run programs with ld-linux.so?Placed library in /usr/lib, but ldconfig doesn't put it in cache
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Consider the shared object dependencies of /bin/bash
, which includes /lib64/ld-linux-x86-64.so.2
(dynamic linker/loader):
ldd /bin/bash
linux-vdso.so.1 (0x00007fffd0887000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f57a04e3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f57a04de000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f57a031d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f57a0652000)
Inspecting /lib64/ld-linux-x86-64.so.2
shows that it is a symlink to /lib/x86_64-linux-gnu/ld-2.28.so
:
ls -la /lib64/ld-linux-x86-64.so.2
lrwxrwxrwx 1 root root 32 May 1 19:24 /lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.28.so
Furthermore, file
reports /lib/x86_64-linux-gnu/ld-2.28.so
to itself be dynamically linked:
file -L /lib64/ld-linux-x86-64.so.2
/lib64/ld-linux-x86-64.so.2: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
I'd like to know:
- How can the dynamically linker/loader (
/lib64/ld-linux-x86-64.so.2
) itself be dynamically linked? Does it link itself at runtime? /lib/x86_64-linux-gnu/ld-2.28.so
is documented to handle a.out
binaries (man ld.so
), but/bin/bash
is an ELF executable?
The program ld.so handles a.out binaries, a format used long ago;
ld-linux.so* (/lib/ld-linux.so.1 for libc5, /lib/ld-linux.so.2 for
glibc2) han‐
dles ELF, which everybody has been using for years now.
linux dynamic-linking shared-library file-command
add a comment
|
Consider the shared object dependencies of /bin/bash
, which includes /lib64/ld-linux-x86-64.so.2
(dynamic linker/loader):
ldd /bin/bash
linux-vdso.so.1 (0x00007fffd0887000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f57a04e3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f57a04de000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f57a031d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f57a0652000)
Inspecting /lib64/ld-linux-x86-64.so.2
shows that it is a symlink to /lib/x86_64-linux-gnu/ld-2.28.so
:
ls -la /lib64/ld-linux-x86-64.so.2
lrwxrwxrwx 1 root root 32 May 1 19:24 /lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.28.so
Furthermore, file
reports /lib/x86_64-linux-gnu/ld-2.28.so
to itself be dynamically linked:
file -L /lib64/ld-linux-x86-64.so.2
/lib64/ld-linux-x86-64.so.2: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
I'd like to know:
- How can the dynamically linker/loader (
/lib64/ld-linux-x86-64.so.2
) itself be dynamically linked? Does it link itself at runtime? /lib/x86_64-linux-gnu/ld-2.28.so
is documented to handle a.out
binaries (man ld.so
), but/bin/bash
is an ELF executable?
The program ld.so handles a.out binaries, a format used long ago;
ld-linux.so* (/lib/ld-linux.so.1 for libc5, /lib/ld-linux.so.2 for
glibc2) han‐
dles ELF, which everybody has been using for years now.
linux dynamic-linking shared-library file-command
The kernel does not care about such subtle taxonomic subtleties (and neither should you ;-)). The kernel only makes the difference between ELFs which need an interpreter and those which don't. And AFAIK, you cannot use an interpreter which itself needs one.
– mosvy
6 hours ago
@StephenKitt mine hasn't (/lib/x86_64-linux-gnu/ld-2.28.so
, debian 10 buster)
– mosvy
6 hours ago
@mosvy yeah, sorry, I got mixed up betweenfile
’s erroneous comment about how it defines static binaries, and the reality ofld-2.28.so
... The differentiator isPT_DYNAMIC
.
– Stephen Kitt
6 hours ago
add a comment
|
Consider the shared object dependencies of /bin/bash
, which includes /lib64/ld-linux-x86-64.so.2
(dynamic linker/loader):
ldd /bin/bash
linux-vdso.so.1 (0x00007fffd0887000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f57a04e3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f57a04de000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f57a031d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f57a0652000)
Inspecting /lib64/ld-linux-x86-64.so.2
shows that it is a symlink to /lib/x86_64-linux-gnu/ld-2.28.so
:
ls -la /lib64/ld-linux-x86-64.so.2
lrwxrwxrwx 1 root root 32 May 1 19:24 /lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.28.so
Furthermore, file
reports /lib/x86_64-linux-gnu/ld-2.28.so
to itself be dynamically linked:
file -L /lib64/ld-linux-x86-64.so.2
/lib64/ld-linux-x86-64.so.2: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
I'd like to know:
- How can the dynamically linker/loader (
/lib64/ld-linux-x86-64.so.2
) itself be dynamically linked? Does it link itself at runtime? /lib/x86_64-linux-gnu/ld-2.28.so
is documented to handle a.out
binaries (man ld.so
), but/bin/bash
is an ELF executable?
The program ld.so handles a.out binaries, a format used long ago;
ld-linux.so* (/lib/ld-linux.so.1 for libc5, /lib/ld-linux.so.2 for
glibc2) han‐
dles ELF, which everybody has been using for years now.
linux dynamic-linking shared-library file-command
Consider the shared object dependencies of /bin/bash
, which includes /lib64/ld-linux-x86-64.so.2
(dynamic linker/loader):
ldd /bin/bash
linux-vdso.so.1 (0x00007fffd0887000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f57a04e3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f57a04de000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f57a031d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f57a0652000)
Inspecting /lib64/ld-linux-x86-64.so.2
shows that it is a symlink to /lib/x86_64-linux-gnu/ld-2.28.so
:
ls -la /lib64/ld-linux-x86-64.so.2
lrwxrwxrwx 1 root root 32 May 1 19:24 /lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.28.so
Furthermore, file
reports /lib/x86_64-linux-gnu/ld-2.28.so
to itself be dynamically linked:
file -L /lib64/ld-linux-x86-64.so.2
/lib64/ld-linux-x86-64.so.2: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
I'd like to know:
- How can the dynamically linker/loader (
/lib64/ld-linux-x86-64.so.2
) itself be dynamically linked? Does it link itself at runtime? /lib/x86_64-linux-gnu/ld-2.28.so
is documented to handle a.out
binaries (man ld.so
), but/bin/bash
is an ELF executable?
The program ld.so handles a.out binaries, a format used long ago;
ld-linux.so* (/lib/ld-linux.so.1 for libc5, /lib/ld-linux.so.2 for
glibc2) han‐
dles ELF, which everybody has been using for years now.
linux dynamic-linking shared-library file-command
linux dynamic-linking shared-library file-command
edited 8 hours ago


Jeff Schaller♦
50k11 gold badges74 silver badges166 bronze badges
50k11 gold badges74 silver badges166 bronze badges
asked 8 hours ago
ShuzhengShuzheng
5252 silver badges10 bronze badges
5252 silver badges10 bronze badges
The kernel does not care about such subtle taxonomic subtleties (and neither should you ;-)). The kernel only makes the difference between ELFs which need an interpreter and those which don't. And AFAIK, you cannot use an interpreter which itself needs one.
– mosvy
6 hours ago
@StephenKitt mine hasn't (/lib/x86_64-linux-gnu/ld-2.28.so
, debian 10 buster)
– mosvy
6 hours ago
@mosvy yeah, sorry, I got mixed up betweenfile
’s erroneous comment about how it defines static binaries, and the reality ofld-2.28.so
... The differentiator isPT_DYNAMIC
.
– Stephen Kitt
6 hours ago
add a comment
|
The kernel does not care about such subtle taxonomic subtleties (and neither should you ;-)). The kernel only makes the difference between ELFs which need an interpreter and those which don't. And AFAIK, you cannot use an interpreter which itself needs one.
– mosvy
6 hours ago
@StephenKitt mine hasn't (/lib/x86_64-linux-gnu/ld-2.28.so
, debian 10 buster)
– mosvy
6 hours ago
@mosvy yeah, sorry, I got mixed up betweenfile
’s erroneous comment about how it defines static binaries, and the reality ofld-2.28.so
... The differentiator isPT_DYNAMIC
.
– Stephen Kitt
6 hours ago
The kernel does not care about such subtle taxonomic subtleties (and neither should you ;-)). The kernel only makes the difference between ELFs which need an interpreter and those which don't. And AFAIK, you cannot use an interpreter which itself needs one.
– mosvy
6 hours ago
The kernel does not care about such subtle taxonomic subtleties (and neither should you ;-)). The kernel only makes the difference between ELFs which need an interpreter and those which don't. And AFAIK, you cannot use an interpreter which itself needs one.
– mosvy
6 hours ago
@StephenKitt mine hasn't (
/lib/x86_64-linux-gnu/ld-2.28.so
, debian 10 buster)– mosvy
6 hours ago
@StephenKitt mine hasn't (
/lib/x86_64-linux-gnu/ld-2.28.so
, debian 10 buster)– mosvy
6 hours ago
@mosvy yeah, sorry, I got mixed up between
file
’s erroneous comment about how it defines static binaries, and the reality of ld-2.28.so
... The differentiator is PT_DYNAMIC
.– Stephen Kitt
6 hours ago
@mosvy yeah, sorry, I got mixed up between
file
’s erroneous comment about how it defines static binaries, and the reality of ld-2.28.so
... The differentiator is PT_DYNAMIC
.– Stephen Kitt
6 hours ago
add a comment
|
2 Answers
2
active
oldest
votes
Yes, it links itself when it initialises. Technically the dynamic linker doesn’t need object resolution and relocation for itself, since it’s fully resolved as-is, but it does define symbols and it has to take care of those when resolving the binary it’s “interpreting”, and those symbols are updated to point to their implementations in the loaded libraries. In particular, this affects
malloc
— the linker has a minimal version built-in, with the corresponding symbol, but that’s replaced by the C library’s version once it’s loaded and relocated (or even by an interposed version if there is one), with some care taken to ensure this doesn’t happen at a point where it might break the linker.The gory details are in
rtld.c
, in thedl_main
function.Note however that
ld.so
has no external dependencies. You can see the symbols involved withnm -D
; none of them are undefined.The manpage only refers to entries directly under
/lib
, i.e./lib/ld.so
(the libc 5 dynamic linker, which supportsa.out
) and/lib*/ld-linux*.so*
(the libc 6 dynamic linker, which supports ELF). The manpage is very specific, andld.so
is notld-2.28.so
.The dynamic linker found on the vast majority of current systems doesn’t include
a.out
support.
file
and ldd
report different things for the dynamic linker because they have different definitions of what constitutes a statically-linked binary. For ldd
, a binary is statically linked if it has no DT_NEEDED
symbols, i.e. no undefined symbols. For file
, an ELF binary is statically linked if it doesn’t have a PT_DYNAMIC
section (this will change in the release of file
following 5.37; it now uses the presence of a PT_INTERP
section as the indicator of a dynamically-linked binary, which matches the comment in the code).
The GNU C library dynamic linker doesn’t have any DT_NEEDED
symbols, but it does have a PT_DYNAMIC
section (since it is technically a shared library). As a result, ldd
(which is the dynamic linker) indicates that it’s statically linked, but file
indicates that it’s dynamically linked. It doesn’t have a PT_INTERP
section, so the next release of file
will also indicate that it’s statically linked.
$ ldd /lib64/ld-linux-x86-64.so.2
statically linked
$ file $(readlink /lib64/ld-linux-x86-64.so.2)
/lib/x86_64-linux-gnu/ld-2.28.so: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
(with file
5.35)
$ file $(readlink /lib64/ld-linux-x86-64.so.2)
/lib/x86_64-linux-gnu/ld-2.28.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
(with the currently in-development version of file
).
Why is the word "interpreting" used in the context of dynamic linking? That word is usually used in the context of programing languages.
– Shuzheng
3 hours ago
What do you mean by "GNU C library dynamic linker"? Are you referring to/lib*/ld-linux*.so*
, or a third dynamic linker?
– Shuzheng
3 hours ago
Where can you seeldd
reports the dynamic linker as statically linked? Because it's list of shared object dependencies is empty?
– Shuzheng
3 hours ago
Dynamically-linked programs need some work done to them before they can be executed; that work is done by the dynamic linker, which ends up playing a similar role to an interpreter — it interprets the relocation tables etc. to produce something which the computer can run.
– Stephen Kitt
3 hours ago
When I say “GNU C library dynamic linker”, I am referring to the implementation included in the GNU C library, usually shipped as/lib*/ld-linux*.so*
. I specified the origin of the dynamic linker because there are other implementations available for Linux.
– Stephen Kitt
3 hours ago
|
show 6 more comments
I suspect the
file
program is wrong about the dynamically linker/loader being dynamically linked itself. Theldd
program does not agree. At least not on my system (Debian Stretch):ldd /lib/x86_64-linux-gnu/ld-2.24.so
statically linkedman ld.so
also reads: "ld-linux.so* handles ELF". On your system (and mine too by the way) both are symlinks to the same binary which I deduce is able to handle both ELF and the (old obsolete) a.out format.
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f543205%2fhow-can-the-dynamic-linker-loader-itself-be-dynamically-linked-as-reported-by-f%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Yes, it links itself when it initialises. Technically the dynamic linker doesn’t need object resolution and relocation for itself, since it’s fully resolved as-is, but it does define symbols and it has to take care of those when resolving the binary it’s “interpreting”, and those symbols are updated to point to their implementations in the loaded libraries. In particular, this affects
malloc
— the linker has a minimal version built-in, with the corresponding symbol, but that’s replaced by the C library’s version once it’s loaded and relocated (or even by an interposed version if there is one), with some care taken to ensure this doesn’t happen at a point where it might break the linker.The gory details are in
rtld.c
, in thedl_main
function.Note however that
ld.so
has no external dependencies. You can see the symbols involved withnm -D
; none of them are undefined.The manpage only refers to entries directly under
/lib
, i.e./lib/ld.so
(the libc 5 dynamic linker, which supportsa.out
) and/lib*/ld-linux*.so*
(the libc 6 dynamic linker, which supports ELF). The manpage is very specific, andld.so
is notld-2.28.so
.The dynamic linker found on the vast majority of current systems doesn’t include
a.out
support.
file
and ldd
report different things for the dynamic linker because they have different definitions of what constitutes a statically-linked binary. For ldd
, a binary is statically linked if it has no DT_NEEDED
symbols, i.e. no undefined symbols. For file
, an ELF binary is statically linked if it doesn’t have a PT_DYNAMIC
section (this will change in the release of file
following 5.37; it now uses the presence of a PT_INTERP
section as the indicator of a dynamically-linked binary, which matches the comment in the code).
The GNU C library dynamic linker doesn’t have any DT_NEEDED
symbols, but it does have a PT_DYNAMIC
section (since it is technically a shared library). As a result, ldd
(which is the dynamic linker) indicates that it’s statically linked, but file
indicates that it’s dynamically linked. It doesn’t have a PT_INTERP
section, so the next release of file
will also indicate that it’s statically linked.
$ ldd /lib64/ld-linux-x86-64.so.2
statically linked
$ file $(readlink /lib64/ld-linux-x86-64.so.2)
/lib/x86_64-linux-gnu/ld-2.28.so: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
(with file
5.35)
$ file $(readlink /lib64/ld-linux-x86-64.so.2)
/lib/x86_64-linux-gnu/ld-2.28.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
(with the currently in-development version of file
).
Why is the word "interpreting" used in the context of dynamic linking? That word is usually used in the context of programing languages.
– Shuzheng
3 hours ago
What do you mean by "GNU C library dynamic linker"? Are you referring to/lib*/ld-linux*.so*
, or a third dynamic linker?
– Shuzheng
3 hours ago
Where can you seeldd
reports the dynamic linker as statically linked? Because it's list of shared object dependencies is empty?
– Shuzheng
3 hours ago
Dynamically-linked programs need some work done to them before they can be executed; that work is done by the dynamic linker, which ends up playing a similar role to an interpreter — it interprets the relocation tables etc. to produce something which the computer can run.
– Stephen Kitt
3 hours ago
When I say “GNU C library dynamic linker”, I am referring to the implementation included in the GNU C library, usually shipped as/lib*/ld-linux*.so*
. I specified the origin of the dynamic linker because there are other implementations available for Linux.
– Stephen Kitt
3 hours ago
|
show 6 more comments
Yes, it links itself when it initialises. Technically the dynamic linker doesn’t need object resolution and relocation for itself, since it’s fully resolved as-is, but it does define symbols and it has to take care of those when resolving the binary it’s “interpreting”, and those symbols are updated to point to their implementations in the loaded libraries. In particular, this affects
malloc
— the linker has a minimal version built-in, with the corresponding symbol, but that’s replaced by the C library’s version once it’s loaded and relocated (or even by an interposed version if there is one), with some care taken to ensure this doesn’t happen at a point where it might break the linker.The gory details are in
rtld.c
, in thedl_main
function.Note however that
ld.so
has no external dependencies. You can see the symbols involved withnm -D
; none of them are undefined.The manpage only refers to entries directly under
/lib
, i.e./lib/ld.so
(the libc 5 dynamic linker, which supportsa.out
) and/lib*/ld-linux*.so*
(the libc 6 dynamic linker, which supports ELF). The manpage is very specific, andld.so
is notld-2.28.so
.The dynamic linker found on the vast majority of current systems doesn’t include
a.out
support.
file
and ldd
report different things for the dynamic linker because they have different definitions of what constitutes a statically-linked binary. For ldd
, a binary is statically linked if it has no DT_NEEDED
symbols, i.e. no undefined symbols. For file
, an ELF binary is statically linked if it doesn’t have a PT_DYNAMIC
section (this will change in the release of file
following 5.37; it now uses the presence of a PT_INTERP
section as the indicator of a dynamically-linked binary, which matches the comment in the code).
The GNU C library dynamic linker doesn’t have any DT_NEEDED
symbols, but it does have a PT_DYNAMIC
section (since it is technically a shared library). As a result, ldd
(which is the dynamic linker) indicates that it’s statically linked, but file
indicates that it’s dynamically linked. It doesn’t have a PT_INTERP
section, so the next release of file
will also indicate that it’s statically linked.
$ ldd /lib64/ld-linux-x86-64.so.2
statically linked
$ file $(readlink /lib64/ld-linux-x86-64.so.2)
/lib/x86_64-linux-gnu/ld-2.28.so: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
(with file
5.35)
$ file $(readlink /lib64/ld-linux-x86-64.so.2)
/lib/x86_64-linux-gnu/ld-2.28.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
(with the currently in-development version of file
).
Why is the word "interpreting" used in the context of dynamic linking? That word is usually used in the context of programing languages.
– Shuzheng
3 hours ago
What do you mean by "GNU C library dynamic linker"? Are you referring to/lib*/ld-linux*.so*
, or a third dynamic linker?
– Shuzheng
3 hours ago
Where can you seeldd
reports the dynamic linker as statically linked? Because it's list of shared object dependencies is empty?
– Shuzheng
3 hours ago
Dynamically-linked programs need some work done to them before they can be executed; that work is done by the dynamic linker, which ends up playing a similar role to an interpreter — it interprets the relocation tables etc. to produce something which the computer can run.
– Stephen Kitt
3 hours ago
When I say “GNU C library dynamic linker”, I am referring to the implementation included in the GNU C library, usually shipped as/lib*/ld-linux*.so*
. I specified the origin of the dynamic linker because there are other implementations available for Linux.
– Stephen Kitt
3 hours ago
|
show 6 more comments
Yes, it links itself when it initialises. Technically the dynamic linker doesn’t need object resolution and relocation for itself, since it’s fully resolved as-is, but it does define symbols and it has to take care of those when resolving the binary it’s “interpreting”, and those symbols are updated to point to their implementations in the loaded libraries. In particular, this affects
malloc
— the linker has a minimal version built-in, with the corresponding symbol, but that’s replaced by the C library’s version once it’s loaded and relocated (or even by an interposed version if there is one), with some care taken to ensure this doesn’t happen at a point where it might break the linker.The gory details are in
rtld.c
, in thedl_main
function.Note however that
ld.so
has no external dependencies. You can see the symbols involved withnm -D
; none of them are undefined.The manpage only refers to entries directly under
/lib
, i.e./lib/ld.so
(the libc 5 dynamic linker, which supportsa.out
) and/lib*/ld-linux*.so*
(the libc 6 dynamic linker, which supports ELF). The manpage is very specific, andld.so
is notld-2.28.so
.The dynamic linker found on the vast majority of current systems doesn’t include
a.out
support.
file
and ldd
report different things for the dynamic linker because they have different definitions of what constitutes a statically-linked binary. For ldd
, a binary is statically linked if it has no DT_NEEDED
symbols, i.e. no undefined symbols. For file
, an ELF binary is statically linked if it doesn’t have a PT_DYNAMIC
section (this will change in the release of file
following 5.37; it now uses the presence of a PT_INTERP
section as the indicator of a dynamically-linked binary, which matches the comment in the code).
The GNU C library dynamic linker doesn’t have any DT_NEEDED
symbols, but it does have a PT_DYNAMIC
section (since it is technically a shared library). As a result, ldd
(which is the dynamic linker) indicates that it’s statically linked, but file
indicates that it’s dynamically linked. It doesn’t have a PT_INTERP
section, so the next release of file
will also indicate that it’s statically linked.
$ ldd /lib64/ld-linux-x86-64.so.2
statically linked
$ file $(readlink /lib64/ld-linux-x86-64.so.2)
/lib/x86_64-linux-gnu/ld-2.28.so: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
(with file
5.35)
$ file $(readlink /lib64/ld-linux-x86-64.so.2)
/lib/x86_64-linux-gnu/ld-2.28.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
(with the currently in-development version of file
).
Yes, it links itself when it initialises. Technically the dynamic linker doesn’t need object resolution and relocation for itself, since it’s fully resolved as-is, but it does define symbols and it has to take care of those when resolving the binary it’s “interpreting”, and those symbols are updated to point to their implementations in the loaded libraries. In particular, this affects
malloc
— the linker has a minimal version built-in, with the corresponding symbol, but that’s replaced by the C library’s version once it’s loaded and relocated (or even by an interposed version if there is one), with some care taken to ensure this doesn’t happen at a point where it might break the linker.The gory details are in
rtld.c
, in thedl_main
function.Note however that
ld.so
has no external dependencies. You can see the symbols involved withnm -D
; none of them are undefined.The manpage only refers to entries directly under
/lib
, i.e./lib/ld.so
(the libc 5 dynamic linker, which supportsa.out
) and/lib*/ld-linux*.so*
(the libc 6 dynamic linker, which supports ELF). The manpage is very specific, andld.so
is notld-2.28.so
.The dynamic linker found on the vast majority of current systems doesn’t include
a.out
support.
file
and ldd
report different things for the dynamic linker because they have different definitions of what constitutes a statically-linked binary. For ldd
, a binary is statically linked if it has no DT_NEEDED
symbols, i.e. no undefined symbols. For file
, an ELF binary is statically linked if it doesn’t have a PT_DYNAMIC
section (this will change in the release of file
following 5.37; it now uses the presence of a PT_INTERP
section as the indicator of a dynamically-linked binary, which matches the comment in the code).
The GNU C library dynamic linker doesn’t have any DT_NEEDED
symbols, but it does have a PT_DYNAMIC
section (since it is technically a shared library). As a result, ldd
(which is the dynamic linker) indicates that it’s statically linked, but file
indicates that it’s dynamically linked. It doesn’t have a PT_INTERP
section, so the next release of file
will also indicate that it’s statically linked.
$ ldd /lib64/ld-linux-x86-64.so.2
statically linked
$ file $(readlink /lib64/ld-linux-x86-64.so.2)
/lib/x86_64-linux-gnu/ld-2.28.so: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
(with file
5.35)
$ file $(readlink /lib64/ld-linux-x86-64.so.2)
/lib/x86_64-linux-gnu/ld-2.28.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
(with the currently in-development version of file
).
edited 3 hours ago
answered 6 hours ago
Stephen KittStephen Kitt
205k27 gold badges485 silver badges553 bronze badges
205k27 gold badges485 silver badges553 bronze badges
Why is the word "interpreting" used in the context of dynamic linking? That word is usually used in the context of programing languages.
– Shuzheng
3 hours ago
What do you mean by "GNU C library dynamic linker"? Are you referring to/lib*/ld-linux*.so*
, or a third dynamic linker?
– Shuzheng
3 hours ago
Where can you seeldd
reports the dynamic linker as statically linked? Because it's list of shared object dependencies is empty?
– Shuzheng
3 hours ago
Dynamically-linked programs need some work done to them before they can be executed; that work is done by the dynamic linker, which ends up playing a similar role to an interpreter — it interprets the relocation tables etc. to produce something which the computer can run.
– Stephen Kitt
3 hours ago
When I say “GNU C library dynamic linker”, I am referring to the implementation included in the GNU C library, usually shipped as/lib*/ld-linux*.so*
. I specified the origin of the dynamic linker because there are other implementations available for Linux.
– Stephen Kitt
3 hours ago
|
show 6 more comments
Why is the word "interpreting" used in the context of dynamic linking? That word is usually used in the context of programing languages.
– Shuzheng
3 hours ago
What do you mean by "GNU C library dynamic linker"? Are you referring to/lib*/ld-linux*.so*
, or a third dynamic linker?
– Shuzheng
3 hours ago
Where can you seeldd
reports the dynamic linker as statically linked? Because it's list of shared object dependencies is empty?
– Shuzheng
3 hours ago
Dynamically-linked programs need some work done to them before they can be executed; that work is done by the dynamic linker, which ends up playing a similar role to an interpreter — it interprets the relocation tables etc. to produce something which the computer can run.
– Stephen Kitt
3 hours ago
When I say “GNU C library dynamic linker”, I am referring to the implementation included in the GNU C library, usually shipped as/lib*/ld-linux*.so*
. I specified the origin of the dynamic linker because there are other implementations available for Linux.
– Stephen Kitt
3 hours ago
Why is the word "interpreting" used in the context of dynamic linking? That word is usually used in the context of programing languages.
– Shuzheng
3 hours ago
Why is the word "interpreting" used in the context of dynamic linking? That word is usually used in the context of programing languages.
– Shuzheng
3 hours ago
What do you mean by "GNU C library dynamic linker"? Are you referring to
/lib*/ld-linux*.so*
, or a third dynamic linker?– Shuzheng
3 hours ago
What do you mean by "GNU C library dynamic linker"? Are you referring to
/lib*/ld-linux*.so*
, or a third dynamic linker?– Shuzheng
3 hours ago
Where can you see
ldd
reports the dynamic linker as statically linked? Because it's list of shared object dependencies is empty?– Shuzheng
3 hours ago
Where can you see
ldd
reports the dynamic linker as statically linked? Because it's list of shared object dependencies is empty?– Shuzheng
3 hours ago
Dynamically-linked programs need some work done to them before they can be executed; that work is done by the dynamic linker, which ends up playing a similar role to an interpreter — it interprets the relocation tables etc. to produce something which the computer can run.
– Stephen Kitt
3 hours ago
Dynamically-linked programs need some work done to them before they can be executed; that work is done by the dynamic linker, which ends up playing a similar role to an interpreter — it interprets the relocation tables etc. to produce something which the computer can run.
– Stephen Kitt
3 hours ago
When I say “GNU C library dynamic linker”, I am referring to the implementation included in the GNU C library, usually shipped as
/lib*/ld-linux*.so*
. I specified the origin of the dynamic linker because there are other implementations available for Linux.– Stephen Kitt
3 hours ago
When I say “GNU C library dynamic linker”, I am referring to the implementation included in the GNU C library, usually shipped as
/lib*/ld-linux*.so*
. I specified the origin of the dynamic linker because there are other implementations available for Linux.– Stephen Kitt
3 hours ago
|
show 6 more comments
I suspect the
file
program is wrong about the dynamically linker/loader being dynamically linked itself. Theldd
program does not agree. At least not on my system (Debian Stretch):ldd /lib/x86_64-linux-gnu/ld-2.24.so
statically linkedman ld.so
also reads: "ld-linux.so* handles ELF". On your system (and mine too by the way) both are symlinks to the same binary which I deduce is able to handle both ELF and the (old obsolete) a.out format.
add a comment
|
I suspect the
file
program is wrong about the dynamically linker/loader being dynamically linked itself. Theldd
program does not agree. At least not on my system (Debian Stretch):ldd /lib/x86_64-linux-gnu/ld-2.24.so
statically linkedman ld.so
also reads: "ld-linux.so* handles ELF". On your system (and mine too by the way) both are symlinks to the same binary which I deduce is able to handle both ELF and the (old obsolete) a.out format.
add a comment
|
I suspect the
file
program is wrong about the dynamically linker/loader being dynamically linked itself. Theldd
program does not agree. At least not on my system (Debian Stretch):ldd /lib/x86_64-linux-gnu/ld-2.24.so
statically linkedman ld.so
also reads: "ld-linux.so* handles ELF". On your system (and mine too by the way) both are symlinks to the same binary which I deduce is able to handle both ELF and the (old obsolete) a.out format.
I suspect the
file
program is wrong about the dynamically linker/loader being dynamically linked itself. Theldd
program does not agree. At least not on my system (Debian Stretch):ldd /lib/x86_64-linux-gnu/ld-2.24.so
statically linkedman ld.so
also reads: "ld-linux.so* handles ELF". On your system (and mine too by the way) both are symlinks to the same binary which I deduce is able to handle both ELF and the (old obsolete) a.out format.
answered 7 hours ago


HkoofHkoof
1,3377 silver badges10 bronze badges
1,3377 silver badges10 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f543205%2fhow-can-the-dynamic-linker-loader-itself-be-dynamically-linked-as-reported-by-f%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The kernel does not care about such subtle taxonomic subtleties (and neither should you ;-)). The kernel only makes the difference between ELFs which need an interpreter and those which don't. And AFAIK, you cannot use an interpreter which itself needs one.
– mosvy
6 hours ago
@StephenKitt mine hasn't (
/lib/x86_64-linux-gnu/ld-2.28.so
, debian 10 buster)– mosvy
6 hours ago
@mosvy yeah, sorry, I got mixed up between
file
’s erroneous comment about how it defines static binaries, and the reality ofld-2.28.so
... The differentiator isPT_DYNAMIC
.– Stephen Kitt
6 hours ago