From d0804aa6dc476f75017a74d5fd77e737efe9a9ea Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Tue, 10 Apr 2018 20:16:35 +0000 Subject: [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 llvm-svn: 329752 --- llvm/lib/MC/MCObjectFileInfo.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'llvm/lib/MC/MCObjectFileInfo.cpp') diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index b154c98cf72..5b3636153d6 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -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, -- cgit v1.2.3