Re: [llvm-dev] Global Variable Initialization via Internal Function
On Mon, May 7, 2018 at 2:43 PM Aaron via llvm-dev <[hidden email]>
> I'm trying to figure out how to initialize global variables via LLVM IR
and I found that clang creates a internal function to initialize global
variables if initialization values are not constants.
> Do we really need to create an internal function for complex global
variable initializations during variable declaration? Can't we create
instructions in global scope?
There might be other ways, but the C++ standard says something about the
order of initialisation of objects, and operating systems usually do this
by a convention. The convention seems to be that it will call functions
that are referred to from specially-named sections in a binary. So far, the
"cleanest" way of doing that is to define functions that get referred to
(by address) from these special sections.