[llvm-commits] CVS: llvm/lib/CodeGen/MachOWriter.cpp

Nate Begeman natebegeman at mac.com
Mon Jan 29 13:21:03 PST 2007



Changes in directory llvm/lib/CodeGen:

MachOWriter.cpp updated: 1.20 -> 1.21
---
Log message:

Properly support cstrings


---
Diffs of the changes:  (+8 -3)

 MachOWriter.cpp |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/MachOWriter.cpp
diff -u llvm/lib/CodeGen/MachOWriter.cpp:1.20 llvm/lib/CodeGen/MachOWriter.cpp:1.21
--- llvm/lib/CodeGen/MachOWriter.cpp:1.20	Fri Jan 26 16:39:48 2007
+++ llvm/lib/CodeGen/MachOWriter.cpp	Mon Jan 29 15:20:42 2007
@@ -245,7 +245,7 @@
     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 @@
   // 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 @@
       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);






More information about the llvm-commits mailing list