xref: /llvm-project/lld/test/ELF/apply-dynamic-relocs.s (revision 9e1319df7e6508795e6f643c8b50306a5046d0b5)
1# REQUIRES: x86
2
3## On RELA targets, --apply-dynamic-relocs writes addends to the relocated positions.
4
5# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
6# RUN: ld.lld %t.o -o %t.so -shared --apply-dynamic-relocs
7# RUN: llvm-readobj -S --section-data -l -r %t.so | FileCheck -check-prefixes=CHECK,APPLY %s
8
9# RUN: ld.lld %t.o -o %t2.so -shared
10# RUN: llvm-readobj -S --section-data -l -r %t2.so | FileCheck -check-prefixes=CHECK,NOAPPLY %s
11# RUN: ld.lld %t.o -o %t3.so -shared --no-apply-dynamic-relocs
12# RUN: cmp %t2.so %t3.so
13
14# CHECK:        Name: .got
15# CHECK:        Address: 0x[[GOT:.*]]
16# CHECK:        SectionData (
17# APPLY-NEXT:     0000: 30220000 00000000                |
18# NOAPPLY-NEXT:   0000: 00000000 00000000                |
19# CHECK-NEXT:   )
20
21# CHECK:      Type: PT_DYNAMIC
22# CHECK-NEXT: Offset: 0x230
23# CHECK-NEXT: VirtualAddress: 0x[[DYNAMIC:.*]]
24# CHECK-NEXT: PhysicalAddress: 0x[[DYNAMIC]]
25
26# CHECK:      Relocations [
27# CHECK-NEXT:   Section ({{.*}}) .rela.dyn {
28# CHECK-NEXT:     0x[[GOT]] R_X86_64_RELATIVE - 0x[[DYNAMIC]]
29# CHECK-NEXT:   }
30# CHECK-NEXT: ]
31
32cmpq    $0, _DYNAMIC@GOTPCREL(%rip)
33