__set_thread_area.s (793B)
1 /* tcc-build aarch64 __set_thread_area. 2 * 3 * Sets the EL0 thread pointer (TPIDR_EL0) to x0 and returns 0. 4 * Stock musl writes `msr tpidr_el0, x0` as a plain mnemonic; the 5 * `msr` system-register move is outside arm64-asm.c phase 1+2, so 6 * we emit the encoding as a raw word. 7 * 8 * d51bd040 msr tpidr_el0, x0 (op0=3 op1=3 CRn=13 CRm=0 op2=2 Rt=0) 9 * 10 * Without this, __init_tls's call to __set_thread_area resolves to 11 * an invalid address (tcc's static linker doesn't fail on undefined 12 * archive references), and hello segfaults inside __libc_start_main 13 * before main runs. 14 * 15 * Note: tcc treats `.word` as 2 bytes; use `.long` for 4. */ 16 17 .global __set_thread_area 18 .hidden __set_thread_area 19 .type __set_thread_area,@function 20 __set_thread_area: 21 .long 0xd51bd040 22 mov w0, #0 23 ret