Say library x.so
has a global variable y
which is being manipulated by a function(say fun1
) in the library.
When a process p1
is loaded into RAM whose code is using function fun1
from library x.so
, the library x.so will be loaded into RAM (if not already present) by ld.so and the function symbol gets resolved before the program starts executing.
Now where is this global variable created. Is it in process p1
?
What happens when another process p2
also uses fun1
(which is making operations on y
)?
Processes will get their private copies of y
and it will be replaced by a fresh copy when you call exec
. It will reside in the library's data segment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With