diff options
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index c1e81d4b5a..094f3c1065 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -2532,7 +2532,19 @@ void CppWriter::parseConstant(std::string name, const Constant* CV, bool calcula } else if (isa<ConstantArray>(CV)) { assert(false); } else if (const ConstantStruct *CS = dyn_cast<ConstantStruct>(CV)) { - if (calculate) { + if (name == "__init_array_start") { + // this is the global static initializer + if (calculate) { + unsigned Num = CS->getNumOperands(); + for (unsigned i = 0; i < Num; i++) { + const Value* C = CS->getOperand(i); + if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) { + C = CE->getOperand(0); // ignore bitcasts + } + GlobalInitializers.push_back(getCppName(C)); + } + } + } else if (calculate) { HeapData *GlobalData = allocateAddress(name); DataLayout DL(TheModule); unsigned Bytes = DL.getTypeStoreSize(CV->getType()); |