1// Test that both Android and RELR packed relocation sections are created
2// correctly for each partition.
3
4// REQUIRES: x86
5
6// RUN: llvm-mc %s -o %t.o -filetype=obj --triple=x86_64-unknown-linux
7// RUN: ld.lld %t.o -o %t --shared --gc-sections --pack-dyn-relocs=android+relr
8
9// RUN: llvm-objcopy --extract-main-partition %t %t0
10// RUN: llvm-objcopy --extract-partition=part1 %t %t1
11
12// RUN: llvm-readelf --all %t0 | FileCheck --check-prefixes=CHECK,PART0 %s
13// RUN: llvm-readelf --all %t1 | FileCheck --check-prefixes=CHECK,PART1 %s
14
15// CHECK: Section Headers:
16// CHECK: .rela.dyn      ANDROID_RELA {{0*}}[[ANDROID_RELA_ADDR:[^ ]*]]
17// CHECK: .relr.dyn      RELR         {{0*}}[[RELR_ADDR:[^ ]*]]
18// PART0: .data          PROGBITS     000000000000[[DATA_SEGMENT:.]]378
19// PART1: .data          PROGBITS     000000000000[[DATA_SEGMENT:.]]340
20
21// CHECK: Dynamic section
22// CHECK: 0x0000000060000011 (ANDROID_RELA)       0x[[ANDROID_RELA_ADDR]]
23// CHECK: 0x0000000000000024 (RELR)               0x[[RELR_ADDR]]
24
25// CHECK: Relocation section '.rela.dyn'
26// CHECK-NEXT: Offset
27// PART0-NEXT: 000000000000[[DATA_SEGMENT]]380 {{.*}} R_X86_64_64 000000000000[[DATA_SEGMENT]]378 p0 + 0
28// PART1-NEXT: 000000000000[[DATA_SEGMENT]]348 {{.*}} R_X86_64_64 000000000000[[DATA_SEGMENT]]340 p1 + 0
29// CHECK-EMPTY:
30
31// CHECK: Relocation section '.relr.dyn'
32// CHECK-NEXT: Offset
33// PART0-NEXT: 000000000000[[DATA_SEGMENT]]378 {{.*}} R_X86_64_RELATIVE
34// PART1-NEXT: 000000000000[[DATA_SEGMENT]]340 {{.*}} R_X86_64_RELATIVE
35// CHECK-EMPTY:
36
37.section .llvm_sympart,"",@llvm_sympart
38.asciz "part1"
39.quad p1
40
41.section .data.p0,"aw",@progbits
42.align 8
43.globl p0
44p0:
45.quad __ehdr_start
46.quad p0
47
48.section .data.p1,"aw",@progbits
49.align 8
50.globl p1
51p1:
52.quad __ehdr_start
53.quad p1
54