Index: ELF/OutputSections.cpp =================================================================== --- ELF/OutputSections.cpp +++ ELF/OutputSections.cpp @@ -538,7 +538,7 @@ static SectionKey createKey(InputSectionBase *C, StringRef OutsecName) { typedef typename ELFT::uint uintX_t; - uintX_t Flags = getOutFlags(C); + uintX_t Flags = getOutFlags(C) & ~SHF_WRITE; // For SHF_MERGE we create different output sections for each alignment. // This makes each output section simple and keeps a single level mapping from Index: test/ELF/Inputs/mixed1.s =================================================================== --- test/ELF/Inputs/mixed1.s +++ test/ELF/Inputs/mixed1.s @@ -0,0 +1,2 @@ +.section .ctors, "a", @progbits + .long -1 Index: test/ELF/Inputs/mixed2.s =================================================================== --- test/ELF/Inputs/mixed2.s +++ test/ELF/Inputs/mixed2.s @@ -0,0 +1,2 @@ +.section .ctors, "aw", @progbits + .long 0 Index: test/ELF/mixed.s =================================================================== --- test/ELF/mixed.s +++ test/ELF/mixed.s @@ -0,0 +1,8 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/mixed1.s -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/mixed2.s -o %t2.o +# RUN: ld.lld -r %t1.o %t2.o -o %t +# RUN: llvm-objdump -s %t | FileCheck %s + +# CHECK: Contents of section .ctors: +# CHECK-NEXT: ffffffff 00000000