Re: Diffs between OpenBSD 3.9 gcc 3.3.5 <-> Linux 2.6 gcc 4.0 ?
- From: "n33ed" <n33ed@xxxxxxxxxxx>
- Date: 23 Sep 2006 10:13:22 -0700
BobH, thanks for your advice but I regret to say that I've already
tried both of those with much the same results. :-(
Your advice on not counting on the compiler passing a pointer for
arrays is well-taken, but for gcc it should be consistent. Besides, it
works fine in other places in the same program, plus it works on little
test programs such as the one below, which seems to work fine and
identically in OpenBSD and Linux.
This seems to be a fundamental problem, but I'm stumped.
Jim
/*
% cc -g -O0 -o mem mem.c
*/
/*
* Test passing of addr to a big array.
*/
#include <stdio.h>
/* Convenience typedefs */
typedef unsigned char UINT8;
typedef char SINT8;
typedef unsigned short UINT16;
typedef short SINT16;
typedef unsigned int UINT32;
typedef int SINT32;
typedef unsigned long UINT64;
typedef long SINT64;
typedef float FLOAT32;
typedef double FLOAT64;
#define SZ 1000488
#define ZERO 0
#define ONE 1
int main(SINT32 argc, UINT8 **argv) {
UINT8 bigarr[SZ];
SINT32 ij;
printf("main: &bigarr %x size %d\n",
&bigarr[0], sizeof(bigarr));
ij = ONE;
for (ij = 0; ij < sizeof(bigarr); ij++) {
bigarr[ij] = ij & 0xFF;
}
sub(bigarr, sizeof(bigarr));
printf("Done\n");
}
sub(UINT8 *mybig, SINT32 mybigsiz) {
SINT32 kk = ZERO;
UINT8 *myname = "sub";
printf("%s: addr mybig %x size %d\n",
myname, mybig, mybigsiz);
kk = ONE;
printf("%s: mybig from 0 to %d:\n", myname, 8 * 16);
for (kk = 0; kk < 8 * 16; kk++) {
printf("%2x ", mybig[kk] & 0xff);
if(kk > 0 && (kk % 16 == 0)) {
printf("\n");
}
}
printf("\n");
printf("%s: mybig from %d to %d:\n",
myname, mybigsiz - 8 * 16 - 1, mybigsiz - 1);
for (kk = mybigsiz - 8 * 16 - 1; kk < mybigsiz; kk++) {
printf("%2x ", mybig[kk] & 0xff);
if(kk > 0 && (kk % 16 == 0)) {
printf("\n");
}
}
printf("\n");
}
BobH wrote:
Hi,
I have had mixed luck assuming that function calls passing arrays
actually pass as a pointer. I think that is a compiler dependent
feature, but it may have been codified by one of the later ansii revisions.
I would try:
err = buildReqExeMsg(&packed[0], sizeof(packed),
&sessEKey[0], &sessHKey[0],
&padKey[0], reqexelen,
&exefile[0], exefileLen,
&packedLen);
Another idea would be to make sure the large arrays are declared in
global space, so that they don't wind up on the stack.
Good Luck,
Bob
.
- Follow-Ups:
- Re: Diffs between OpenBSD 3.9 gcc 3.3.5 <-> Linux 2.6 gcc 4.0 ?
- From: DoN. Nichols
- Re: Diffs between OpenBSD 3.9 gcc 3.3.5 <-> Linux 2.6 gcc 4.0 ?
- References:
- Prev by Date: Re: Diffs between OpenBSD 3.9 gcc 3.3.5 <-> Linux 2.6 gcc 4.0 ?
- Next by Date: Re: Diffs between OpenBSD 3.9 gcc 3.3.5 <-> Linux 2.6 gcc 4.0 ?
- Previous by thread: Re: Diffs between OpenBSD 3.9 gcc 3.3.5 <-> Linux 2.6 gcc 4.0 ?
- Next by thread: Re: Diffs between OpenBSD 3.9 gcc 3.3.5 <-> Linux 2.6 gcc 4.0 ?
- Index(es):
Relevant Pages
|
|