1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t1
3# RUN: ld.lld --emit-relocs %t1 -o %t2
4# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s
5
6## Check lf we produce proper relocations when doing merging of SHF_MERGE sections.
7
8## Check addends of relocations are: 0x0, 0x8, 0x8, 0x4
9# CHECK:      Section {
10# CHECK:        Index:
11# CHECK:        Name: .foo
12# CHECK-NEXT:   Type: SHT_PROGBITS
13# CHECK-NEXT:   Flags [
14# CHECK-NEXT:     SHF_ALLOC
15# CHECK-NEXT:     SHF_EXECINSTR
16# CHECK-NEXT:   ]
17# CHECK-NEXT:   Address:
18# CHECK-NEXT:   Offset:
19# CHECK-NEXT:   Size:
20# CHECK-NEXT:   Link:
21# CHECK-NEXT:   Info:
22# CHECK-NEXT:   AddressAlignment:
23# CHECK-NEXT:   EntrySize:
24# CHECK-NEXT:   SectionData (
25# CHECK-NEXT:     0000: 00000000 08000000 08000000 04000000
26# CHECK-NEXT:   )
27# CHECK-NEXT: }
28
29## Check that offsets for AAA is 0x0, for BBB is 0x8 and CCC has offset 0x4.
30# CHECK:      Section {
31# CHECK:        Index:
32# CHECK:        Name: .strings
33# CHECK-NEXT:   Type: SHT_PROGBITS
34# CHECK-NEXT:   Flags [
35# CHECK-NEXT:     SHF_MERGE
36# CHECK-NEXT:     SHF_STRINGS
37# CHECK-NEXT:   ]
38# CHECK-NEXT:   Address:
39# CHECK-NEXT:   Offset:
40# CHECK-NEXT:   Size:
41# CHECK-NEXT:   Link:
42# CHECK-NEXT:   Info:
43# CHECK-NEXT:   AddressAlignment:
44# CHECK-NEXT:   EntrySize:
45# CHECK-NEXT:   SectionData (
46# CHECK-NEXT:     |AAA.CCC.BBB.|
47# CHECK-NEXT:   )
48# CHECK-NEXT: }
49
50.section .strings,"MS",@progbits,1,unique,10
51.Linfo_string0:
52  .asciz "AAA"
53.Linfo_string1:
54  .asciz "BBB"
55
56.section .strings,"MS",@progbits,1,unique,20
57.Linfo_string2:
58  .asciz "BBB"
59.Linfo_string3:
60  .asciz "CCC"
61
62.section .foo,"ax",@progbits
63.long .Linfo_string0
64.long .Linfo_string1
65.long .Linfo_string2
66.long .Linfo_string3
67