-
- DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
- DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
- DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
- DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
- DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
- DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
- DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
- DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
- DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
- DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
- DwarfMacroInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
-}
-
-/// emitUsedDirectiveFor - On Darwin, internally linked data beginning with
-/// the PrivateGlobalPrefix or the LinkerPrivateGlobalPrefix does not have the
-/// directive emitted (this occurs in ObjC metadata).
-bool DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV,
- Mangler *Mang) const {
- if (!GV) return false;
-
- // Check whether the mangled name has the "Private" or "LinkerPrivate" prefix.
- if (GV->hasLocalLinkage() && !isa<Function>(GV)) {
- // FIXME: ObjC metadata is currently emitted as internal symbols that have
- // \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and
- // this horrible hack can go away.
- const std::string &Name = Mang->getMangledName(GV);
- if (Name[0] == 'L' || Name[0] == 'l')
- return false;
- }
-
- return true;
-}
-
-const Section*
-DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
- SectionKind Kind) const {
- assert(!Kind.isThreadLocal() && "Darwin doesn't support TLS");
-
- // FIXME: Use sectionflags:linkonce instead of isWeakForLinker() here.
- bool isWeak = GV->isWeakForLinker();
-
- if (Kind.isText())
- return isWeak ? TextCoalSection : TextSection;
-
- // If this is weak/linkonce, put this in a coalescable section, either in text
- // or data depending on if it is writable.
- if (isWeak) {
- if (Kind.isReadOnly())
- return ConstTextCoalSection;
- return DataCoalSection;
- }
-
- // FIXME: Alignment check should be handled by section classifier.
- if (Kind.isMergableCString())
- return MergeableStringSection(cast<GlobalVariable>(GV));
-
- if (Kind.isMergableConst()) {
- if (Kind.isMergableConst4())
- return FourByteConstantSection;
- if (Kind.isMergableConst8())
- return EightByteConstantSection;
- if (Kind.isMergableConst16() && SixteenByteConstantSection)
- return SixteenByteConstantSection;
- return ReadOnlySection; // .const
- }
-
- // FIXME: ROData -> const in -static mode that is relocatable but they happen
- // by the static linker. Why not mergable?
- if (Kind.isReadOnly())
- return getReadOnlySection();
-
- // If this is marked const, put it into a const section. But if the dynamic
- // linker needs to write to it, put it in the data segment.
- if (Kind.isReadOnlyWithRel())
- return ConstDataSection;
-
- // Otherwise, just drop the variable in the normal data section.
- return DataSection;
-}
-
-const Section*
-DarwinTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
- const TargetData *TD = TM.getTargetData();
- Constant *C = cast<GlobalVariable>(GV)->getInitializer();
- const Type *Ty = cast<ArrayType>(C->getType())->getElementType();
-
- unsigned Size = TD->getTypeAllocSize(Ty);
- if (Size) {
- unsigned Align = TD->getPreferredAlignment(GV);
- if (Align <= 32)
- return getCStringSection_();
- }
-
- return getReadOnlySection();
-}