Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-11-25 08:47:54


>From: "Pavol Droba" <droba_at_[hidden]>

> > > On Sun, Nov 24, 2002 at 07:27:42PM +0100, Terje Sletteb? wrote:
> >
> > For example, if you have a buffer like this (starting at an aligned
> > address):
> >
> > +0 - One byte
> > +1 - Number 1
> > +5 - Number 2
> > +9 - Number 3
> >
> > Even if you have a struct with three 32-bit ints, no internal padding,
if
> > you try to map it to the above buffer (at offset 1), on a platform that
> > requires 4-byte alignments for ints, it won't work.
>
> I see your point now. I'have used offset_cast mostly on x86 platform where
to
> misalignment is tolerated. I have used it also on ARM processor and we
have to
> make some sort of special arrangements to make it work. For network
strutures,
> however it worked fine, because most of them are internaly aligned.
>
> Anyway now I see that in the current implementation offset_cast is too
dangerous
> and unpredictable and so it is not usable for general purpose.

As you say, and as was pointed out at the start of the thread, it may work
on a specific platform (like x86). Perhaps it could be possible to have code
that detects the platform, and which could then report an error on
misalignment, if that is not tolerated on the given platform. It appears
Boost.Config isn't enough for this, though, as it only detects the OS, not
the underlying hardware.

How did you do it on the ARM? As I understand, it requires word-alignment
for words (and half-word alignment for half-words, if that is supported on
the given ARM version).

> I have mentioned before, that binary analysis could be done also using a
more
> complicated framework. Would it make sense to create one?

What does it do?

Regards,

Terje


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk