[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 09:11:57 PST 2017
peter.smith updated this revision to Diff 125160.
peter.smith added a comment.
Thanks for the comment, I've uploaded a new diff that tests each case individually.
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
@@ -1,3 +1,4 @@
+// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t.o
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/copy-in-shared.s -o %t2.o
// RUN: ld.lld -shared %t.o %t2.o -o %t.so
@@ -15,14 +16,36 @@
// RUN: not ld.lld %t3.o %t.so -z relro -o %t --script=%t.script 2>&1 | FileCheck %s
// No error when we do not request relro.
// RUN: ld.lld %t3.o %t.so -z norelro -o %t --script=%t.script
-// 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: .nonempty : { BYTE(1); *(.empty) } \
+// 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
+
+// RUN: echo "SECTIONS { \
+// RUN: .got.plt : { *(.got.plt) } \
+// RUN: .nonempty : { . = . + 3 ; *(.empty) } \
+// RUN: .dynamic : { *(.dynamic) } \
+// RUN: } " > %t.script3
+// RUN: not ld.lld %t3.o %t.so -z relro -o %t --script=%t.script3 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 .empty, "ax", @progbits
+ .global empty
+empty:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40732.125160.patch
Type: text/x-patch
Size: 1894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171201/d390085f/attachment.bin>
More information about the llvm-commits
mailing list