Reference bsp_section_data_start from C yields "R_PPC_EMB_SDA21 relocation is in the wrong output section"

Till Straumann strauman at slac.stanford.edu
Sun May 16 16:49:17 UTC 2010


In the linker script the symbols are residing in the following sections

bsp_section_text_end     in .sbss2
bsp_section_data_start  in .data
bsp_section_data_end    in .sdata

In your C code you declare all three symbols as 'void *'.
Since a void* is a 'small' object gcc assumes that all the
three of them are located in the 'small data area' (.sdata/.sbss)
so that their address can be computed from r13 + offset
and it emits a corresponding relocation.

The linker cannot resolve this in the case of bsp_section_data_start
since that symbol is not in the short data area.

You probably want to use a variable 'section' attribute when
declaring these symbols that are defined in the linker script
to make sure gcc knows in what section they reside.

It would IMO best to do these declarations in a single
place (e.g., bsp.h) and document the interrelation between
linker script and declaration at both places (linkcmds and bsp.h).

HTH
-- Till

On 05/16/2010 05:41 AM, Peter Dufault wrote:
> This is in the MPC55XXEVB in the head, but it's a general question.
>
> I need to reference bsp_section_start from a routine that duplicates a program that's been running in RAM into the FLASH once it's been debugged.
> I have this expression:
>
> extern void *bsp_section_text_end,
>      *bsp_section_data_start,
>      *bsp_section_data_end;
>
> ...
>
>      te = (uint32_t)&bsp_section_text_end;
>      ds = (uint32_t)0x40000180; /* XXX Should be&bsp_section_data_start; but linker error */
>      de = (uint32_t)&bsp_section_data_end;
>      end = (te + ((de - ds) + 16))&~0x7;
>
> However, if I reference bsp_section_data_start in that instead of the hard-wired number I get this link error:
>
> /opt/rtems-4.10/lib/gcc/powerpc-rtems4.10/4.4.4/../../../../powerpc-rtems4.10/bin/ld: /home/dufault/work/scratch/peter_6600_dev/powerpcphycore_mpc5554rtems4.10/lib/libmpc55xx_misc.a(flash.o): the target (bsp_section_data_start) of a R_PPC_EMB_SDA21 relocation is in the wrong output section (.data)
> /opt/rtems-4.10/lib/gcc/powerpc-rtems4.10/4.4.4/../../../../powerpc-rtems4.10/bin/ld: final link failed: Bad value
> collect2: ld returned 1 exit status
> make: *** [o-optimize/motobank.exe] Error 1
>
> Does anyone know how to fix this?  I've done some searches and don't know enough about the issues to solve it quickly.
>
>  From the name list:
>
> 40000180 D bsp_section_data_start
> 40004ba0 G bsp_section_data_end
> 000f5160 G bsp_section_text_end
>
> Peter
> -----------------
> Peter Dufault
> HD Associates, Inc.      Software and System Engineering
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-users
>    




More information about the users mailing list