This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Problems with Sun4 alignment
- To: help-gcc-request at gnu dot org
- Subject: Problems with Sun4 alignment
- From: Michael White <mwhite at ftw dot mot dot com>
- Date: Mon, 24 Jan 2000 11:29:56 -0600 (CST)
- cc: help-gcc at gnu dot org
- Reply-To: Michael White <mwhite at ftw dot mot dot com>
Hi all,
I'm having a problem with the executable generated by gcc 2.8.1 for Sun
4 (uname -a: SunOS drywall3 4.1.3_U1 2 sun4m). Specifically, I've
specified the following flags/defines in tm.h:
#define STRICT_ALIGNMENT 1
#define STRUCTURE_SIZE_BOUNDARY 32
Here's the structure I'm having problems with:
typedef struct
{
UBYTE hdr_ver:4;
UBYTE data_ver:4;
UBYTE reserved:4;
UBYTE chan_id:4;
UWORD len;
UWORD msg_type;
STD_SCAP_ADDR dest_addr;
UWORD resp_type;
XC_SCAP_ADDR src_addr;
} SCAP_HDR;
Where:
#define UBYTE unsigned char
#define UWORD unsigned short
#define ULONG unsigned long
typedef struct
{
UBYTE system;
UBYTE sub_system[2];
UBYTE group;
UBYTE device;
UBYTE element;
} STD_SCAP_ADDR;
typedef struct
{
UBYTE system;
UBYTE sub_system;
UBYTE device;
UBYTE id_1;
UBYTE id_2;
UBYTE id_3;
} XC_SCAP_ADDR;
And finally, here's the line that causes a bus fault (SIGBUS):
i = *(UWORD *)outgoing_scap_msg->scap_hdr.dest_addr.sub_system;
The value of outgoing_scap_msg is 0x3fa89c
The value of &outgoing_scap_msg->scap_hdr.dest_addr is 0x3fa8a4
The value of &outgoing_scap_msg->scap_hdr.dest_addr.sub_system 0x3fa8a5
Perhaps I'm way off base here, but it seems to me that when gcc was
built, it ignored the STRICT_ALIGNMENT define. This code works correctly
under "cc" (the native Sun4 compiler).
Any solutions would be greatly appreciated. Please email me if possible.
Thank you.
---
Michael White, qa1402@ftw.mot.com
Cellular Infrastructure Group
Ft. Worth, Texas (817)245-6418
P.S. If this is not the proper place to ask these sort of questions, my
apologies. If you happen to know the proper place, please tell me and/or
forward my email.