[llvm-dev] llvm-link: why link '@llvm.global_ctors' into dest file even it's not used in dest file?

Mehdi AMINI via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 3 15:15:15 PST 2019


On Wed, Jan 2, 2019 at 2:52 PM Fangqing Du via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi all,
> Recently I do some jobs based on llvm-link tool.
> I wonder why link '@llvm.global_ctors' into dest file, even it's not used
> in dest file?

This is a "magic" global variable:

It is implicitly used by the loader of the program before entering main().

Think about how a C++ global variable constructor can register itself and
the "destination file" you're mentionning can query this registry.

> And how can I remove it?

Like other global variables? You need to transform the module yourself
before linking it (if you believe it is safe to do so).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190103/99f1a843/attachment.html>

More information about the llvm-dev mailing list