what are the executable ELF files respectively for static linker, dynamic linker, loader and dynamic loader?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
In Linux, what are the executable ELF files respectively for
- static linker
- dynamic linker
- loader
- dynamic loader?
Which of them are invoked
- by
execve()
- by
dlopen()
?
How are them invoked by execve()
or dlopen()
, to solve the chicken-egg problem that execve()
or dlopen()
are used for invoking executable files?
Thanks.
linux dynamic-linking load linker dynamic-loading
add a comment |Â
up vote
0
down vote
favorite
In Linux, what are the executable ELF files respectively for
- static linker
- dynamic linker
- loader
- dynamic loader?
Which of them are invoked
- by
execve()
- by
dlopen()
?
How are them invoked by execve()
or dlopen()
, to solve the chicken-egg problem that execve()
or dlopen()
are used for invoking executable files?
Thanks.
linux dynamic-linking load linker dynamic-loading
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In Linux, what are the executable ELF files respectively for
- static linker
- dynamic linker
- loader
- dynamic loader?
Which of them are invoked
- by
execve()
- by
dlopen()
?
How are them invoked by execve()
or dlopen()
, to solve the chicken-egg problem that execve()
or dlopen()
are used for invoking executable files?
Thanks.
linux dynamic-linking load linker dynamic-loading
In Linux, what are the executable ELF files respectively for
- static linker
- dynamic linker
- loader
- dynamic loader?
Which of them are invoked
- by
execve()
- by
dlopen()
?
How are them invoked by execve()
or dlopen()
, to solve the chicken-egg problem that execve()
or dlopen()
are used for invoking executable files?
Thanks.
linux dynamic-linking load linker dynamic-loading
linux dynamic-linking load linker dynamic-loading
edited 7 mins ago
Stephen Kitt
151k23337405
151k23337405
asked 28 mins ago
Tim
24.2k67233424
24.2k67233424
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
I take it youâÂÂre using Jeff DarcyâÂÂs definitions:
- static linking involves resolving symbols at compile time, whereas dynamic linking involves resolving them at run time;
- static loading involves mapping executables and libraries at load time, whereas dynamic loading involves mapping libraries after the process has started.
It doesnâÂÂt really make sense to try to split everything up; instead, you should consider the pairs of features:
- static loading, static linking: the linker is
/usr/bin/ld
typically, along with static libraries (.a
); the loader is the kernel; - static loading, dynamic linking: the linker is
/usr/bin/ld
again, but with shared libraries (.so
); the loader is the binaryâÂÂs interpreter, e.g./lib64/ld-linux-x86-64.so.2
(which maps to/lib/x86_64-linux-gnu/ld-2.24.so
currently) on Debian 9 on 64-bit x86, itself loaded by the kernel, which also loads the main executable; - dynamic loading, static linking: this isnâÂÂt used on Linux as far as IâÂÂm aware;
- dynamic loading, dynamic linking: the loader is a library such as
libdl
; the linker is split between the library and the program callinglibdl
.
Perhaps some more explanation is called for in relation to the last point. When a program uses libdl
to load a library, it calls dlopen
, which loads the named library, along with any of its dependencies which arenâÂÂt already available in the process, and links the named library with its dependencies. Thus libdl
performs both loading (of the necessary libraries) and linking (of the libraries only, not the calling program). When the calling program needs to use a symbol from the named library, it calls dlsym
which returns the address of the requested symbol (if it can find it). Thus the calling program performs part of the linking.
There is no chicken-and-egg problem with regards to execve
or dlopen
. Programs compiled to use execve
are compiled with the appropriate references to libc
(which contains the wrapper most programs actually use) and the execve
symbol (strictly speaking, the aforementioned wrapper). Those references are resolved either at compile-time (for statically-linked programs) or at load-time (for dynamically-linked programs); after that, the symbol is available for use and the program can call execve
. The same goes for dlopen
: programs which want to use dlopen
are compiled with the appropriate references to libdl
and dlopen
. The dynamic linker itself is a static binary, so the kernel can load it without the help of the dynamic linker. YouâÂÂll find lots more detail on this topic in How programs get run and How programs get run: ELF binaries.
(Note that in all cases of dynamic linking, if lazy binding is enabled, linking can happen just-in-time, and not necessarily at load time.)
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I take it youâÂÂre using Jeff DarcyâÂÂs definitions:
- static linking involves resolving symbols at compile time, whereas dynamic linking involves resolving them at run time;
- static loading involves mapping executables and libraries at load time, whereas dynamic loading involves mapping libraries after the process has started.
It doesnâÂÂt really make sense to try to split everything up; instead, you should consider the pairs of features:
- static loading, static linking: the linker is
/usr/bin/ld
typically, along with static libraries (.a
); the loader is the kernel; - static loading, dynamic linking: the linker is
/usr/bin/ld
again, but with shared libraries (.so
); the loader is the binaryâÂÂs interpreter, e.g./lib64/ld-linux-x86-64.so.2
(which maps to/lib/x86_64-linux-gnu/ld-2.24.so
currently) on Debian 9 on 64-bit x86, itself loaded by the kernel, which also loads the main executable; - dynamic loading, static linking: this isnâÂÂt used on Linux as far as IâÂÂm aware;
- dynamic loading, dynamic linking: the loader is a library such as
libdl
; the linker is split between the library and the program callinglibdl
.
Perhaps some more explanation is called for in relation to the last point. When a program uses libdl
to load a library, it calls dlopen
, which loads the named library, along with any of its dependencies which arenâÂÂt already available in the process, and links the named library with its dependencies. Thus libdl
performs both loading (of the necessary libraries) and linking (of the libraries only, not the calling program). When the calling program needs to use a symbol from the named library, it calls dlsym
which returns the address of the requested symbol (if it can find it). Thus the calling program performs part of the linking.
There is no chicken-and-egg problem with regards to execve
or dlopen
. Programs compiled to use execve
are compiled with the appropriate references to libc
(which contains the wrapper most programs actually use) and the execve
symbol (strictly speaking, the aforementioned wrapper). Those references are resolved either at compile-time (for statically-linked programs) or at load-time (for dynamically-linked programs); after that, the symbol is available for use and the program can call execve
. The same goes for dlopen
: programs which want to use dlopen
are compiled with the appropriate references to libdl
and dlopen
. The dynamic linker itself is a static binary, so the kernel can load it without the help of the dynamic linker. YouâÂÂll find lots more detail on this topic in How programs get run and How programs get run: ELF binaries.
(Note that in all cases of dynamic linking, if lazy binding is enabled, linking can happen just-in-time, and not necessarily at load time.)
add a comment |Â
up vote
1
down vote
I take it youâÂÂre using Jeff DarcyâÂÂs definitions:
- static linking involves resolving symbols at compile time, whereas dynamic linking involves resolving them at run time;
- static loading involves mapping executables and libraries at load time, whereas dynamic loading involves mapping libraries after the process has started.
It doesnâÂÂt really make sense to try to split everything up; instead, you should consider the pairs of features:
- static loading, static linking: the linker is
/usr/bin/ld
typically, along with static libraries (.a
); the loader is the kernel; - static loading, dynamic linking: the linker is
/usr/bin/ld
again, but with shared libraries (.so
); the loader is the binaryâÂÂs interpreter, e.g./lib64/ld-linux-x86-64.so.2
(which maps to/lib/x86_64-linux-gnu/ld-2.24.so
currently) on Debian 9 on 64-bit x86, itself loaded by the kernel, which also loads the main executable; - dynamic loading, static linking: this isnâÂÂt used on Linux as far as IâÂÂm aware;
- dynamic loading, dynamic linking: the loader is a library such as
libdl
; the linker is split between the library and the program callinglibdl
.
Perhaps some more explanation is called for in relation to the last point. When a program uses libdl
to load a library, it calls dlopen
, which loads the named library, along with any of its dependencies which arenâÂÂt already available in the process, and links the named library with its dependencies. Thus libdl
performs both loading (of the necessary libraries) and linking (of the libraries only, not the calling program). When the calling program needs to use a symbol from the named library, it calls dlsym
which returns the address of the requested symbol (if it can find it). Thus the calling program performs part of the linking.
There is no chicken-and-egg problem with regards to execve
or dlopen
. Programs compiled to use execve
are compiled with the appropriate references to libc
(which contains the wrapper most programs actually use) and the execve
symbol (strictly speaking, the aforementioned wrapper). Those references are resolved either at compile-time (for statically-linked programs) or at load-time (for dynamically-linked programs); after that, the symbol is available for use and the program can call execve
. The same goes for dlopen
: programs which want to use dlopen
are compiled with the appropriate references to libdl
and dlopen
. The dynamic linker itself is a static binary, so the kernel can load it without the help of the dynamic linker. YouâÂÂll find lots more detail on this topic in How programs get run and How programs get run: ELF binaries.
(Note that in all cases of dynamic linking, if lazy binding is enabled, linking can happen just-in-time, and not necessarily at load time.)
add a comment |Â
up vote
1
down vote
up vote
1
down vote
I take it youâÂÂre using Jeff DarcyâÂÂs definitions:
- static linking involves resolving symbols at compile time, whereas dynamic linking involves resolving them at run time;
- static loading involves mapping executables and libraries at load time, whereas dynamic loading involves mapping libraries after the process has started.
It doesnâÂÂt really make sense to try to split everything up; instead, you should consider the pairs of features:
- static loading, static linking: the linker is
/usr/bin/ld
typically, along with static libraries (.a
); the loader is the kernel; - static loading, dynamic linking: the linker is
/usr/bin/ld
again, but with shared libraries (.so
); the loader is the binaryâÂÂs interpreter, e.g./lib64/ld-linux-x86-64.so.2
(which maps to/lib/x86_64-linux-gnu/ld-2.24.so
currently) on Debian 9 on 64-bit x86, itself loaded by the kernel, which also loads the main executable; - dynamic loading, static linking: this isnâÂÂt used on Linux as far as IâÂÂm aware;
- dynamic loading, dynamic linking: the loader is a library such as
libdl
; the linker is split between the library and the program callinglibdl
.
Perhaps some more explanation is called for in relation to the last point. When a program uses libdl
to load a library, it calls dlopen
, which loads the named library, along with any of its dependencies which arenâÂÂt already available in the process, and links the named library with its dependencies. Thus libdl
performs both loading (of the necessary libraries) and linking (of the libraries only, not the calling program). When the calling program needs to use a symbol from the named library, it calls dlsym
which returns the address of the requested symbol (if it can find it). Thus the calling program performs part of the linking.
There is no chicken-and-egg problem with regards to execve
or dlopen
. Programs compiled to use execve
are compiled with the appropriate references to libc
(which contains the wrapper most programs actually use) and the execve
symbol (strictly speaking, the aforementioned wrapper). Those references are resolved either at compile-time (for statically-linked programs) or at load-time (for dynamically-linked programs); after that, the symbol is available for use and the program can call execve
. The same goes for dlopen
: programs which want to use dlopen
are compiled with the appropriate references to libdl
and dlopen
. The dynamic linker itself is a static binary, so the kernel can load it without the help of the dynamic linker. YouâÂÂll find lots more detail on this topic in How programs get run and How programs get run: ELF binaries.
(Note that in all cases of dynamic linking, if lazy binding is enabled, linking can happen just-in-time, and not necessarily at load time.)
I take it youâÂÂre using Jeff DarcyâÂÂs definitions:
- static linking involves resolving symbols at compile time, whereas dynamic linking involves resolving them at run time;
- static loading involves mapping executables and libraries at load time, whereas dynamic loading involves mapping libraries after the process has started.
It doesnâÂÂt really make sense to try to split everything up; instead, you should consider the pairs of features:
- static loading, static linking: the linker is
/usr/bin/ld
typically, along with static libraries (.a
); the loader is the kernel; - static loading, dynamic linking: the linker is
/usr/bin/ld
again, but with shared libraries (.so
); the loader is the binaryâÂÂs interpreter, e.g./lib64/ld-linux-x86-64.so.2
(which maps to/lib/x86_64-linux-gnu/ld-2.24.so
currently) on Debian 9 on 64-bit x86, itself loaded by the kernel, which also loads the main executable; - dynamic loading, static linking: this isnâÂÂt used on Linux as far as IâÂÂm aware;
- dynamic loading, dynamic linking: the loader is a library such as
libdl
; the linker is split between the library and the program callinglibdl
.
Perhaps some more explanation is called for in relation to the last point. When a program uses libdl
to load a library, it calls dlopen
, which loads the named library, along with any of its dependencies which arenâÂÂt already available in the process, and links the named library with its dependencies. Thus libdl
performs both loading (of the necessary libraries) and linking (of the libraries only, not the calling program). When the calling program needs to use a symbol from the named library, it calls dlsym
which returns the address of the requested symbol (if it can find it). Thus the calling program performs part of the linking.
There is no chicken-and-egg problem with regards to execve
or dlopen
. Programs compiled to use execve
are compiled with the appropriate references to libc
(which contains the wrapper most programs actually use) and the execve
symbol (strictly speaking, the aforementioned wrapper). Those references are resolved either at compile-time (for statically-linked programs) or at load-time (for dynamically-linked programs); after that, the symbol is available for use and the program can call execve
. The same goes for dlopen
: programs which want to use dlopen
are compiled with the appropriate references to libdl
and dlopen
. The dynamic linker itself is a static binary, so the kernel can load it without the help of the dynamic linker. YouâÂÂll find lots more detail on this topic in How programs get run and How programs get run: ELF binaries.
(Note that in all cases of dynamic linking, if lazy binding is enabled, linking can happen just-in-time, and not necessarily at load time.)
edited 2 mins ago
answered 8 mins ago
Stephen Kitt
151k23337405
151k23337405
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476780%2fwhat-are-the-executable-elf-files-respectively-for-static-linker-dynamic-linker%23new-answer', 'question_page');
);
Post as a guest
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
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
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