Article ID: 000081636 Content Type: Troubleshooting Last Reviewed: 09/11/2012

Why does my linker script not include my subroutine in the target memory section when I declare (void) __attribute__ ((section (".rwdata"))) in the code?

Environment

  • Nios® II Processor
  • BUILT IN - ARTICLE INTRO SECOND COMPONENT
    Description

    The linker in the Nios® II IDE will not automatically put a subroutine in a memory that is not designated as .text.

    In order to include the subroutine in a specific memory section other than .text (in this example, .rwdata), do the following:

    1. Define a custom section for this specific routine, for example: void my_subroutine(void) __attribute__ ((section (".usersection")));
    2. Open the generated.x file that is located in your <sw_proj>_syslib/Debug/system_description folder and look for the __ram_rwdata_end
    3. Add the following lines to the generated.x file:


    .usersection : AT ( LOADADDR (.rwdata) SIZEOF (.rwdata) )

    {
          PROVIDE (_alt_partition_usersection_start = ABSOLUTE(.));
         *(.usersection .usersection.*)
         . = ALIGN(4);
         PROVIDE (_alt_partition_usersection_end = ABSOLUTE(.));

    } >onchip_ram

            PROVIDE (__flash_alt_partition_usersection_start = LOADADDR(.usersection));

    1. Modify alt_load.c to perform the custom section copy operation. See below for reference:

    extern void __flash_alt_partition_usersection_start;
    extern void _alt_partition_usersection_end;
    extern void _alt_partition_usersection_start;

    /*

    * Copy the .usersection section.

    */     
          
      alt_load_section (&__flash_alt_partition_usersection_start,
                      &_alt_partition_usersection_start,
                      &_alt_partition_usersection_end);

    Related Products

    This article applies to 1 products

    Intel® Programmable Devices