This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Mark Palmerino wrote: [snip] It looks like the compiler is trying to pack the constants on byte boundarys. there is a switch that you can tell it to align things on word boundarys, you might try that. As to why that breaks it, I would guess there is some CPUtype=M68K define that is missing, and packing constants on word boundarys would result if it were in there. Just a guess. > If the referenced string is an odd number of characters, the program does > *not* bomb. For example, the following works: > > lcd_print("123"); > > And the following does not work: > > lcd_print("12"); > > The following works: > > lcd_print("12\0"); //That's a backslash-zero for a Null, is interpreted as > 1 char > > And the following does not work: > > lcd_print("123\0"); > > I'm guessing this gives credence to this being an 'alignment' problem. > Unfortunately, I don't know what to do about it. > > Here is a simple test c program: > > #include <string.h> > #include <stdio.h> > > int main(void) { > int i; > char someText[256]; > > strcpy(someText,"12"); > } > > and here is the assembly that is produced by m68k-elf-gcc -S test.c > > .file "alcdtest.c" > gcc2_compiled.: > .globl __main > .section .rodata > .LC0: > .string "12" > .text > .globl main > .type main,@function > main: > link.w %a6,#-260 > jsr __main > pea .LC0 > move.l %a6,%d0 > add.l #-260,%d0 > move.l %d0,-(%sp) > jsr strcpy > addq.l #8,%sp > .L2: > unlk %a6 > rts > .Lfe1: > .size main,.Lfe1-main > .ident "GCC: (GNU) 2.95.2 19991024 (release)" > > When compiled and downloaded, this program bombs with the following output > from cpu32bug: > > Exception: Address Error > Format/Vector=C00C > SSW=00D6 Fault Addr.=00090CB9 Data=00007FEC Cur. PC=00090120 Cnt. > Reg.=0001 > PC =00090126 SR =2704=TR:OFF_S_7_..Z.. VBR =00000000 > SFC =5=SD DFC =5=SD USP =0000FC00 SSP* =00007FD4 > D0 =00000000 D1 =01D6FFFF D2 =00000000 D3 =00000000 > D4 =00000000 D5 =00000000 D6 =00000000 D7 =00000000 > A0 =0000315E A1 =00003156 A2 =0000315A A3 =00000000 > A4 =00000000 A5 =00000000 A6 =00007FF8 A7 =00007FD4 > 00090126 48780000 PEA.L ($0).W > > Now, if I change the string from "12" to "123", the program does not bomb. > > I tried compiling with -fno-writable-strings and this made no difference. > Also, if I do the following with char const, the program bombs: > > char const footext[] = "12"; > . > . > . > strcpy(someText,footext); > > However, building the string up in the following manner, does work > regardless of the number of characters that end up in the string: > > int main(void) { > int i; > char someText[256]; > char footext[256]; > > footext[0] = '1'; > footext[1] = '2'; > footext[2] = '3'; > footext[3] = '4'; > footext[4] = '\0'; > > strcpy(someText,footext); > } > > So, with this new information, does anyone have any ideas for how to fix the > problem? > > Again, many, many thanks! > > To unsubscribe from this group, send an email to: > 68332ABB-unsubscribe@egroups.com > > > > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ -- http://www.visi.com/~brynn my triplets ! http://www.tcrobots.org/ our robot club http://www.visi.com/~brynn/tryclops My robot, Tryclops ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |