Hi - gcc-4.3.2 seems to set a 8-byte unsigned long long variable on a
4-byte boundary
and then generates extended 8-byte operation on that memory leading to
a BUS error.
I am building 3rd party C code. A typical gcc invocation is,
gcc -O3 -D_SOLARIS -D_SPARC -Wall -Wa,-xarch=v8plus -fexceptions -
c ...
There are two build configurations (details in post-script):
1. dual processor ultrasparc3 gcc.3.4.6 with Sun assembler Common
patch 10 09/04/2007
2. 16 processor UltraSPARC-T2+ T5240 gcc-4.3.2 with Sun assembler
Common patch 10 09/04/2007
When built on (1) and run on (2) things are fine. When built on (2)
and run on (2)
the code cores with a BUS error as follows. The C code is assigning 0
to an unsigned long long
which is the last element of a struct. However, this item is not
aligned on a 8-byte boundary.
But gcc-4.3.2 assumes it is because it uses extended instructions
whereas gcc.3.4.6 does not:
// gcc-4.3.2: tm->counter =0
stx %g0, [%i0+56] <- BUS ERROR HERE. 8 byte
operation
mov %i1, %o0 on 8 bytes not on a 8 byte
boundary
versus:
// gcc.3.4.6: tm->counter =0
mov 0, %o4 <- no stx: this works
mov 0, %o5
Because this is a 32-bit build it makes sense counter could be on a 4-
byte boundary. So it
seems like GCC-4.3.2 has just made the wrong code. The 3rd party gcc
command line is non-conventional.
I subsequently rebuilt on (2) with this command line plus several
other variations. Same problem:
gcc -O3 -D_SOLARIS -D_SPARC -Wall -mv8plus -m32 -fexceptions -c ...
There appear to be no align or #pragma pack instructions in this code
at least when building the file
containing this code. Any help would be appreciated.
================================
Code details:
typedef struct tmgr_t_ tmgr_t, * tmgr_h;
struct tmgr_t_
{
.
. // other data fields some volatile
.
unsigned long long trans_counter; // last item
};
int tmgr_init(tmgr_h tm)
{
. . .
tm->trans_counter = 0; // cores here
. . .
}
================================
Build environment details:
(1) Build system that works
bash-3.00$ uname -a
SunOS 5.10 Generic_139555-08 sun4u sparc SUNW,Sun-Blade-2500
-bash-3.00$ gcc -v
Reading specs from /opt/csw/gcc3/lib/gcc/sparc-sun-solaris2.8/3.4.6/
specs
Configured with: ../sources/gcc-3.4.6/configure --prefix=/opt/csw/gcc3
--with-local-prefix=/opt/csw --without-gnu-as --with-as=/usr/ccs/bin/
as --without-gnu-ld --with-ld=/usr/ccs/bin/ld --enable-threads=posix --
enable-shared --enable-multilib --enable-nls --with-included-gettext --
with-libiconv-prefix=/opt/csw --with-x --enable-java-awt=xlib --enable-
languages=all
Thread model: posix
gcc version 3.4.6
-bash-3.00$ gcc -dumpmachine
sparc-sun-solaris2.8
(2) Build system that does not work
$ uname -a
SunOS 5.10 Generic_137111-08 sun4v sparc SUNW,T5240
$ gcc -v
Using built-in specs.
Target: sparc-sun-solaris2.9
Configured with: ./configure --prefix=/opt/swt/install/gcc-4.3.2
Thread model: posix
gcc version 4.3.2 (GCC)
$ gcc -dumpmachine
sparc-sun-solaris2.9