xref: /llvm-project/lld/test/ELF/relro-non-contiguous.s (revision 8f10a5f42d5b391efe57a982c98de5e1ae245e4d)
1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t.o
3// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/copy-in-shared.s -o %t2.o
4// RUN: ld.lld -shared %t.o %t2.o -o %t.so
5
6// Separate RelRo sections .dynamic .bss.rel.ro with non RelRo .got.plt.
7// This causes the RelRo sections to be non-contiguous.
8// RUN: echo "SECTIONS { \
9// RUN: .dynamic : { *(.dynamic) } \
10// RUN: .got.plt : { *(.got.plt) } \
11// RUN: .bss.rel.ro : { *(.bss.rel.o) } \
12// RUN: } " > %t.script
13// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t3.o
14
15// Expect error for non-contiguous relro
16// RUN: not ld.lld %t3.o %t.so -z relro -o /dev/null --script=%t.script 2>&1 | FileCheck %s
17// No error when we do not request relro.
18// RUN: ld.lld %t3.o %t.so -z norelro -o %t --script=%t.script
19
20// CHECK: error: section: .bss.rel.ro is not contiguous with other relro sections
21        .section .text, "ax", @progbits
22        .global _start
23        .global bar
24        .global foo
25_start:
26        .quad bar
27        .quad foo
28
29