mirror of
https://github.com/apache/nuttx.git
synced 2026-09-11 21:20:10 +00:00
arch/arm: Fix TLS initialization to account for padding between sections
The TLS initialization logic needs to be updated to match the modified linker script section definitions. The previous implementation assumed that _END_TDATA and _START_TBSS were contiguous, but there may be padding between these sections for alignment purposes. This commit updates up_tls_initialize() to explicitly account for the padding gap between _END_TDATA and _START_TBSS when zeroing the .tbss section. The size calculation in up_tls_size() is also updated to use _END_TBSS instead of the previous _END_TXXX definition to match the current linker script layout. Changes: - Calculate padding gap: (_START_TBSS - _END_TDATA) - Zero .tbss at correct offset accounting for padding - Update size calculation to use proper section boundaries Signed-off-by: guoshengyuan1 <guoshengyuan1@xiaomi.com>
This commit is contained in:
parent
dd9f666ad2
commit
fac76746ea
1 changed files with 5 additions and 8 deletions
|
|
@ -69,7 +69,7 @@ int up_tls_size(void)
|
|||
|
||||
return sizeof(struct tls_info_s) +
|
||||
sizeof(void *) * 2 +
|
||||
sizeof(uint32_t) * (_END_TBSS - _START_TDATA);
|
||||
(_END_TBSS - _START_TDATA);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
@ -85,15 +85,12 @@ int up_tls_size(void)
|
|||
|
||||
void up_tls_initialize(struct tls_info_s *info)
|
||||
{
|
||||
uint8_t *tls_data = (uint8_t *)(info + 1);
|
||||
|
||||
uint32_t tdata_len = sizeof(uint32_t) * (_END_TDATA - _START_TDATA);
|
||||
uint32_t tbss_len = sizeof(uint32_t) * (_END_TBSS - _START_TBSS);
|
||||
|
||||
tls_data += sizeof(void *) * 2;
|
||||
uint8_t *tls_data = (uint8_t *)(info + 1) + sizeof(void *) * 2;
|
||||
uint32_t tdata_len = _END_TDATA - _START_TDATA;
|
||||
uint32_t tbss_len = _END_TBSS - _START_TBSS;
|
||||
|
||||
memcpy(tls_data, _START_TDATA, tdata_len);
|
||||
memset(tls_data + tdata_len, 0, tbss_len);
|
||||
memset(tls_data + tdata_len + (_START_TBSS - _END_TDATA), 0, tbss_len);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue