This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: R_PPC_EMB_SDA21 relocation
- From: "Dave Murphy" <wintermute2k4 at ntlworld dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Thu, 1 Jul 2004 19:52:51 +0100
- Subject: RE: R_PPC_EMB_SDA21 relocation
This appears to be a regression against 3.3.x present in both 3.4.0 & 3.4.1
I've had a look at the EABI spec and it seems to me that the compiler is
generating invalid code for the testcase although I may have misunderstood
something.
The problem appears to be with the small_data_operand function in rs6000.c -
the tail of the function has had
if (*XSTR (sym_ref, 0) != '@')
return 0;
return 1;
replaced with
return SYMBOL_REF_SMALL_P (sym_ref);
so I assume that this macro somehow flags a reference to a function address
as valid for the small data area.
I'm having trouble following the macro in question although
if (*XSTR (sym_ref, 0) != '@')
return 0;
return SYMBOL_REF_SMALL_P (sym_ref);
appears to allow -msdata=eabi to produce valid code.
I'm nowhere near confident enough to say this is a solution but perhaps it
might help someone with better knowlege to fix it properly
Dave
> -----Original Message-----
> From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org]On Behalf Of
> Dave Murphy
> Sent: 29 June 2004 12:10
> To: gcc@gcc.gnu.org
> Subject: R_PPC_EMB_SDA21 relocation
>
>
> Hi,
>
> I'm getting an R_PPC_EMB_SDA21 relocation is in the wrong output section
> error with the following testcase on powerpc targetted gcc 3.4.0
> when using
> the -msdata=eabi switch.
>
> I've attached pre-processed source & assembly output.
>
> Is this a bug or am I missing something?
>
> typedef void (*Callback)(int);
>
> Callback SetCallback(Callback callback)
> {
> return callback;
> }
>
> static void testCB(int count)
> {
> int i;
> for (i=0; i<count;i++);
> }
>
> int main()
> {
> SetCallback(testCB);
> }
>
>
> davem@NEUROMANCER /c/projects/gamecube/test
> $ powerpc-elf-gcc -c -meabi -msdata test.c
>
> davem@NEUROMANCER /c/projects/gamecube/test
> $ powerpc-elf-gcc -meabi -msdata test.o
> c:\devkitPPC_r7a\bin\..\lib\gcc\powerpc-elf\3.4.0\..\..\..\..\powe
> rpc-elf\bi
> n\ld.exe: warning: cannot find entry symbol _start
> ; defaulting to 01800074
> c:\devkitPPC_r7a\bin\..\lib\gcc\powerpc-elf\3.4.0\..\..\..\..\powe
> rpc-elf\bi
> n\ld.exe: test.o: the target (testCB) of a R_PPC_EMB_SDA21
> relocation is in
> the wrong output section (.text)
> c:\devkitPPC_r7a\bin\..\lib\gcc\powerpc-elf\3.4.0\..\..\..\..\powe
> rpc-elf\bi
> n\ld.exe: final link failed: Bad value
> collect2: ld returned 1 exit status
>
> davem@NEUROMANCER /c/projects/gamecube/test
> $ powerpc-elf-gcc -v
> Reading specs from c:/devkitPPC_r7a/bin/../lib/gcc/powerpc-elf/3.4.0/specs
> Configured with:
> ../../gcc-3.4.0//configure --enable-languages=c,c++
> --with-cpu=750 --with-gc
> c --with-gnu-ld --with-gnu-as --with-stabs --disable-nls
> --disable-shared --
> disable-threads --disable-multilib --disable-win32-registry
> --target=powerpc
> -elf --
> with-newlib --prefix=c:/devkitPPC_r7a -v
> Thread model: single
> gcc version 3.4.0 (mingw special)
>
> davem@NEUROMANCER /c/projects/gamecube/test
> $ powerpc-elf-ld --version
> GNU ld version 2.15
> Copyright 2002 Free Software Foundation, Inc.
> This program is free software; you may redistribute it under the terms of
> the GNU General Public License. This program has absolutely no warranty.
>