[PATCH] D27988: [LLD] Combine read-only and writable input sections into single output section

Mark Kettenis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 20 14:07:25 PST 2016


kettenis updated this revision to Diff 82150.
kettenis added a comment.

Added a test case.


https://reviews.llvm.org/D27988

Files:
  ELF/OutputSections.cpp
  test/ELF/Inputs/mixed1.s
  test/ELF/Inputs/mixed2.s
  test/ELF/mixed.s


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/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/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
Index: ELF/OutputSections.cpp
===================================================================
--- ELF/OutputSections.cpp
+++ ELF/OutputSections.cpp
@@ -538,7 +538,7 @@
 static SectionKey<ELFT::Is64Bits> createKey(InputSectionBase<ELFT> *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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27988.82150.patch
Type: text/x-patch
Size: 1531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161220/a2bcfd89/attachment.bin>


More information about the llvm-commits mailing list