This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Yet another ARM alignment question


Hello Wilson,

>My question is has anyone solved the word and dword alignment problems on
>ARM? Is is any combination of gcc compiler options that will overcome this
>limitation albeit at a performance cost. What about an alignment trap

If you specify -fpack-struct on the gcc command line, gcc will not align 
data items in structures and will generate multiple ldrh/ldrb/strh/strb 
instructions to access the misaligned data items in those structures; is 
that what you're asking? The performance cost of doing this globally is 
_high_ and it's best avoided!

Is this a theoretical question or do you have an actual problem? (Can you 
post a little sample code along with a description of the symptom?) I can't 
see where it would be an issue except in certain structures (e.g. my 
problem I had a while back generating structs to reflect various FAT 
structures). gcc will normally handle pointer arithmetic and dereferencing 
for you without difficulty.

The more efficient way to solve the latter problem is to specify just those 
structures as packed, which is what I'm doing, e.g. :

// Master Boot Record
typedef struct {
         unsigned char fill[0x1be];      // boot code
         PARTENTRY partitions[4];        // partition table
         unsigned char sig_55;           // 55h boot signature
         unsigned char sig_aa;           // AAh boot signature
} __attribute__((packed)) MBR, *PMBR;


=== Lewin A.R.W. Edwards (Embedded Engineer)
Work: http://www.digi-frame.com/
Personal: http://www.zws.com/ and http://www.larwe.com/

"... a man who is endowed with real qualities of leadership will be tempted 
to refrain from taking part in political life; because [...] the situation 
does not call for a man who has a capacity for constructive statesmanship 
but rather for a man who is capable of bargaining for the favour of the 
majority. Thus the situation will appeal to small minds and will attract 
them accordingly."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]