[MachO] Emit Weak ReadOnlyWithRel to ConstDataSection

Summary:
Darwin dynamic linker can handle weak symbols in ConstDataSection.
ReadonReadOnlyWithRel symbols should be emitted in ConstDataSection
instead of normal DataSection.

rdar://problem/39298457

Reviewers: dexonsmith, kledzik

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D45472

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329752 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Steven Wu
2018-04-10 20:16:35 +00:00
parent e000e64fd8
commit bba7686b46
4 changed files with 17 additions and 3 deletions
+6 -3
View File
@@ -135,6 +135,10 @@ void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) {
// "__DATA/__datacoal_nt" => section "__DATA/__data"
Triple::ArchType ArchTy = T.getArch();
ConstDataSection // .const_data
= Ctx->getMachOSection("__DATA", "__const", 0,
SectionKind::getReadOnlyWithRel());
if (ArchTy == Triple::ppc || ArchTy == Triple::ppc64) {
TextCoalSection
= Ctx->getMachOSection("__TEXT", "__textcoal_nt",
@@ -147,15 +151,14 @@ void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) {
SectionKind::getReadOnly());
DataCoalSection = Ctx->getMachOSection(
"__DATA", "__datacoal_nt", MachO::S_COALESCED, SectionKind::getData());
ConstDataCoalSection = DataCoalSection;
} else {
TextCoalSection = TextSection;
ConstTextCoalSection = ReadOnlySection;
DataCoalSection = DataSection;
ConstDataCoalSection = ConstDataSection;
}
ConstDataSection // .const_data
= Ctx->getMachOSection("__DATA", "__const", 0,
SectionKind::getReadOnlyWithRel());
DataCommonSection
= Ctx->getMachOSection("__DATA","__common",
MachO::S_ZEROFILL,