[PATCH] D37736: [ELF] - Do not spread specific flags when emiting output sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 6 03:46:07 PDT 2017


grimar updated this revision to Diff 117973.
grimar added a comment.

- Addressed review comment: added testcase for testing SHF_TLS flag spreading.


https://reviews.llvm.org/D37736

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript/arm-exidx-order.s
  test/ELF/linkerscript/symbol-only-flags.s


Index: test/ELF/linkerscript/symbol-only-flags.s
===================================================================
--- test/ELF/linkerscript/symbol-only-flags.s
+++ test/ELF/linkerscript/symbol-only-flags.s
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; \
+# RUN:         .tbss : { *(.tbss) }         \
+# RUN:         .foo : { bar = .; } }" > %t.script
+# RUN: ld.lld -o %t --script %t.script %t.o
+# RUN: llvm-readobj -s %t | FileCheck %s
+
+## Check .foo does not get SHF_TLS flag.
+# CHECK:     Section {
+# CHECK:       Index:
+# CHECK:       Name: .foo
+# CHECK-NEXT:  Type: SHT_PROGBITS
+# CHECK-NEXT:  Flags [
+# CHECK-NEXT:    SHF_ALLOC
+# CHECK-NEXT:    SHF_WRITE
+# CHECK-NEXT:  ]
+
+.section .tbss,"awT", at nobits
+.quad 0
Index: test/ELF/linkerscript/arm-exidx-order.s
===================================================================
--- test/ELF/linkerscript/arm-exidx-order.s
+++ test/ELF/linkerscript/arm-exidx-order.s
@@ -0,0 +1,19 @@
+# REQUIRES: arm
+# RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
+# RUN: echo "SECTIONS { . = SIZEOF_HEADERS;    \
+# RUN:         .ARM.exidx : { *(.ARM.exidx*) } \
+# RUN:         .foo : { _foo = 0; } }" > %t.script
+# RUN: ld.lld -T %t.script %t.o -shared -o %t.so
+# RUN: llvm-readobj -s %t.so | FileCheck %s
+
+# CHECK:      Section {
+# CHECK:        Index: 
+# CHECK:        Name: .foo
+# CHECK-NEXT:   Type: SHT_PROGBITS
+# CHECK-NEXT:   Flags [
+# CHECK-NEXT:     SHF_ALLOC
+# CHECK-NEXT:   ]
+
+.fnstart
+.cantunwind
+.fnend
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -661,7 +661,7 @@
     if (!Sec)
       continue;
     if (Sec->Live) {
-      Flags = Sec->Flags;
+      Flags = Sec->Flags & (SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR);
       continue;
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37736.117973.patch
Type: text/x-patch
Size: 1960 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171006/4c3dca94/attachment.bin>


More information about the llvm-commits mailing list