Hi Jay,
On Thu, 20 Jan 2011, Jay Foster wrote:
Looking at the definition of CYG_HAL_TABLE_TYPE and
CYG_HAL_TABLE_BEGIN, I see that the CYG_HAL_TABLE_BEGIN uses an
alignment of CYGARC_P2ALIGNMENT and the CYG_HAL_TABLE_TYPE uses an
alignment of CYGARC_ALIGNMENT.
For the ARM architecture, these are defined to be different
(CYGARC_P2ALIGNMENT is 2 and CYGARC_ALIGNMENT is 4). This would
result in the table label being 4 byte aligned and the elements 16
byte aligned.
It seemed for me "P2" stands for "power of 2", so 2^2 == 4 and that is
okay ~ http://sourceware.org/binutils/docs/as/P2align.html
For example for i386 architecture they defined
# define CYGARC_ALIGNMENT 32
# define CYGARC_P2ALIGNMENT 5
i.e. 2^5 == 32
The question is why has this not caused me problems before this?
Jay, I tried your example 'as is' for a few ARM targets (LE/BE) (well I
could only guess what MY_TYPE is) and couldn't reproduce such a miss-
alignment for _MY_LABEL_.
I just use GDB to test your example for ARM targets
## .gdbinit --
set output-radix 16
target sim
print&(_MY_LABEL_)
print&(my_instance1)
detach
quit
This did print always the same addresses. Hm, puzzle. Just a guess, may
be you use some -falign-* GCC option? However, TAB macros written in
asm. And how did you declare the labels? Hope, that is something like
extern MY_TYPE _MY_LABEL_[],
_MY_LABEL_END_;
Is it possible to reproduce the issue if you will provide more
information?
Sergei
On 1/20/2011 9:30 AM, Jay Foster wrote:
I have used the CYG_HAL_TABLE mechanism before with success, but I am now
running into an alignment problem with a new application. This is on an ARM
architecture.
I have an object defined as:
typedef struct
{
....
} CYG_HAL_TABLE_TYPE MY_TYPE;
I then declare the HAL table array as:
CYG_HAL_TABLE_BEGIN( _MY_LABEL_, _my_name_ );
CYG_HAL_TABLE_END( _MY_LABEL_END_, _my_name_ );
I then place two instances of the object into the HAL table array:
MY_TYPE my_instance1 CYG_HAL_TABLE_QUALIFIED_ENTRY(_my_name_, 2) =
{
....
};
MY_TYPE my_instance2 CYG_HAL_TABLE_QUALIFIED_ENTRY(_my_name_, 3) =
{
....
};
I then iterate the table using:
MY_TYPE *p;
for (p=&(_MY_LABEL_[0]); p!=&(_MY_LABEL_END_); p++)
{
}
This fails due to alignment issues:
The _MY_LABEL_ is not at the same address as the first element in the
array (my_instance1) due to alignment issues. The iteration then fails.
_MY_LABEL_ is aligned on a 4 byte boundary and the array elements are
aligned on 16 byte boundaries. Is there any way to make this work?
Jay
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss