let’s say I have a source file dll.c
that use dlopen
and dlsym
functions to load a shared library called F.so
in run time.
dll.c
has a reference to some_function()
, and F.so
has the definition of some_function()
.
and let’s say the picture below is the executable object prog
which is obtained by
linux> gcc -rdynamic -o prog dll.c -ldl
so .text
section contains the reference of some_function()
that needs to be resolved when the porgram load F.so
and start to call some_function()
My questions are:
Q1-it seems to me that the .text
section(where some_function()
belongs to) in RAM(executable is copied into memory) needs to be modified by the dynamic linker so that the reference of some_function()
can be resolved, is my understanding correct?
Q2-If the dynamic linker needs to modify the .text
section in RAM, how does it do it? from my understanding, .text
section is read-only segment in RAM, how can a read-only segment be modified if it is called read-only?
Go to Source
Author: slowjams