[ELF] Make SyntheticSection parameter order match InputSection
[llvm-project.git] / lld / test / ELF / hexagon-shared.s
blob01f7286584705686610ab997de0a9e38e3d77dd2
1 # REQUIRES: hexagon
2 # RUN: llvm-mc -mno-fixup -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o
3 # RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %S/Inputs/hexagon-shared.s -o %t2.o
4 # RUN: ld.lld -shared %t2.o -soname so -o %t3.so
5 # RUN: ld.lld -shared %t.o %t3.so -o %t4.so
6 # RUN: ld.lld -Bsymbolic -shared %t.o %t3.so -o %t5.so
7 # RUN: llvm-objdump --no-print-imm-hex -d -j .plt %t4.so | FileCheck --check-prefix=PLT %s
8 # RUN: llvm-objdump --no-print-imm-hex -d -j .text %t4.so | FileCheck --check-prefix=TEXT %s
9 # RUN: llvm-objdump --no-print-imm-hex -D -j .got %t4.so | FileCheck --check-prefix=GOT %s
10 # RUN: llvm-readelf -r %t4.so | FileCheck --check-prefix=RELO %s
11 # RUN: llvm-readelf -r %t5.so | FileCheck --check-prefix=SYMBOLIC %s
13 .global _start, foo, hidden_symbol
14 .hidden hidden_symbol
15 _start:
16 # When -Bsymbolic is specified calls to locally resolvables should
17 # not generate a plt.
18 call ##foo
19 # Calls to hidden_symbols should not trigger a plt.
20 call ##hidden_symbol
22 # _HEX_32_PCREL
23 .word _DYNAMIC - .
24 call ##bar
26 # R_HEX_PLT_B22_PCREL
27 call bar@PLT
28 # R_HEX_B15_PCREL_X
29 if (p0) jump bar
30 # R_HEX_B9_PCREL_X
31 { r0 = #0; jump bar }
33 # R_HEX_GOT_11_X and R_HEX_GOT_32_6_X
34 r2=add(pc,##_GLOBAL_OFFSET_TABLE_@PCREL)
35 r0 = memw (r2+##bar@GOT)
36 jumpr r0
38 # R_HEX_GOT_16_X
39 r0 = add(r1,##bar@GOT)
41 # R_HEX_GOT_16_X, duplex
42 { r0 = add(r0,##bar@GOT)
43 memw(r0) = r2 }
45 # R_HEX_GOT_16_X, pred add
46 if (p0) r0 = add(r0,##bar@GOT)
47 if (!p0) r0 = add(r0,##bar@GOT)
48 { p0 = cmp.gtu(r0, r1)
49 if (p0.new) r0 = add(r0,##bar@GOT) }
50 { p0 = cmp.gtu(r0, r1)
51 if (!p0.new) r0 = add(r0,##bar@GOT) }
53 # foo is local so no plt will be generated
54 foo:
55 jumpr lr
57 hidden_symbol:
58 jumpr lr
60 # R_HEX_32
61 .data
62 .global var
63 .type var,@object
64 .p2align 2
65 var:
66 .word 10
67 .size var, 4
68 .global pvar
69 .type pvar,@object
70 pvar:
71 .word var
72 .size pvar, 4
75 # PLT: { immext(#131264
76 # PLT-NEXT: r28 = add(pc,##131268) }
77 # PLT-NEXT: { r14 -= add(r28,#16)
78 # PLT-NEXT: r15 = memw(r28+#8)
79 # PLT-NEXT: r28 = memw(r28+#4) }
80 # PLT-NEXT: { r14 = asr(r14,#2)
81 # PLT-NEXT: jumpr r28 }
82 # PLT-NEXT: { trap0(#219) }
83 # PLT-NEXT: immext(#131200)
84 # PLT-NEXT: r14 = add(pc,##131252) }
85 # PLT-NEXT: r28 = memw(r14+#0) }
86 # PLT-NEXT: jumpr r28 }
88 # TEXT: bc 00 01 00 000100bc
89 # TEXT: { call 0x10300 }
90 # TEXT: if (p0) jump:nt 0x10300
91 # TEXT: r0 = #0 ; jump 0x10300
92 # TEXT: r0 = add(r1,##-65548)
93 # TEXT: r0 = add(r0,##-65548); memw(r0+#0) = r2 }
94 # TEXT: if (p0) r0 = add(r0,##-65548)
95 # TEXT: if (!p0) r0 = add(r0,##-65548)
96 # TEXT: if (p0.new) r0 = add(r0,##-65548)
97 # TEXT: if (!p0.new) r0 = add(r0,##-65548)
99 # GOT: .got:
100 # GOT: 00 00 00 00 00000000 <unknown>
102 # RELO: R_HEX_GLOB_DAT
103 # RELO: R_HEX_32
104 # RELO: Relocation section '.rela.plt' at offset 0x22c contains 2 entries:
105 # RELO: R_HEX_JMP_SLOT {{.*}} foo
106 # RELO-NEXT: R_HEX_JMP_SLOT {{.*}} bar
107 # RELO-NOT: R_HEX_JMP_SLOT {{.*}} hidden
109 # Make sure that no PLT is generated for a local call.
110 # SYMBOLIC: Relocation section '.rela.plt' at offset 0x22c contains 1 entries:
111 # SYMBOLIC: R_HEX_JMP_SLOT {{.*}} bar
112 # SYMBOLIC-NOT: R_HEX_JMP_SLOT {{.*}} foo