new file mode 100644
@@ -0,0 +1,19 @@
+ .text
+ .globl aa
+ .section .tbss,"awT",@nobits
+ .align 2
+ .type aa, @object
+ .size aa, 4
+aa:
+ .space 4
+ .text
+ .align 2
+ .globl main
+ .type main, @function
+main:
+ lu12i.w $r12,%le_hi20(aa)
+ ori $r12,$r12,%le_lo12(aa)
+ add.d $r12,$r12,$r2
+ addi.w $r13,$r0,2 # 0x2
+ stptr.w $r13,$r12,0
+
new file mode 100644
@@ -0,0 +1,48 @@
+ .text
+ .globl count1
+ .section .tbss,"awT",@nobits
+ .align 2
+ .type count1, @object
+ .size count1, 4
+count1:
+ .space 0x400
+ .globl count2
+ .align 2
+ .type count2, @object
+ .size count2, 4
+count2:
+ .space 0x400
+ .globl count3
+ .align 2
+ .type count3, @object
+ .size count3, 4
+count3:
+ .space 0x400
+ .globl count4
+ .align 2
+ .type count4, @object
+ .size count4, 4
+count4:
+ .space 4
+ .text
+ .align 2
+ .globl main
+ .type main, @function
+main:
+ lu12i.w $r12,%tls_le_hi20(count1)
+ add.d $r12,$r12,$r2,%tprel_add(count1)
+ addi.w $r13,$r0,1 # 0x1
+ st.w $r13,$r12,%tls_le_lo12(count1)
+ lu12i.w $r12,%tls_le_hi20(count2)
+ add.d $r12,$r12,$r2,%tprel_add(count2)
+ addi.w $r13,$r0,2 # 0x2
+ st.w $r13,$r12,%tls_le_lo12(count2)
+ lu12i.w $r12,%tls_le_hi20(count3)
+ add.d $r12,$r12,$r2,%tprel_add(count3)
+ addi.w $r13,$r0,3 # 0x3
+ st.w $r13,$r12,%tls_le_lo12(count3)
+ lu12i.w $r12,%tls_le_hi20(count4)
+ add.d $r12,$r12,$r2,%tprel_add(count4)
+ addi.w $r13,$r0,4 # 0x4
+ st.w $r13,$r12,%tls_le_lo12(count4)
+
new file mode 100644
@@ -0,0 +1,43 @@
+ .file "tls_relax_compatible_check_new.c"
+ .text
+ .globl new
+ .section .tbss,"awT",@nobits
+ .align 2
+ .type new, @object
+ .size new, 4
+new:
+ .space 4
+ .text
+ .align 2
+ .globl main
+ .type main, @function
+main:
+.LFB0 = .
+ .cfi_startproc
+ addi.d $r3,$r3,-16
+ .cfi_def_cfa_offset 16
+ st.d $r1,$r3,8
+ stptr.d $r22,$r3,0
+ .cfi_offset 1, -8
+ .cfi_offset 22, -16
+ addi.d $r22,$r3,16
+ .cfi_def_cfa 22, 0
+ bl %plt(old)
+ lu12i.w $r12,%tls_le_hi20(new)
+ add.d $r12,$r12,$r2,%tprel_add(new)
+ addi.w $r13,$r0,2 # 0x2
+ st.w $r13,$r12,%tls_le_lo12(new)
+ or $r12,$r0,$r0
+ or $r4,$r12,$r0
+ ld.d $r1,$r3,8
+ .cfi_restore 1
+ ldptr.d $r22,$r3,0
+ .cfi_restore 22
+ addi.d $r3,$r3,16
+ .cfi_def_cfa_register 3
+ jr $r1
+ .cfi_endproc
+.LFE0:
+ .size main, .-main
+ .ident "GCC: (GNU) 14.0.0 20230526 (experimental)"
+ .section .note.GNU-stack,"",@progbits
new file mode 100644
@@ -0,0 +1,17 @@
+ .text
+ .globl a
+ .section .tbss,"awT",@nobits
+ .align 2
+ .type a, @object
+ .size a, 4
+a:
+ .space 4
+ .text
+ .align 2
+ .globl main
+ .type main, @function
+main:
+ lu12i.w $r12,%tls_le_hi20(a)
+ add.d $r12,$r12,$r2,%tprel_add(a)
+ addi.w $r13,$r0,1 # 0x1
+ st.w $r13,$r12,%tls_le_lo12(a)
@@ -33,8 +33,90 @@ if [istarget loongarch64-*-*] {
"relax" \
] \
]
+ set tls_relax_builds [list \
+ [list \
+ "tls_relax_builds" \
+ "" \
+ "" \
+ {relax-tls-le.s} \
+ {} \
+ "relax-tls-le" \
+ ] \
+ ]
+ set tls_no_relax_builds [list \
+ [list \
+ "tls_no_relax_builds" \
+ "-Wl,--no-relax" \
+ "" \
+ {relax-tls-le.s} \
+ {} \
+ "no-relax-tls-le" \
+ ] \
+ ]
+
+ set relax_bound_check [list \
+ [list \
+ "relax_bound_check" \
+ "" \
+ "" \
+ {relax-bound-check-tls-le.s} \
+ {} \
+ "relax-bound-check-tls-le" \
+ ] \
+ ]
+ set no_relax_bound_check [list \
+ [list \
+ "no_relax_bound_check" \
+ "-Wl,--no-relax" \
+ "" \
+ {relax-bound-check-tls-le.s} \
+ {} \
+ "no-relax-bound-check-tls-le" \
+ ] \
+ ]
+
+ set old_tls_le [list \
+ [list \
+ "old_tls_le" \
+ "" \
+ "" \
+ {old-tls-le.s} \
+ {} \
+ "old-tls-le" \
+ ] \
+ ]
+
+ set relax_compatible [list \
+ [list \
+ "relax_compatible" \
+ "" \
+ "" \
+ {relax-check-tls-le.s tls-relax-compatible-check-old.s} \
+ {} \
+ "realx-compatible" \
+ ] \
+ ]
+
+ set no_relax_compatible [list \
+ [list \
+ "no_relax_compatible" \
+ "-Wl,--no-relax" \
+ "" \
+ {relax-check-tls-le.s tls-relax-compatible-check-old.s} \
+ {} \
+ "no-realx-compatible" \
+ ] \
+ ]
+
run_cc_link_tests $pre_builds
+ run_cc_link_tests $tls_relax_builds
+ run_cc_link_tests $tls_no_relax_builds
+ run_cc_link_tests $relax_bound_check
+ run_cc_link_tests $no_relax_bound_check
+ run_cc_link_tests $old_tls_le
+ run_cc_link_tests $relax_compatible
+ run_cc_link_tests $no_relax_compatible
if [file exist "tmpdir/relax"] {
set objdump_output [run_host_cmd "objdump" "-d tmpdir/relax"]
@@ -44,8 +126,70 @@ if [istarget loongarch64-*-*] {
fail "loongarch relax"
}
}
- }
+ if [file exist "tmpdir/relax-tls-le"] {
+ set objdump_output1 [run_host_cmd "objdump" "-d tmpdir/relax-tls-le"]
+ if { [ regexp ".addi.*st.*" $objdump_output1] } {
+ pass "loongarch relax success"
+ } {
+ fail "loongarch relax fail"
+ }
+ }
+ if [file exist "tmpdir/no-relax-tls-le"] {
+ set objdump_output2 [run_host_cmd "objdump" "-d tmpdir/no-relax-tls-le"]
+ if { [ regexp ".*lu12i.*add.*addi.*st.*" $objdump_output2] } {
+ pass "loongarch no-relax success"
+ } {
+ fail "loongarch no-relax fail"
+ }
+ }
+ if [file exist "tmpdir/old-tls-le"] {
+ set objdump_output3 [run_host_cmd "objdump" "-d tmpdir/old-tls-le"]
+ if { [ regexp ".*lu12i.*ori.*add.*addi.*stptr.*" $objdump_output3] } {
+ pass "loongarch old tls le success"
+ } {
+ fail "loongarch old tls le fail"
+ }
+
+ }
+
+ if [file exist "tmpdir/realx-compatible"] {
+ if { [catch {exec tmpdir/realx-compatible} number]} {
+ fail "loongarch tls le relax compatible check fail"
+ } {
+ pass "loongarch tls le relax compatible check success"
+ }
+ }
+
+ if [file exist "tmpdir/no-realx-compatible"] {
+ if { [catch {exec tmpdir/no-realx-compatible} number] } {
+ fail "loongarch tls le no-relax compatible check fail"
+ } {
+ pass "loongarch tls le no-relax compatible check success"
+ }
+ }
+
+
+ if [file exist "tmpdir/relax-bound-check-tls-le"] {
+ set objdump_output4 [run_host_cmd "objdump" "-d tmpdir/relax-bound-check-tls-le"]
+ if { [ regexp ".*lu12i.*add.*addi.*st.*" $objdump_output4] && \
+ [ regexp ".addi.*st.*" $objdump_output4] } {
+ pass "loongarch no-relax success"
+ } {
+ fail "loongarch no-relax fail"
+ }
+
+ }
+ if [file exist "tmpdir/no-relax-bound-check-tls-le"] {
+ set objdump_output5 [run_host_cmd "objdump" "-d tmpdir/no-relax-bound-check-tls-le"]
+ if { [ regexp ".*addi.*st.*" $objdump_output4] } {
+ pass "loongarch no-relax success"
+ } {
+ fail "loongarch no-relax fail"
+ }
+ }
+
+ }
run_ld_link_tests \
[list \
[list \
new file mode 100644
@@ -0,0 +1,39 @@
+ .file "tls_relax_compatible_check_old.c"
+ .text
+ .globl older
+ .section .tbss,"awT",@nobits
+ .align 2
+ .type older, @object
+ .size older, 4
+older:
+ .space 4
+ .text
+ .align 2
+ .globl old
+ .type old, @function
+old:
+.LFB0 = .
+ .cfi_startproc
+ addi.d $r3,$r3,-16
+ .cfi_def_cfa_offset 16
+ st.d $r22,$r3,8
+ .cfi_offset 22, -8
+ addi.d $r22,$r3,16
+ .cfi_def_cfa 22, 0
+ lu12i.w $r12,%le_hi20(older)
+ ori $r12,$r12,%le_lo12(older)
+ add.d $r12,$r12,$r2
+ addi.w $r13,$r0,1 # 0x1
+ stptr.w $r13,$r12,0
+ nop
+ or $r4,$r12,$r0
+ ld.d $r22,$r3,8
+ .cfi_restore 22
+ addi.d $r3,$r3,16
+ .cfi_def_cfa_register 3
+ jr $r1
+ .cfi_endproc
+.LFE0:
+ .size old, .-old
+ .ident "GCC: (GNU) 13.0.1 20230316 (experimental)"
+ .section .note.GNU-stack,"",@progbits