[ELF] Make section member orders consistent
[llvm-project.git] / lld / test / ELF / loongarch-tls-gd-pcrel20-s2.s
blobd4d12b9d4a520de6b96287926812dabd9fec836e
1 # REQUIRES: loongarch
2 # RUN: rm -rf %t && split-file %s %t
4 # RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/a.s -o %t/a.32.o
5 # RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/bc.s -o %t/bc.32.o
6 # RUN: ld.lld -shared -soname=bc.so %t/bc.32.o -o %t/bc.32.so
7 # RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/tga.s -o %t/tga.32.o
8 # RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/a.s -o %t/a.64.o
9 # RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/bc.s -o %t/bc.64.o
10 # RUN: ld.lld -shared -soname=bc.so %t/bc.64.o -o %t/bc.64.so
11 # RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/tga.s -o %t/tga.64.o
13 ## LA32 GD
14 # RUN: ld.lld -shared %t/a.32.o %t/bc.32.o -o %t/gd.32.so
15 # RUN: llvm-readobj -r %t/gd.32.so | FileCheck --check-prefix=GD32-REL %s
16 # RUN: llvm-objdump -d --no-show-raw-insn %t/gd.32.so | FileCheck --check-prefix=GD32 %s
18 ## LA32 GD -> LE
19 # RUN: ld.lld %t/a.32.o %t/bc.32.o %t/tga.32.o -o %t/le.32
20 # RUN: llvm-readelf -r %t/le.32 | FileCheck --check-prefix=NOREL %s
21 # RUN: llvm-readelf -x .got %t/le.32 | FileCheck --check-prefix=LE32-GOT %s
22 # RUN: ld.lld -pie %t/a.32.o %t/bc.32.o %t/tga.32.o -o %t/le-pie.32
23 # RUN: llvm-readelf -r %t/le-pie.32 | FileCheck --check-prefix=NOREL %s
24 # RUN: llvm-readelf -x .got %t/le-pie.32 | FileCheck --check-prefix=LE32-GOT %s
26 ## LA32 GD -> IE
27 # RUN: ld.lld %t/a.32.o %t/bc.32.so %t/tga.32.o -o %t/ie.32
28 # RUN: llvm-readobj -r %t/ie.32 | FileCheck --check-prefix=IE32-REL %s
29 # RUN: llvm-readelf -x .got %t/ie.32 | FileCheck --check-prefix=IE32-GOT %s
31 ## LA64 GD
32 # RUN: ld.lld -shared %t/a.64.o %t/bc.64.o -o %t/gd.64.so
33 # RUN: llvm-readobj -r %t/gd.64.so | FileCheck --check-prefix=GD64-REL %s
34 # RUN: llvm-objdump -d --no-show-raw-insn %t/gd.64.so | FileCheck --check-prefix=GD64 %s
36 ## LA64 GD -> LE
37 # RUN: ld.lld %t/a.64.o %t/bc.64.o %t/tga.64.o -o %t/le.64
38 # RUN: llvm-readelf -r %t/le.64 | FileCheck --check-prefix=NOREL %s
39 # RUN: llvm-readelf -x .got %t/le.64 | FileCheck --check-prefix=LE64-GOT %s
40 # RUN: ld.lld -pie %t/a.64.o %t/bc.64.o %t/tga.64.o -o %t/le-pie.64
41 # RUN: llvm-readelf -r %t/le-pie.64 | FileCheck --check-prefix=NOREL %s
42 # RUN: llvm-readelf -x .got %t/le-pie.64 | FileCheck --check-prefix=LE64-GOT %s
44 ## LA64 GD -> IE
45 # RUN: ld.lld %t/a.64.o %t/bc.64.so %t/tga.64.o -o %t/ie.64
46 # RUN: llvm-readobj -r %t/ie.64 | FileCheck --check-prefix=IE64-REL %s
47 # RUN: llvm-readelf -x .got %t/ie.64 | FileCheck --check-prefix=IE64-GOT %s
49 # GD32-REL: .rela.dyn {
50 # GD32-REL-NEXT: 0x20300 R_LARCH_TLS_DTPMOD32 a 0x0
51 # GD32-REL-NEXT: 0x20304 R_LARCH_TLS_DTPREL32 a 0x0
52 # GD32-REL-NEXT: 0x20308 R_LARCH_TLS_DTPMOD32 b 0x0
53 # GD32-REL-NEXT: 0x2030C R_LARCH_TLS_DTPREL32 b 0x0
54 # GD32-REL-NEXT: }
56 ## &DTPMOD(a) - . = 0x20300 - 0x10250 = 16428<<2
57 # GD32: 10250: pcaddi $a0, 16428
58 # GD32-NEXT: bl 44
60 ## &DTPMOD(b) - . = 0x20308 - 0x10258 = 16428<<2
61 # GD32: 10258: pcaddi $a0, 16428
62 # GD32-NEXT: bl 36
64 # GD64-REL: .rela.dyn {
65 # GD64-REL-NEXT: 0x204C0 R_LARCH_TLS_DTPMOD64 a 0x0
66 # GD64-REL-NEXT: 0x204C8 R_LARCH_TLS_DTPREL64 a 0x0
67 # GD64-REL-NEXT: 0x204D0 R_LARCH_TLS_DTPMOD64 b 0x0
68 # GD64-REL-NEXT: 0x204D8 R_LARCH_TLS_DTPREL64 b 0x0
69 # GD64-REL-NEXT: }
71 ## &DTPMOD(a) - . = 0x204c0 - 0x10398 = 16458<<2
72 # GD64: 10398: pcaddi $a0, 16458
73 # GD64-NEXT: bl 52
75 ## &DTPMOD(b) - . = 0x204d0 - 0x103a4 = 16460<<2
76 # GD64: 103a0: pcaddi $a0, 16460
77 # GD64-NEXT: bl 44
79 # NOREL: no relocations
81 ## .got contains pre-populated values: [a@dtpmod, a@dtprel, b@dtpmod, b@dtprel]
82 ## a@dtprel = st_value(a) = 0x8
83 ## b@dtprel = st_value(b) = 0xc
84 # LE32-GOT: section '.got':
85 # LE32-GOT-NEXT: 0x[[#%x,A:]] 01000000 08000000 01000000 0c000000
86 # LE64-GOT: section '.got':
87 # LE64-GOT-NEXT: 0x[[#%x,A:]] 01000000 00000000 08000000 00000000
88 # LE64-GOT-NEXT: 0x[[#%x,A:]] 01000000 00000000 0c000000 00000000
90 ## a is local - relaxed to LE - its DTPMOD/DTPREL slots are link-time constants.
91 ## b is external - DTPMOD/DTPREL dynamic relocations are required.
92 # IE32-REL: .rela.dyn {
93 # IE32-REL-NEXT: 0x30220 R_LARCH_TLS_DTPMOD32 b 0x0
94 # IE32-REL-NEXT: 0x30224 R_LARCH_TLS_DTPREL32 b 0x0
95 # IE32-REL-NEXT: }
96 # IE32-GOT: section '.got':
97 # IE32-GOT-NEXT: 0x00030218 01000000 08000000 00000000 00000000
99 # IE64-REL: .rela.dyn {
100 # IE64-REL-NEXT: 0x30380 R_LARCH_TLS_DTPMOD64 b 0x0
101 # IE64-REL-NEXT: 0x30388 R_LARCH_TLS_DTPREL64 b 0x0
102 # IE64-REL-NEXT: }
103 # IE64-GOT: section '.got':
104 # IE64-GOT-NEXT: 0x00030370 01000000 00000000 08000000 00000000
105 # IE64-GOT-NEXT: 0x00030380 00000000 00000000 00000000 00000000
107 #--- a.s
108 pcaddi $a0, %gd_pcrel_20(a)
109 bl %plt(__tls_get_addr)
111 pcaddi $a0, %gd_pcrel_20(b)
112 bl %plt(__tls_get_addr)
114 .section .tbss,"awT",@nobits
115 .globl a
116 .zero 8
118 .zero 4
120 #--- bc.s
121 .section .tbss,"awT",@nobits
122 .globl b, c
124 .zero 4
127 #--- tga.s
128 .globl __tls_get_addr
129 __tls_get_addr: