This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc 2.96.2 cross compiler problem on ARM
- From: Benny Sjostrand <benny at hostmobility dot com>
- To: linux-arm-kernel at lists dot arm dot linux dot org dot uk, gcc-bugs at gcc dot gnu dot org
- Date: Thu, 21 Feb 2002 00:01:25 +0100
- Subject: gcc 2.96.2 cross compiler problem on ARM
Theese days i've found a strange problem related to the compiler,
probably a gcc bug,
i'm using gcc 2.95.2 building on a Linux Sparc64 (Sun Ultra5) host,
target arm, that
probably does not make things easier. I've have been using gcc 2.95.2
since ~ September 2001,
compiled most all linux-2.4.x-rmkx kernels without any known problem
related to the compiler.
Having the following struct:
typedef unsigned long long sapfsel_t;
struct xrp_header {
unsigned int xrp_version:4;
unsigned int xrp_reserved:4;
unsigned char xrp_msgtype;
unsigned short xrp_paramlen;
sapfsel_t xrp_selector;
};
--> sizeof (xrp_header) == 2
where the data layout should be aligned in the following way:
4 4 8 16 bits
+-----------------------------------------------------------+
0 | vers | rsrvd | msg type | param len 31 |
+-----------------------------------------------------------+
32 | LSB 63 |
+ xrp_selector +
64 | MSB 95 |
+-----------------------------------------------------------+
now strange thing is the the LSB(i) and LSB(i-1) of xrp_selector field
overlaps the xrp_paramlen, so compiling the following piece off code:
byte 0 1 2 3 4 5
6 7 8 9 10 11
+---------------------------------------------------+
0 | vers | rsrvd | msg type | param len 15 |
+-----------------------------+---------------------+-------------------------------+--------+
|LSB
xrp_selector MSB| unused |
+-----------------------------------------------------+--------+
struct xrp_header h;
h.xrp_version = 0;
h.xrp_reserved = 0;
h.xrp_msgtype = 0;
h.xrp_selector = 0;
h.xrp_paramlen = 1;
and the h.xrp_selector == 0x01 00 00 00 00 00 00 00;
I dont find any other explication to this than a gcc compiler bug,
well, there's a uggly way to get around the problem:
struct xrp_header {
unsigned int xrp_version:4;
unsigned int xrp_reserved:4;
unsigned char xrp_msgtype;
unsigned short xrp_paramlen;
unsigned short dummy;
sapfsel_t xrp_selector;
};
#define SIZE_OF_XRP_HEADER sizeof(struct xrp_header) - sizeof(short)
Well, if anyone is interested, i discovered this issue trying to make Lunar
(Lightweight Underlay Network Ad-Hoc Routing) run on a iPAQ 3760, Lunar
code can be found at:
http://www.docs.uu.se/docs/research/projects/selnet/lunar/
/Benny