//===----------------------------------------------------------------------===//
TargetLoweringObjectFileMachO::
-TargetLoweringObjectFileMachO() {
+TargetLoweringObjectFileMachO(const TargetMachine &TM) {
TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel);
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);
return FourByteConstantSection;
if (Kind.isMergeableConst8())
return EightByteConstantSection;
- if (Kind.isMergeableConst16())
+ if (Kind.isMergeableConst16() && SixteenByteConstantSection)
return SixteenByteConstantSection;
return ReadOnlySection; // .const
}
return FourByteConstantSection;
if (Kind.isMergeableConst8())
return EightByteConstantSection;
- if (Kind.isMergeableConst16())
+ if (Kind.isMergeableConst16() && SixteenByteConstantSection)
return SixteenByteConstantSection;
return ReadOnlySection; // .const
}
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: