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

Eric Norum wenorum at
Mon May 17 15:53:16 UTC 2010

On May 16, 2010, at 8:52 PM, Till Straumann wrote:

> I did that, too, but you have to know what you are doing.
> This trick *only* works if you know that your symbol is
> in the 'data' area and you want to avoid the compiler to
> assume it to be in the short data area.
> E.g., if you know our symbol is .text then you would declare
> it as a function, of course.
> Using a section __attribute__ is IMO preferable.

I must be missing something.   Here's a section of the uc5282 BSP linkcmds:

    _header_offset = 0;

     * Text, data and bss segments
    .text _DownloadLocation : {


         * C++ constructors/destructors

         * Initialization and finalization code.
         * Various files can provide initialization and finalization
         * functions.  crtbegin.o and crtend.o are two instances. The
         * body of these functions are in .init and .fini sections. We
         * accumulate the bodies here, and prepend function prologues
         * from crti.o and function epilogues from crtn.o. crti.o must
         * be linked first; crtn.o must be linked last.  Because these
         * are wildcards, it doesn't matter if the user does not
         * actually link against crti.o and crtn.o; the linker won't
         * look for a file to match a wildcard.  The wildcard also
         * means that it doesn't matter which directory crti.o and
         * crtn.o are in.
        PROVIDE (_init = .);
        PROVIDE (_fini = .);

         * Special FreeBSD sysctl sections.
        . = ALIGN (16);
        __start_set_sysctl_set = .;
        __stop_set_sysctl_set = ABSOLUTE(.);


In a C program I tried:
extern char __start_set_sysctl_set[];
printf("%ld\n", (unsigned long)__start_set_sysctl_set);

This compiled and linked with no complaints even though the symbol is in the text segment:
 m68k-rtems4.10-nm example | grep __start_set_sysctl_set
00143360 T __start_set_sysctl_set

Am I venturing into 'undefined behaviour' territory?
Eric Norum
wenorum at

More information about the users mailing list