This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
rodata truncated by two
- From: Jason W Larsen <Jason dot Larsen at inl dot gov>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 13 Oct 2006 18:31:24 -0600
- Subject: rodata truncated by two
I'm not sure this is the correct mailing list, but here goes. I was
trying to debug a program
and finally got down to the raw object file. Under certain circumstances,
constants in the .rodata
section of an object file are getting truncated. Here's the data:
Smallest C program that has the bug:
int ObjectLoad(void* vars,void* Object){
int x = (int)Object;
switch (x){
case 0:
printf("X is %i\n",x);
break;
case 1:
printf("X is %i\n",x);
break;
case 2:
printf("X is %i\n",x);
break;
case 3:
printf("X is %i\n",x);
break;
case 4:
printf("X is %i\n",x);
break;
case 5:
printf("X is %i\n",x);
break;
case 6:
printf("X is %i\n",x);
break;
case 7:
printf("X is %i\n",x);
break;
case 8:
printf("X is %i\n",x);
break;
case 9:
printf("X is %i\n",x);
break;
default:
printf("Some other x\n");
}
}
int main(int artc, char**argv){
}
Compiler Info and command line
gcc -c -o testobject.o testobject.c -g -Wall
gcc --version
->gcc (GCC) 4.1.1 (Gentoo 4.1.1-r1)
hex dump of the truncated part
00000ce0 2f 5a 08 2f 5a 08 2f 5a 08 2f 30 08 2f 30 08 2f
|/Z./Z./Z./0./0./|
00000cf0 30 08 2f 30 08 2f 30 08 2f 30 bc 30 d7 02 06 00
|0./0./0./0.0....|
00000d00 01 01 00 00 58 20 69 73 20 25 69 0a 00 53 6f 6d |....X is
%i..Som|
00000d10 65 20 6f 74 68 65 72 20 78 00 00 00 24 00 00 00 |e other
x...$...|
00000d20 3c 00 00 00 54 00 00 00 6c 00 00 00 84 00 00 00
|<...T...l.......|
00000d30 99 00 00 00 ae 00 00 00 c3 00 00 00 d8 00 00 00
|................|
00000d40 ed 00 00 00 10 00 00 00 ff ff ff ff 01 00 01 7c
|...............||
00000d50 08 0c 04 04 88 01 00 00 14 00 00 00 00 00 00 00
|................|
00000d60 00 00 00 00 10 01 00 00 41 0e 08 85 02 42 0d 05
|........A....B..|
00000d70 24 00 00 00 00 00 00 00 10 01 00 00 14 00 00 00
|$...............|
Are you can see the constant strings fall before the jump table later
filled in by the
the linker for use by the case statement. The jump table entries are
intact, but the
string "Some other x\n" is missing the trailing <cr> as well as the
terminating NULL.
Let me know if you need more data.
Jason Larsen
larsj@inel.gov