diff options
author | Nate Begeman <natebegeman@mac.com> | 2007-01-29 21:20:42 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2007-01-29 21:20:42 +0000 |
commit | 1257c855d7546afc2705463d9ca913d405724738 (patch) | |
tree | a9e66a989b14c4a5ba89ed2d4cbec0b736563700 /lib/CodeGen/MachOWriter.cpp | |
parent | 1b340dc8e20dc1ce204ebdcc2ff11c3dd36888f1 (diff) | |
download | external_llvm-1257c855d7546afc2705463d9ca913d405724738.tar.gz external_llvm-1257c855d7546afc2705463d9ca913d405724738.tar.bz2 external_llvm-1257c855d7546afc2705463d9ca913d405724738.zip |
Properly support cstrings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33629 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachOWriter.cpp')
-rw-r--r-- | lib/CodeGen/MachOWriter.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp index 63f1ad4da8..bd7c536496 100644 --- a/lib/CodeGen/MachOWriter.cpp +++ b/lib/CodeGen/MachOWriter.cpp @@ -245,7 +245,7 @@ void MachOCodeEmitter::emitConstantPool(MachineConstantPool *MCP) { const Type *Ty = CP[i].getType(); unsigned Size = TM.getTargetData()->getTypeSize(Ty); - MachOWriter::MachOSection *Sec = MOW.getConstSection(Ty); + MachOWriter::MachOSection *Sec = MOW.getConstSection(CP[i].Val.ConstVal); OutputBuffer SecDataOut(Sec->SectionData, is64Bit, isLittleEndian); CPLocations.push_back(Sec->SectionData.size()); @@ -390,7 +390,8 @@ void MachOWriter::EmitGlobal(GlobalVariable *GV) { // Scalar read-only data goes in a literal section if the scalar is 4, 8, or // 16 bytes, or a cstring. Other read only data goes into a regular const // section. Read-write data goes in the data section. - MachOSection *Sec = GV->isConstant() ? getConstSection(Ty) : getDataSection(); + MachOSection *Sec = GV->isConstant() ? getConstSection(GV->getInitializer()) : + getDataSection(); AddSymbolToSection(Sec, GV); InitMem(GV->getInitializer(), &Sec->SectionData[0], GVOffset[GV], TM.getTargetData(), Sec->Relocations); @@ -716,7 +717,11 @@ void MachOWriter::CalculateRelocations(MachOSection &MOS) { intptr_t Offset = GVOffset[GV]; Scattered = TargetSection != 0; - assert(MOSPtr && "Trying to relocate unknown global!"); + if (!MOSPtr) { + cerr << "Trying to relocate unknown global " << *GV << '\n'; + continue; + //abort(); + } TargetSection = MOSPtr->Index; MR.setResultPointer((void*)Offset); |