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