ARM and padding

Ilya Vershkov ilya.vershkov@SeabridgeNetworks.com
Wed Jul 19 02:12:00 GMT 2000


Title: RE: ARM and padding





Do you use C or C++?
We had some problems with structure alignment in C++ code


 ## -----Original Message-----
 ## From: jens.ohlund@secrc.abb.se [ mailto:jens.ohlund@secrc.abb.se ]
 ## Sent: 18 July 2000 11:14
 ## To: crossgcc@sources.redhat.com
 ## Subject: Re: ARM and padding
 ## 
 ## 
 ## Hi !
 ## 
 ## It doesn't help. I've made a struct like this:
 ## struct
 ## {
 ##   unsigned char buf[250] __attribute__ ((packed));
 ##   unsigned char currPos __attribute__ ((packed));
 ##   unsigned int  remainingBytes __attribute__ ((packed));
 ##   unsigned char state __attribute__ ((packed));
 ## } __attribute__ ((packed)) lowRx;
 ## 
 ## And still, it's on the adresses:
 ## &buf[] = 0x241E0
 ## &currPos = 0x242DA
 ## &remainingBytes = 0x242DC
 ## &state = 0x242DF
 ## 
 ## Which makes the sizes:
 ## buf -> currPos =  250
 ## currPos -> remainingBytes = 2 !!!!!
 ## remainingBytes -> state = 4
 ## 
 ## currPos -> remainingBytes should only be 1.
 ## 
 ## This is just one struct out of many, with the same problem. 
 ## I can change Some of them, as this example. But not many compared to
 ## amount of troublesome structs.
 ## 
 ## yours
 ## Jens
 ## 
 ## 
 ## 
 ## 
 ## crossgcc-owner@sources.redhat.com
 ## 2000-07-18 10:38
 ## 
 ## 
 ## To:   jens.ohlund@secrc.abb.se
 ## cc:   crossgcc@sourceware.cygnus.com
 ## Subject:  Re: ARM and padding
 ## 
 ## Security Level:?         Internal
 ## 
 ## 
 ## >How do I tell the compiler that the structs are to be packed ?
 ## 
 ## __attribute__ (( packed )).  See the gcc manual.
 ## 
 ## p.
 ## 
 ## 
 ## 
 ## ------
 ## Want more information?  See the CrossGCC FAQ, 
 ## http://www.objsw.com/CrossGCC/
 ## Want to unsubscribe? Send a note to 
 ## crossgcc-unsubscribe@sourceware.cygnus.com
 ## 
 ## 
 ## 
 ## 
 ## 
 ## 
 ## ------
 ## Want more information?  See the CrossGCC FAQ, 
 ## http://www.objsw.com/CrossGCC/
 ## Want to unsubscribe? Send a note to 
 ## crossgcc-unsubscribe@sourceware.cygnus.com
 ## 






More information about the crossgcc mailing list