return DataRelROSection;
}
-const MCSection *TargetLoweringObjectFileELF::getStaticCtorSection(
- unsigned Priority, const MCSymbol *KeySym) const {
+static const MCSectionELF *getStaticStructorSection(MCContext &Ctx,
+ bool UseInitArray,
+ bool IsCtor,
+ unsigned Priority,
+ const MCSymbol *KeySym) {
std::string Name;
unsigned Type;
unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE;
Flags |= ELF::SHF_GROUP;
if (UseInitArray) {
- Name = ".init_array";
+ if (IsCtor) {
+ Type = ELF::SHT_INIT_ARRAY;
+ Name = ".init_array";
+ } else {
+ Type = ELF::SHT_FINI_ARRAY;
+ Name = ".fini_array";
+ }
if (Priority != 65535) {
Name += '.';
Name += utostr(Priority);
}
- Type = ELF::SHT_INIT_ARRAY;
} else {
// The default scheme is .ctor / .dtor, so we have to invert the priority
// numbering.
- Name = std::string(".ctors");
+ if (IsCtor)
+ Name = ".ctors";
+ else
+ Name = ".dtors";
if (Priority != 65535) {
Name += '.';
Name += utostr(65535 - Priority);
Type = ELF::SHT_PROGBITS;
}
- return getContext().getELFSection(Name, Type, Flags, Kind, 0, COMDAT);
+ return Ctx.getELFSection(Name, Type, Flags, Kind, 0, COMDAT);
}
-const MCSection *TargetLoweringObjectFileELF::getStaticDtorSection(
+const MCSection *TargetLoweringObjectFileELF::getStaticCtorSection(
unsigned Priority, const MCSymbol *KeySym) const {
- std::string Name;
- unsigned Type;
- unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE;
- SectionKind Kind = SectionKind::getDataRel();
- StringRef COMDAT = KeySym ? KeySym->getName() : "";
-
- if (KeySym)
- Flags |= ELF::SHF_GROUP;
-
- if (UseInitArray) {
- Name = ".fini_array";
- if (Priority != 65535) {
- Name += '.';
- Name += utostr(Priority);
- }
- Type = ELF::SHT_FINI_ARRAY;
- } else {
- // The default scheme is .ctor / .dtor, so we have to invert the priority
- // numbering.
- Name = ".dtors";
- if (Priority != 65535) {
- Name += '.';
- Name += utostr(65535 - Priority);
- }
- Type = ELF::SHT_PROGBITS;
- }
+ return getStaticStructorSection(getContext(), UseInitArray, true, Priority,
+ KeySym);
+}
- return getContext().getELFSection(Name, Type, Flags, Kind, 0, COMDAT);
+const MCSection *TargetLoweringObjectFileELF::getStaticDtorSection(
+ unsigned Priority, const MCSymbol *KeySym) const {
+ return getStaticStructorSection(getContext(), UseInitArray, false, Priority,
+ KeySym);
}
void
VersionVal = cast<ConstantInt>(Val)->getZExtValue();
} else if (Key == "Objective-C Garbage Collection" ||
Key == "Objective-C GC Only" ||
- Key == "Objective-C Is Simulated") {
+ Key == "Objective-C Is Simulated" ||
+ Key == "Objective-C Image Swift Version") {
ImageInfoFlags |= cast<ConstantInt>(Val)->getZExtValue();
} else if (Key == "Objective-C Image Info Section") {
SectionVal = cast<MDString>(Val)->getString();
if (SMO.getKind().isMergeable1ByteCString())
return false;
+ if (SMO.getSegmentName() == "__TEXT" &&
+ SMO.getSectionName() == "__objc_classname" &&
+ SMO.getType() == MachO::S_CSTRING_LITERALS)
+ return false;
+
+ if (SMO.getSegmentName() == "__TEXT" &&
+ SMO.getSectionName() == "__objc_methname" &&
+ SMO.getType() == MachO::S_CSTRING_LITERALS)
+ return false;
+
+ if (SMO.getSegmentName() == "__TEXT" &&
+ SMO.getSectionName() == "__objc_methtype" &&
+ SMO.getType() == MachO::S_CSTRING_LITERALS)
+ return false;
+
if (SMO.getSegmentName() == "__DATA" &&
SMO.getSectionName() == "__cfstring")
return false;
+ // no_dead_strip sections are not atomized in practice.
+ if (SMO.hasAttribute(MachO::S_ATTR_NO_DEAD_STRIP))
+ return false;
+
switch (SMO.getType()) {
default:
return true;
COFF::IMAGE_SCN_MEM_EXECUTE |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_CNT_CODE;
- else if (K.isBSS ())
+ else if (K.isBSS())
Flags |=
COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_MEM_WRITE;
- else if (K.isReadOnly())
+ else if (K.isReadOnly() || K.isReadOnlyWithRel())
Flags |=
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ;
if (ComdatGV->getComdat() != C)
report_fatal_error("Associative COMDAT symbol '" + ComdatGVName +
- "' is not a key for it's COMDAT.");
+ "' is not a key for its COMDAT.");
return ComdatGV;
}
return ".bss";
if (Kind.isThreadLocal())
return ".tls$";
- if (Kind.isWriteable())
- return ".data";
- return ".rdata";
+ if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
+ return ".rdata";
+ return ".data";
}
if (Kind.isThreadLocal())
return TLSDataSection;
- if (Kind.isReadOnly())
+ if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
return ReadOnlySection;
// Note: we claim that common symbols are put in BSSSection, but they are