xref: /llvm-project/bolt/test/X86/pt_gnu_relro.s (revision 887f7002b65f7376c7a5004535bd08c95bdaa8f8)
1# REQUIRES: system-linux
2
3## Check that BOLT recognizes PT_GNU_RELRO segment and marks respective sections
4## accordingly.
5
6# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
7# RUN: ld.lld %t.o -o %t.exe -q --no-relax
8# RUN: llvm-readelf -We %t.exe | FileCheck --check-prefix=READELF %s
9# Unfortunately there's no direct way to extract a segment to section mapping
10# for a given section from readelf. Use the fool-proof way of matching
11# readelf output line-by-line.
12# READELF:      Program Headers:
13# READELF-NEXT: Type Offset {{.*}}
14# READELF-NEXT: PHDR
15# READELF-NEXT: LOAD
16# READELF-NEXT: LOAD
17# READELF-NEXT: LOAD
18# READELF-NEXT: GNU_RELRO
19# (GNU_RELRO is segment 4)
20
21# READELF: Section to Segment mapping:
22# READELF: 04 .got
23
24# RUN: llvm-bolt %t.exe --relocs -o %t.null -v=1 \
25# RUN:   2>&1 | FileCheck --check-prefix=BOLT %s
26# BOLT: BOLT-INFO: marking .got as GNU_RELRO
27
28  .globl _start
29  .type _start, %function
30_start:
31  .cfi_startproc
32  jmp *foo@GOTPCREL(%rip)
33  ret
34  .cfi_endproc
35  .size _start, .-_start
36
37  .globl foo
38  .type foo, %function
39foo:
40  .cfi_startproc
41  ret
42  .cfi_endproc
43  .size foo, .-foo
44