summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/ELFWriter.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-04-11 22:11:20 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-04-11 22:11:20 +0000
commit0f85789800846dc3beeab75bd7e8d3af0f26a362 (patch)
treeabf2ae7d01213f9d8889e2463d27e97806f40d21 /llvm/lib/CodeGen/ELFWriter.cpp
parent82065cb6cfd207aaa9779534cd93afb5a8a097be (diff)
downloadbcm5719-llvm-0f85789800846dc3beeab75bd7e8d3af0f26a362.tar.gz
bcm5719-llvm-0f85789800846dc3beeab75bd7e8d3af0f26a362.zip
Just because a GlobalVariable's initializer is [N x { i32, void ()* }] doesn't
mean that it has to be ConstantArray of ConstantStruct. We might have ConstantAggregateZero, at either level, so don't crash on that. Also, semi-deprecate the sentinal value. The linker isn't aware of sentinals so we end up with the two lists appended, each with their "sentinals" on them. Different parts of LLVM treated sentinals differently, so make them all just ignore the single entry and continue on with the rest of the list. llvm-svn: 129307
Diffstat (limited to 'llvm/lib/CodeGen/ELFWriter.cpp')
-rw-r--r--llvm/lib/CodeGen/ELFWriter.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/ELFWriter.cpp b/llvm/lib/CodeGen/ELFWriter.cpp
index 25c2e02599e..b321a15addd 100644
--- a/llvm/lib/CodeGen/ELFWriter.cpp
+++ b/llvm/lib/CodeGen/ELFWriter.cpp
@@ -662,12 +662,16 @@ bool ELFWriter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
void ELFWriter::EmitXXStructorList(Constant *List, ELFSection &Xtor) {
// Should be an array of '{ i32, void ()* }' structs. The first value is the
// init priority, which we ignore.
+ if (List->isNullValue()) return;
ConstantArray *InitList = cast<ConstantArray>(List);
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
+ if (InitList->getOperand(i)->isNullValue())
+ continue;
ConstantStruct *CS = cast<ConstantStruct>(InitList->getOperand(i));
if (CS->getOperand(1)->isNullValue())
- return; // Found a null terminator, exit printing.
+ continue;
+
// Emit the function pointer.
EmitGlobalConstant(CS->getOperand(1), Xtor);
}
OpenPOWER on IntegriCloud