add a comment.
[oota-llvm.git] / lib / Target / XCore / XCoreTargetObjectFile.cpp
index e4d83dd53189b34f9e2e7372a15c518a0d30a70e..7de3b55d38f64107c3e5f9ab93d9ebe5251493a7 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "XCoreTargetObjectFile.h"
 #include "XCoreSubtarget.h"
+#include "MCSectionXCore.h"
 #include "llvm/Target/TargetMachine.h"
 using namespace llvm;
 
@@ -16,24 +17,51 @@ using namespace llvm;
 void XCoreTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM){
   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
 
-  TextSection = getOrCreateSection("\t.text", true, 
-                                   SectionKind::get(SectionKind::Text));
-  DataSection = getOrCreateSection("\t.dp.data", false, 
-                                   SectionKind::get(SectionKind::DataRel));
-  BSSSection = getOrCreateSection("\t.dp.bss", false, 
-                                  SectionKind::get(SectionKind::BSS));
+  DataSection =
+    MCSectionXCore::Create(".dp.data", MCSectionELF::SHT_PROGBITS, 
+                           MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
+                           MCSectionXCore::SHF_DP_SECTION,
+                           SectionKind::getDataRel(), false, getContext());
+  BSSSection =
+    MCSectionXCore::Create(".dp.bss", MCSectionELF::SHT_NOBITS,
+                           MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
+                           MCSectionXCore::SHF_DP_SECTION,
+                           SectionKind::getBSS(), false, getContext());
+  
+  MergeableConst4Section = 
+    MCSectionXCore::Create(".cp.rodata.cst4", MCSectionELF::SHT_PROGBITS,
+                           MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
+                           MCSectionXCore::SHF_CP_SECTION,
+                           SectionKind::getMergeableConst4(), false,
+                           getContext());
+  MergeableConst8Section = 
+    MCSectionXCore::Create(".cp.rodata.cst8", MCSectionELF::SHT_PROGBITS,
+                           MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
+                           MCSectionXCore::SHF_CP_SECTION,
+                           SectionKind::getMergeableConst8(), false,
+                           getContext());
+  MergeableConst16Section = 
+    MCSectionXCore::Create(".cp.rodata.cst16", MCSectionELF::SHT_PROGBITS,
+                           MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
+                           MCSectionXCore::SHF_CP_SECTION,
+                           SectionKind::getMergeableConst16(), false,
+                           getContext());
   
   // TLS globals are lowered in the backend to arrays indexed by the current
   // thread id. After lowering they require no special handling by the linker
   // and can be placed in the standard data / bss sections.
   TLSDataSection = DataSection;
   TLSBSSSection = BSSSection;
-  
-  if (TM.getSubtarget<XCoreSubtarget>().isXS1A())
-    // FIXME: Why is this writable ("datarel")???
-    ReadOnlySection = getOrCreateSection("\t.dp.rodata", false,
-                                        SectionKind::get(SectionKind::DataRel));
-  else
-    ReadOnlySection = getOrCreateSection("\t.cp.rodata", false,
-                                       SectionKind::get(SectionKind::ReadOnly));
+
+  ReadOnlySection = 
+    MCSectionXCore::Create(".cp.rodata", MCSectionELF::SHT_PROGBITS,
+                           MCSectionELF::SHF_ALLOC |
+                           MCSectionXCore::SHF_CP_SECTION,
+                           SectionKind::getReadOnlyWithRel(), false,
+                           getContext());
+
+  // Dynamic linking is not supported. Data with relocations is placed in the
+  // same section as data without relocations.
+  DataRelSection = DataRelLocalSection = DataSection;
+  DataRelROSection = DataRelROLocalSection = ReadOnlySection;
 }