[llvm-dev] Create the GlobalVariable which have extern in one header file

Mustakimur Khandaker via llvm-dev llvm-dev at lists.llvm.org
Thu Feb 21 18:53:04 PST 2019

Good day. I am facing issue with creating a GlobalVariable. I already have an extern for that global in a header file to use it in the following way

extern const void* DATA_TABLE[];

And with a LLVM PASS, I am trying to create this array with the same name and with initializer. So, I have following:

GlobalVariable *gvar_data = new GlobalVariable(
    M, blockItems->getType(), true, GlobalValue::CommonLinkage,
    blockItems, "DATA_TABLE");

I am not sure if I am using the correct Linkage or not.
The pass has failed to complete it. Here is the runtime fault. Any guess what I am doing incorrect?

'common' global must have a zero initializer!
[10 x i8*]* @DATA_TABLE.1
LLVM ERROR: Broken module found, compilation aborted:::::::::!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190222/4fd50559/attachment.html>

More information about the llvm-dev mailing list