This is the mail archive of the
crossgcc@cygnus.com
mailing list for the crossgcc project.
RE: Function call problem
- To: "'crossgcc@cygnus.com'" <crossgcc@cygnus.com>
- Subject: RE: Function call problem
- From: "Duszczak, Richard" <richd@enikia.com>
- Date: Fri, 18 Jun 1999 11:14:14 -0400
- Reply-To: crossgcc@cygnus.com
>-----Original Message-----
>From: Duszczak, Richard [mailto:richd@enikia.com]
>Sent: Thursday, June 17, 1999 7:31 PM
>To: 'crossgcc@cygnus.com'
>Subject: Function call problem
>
>
>Hi,
>
>I just recently compiled a i686-cygwin32 cross powerpc-eabi compiler. The
>compiler and all the utilities seem to work but I have a problem with the
>final executable. I modified test.c in src/libgloss/rs6000 to call a
>function test from main and ran make ads-test. Everything seems ok until I
>look at the disassembly of ads-test.x and find that instead of calling test
>it branches to the beginning of .etext0. If I add test() to ads-io.c and
>rebuild libads.a the call appears fine.
>
>It appears that the linker is having a problem with the relocation
>information.
>
>Any info would be appreciated.
>
>Thanks,
_______________
I wrote the first message rather hastily, so I'll try to explain what the
problem is a little better.
I downloaded and installed the native winnt binaries and source for
cygwin-b20.1. Here's what I did to build the cross compiler:
I first wanted to build a native compiler from the source (for sanity)
$configure --prefix=/cygnus/cygwin-b20
--exec-prefix=/cygnus/cygwin-b20/H-i686-cygwin32
$make all
I needed the -k (keep going) because the install would stop on some .info
files that weren't found.
$make -k install
This seemed to be fine. So I proceeded to make the cross compiler.
$mkdir build-ppc (Not sure if separate build dir is necessary)
$configure --prefix=/cygnus/cygwin-b20
--exec-prefix=/cygnus/cygwin-b20/H-i686-cygwin32
--target=powerpc-eabi --verbose
$make all
Same problem with the install (-k)
$make -k install
The first run of 'make all' complained about an unmatched #endif in
eelf32ppc.c. I deleted the offending line and the make then completed
successfully.
Here's where the real trouble starts. I build ads-test in the
build/powerpc-eabi/libgloss/rs6000 directory with mo problem. I modify it
to count and write that value to port D (has a bank of LEDs) with no
problem. I then do this:
main()
{
char buf[20];
outbyte ('&');
print("blah") ;
outbyte ('@');
outbyte ('$');
outbyte ('%');
write (2, "Enter 5 characters... ", 24);
test ("asdf") ;
test ("asdf") ;
write (2, "Enter 5 characters... ", 24);
test ("asdf") ;
print ("FooBar\r\n");
test ("asdf") ;
write (2, "Enter 5 characters... ", 24);
test ("asdf") ;
/*#if 0
write (2, "Enter 5 characters... ", 24);
read (0, buf, 5);
print (buf);
print ("\r\n");
#endif*/
/* whew, we made it */
print ("\r\nDone...");
}
int test (char *cc)
{
int i ;
i = 5 ;
test2 (i) ;
}
int test2 ()
{
return (-1);
}
It compiles and links fine, but does not run. Inspection of the dissasembly
file shows:
000100b4 <main>:
100b4: 94 21 ff d0 stwu r1,-48(r1)
100b8: 7c 08 02 a6 mflr r0
100bc: 93 c1 00 28 stw r30,40(r1)
100c0: 93 e1 00 2c stw r31,44(r1)
100c4: 90 01 00 34 stw r0,52(r1)
100c8: 48 00 00 05 bl 100cc <main+0x18>
100cc: 7f c8 02 a6 mflr r30
100d0: 80 1e ff e4 lwz r0,-28(r30)
100d4: 7f c0 f2 14 add r30,r0,r30
100d8: 38 60 00 26 li r3,38
100dc: 4c c6 31 82 crclr 4*cr1+eq
100e0: 48 00 01 15 bl 101f4 <outbyte>
100e4: 80 7e 80 00 lwz r3,-32768(r30)
100e8: 4c c6 31 82 crclr 4*cr1+eq
100ec: 48 00 01 51 bl 1023c <print>
100f0: 38 60 00 40 li r3,64
100f4: 4c c6 31 82 crclr 4*cr1+eq
100f8: 48 00 00 fd bl 101f4 <outbyte>
100fc: 38 60 00 24 li r3,36
10100: 4c c6 31 82 crclr 4*cr1+eq
10104: 48 00 00 f1 bl 101f4 <outbyte>
10108: 38 60 00 25 li r3,37
1010c: 4c c6 31 82 crclr 4*cr1+eq
10110: 48 00 00 e5 bl 101f4 <outbyte>
10114: 80 9e 80 04 lwz r4,-32764(r30)
10118: 38 60 00 02 li r3,2
1011c: 38 a0 00 18 li r5,24
10120: 4c c6 31 82 crclr 4*cr1+eq
10124: 48 00 00 d5 bl 101f8 <write>
10128: 80 7e 80 08 lwz r3,-32760(r30)
1012c: 4c c6 31 82 crclr 4*cr1+eq
** <.Ltext0> should be <test>
** 10130: 4b ff ff 81 bl 100b0 <.Ltext0>
10134: 80 7e 80 08 lwz r3,-32760(r30)
10138: 4c c6 31 82 crclr 4*cr1+eq
** Also should be <test>
** 1013c: 4b ff ff 75 bl 100b0 <.Ltext0>
10140: 80 9e 80 04 lwz r4,-32764(r30)
10144: 38 60 00 02 li r3,2
10148: 38 a0 00 18 li r5,24
1014c: 4c c6 31 82 crclr 4*cr1+eq
10150: 48 00 00 a9 bl 101f8 <write>
10154: 80 7e 80 08 lwz r3,-32760(r30)
10158: 4c c6 31 82 crclr 4*cr1+eq
** 1015c: 4b ff ff 55 bl 100b0 <.Ltext0>
10160: 80 7e 80 0c lwz r3,-32756(r30)
10164: 4c c6 31 82 crclr 4*cr1+eq
10168: 48 00 00 d5 bl 1023c <print>
1016c: 80 7e 80 08 lwz r3,-32760(r30)
10170: 4c c6 31 82 crclr 4*cr1+eq
** 10174: 4b ff ff 3d bl 100b0 <.Ltext0>
10178: 80 9e 80 04 lwz r4,-32764(r30)
1017c: 38 60 00 02 li r3,2
10180: 38 a0 00 18 li r5,24
10184: 4c c6 31 82 crclr 4*cr1+eq
10188: 48 00 00 71 bl 101f8 <write>
1018c: 80 7e 80 08 lwz r3,-32760(r30)
10190: 4c c6 31 82 crclr 4*cr1+eq
** 10194: 4b ff ff 1d bl 100b0 <.Ltext0>
10198: 80 7e 80 10 lwz r3,-32752(r30)
1019c: 4c c6 31 82 crclr 4*cr1+eq
101a0: 48 00 00 9d bl 1023c <print>
101a4: 80 01 00 34 lwz r0,52(r1)
101a8: 7c 08 03 a6 mtlr r0
101ac: 83 c1 00 28 lwz r30,40(r1)
101b0: 83 e1 00 2c lwz r31,44(r1)
101b4: 38 21 00 30 addi r1,r1,48
101b8: 4e 80 00 20 blr
This only happens to functions that I add. Also, if I move test() and
test2() into the libads.a library main can now call test() fine, but test()
does not call test2() properly.
This problem is driving me crazy. Is there something wrong with the way I'm
doing this? I used the exact same makefile used to build the original
ads-test program. Could this be a bug in the compiler/linker?
ANY advice or info would be greatly appreciated.
Thank you,
Richard E. Duszczak
Design/Software Engineer
Enikia, Inc.
E-mail: richd@enikia.com
(732) 980-1200 x2777 (Voice)
(732) 980-0700 (Fax)
http://www.enikia.com/
Richard E. Duszczak
Design/Software Engineer
Enikia, Inc.
E-mail: richd@enikia.com
(732) 980-1200 x2777 (Voice)
(732) 980-0700 (Fax)
http://www.enikia.com/
_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.
_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.