Iam going through a linker descriptor file and found following lines of code and I am unable to understand the typecasting concept used here.
extern std::uintptr_t __sROData_LMA[]; /* start of LOAD region for DATA */
uint32_t * p_src, * p_dest;
#ifdef XMC_BOOT
// Copy the rodata segment initializers from ROM to RAM.
// Note that all data segments are aligned by 4.
p_src = static_cast<uint32_t *>(static_cast<void*>(__sROData_LMA));
p_dest = static_cast<uint32_t *>(static_cast<void*>(__sROData));
while (p_dest < static_cast<uint32_t*>(static_cast<void*>(__eROData)))
{
*p_dest++ = *p_src++;
}
#endif
What does the line p_src = static_cast<uint32_t *>(static_cast<void*>(__sROData_LMA));
meant in the program? How is typecasting being done here? Thanks in advance.
The thing is, that you cannot dereference a void pointer, but a uint32_t pointer. The code itself is used for Copy the rodata segment initializers from ROM to RAM.
, which is afaik required for ELF binaries. In fact, this is a mempcy
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.