the apple "ld_classic" linker doesn't support .literal16 in 32-bit
authorChris Lattner <sabre@nondot.org>
Tue, 28 Jul 2009 17:50:28 +0000 (17:50 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 28 Jul 2009 17:50:28 +0000 (17:50 +0000)
mode, and "ld64" (the default linker) falls back to it in -static
mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77334 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetLoweringObjectFile.h
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/TargetLoweringObjectFile.cpp
lib/Target/X86/X86ISelLowering.cpp

index 18ce1de01a00a82ff2008f531dd1dd6d2911713d..03bc5a09328853fb3c786ba39ce7af3d0a359b24 100644 (file)
@@ -160,7 +160,7 @@ class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
   const Section *EightByteConstantSection;
   const Section *SixteenByteConstantSection;
 public:
-  TargetLoweringObjectFileMachO();
+  TargetLoweringObjectFileMachO(const TargetMachine &TM);
   virtual const Section *SelectSectionForGlobal(const GlobalValue *GV,
                                                 SectionKind Kind,
                                                 const TargetMachine &TM) const;
index 3b1be7642487dec2af51cac3f3e6856d83be1cd5..afb0b69c54ea6786fc451e74c52c2eebf90e0e85 100644 (file)
@@ -106,7 +106,7 @@ void ARMTargetLowering::addQRTypeForNEON(MVT VT) {
 
 static TargetLoweringObjectFile *createTLOF(TargetMachine &TM) {
   if (TM.getSubtarget<ARMSubtarget>().isTargetDarwin())
-    return new TargetLoweringObjectFileMachO();
+    return new TargetLoweringObjectFileMachO(TM);
   return new TargetLoweringObjectFileELF(true);
 }
 
index fa1989b3d7e0c9323d96a9d2b1feede1b9242cbb..df71838b1e6c238f69260169f3dc9e63d964e057 100644 (file)
@@ -59,7 +59,7 @@ cl::desc("enable preincrement load/store generation on PPC (experimental)"),
 
 static TargetLoweringObjectFile *CreateTLOF(const PPCTargetMachine &TM) {
   if (TM.getSubtargetImpl()->isDarwin())
-    return new TargetLoweringObjectFileMachO();
+    return new TargetLoweringObjectFileMachO(TM);
   return new TargetLoweringObjectFileELF(false, true);
 }
 
index e3c0dfa562611176fb183bc5d1a2e65d997e3797..2074b6c5d69d8cd2ef35b6cc09984410fda77a42 100644 (file)
@@ -486,7 +486,7 @@ getSectionForMergeableConstant(SectionKind Kind) const {
 //===----------------------------------------------------------------------===//
 
 TargetLoweringObjectFileMachO::
-TargetLoweringObjectFileMachO() {
+TargetLoweringObjectFileMachO(const TargetMachine &TM) {
   TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
   DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel);
   
@@ -496,8 +496,15 @@ TargetLoweringObjectFileMachO() {
                                                SectionKind::MergeableConst4);
   EightByteConstantSection = getOrCreateSection("\t.literal8\n", true,
                                                 SectionKind::MergeableConst8);
-  SixteenByteConstantSection = 
-  getOrCreateSection("\t.literal16\n", true, SectionKind::MergeableConst16);
+  
+  // ld_classic doesn't support .literal16 in 32-bit mode, and ld64 falls back
+  // to using it in -static mode.
+  if (TM.getRelocationModel() != Reloc::Static &&
+      TM.getTargetData()->getPointerSize() == 32)
+    SixteenByteConstantSection = 
+      getOrCreateSection("\t.literal16\n", true, SectionKind::MergeableConst16);
+  else
+    SixteenByteConstantSection = 0;
   
   ReadOnlySection = getOrCreateSection("\t.const", true, SectionKind::ReadOnly);
   
@@ -551,7 +558,7 @@ TargetLoweringObjectFileMachO::SelectSectionForGlobal(const GlobalValue *GV,
       return FourByteConstantSection;
     if (Kind.isMergeableConst8())
       return EightByteConstantSection;
-    if (Kind.isMergeableConst16())
+    if (Kind.isMergeableConst16() && SixteenByteConstantSection)
       return SixteenByteConstantSection;
     return ReadOnlySection;  // .const
   }
@@ -582,7 +589,7 @@ getSectionForMergeableConstant(SectionKind Kind) const {
     return FourByteConstantSection;
   if (Kind.isMergeableConst8())
     return EightByteConstantSection;
-  if (Kind.isMergeableConst16())
+  if (Kind.isMergeableConst16() && SixteenByteConstantSection)
     return SixteenByteConstantSection;
   return ReadOnlySection;  // .const
 }
index 29f5765d5e10e9a90e5133e36146e400ed96bab0..f34deb1f4640d61e1201dbe58ecbf3a21143ba49 100644 (file)
@@ -55,7 +55,7 @@ static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) {
   switch (TM.getSubtarget<X86Subtarget>().TargetType) {
   default: llvm_unreachable("unknown subtarget type");
   case X86Subtarget::isDarwin:
-    return new TargetLoweringObjectFileMachO();
+    return new TargetLoweringObjectFileMachO(TM);
   case X86Subtarget::isELF:
     return new TargetLoweringObjectFileELF();
   case X86Subtarget::isMingw: