From fb01e6a3fb295ef3ce728d9c3450d7adabe11432 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 2 Mar 2023 22:48:06 -0800 Subject: [PATCH] cpu: Add TLS symbols for newer picolibc to linker scripts Newer picolibc versions require some additional symbols defined in the linker script to correctly manage alignment constraints on thread local storage. Signed-off-by: Keith Packard --- cpu/cortexm_common/ldscripts/cortexm_base.ld | 4 ++++ cpu/lpc23xx/ldscripts/lpc23xx.ld | 3 +++ cpu/riscv_common/ldscripts/riscv_base.ld | 2 ++ 3 files changed, 9 insertions(+) diff --git a/cpu/cortexm_common/ldscripts/cortexm_base.ld b/cpu/cortexm_common/ldscripts/cortexm_base.ld index 4145e9219c..06283bc805 100644 --- a/cpu/cortexm_common/ldscripts/cortexm_base.ld +++ b/cpu/cortexm_common/ldscripts/cortexm_base.ld @@ -132,6 +132,10 @@ SECTIONS } > rom __tls_size = __tbss_end - __tdata_start; __tbss_size = __tls_size - __tdata_size; + PROVIDE( __tbss_offset = ADDR(.tbss) - ADDR(.tdata) ); + PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); + PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); + PROVIDE( __arm64_tls_tcb_offset = MAX(16, __tls_align) ); /* .ARM.exidx is sorted, so has to go in its own output section. */ PROVIDE_HIDDEN (__exidx_start = .); diff --git a/cpu/lpc23xx/ldscripts/lpc23xx.ld b/cpu/lpc23xx/ldscripts/lpc23xx.ld index 48c5e91f9e..35e70ce3fc 100644 --- a/cpu/lpc23xx/ldscripts/lpc23xx.ld +++ b/cpu/lpc23xx/ldscripts/lpc23xx.ld @@ -106,6 +106,9 @@ SECTIONS } > rom __tls_size = __tbss_end - __tdata_start; __tbss_size = __tls_size - __tdata_size; + PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); + PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); + PROVIDE( __arm64_tls_tcb_offset = MAX(16, __tls_align) ); /* .ARM.exidx is sorted, so has to go in its own output section. */ PROVIDE_HIDDEN (__exidx_start = .); diff --git a/cpu/riscv_common/ldscripts/riscv_base.ld b/cpu/riscv_common/ldscripts/riscv_base.ld index 3097a30aed..609a47699d 100644 --- a/cpu/riscv_common/ldscripts/riscv_base.ld +++ b/cpu/riscv_common/ldscripts/riscv_base.ld @@ -159,6 +159,8 @@ SECTIONS } >flash : tls __tls_size = __tbss_end - __tdata_start; __tbss_size = __tls_size - __tdata_size; + PROVIDE( __tbss_offset = ADDR(.tbss) - ADDR(.tdata) ); + PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); .lalign : {