From a3242e93b766f05979f76a5874e7558035a24e79 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 28 Jul 2009 17:50:28 +0000 Subject: the apple "ld_classic" linker doesn't support .literal16 in 32-bit mode, and "ld64" (the default linker) falls back to it in -static mode. llvm-svn: 77334 --- llvm/lib/Target/TargetLoweringObjectFile.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Target/TargetLoweringObjectFile.cpp') diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp index e3c0dfa5626..2074b6c5d69 100644 --- a/llvm/lib/Target/TargetLoweringObjectFile.cpp +++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp @@ -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 } -- cgit v1.2.3