diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-09-20 07:31:46 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-09-20 07:31:46 +0000 |
commit | b8dbebb31c5d191e766e5e4bc6ea5b19b9bec0d5 (patch) | |
tree | b0b59674ea1929007933c791311164a6fba85b6f | |
parent | 8c4cccd4aae0d385ccc86b46f0810bb5fa4c1d6b (diff) | |
download | bcm5719-llvm-b8dbebb31c5d191e766e5e4bc6ea5b19b9bec0d5.tar.gz bcm5719-llvm-b8dbebb31c5d191e766e5e4bc6ea5b19b9bec0d5.zip |
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.
llvm-svn: 218179
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/MC/MCSectionCOFF.cpp | 2 | ||||
-rw-r--r-- | llvm/test/MC/COFF/const-gv-with-rel-init.ll | 8 |
3 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 7a14f2c6dcd..6d5e27c00e8 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -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; diff --git a/llvm/lib/MC/MCSectionCOFF.cpp b/llvm/lib/MC/MCSectionCOFF.cpp index fc2bd365e16..ee6b249522b 100644 --- a/llvm/lib/MC/MCSectionCOFF.cpp +++ b/llvm/lib/MC/MCSectionCOFF.cpp @@ -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'; diff --git a/llvm/test/MC/COFF/const-gv-with-rel-init.ll b/llvm/test/MC/COFF/const-gv-with-rel-init.ll new file mode 100644 index 00000000000..7e1b61b846b --- /dev/null +++ b/llvm/test/MC/COFF/const-gv-with-rel-init.ll @@ -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" |