1/* 2* Copyright (C) 2025 Huawei Device Co., Ltd. 3* Licensed under the Apache License, Version 2.0 (the "License"); 4* you may not use this file except in compliance with the License. 5* You may obtain a copy of the License at 6* 7* http://www.apache.org/licenses/LICENSE-2.0 8* 9* Unless required by applicable law or agreed to in writing, software 10* distributed under the License is distributed on an "AS IS" BASIS, 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12* See the License for the specific language governing permissions and 13* limitations under the License. 14*/ 15 .text 16 17 18 .globl tlsdesc_f1 19 .p2align 2 20 .type tlsdesc_f1,@function 21tlsdesc_f1: 22 sub sp, sp, #32 23 stp x29, x30, [sp, #16] 24 add x29, sp, #16 25 str x0, [sp, #8] 26 27 adrp x0, :tlsdesc:tlsdesc_adr_page21_tls_var1 // R_AARCH64_TLSDESC_ADR_PAGE21 28 ldr x1, [x0, :tlsdesc_lo12:tlsdesc_adr_page21_tls_var1] // R_AARCH64_TLSDESC_LD64_LO12 29 add x0, x0, :tlsdesc_lo12:tlsdesc_adr_page21_tls_var1 // R_AARCH64_TLSDESC_ADD_LO12 30 .tlsdesccall tlsdesc_adr_page21_tls_var1 31 blr x1 // R_AARCH64_TLSDESC_CALL 32 mrs x8, TPIDR_EL0 33 ldr w10, [x8, x0] 34 35 adrp x9, :got:tlsdesc_var1 36 ldr x9, [x9, :got_lo12:tlsdesc_var1] 37 ldr w8, [x9] 38 add w8, w8, w10 39 str w8, [x9] 40 41 mov x0, xzr 42 ldp x29, x30, [sp, #16] 43 add sp, sp, #32 44 ret 45.Lfunc_end0: 46 .size tlsdesc_f1, .Lfunc_end0-tlsdesc_f1 47 48 49 .globl tlsdesc_test 50 .p2align 2 51 .type tlsdesc_test,@function 52tlsdesc_test: 53 sub sp, sp, #48 54 stp x29, x30, [sp, #32] 55 add x29, sp, #32 56 sub x0, x29, #8 57 mov x3, xzr 58 str x3, [sp, #8] 59 mov x1, x3 60 adrp x2, :got:tlsdesc_f1 61 ldr x2, [x2, :got_lo12:tlsdesc_f1] 62 str x2, [sp] 63 bl pthread_create 64 ldr x2, [sp] 65 ldr x3, [sp, #8] 66 add x0, sp, #16 67 mov x1, x3 68 bl pthread_create 69 ldr x1, [sp, #8] 70 ldur x0, [x29, #-8] 71 bl pthread_join 72 ldr x1, [sp, #8] 73 ldr x0, [sp, #16] 74 bl pthread_join 75 adrp x8, :got:tlsdesc_var1 76 ldr x8, [x8, :got_lo12:tlsdesc_var1] 77 ldr w0, [x8] 78 ldp x29, x30, [sp, #32] 79 add sp, sp, #48 80 ret 81.Lfunc_end3: 82 .size tlsdesc_test, .Lfunc_end3-tlsdesc_test 83 84 85 .type tlsdesc_adr_page21_tls_var1,@object 86 .section .tdata,"awT",@progbits 87 .globl tlsdesc_adr_page21_tls_var1 88 .p2align 2 89tlsdesc_adr_page21_tls_var1: 90 .word 1 91 .size tlsdesc_adr_page21_tls_var1, 4 92 93 94 .type tlsdesc_var1,@object 95 .bss 96 .globl tlsdesc_var1 97 .p2align 2 98tlsdesc_var1: 99 .word 0 100 .size tlsdesc_var1, 4 101 102 103 .section ".note.GNU-stack","",@progbits 104 .addrsig 105 .addrsig_sym tlsdesc_f1 106 .addrsig_sym pthread_create 107 .addrsig_sym pthread_join 108 .addrsig_sym tlsdesc_var1 109