summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachOWriter.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2007-01-29 21:20:42 +0000
committerNate Begeman <natebegeman@mac.com>2007-01-29 21:20:42 +0000
commit2a562ba47bcbaeafe9216090ec36fe5c64d639fe (patch)
treec2aadb61e6bdfd19aa2703c8e75c65d8884ad582 /llvm/lib/CodeGen/MachOWriter.cpp
parentd1154860a4de51b9face644d146c28cba3ac7e46 (diff)
downloadbcm5719-llvm-2a562ba47bcbaeafe9216090ec36fe5c64d639fe.tar.gz
bcm5719-llvm-2a562ba47bcbaeafe9216090ec36fe5c64d639fe.zip
Properly support cstrings
llvm-svn: 33629
Diffstat (limited to 'llvm/lib/CodeGen/MachOWriter.cpp')
-rw-r--r--llvm/lib/CodeGen/MachOWriter.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachOWriter.cpp b/llvm/lib/CodeGen/MachOWriter.cpp
index 63f1ad4da8f..bd7c5364968 100644
--- a/llvm/lib/CodeGen/MachOWriter.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud