MC: Treat ReadOnlyWithRel and ReadOnlyWithRelLocal as ReadOnly for COFF

A problem with our old behavior becomes observable under x86-64 COFF
when we need a read-only GV which has an initializer which is referenced
using a relocation: we would mark the section as writable.  Marking the
section as writable interferes with section merging.

This fixes PR21009.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218179 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2014-09-20 07:31:46 +00:00
parent c16105b078
commit 3f34ae97b9
3 changed files with 11 additions and 3 deletions

View File

@ -761,7 +761,7 @@ getCOFFSectionFlags(SectionKind K) {
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 |
@ -771,7 +771,7 @@ getCOFFSectionFlags(SectionKind K) {
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;

View File

@ -51,7 +51,7 @@ void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,
OS << 'x';
else if (getKind().isBSS())
OS << 'b';
if (getKind().isWriteable())
if (getKind().isWriteable() && !getKind().isReadOnlyWithRel())
OS << 'w';
else
OS << 'r';

View File

@ -0,0 +1,8 @@
; RUN: llc -mtriple x86_64-pc-windows-msvc < %s | FileCheck %s
define void @f() {
ret void
}
@ptr = constant void ()* @f, section ".CRT$XLB", align 8
; CHECK: .section .CRT$XLB,"rd"