1# REQUIRES: x86
2
3# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
4# RUN: echo 'mov aaa@gotpcrel(%rip), %rax' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
5
6# RUN: ld.lld -shared %t.o %t1.o -o %t.so
7# RUN: llvm-readobj -r --dynamic-table %t.so | FileCheck %s
8# RUN: ld.lld -shared %t.o %t1.o -o %t.so -z combreloc
9# RUN: llvm-readobj -r --dynamic-table %t.so | FileCheck %s
10
11# -z combreloc is the default: sort relocations by (!IsRelative,SymIndex,r_offset),
12# and emit DT_RELACOUNT (except on MIPS) to indicate the number of relative
13# relocations.
14
15# CHECK:      DynamicSection [
16# CHECK:        RELACOUNT 1
17# CHECK:      Relocations [
18# CHECK-NEXT:   Section ({{.*}}) .rela.dyn {
19# CHECK-NEXT:     0x3428 R_X86_64_RELATIVE - 0x3430
20# CHECK-NEXT:     0x2400 R_X86_64_GLOB_DAT aaa 0x0
21# CHECK-NEXT:     0x3408 R_X86_64_64 aaa 0x0
22# CHECK-NEXT:     0x3420 R_X86_64_64 aaa 0x0
23# CHECK-NEXT:     0x3418 R_X86_64_64 bbb 0x0
24# CHECK-NEXT:     0x3410 R_X86_64_64 ccc 0x0
25# CHECK-NEXT:   }
26
27# RUN: ld.lld -z nocombreloc -shared %t.o %t1.o -o %t.so
28# RUN: llvm-readobj -r --dynamic-table %t.so | FileCheck --check-prefix=NOCOMB %s
29
30# NOCOMB:      DynamicSection [
31# NOCOMB-NOT:    RELACOUNT
32# NOCOMB:      Relocations [
33# NOCOMB-NEXT:   Section ({{.*}}) .rela.dyn {
34# NOCOMB-NEXT:     0x33F8 R_X86_64_64 aaa 0x0
35# NOCOMB-NEXT:     0x3400 R_X86_64_64 ccc 0x0
36# NOCOMB-NEXT:     0x3408 R_X86_64_64 bbb 0x0
37# NOCOMB-NEXT:     0x3410 R_X86_64_64 aaa 0x0
38# NOCOMB-NEXT:     0x3418 R_X86_64_RELATIVE - 0x3420
39# NOCOMB-NEXT:     0x23F0 R_X86_64_GLOB_DAT aaa 0x0
40# NOCOMB-NEXT:   }
41
42.data
43 .quad aaa
44 .quad ccc
45 .quad bbb
46 .quad aaa
47 .quad relative
48relative:
49