This is the mail archive of the
mailing list for the binutils project.
[gold-linker] [ld-linker] Implementation of dynamic initialization for global variables and static member variables in C++
- From: Sanee Berlow <nepnepparadise at gmail dot com>
- To: binutils at sourceware dot org
- Date: Thu, 2 Jul 2015 23:02:23 +0800
- Subject: [gold-linker] [ld-linker] Implementation of dynamic initialization for global variables and static member variables in C++
- Authentication-results: sourceware.org; auth=none
I have a general question about the implementation of a linker feature
that I'm addressing to the knowledgeable maintainers of the gold/ld
linkers. I hope it's not too disruptive for me to ask here; if so then
I apologize. I'm not sure where else to go to get this information.
I'm a CS student working on a small linker for C++ programs, mostly
for self-learning purposes. I've figured things out so far by trial
and error and comparing the output of different linkers, but I've hit
a feature I'm having difficulty puzzling out and I can't find any
information about it whatsoever on the internet.
I've put the full question here:
To summarize the problem, I would like to know:
What information does the compiler place into a generated object file
relating to dynamic initialization of global variables and static
member variables for the linker to use?
What information does the linker place into the final linked module
during the linking process so that the OS module loader is able to
correctly initialize all variables (including dynamically initialized
global/static member variables that make calls to functions as part of
How is the function that needs to be executed during dynamic variable
initialization mapped to the particular variable that needs to be
initialized with that code?
When an executable or dynamically linked module is loaded, how is
dynamic initialization of variables performed?
Does the implementation of C++11 constant expressions (marked by the
constexpr specifier) involve any special considerations compared to
the implementation of regular static member variables and functions?
On stackoverflow I was looking for a very complete and detailed answer
thinking that it could potentially be useful for other users in the
future but I know that you guys have real issues to address and
limited time so I would be very happy to just have someone briefly
tell me the general gist of how it works and work out the details
myself from there.
I would greatly appreciate any help I'm given with this, I really want
to get this important feature working!
Thanks a lot for your time,