In need of help to understand the program behaviour while loading shared libraries and at linking time.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear GCC community,

I was working on making an interception library; which I pre-load before
I run the application that I need to use it for. This is intended to
perform some redirection for logging purposes.
In my library, I have the *__attribute__ constructor(()) *to set up the
logging environment that is needed to be run *before *any resolutions to
the calls defined in my library are made.
Now, my assumption was that at runtime, this constructor will be called
before any resolutions have been made to the functions that I have defined
in this library. For example, let's say that I was intercepting the
*ioctl *function.
My assumption was that the dynamic linker would only resolve any calls (and
call them) ONLY after the *__attribute__ constructor(())* has run; or
at-least run the *ctor *when it is found. But to my surprise, it happens to
be the case that the *ctor *is delayed (17-30 milliseconds).
I have made attempts to understand the stuff that happens between the
program getting loaded, but it was challenging to come to any conclusion. I
did watch a cppCon talk by Matt Godbolt which helped me understand the
specifics at this low-level, but I am afraid that I do not understand this
totally. I am a newbie into low-level systems programming, and I am loving
to work on this. Could I please have resources to understand this behaviour
from the community? It would also be great if there is any resolution (or
is it UB) to the behaviour that I asked about.

Thank you so much for your time, and for making the world a better place
with GCC. I truly appreciate it!

Thanks and Regards,
Shrihari H



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux