forked from Imagelibrary/rtems
PR1560: _Objects_Extend_information improper alignment
_Objects_Extend_information uses a sizeof(uint32_t) offset that leads to improper alignment in case the CPU (actually, heap) alignment is 8 or higher. The problem is solved by adding enough padding to align the sub-tables.
This commit is contained in:
@@ -141,10 +141,15 @@ void _Objects_Extend_information(
|
||||
block_count++;
|
||||
|
||||
/*
|
||||
* Allocate the tables and break it up.
|
||||
* Allocate the tables and break it up. The tables are:
|
||||
* 1. object_locks : void*
|
||||
* 2. inactive_per_blocks : uint32_t
|
||||
* 3. local_table : Objects_Name*
|
||||
*/
|
||||
block_size = block_count *
|
||||
(sizeof(void *) + sizeof(uint32_t) + sizeof(Objects_Name *)) +
|
||||
#define ALIGN_BLOCK_SIZE(_s) \
|
||||
(((_s) + (CPU_ALIGNMENT - 1)) & ~(CPU_ALIGNMENT - 1))
|
||||
block_size = ALIGN_BLOCK_SIZE( block_count * sizeof(void*) ) +
|
||||
ALIGN_BLOCK_SIZE( block_count * sizeof(uint32_t) ) +
|
||||
((maximum + minimum_index) * sizeof(Objects_Control *));
|
||||
if ( information->auto_extend ) {
|
||||
object_blocks = _Workspace_Allocate( block_size );
|
||||
@@ -160,9 +165,17 @@ void _Objects_Extend_information(
|
||||
* Break the block into the various sections.
|
||||
*/
|
||||
inactive_per_block = (uint32_t *) _Addresses_Add_offset(
|
||||
object_blocks, block_count * sizeof(void*) );
|
||||
object_blocks,
|
||||
ALIGN_BLOCK_SIZE( block_count * sizeof(void*) )
|
||||
);
|
||||
local_table = (Objects_Control **) _Addresses_Add_offset(
|
||||
inactive_per_block, block_count * sizeof(uint32_t) );
|
||||
inactive_per_block,
|
||||
ALIGN_BLOCK_SIZE( block_count * sizeof(uint32_t) )
|
||||
);
|
||||
if ( !_Addresses_Is_aligned( local_table ) ) {
|
||||
local_table = (Objects_Control **)
|
||||
(((uintptr_t)local_table + CPU_ALIGNMENT - 1) & ~(CPU_ALIGNMENT - 1));
|
||||
}
|
||||
|
||||
/*
|
||||
* Take the block count down. Saves all the (block_count - 1)
|
||||
|
||||
Reference in New Issue
Block a user