linker: Round TLS sizes up in linker script
Instead of rounding up both __tdata_size and __tbss_size at runtime, perform the calculation when the image is built. Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
parent
28276ce982
commit
ee9c44fee6
|
@ -24,14 +24,14 @@
|
|||
#else
|
||||
PROVIDE(__tdata_start = ADDR(tdata));
|
||||
#endif
|
||||
PROVIDE(__tdata_size = SIZEOF(tdata));
|
||||
PROVIDE(__tdata_end = __tdata_start + __tdata_size);
|
||||
PROVIDE(__tdata_align = ALIGNOF(tdata));
|
||||
PROVIDE(__tdata_size = (SIZEOF(tdata) + __tdata_align - 1) & ~(__tdata_align - 1));
|
||||
PROVIDE(__tdata_end = __tdata_start + __tdata_size);
|
||||
|
||||
PROVIDE(__tbss_start = ADDR(tbss));
|
||||
PROVIDE(__tbss_size = SIZEOF(tbss));
|
||||
PROVIDE(__tbss_end = __tbss_start + __tbss_size);
|
||||
PROVIDE(__tbss_align = ALIGNOF(tbss));
|
||||
PROVIDE(__tbss_start = ADDR(tbss));
|
||||
PROVIDE(__tbss_size = (SIZEOF(tbss) + __tbss_align - 1) & ~(__tbss_align - 1));
|
||||
PROVIDE(__tbss_end = __tbss_start + __tbss_size);
|
||||
|
||||
PROVIDE(__tls_start = __tdata_start);
|
||||
PROVIDE(__tls_end = __tbss_end);
|
||||
|
|
|
@ -28,10 +28,8 @@
|
|||
*/
|
||||
static inline size_t z_tls_data_size(void)
|
||||
{
|
||||
size_t tdata_size = ROUND_UP(__tdata_size, __tdata_align);
|
||||
size_t tbss_size = ROUND_UP(__tbss_size, __tbss_align);
|
||||
|
||||
return tdata_size + tbss_size;
|
||||
return (size_t)(uintptr_t)__tdata_size +
|
||||
(size_t)(uintptr_t)__tbss_size;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,15 +42,12 @@ static inline size_t z_tls_data_size(void)
|
|||
*/
|
||||
static inline void z_tls_copy(char *dest)
|
||||
{
|
||||
size_t tdata_size = (size_t)__tdata_size;
|
||||
size_t tbss_size = (size_t)__tbss_size;
|
||||
|
||||
/* Copy initialized data (tdata) */
|
||||
memcpy(dest, __tdata_start, tdata_size);
|
||||
memcpy(dest, __tdata_start, (size_t)(uintptr_t)__tdata_size);
|
||||
|
||||
/* Clear BSS data (tbss) */
|
||||
dest += ROUND_UP(tdata_size, __tdata_align);
|
||||
memset(dest, 0, tbss_size);
|
||||
dest += (size_t)(uintptr_t)__tdata_size;
|
||||
memset(dest, 0, (size_t)(uintptr_t)__tbss_size);
|
||||
}
|
||||
|
||||
#endif /* ZEPHYR_KERNEL_INCLUDE_KERNEL_TLS_H_ */
|
||||
|
|
Loading…
Reference in New Issue