public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Privat <PicassoCT@gmx.de>
To: ecos-discuss@ecos.sourceware.org,
	"Max Seidenstücker" <max.seidenstuecker@googlemail.com>
Subject: [ECOS] Eabi error or Compiler Bug?
Date: Wed, 02 Mar 2016 08:36:00 -0000	[thread overview]
Message-ID: <56D6A602.10908@gmx.de> (raw)

Hi Max, Hi Edwards,  hi everyone

i ve bumped into some strange behaviour again lately during some code
cleanup.
I can work around it, but i wondered if other before me ran into this
and wether this is UB, a compiler bug or something ecos specific.

My Compiler:
Im compiling under ubuntu 14.04 for the MPC5668x powerpc architecture
with ppc-eabi-gcc 4.8.2 toolchain (if i found the correct compiler there) .

The problem occurs when casting pointers to a smaller size;

Example:
cyg_uint32 testValue = 0x12345678;
cyg_uint8  *ptrToLowestByte;
cyg_uint32 *ptrToWholeValue;

ptrToLowestByte = (cyg_uint8 *) (&testValue);
ptrToWholeValue = (cyg_uint32 *) ptrToLowestByte;

I can work with the ptrToTheWholeValue as long i do not use any binary
operations with a diffrent size
For example

cyg_uint32 container32 = ((*ptrToWholeValue) & 0xFF00 0000)
will return valid Value into the corresponding 32uint container;

cyg_uint8 container8 = (cyg_uint8) ((ptrToWholeValue & 0xFF00 0000 ) >>
24);

However will not.
My assumption is that the endianess of the dereferenced Value is wrong,
a cast pointer does no longer point to the lowest byte, but to the
highest instead.
I worked around it by not using bitops that shift into a diffrently
sized variable from a pointer.

If requested i could upload some dissasembly.

I also experienced some problems using memcpy and strncpy, when using
casted down uint8* ptr to uint8 arrays
- where the values to copy where copyied in at a offset off the original
ptrs data type (uint32*).

This all may be perfectly normal behaviour and i m just lacking
experience- in that case i would be very glad for any explenation.
Anybody experienced something similar?
There seem to be some todos regarding assembly binary operations in the
vle.h still open.
Should i report this to the gnu or will i get trampled by a stampede?

Regards Pica






-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

             reply	other threads:[~2016-03-02  8:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02  8:36 Privat [this message]
2016-03-02  9:25 ` Privat

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=56D6A602.10908@gmx.de \
    --to=picassoct@gmx.de \
    --cc=ecos-discuss@ecos.sourceware.org \
    --cc=max.seidenstuecker@googlemail.com \
    /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).