[PATCH] D40732: [LLD][ELF] Add linker script generated data to non-contiguous relro test [NFC].

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 1 08:23:13 PST 2017


peter.smith created this revision.
Herald added a subscriber: emaste.

Adapted from an example in PR35478. If in the future we are going to ignore zero sized sections we need to account for linker scripts with location counter expressions or data creating functions such as BYTE. These linker script commands may be evaluated late on so testing early for OutputSection size will miss them.

This should only be committed once the revert of r318924 has been done (https://reviews.llvm.org/D40710).


https://reviews.llvm.org/D40732

Files:
  test/ELF/relro-non-contiguous.s


Index: test/ELF/relro-non-contiguous.s
===================================================================
--- test/ELF/relro-non-contiguous.s
+++ test/ELF/relro-non-contiguous.s
@@ -18,11 +18,32 @@
 // REQUIRES: x86
 
 // CHECK: error: section: .bss.rel.ro is not contiguous with other relro sections
+
+// Insert a linkerscript command generating non-relro inbetween relro, these
+// may not have been evaluated by the time we calculate relro. This test is to
+// guard against skipping past non zero sized sections incorrectly.
+// RUN: echo "SECTIONS { \
+// RUN: .got.plt : { *(.got.plt) } \
+// RUN: .nonempty1  : { BYTE(1); *(.empty1) } \
+// RUN: .nonempty2 : { . = . + 3 ; *(.empty2) } \
+// RUN: .dynamic : { *(.dynamic) } \
+// RUN: } " > %t.script2
+// RUN: not ld.lld %t3.o %t.so -z relro -o %t --script=%t.script2 2>&1 | FileCheck -check-prefix=CHECK-DYNAMIC %s
+
+// CHECK-DYNAMIC: error: section: .dynamic is not contiguous with other relro sections
+
         .section .text, "ax", @progbits
         .global _start
         .global bar
         .global foo
 _start:
         .quad bar
         .quad foo
 
+        .section .empty1, "ax", @progbits
+        .global empty1
+empty1:
+
+        .section .empty2, "ax", @progbits
+        .global empty2
+empty2:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40732.125148.patch
Type: text/x-patch
Size: 1278 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171201/663286af/attachment.bin>


More information about the llvm-commits mailing list