From: Ola Liljedahl <olli@enea.se>
To: jens.ohlund@secrc.abb.se
Cc: crossgcc@sources.redhat.com
Subject: Re: ARM and padding
Date: Tue, 18 Jul 2000 02:28:00 -0000 [thread overview]
Message-ID: <39742318.6641E2A6@enea.se> (raw)
In-Reply-To: <OF381DC566.027185DC-ONC1256920.0032AE03@secrc.abb.se>
You are transferring a binary structure from one architecture to another
using the compiler's struct layout as the format of the packet?!?
Don't expect this to work more than in some rare instance (depending on
the involved processor architectures and compilers).
You need some more protocol layer to get this communication reliable. Or
some packet format which is inherently more portable.
--
Ola Liljedahl
jens.ohlund@secrc.abb.se wrote:
>
> 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
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
next prev parent reply other threads:[~2000-07-18 2:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-07-18 2:14 jens.ohlund
2000-07-18 2:28 ` Ola Liljedahl [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-07-19 2:12 Ilya Vershkov
2000-07-18 1:01 jens.ohlund
2000-07-18 1:36 ` Philip Blundell
2000-07-18 2:38 ` Luke Diamand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=39742318.6641E2A6@enea.se \
--to=olli@enea.se \
--cc=crossgcc@sources.redhat.com \
--cc=jens.ohlund@secrc.abb.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).