Menu

fill pattern in linker script

Help
marc_sp
2011-10-06
2013-03-06
  • marc_sp

    marc_sp - 2011-10-06

    Hello all,

    I want to fill all unused flash memory with a specific pattern. I found out that this could be done by adding a fill pattern to the linker script. I changed my linker script (msp430x169.x) as follows (in bold is what I added):

      .text :
      {
        . = ALIGN(2);
        *(.init)
        *(.init0)  /* Start here after reset.  */
        *(.init1)
        *(.init2)  /* Copy data loop  */
        *(.init3)
        *(.init4)  /* Clear bss  */
        *(.init5)
        *(.init6)  /* C++ constructors.  */
        *(.init7)
        *(.init8)
        *(.init9)  /* Call main().  */
         __ctors_start = . ;
         *(.ctors)
         __ctors_end = . ;
         __dtors_start = . ;
         *(.dtors)
         __dtors_end = . ;
        . = ALIGN(2);
        *(.text)
        . = ALIGN(2);
        *(.text.*)
        . = ALIGN(2);
        *(.fini9)  /*   */
        *(.fini8)
        *(.fini7)
        *(.fini6)  /* C++ destructors.  */
        *(.fini5)
        *(.fini4)
        *(.fini3)
        *(.fini2)
        *(.fini1)
        *(.fini0)  /* Infinite loop after program termination.  */
        *(.fini)
        _etext = .;
      }  > text =0x5A5A5A5A

    However, the pattern is nowhere to be found in the generated files. What am I doing wrong? Does the GCC toolchain for MSP430 support this?

    Thanks in advance for your help.

    Kind regards,
    Marc

     
  • Peter A. Bigot

    Peter A. Bigot - 2011-10-06

    That would only fill gaps between sections and values due to alignment.  If you want to fill the area above the end of the program, you'd have to put something there, after _etext, that updates the location counter to go to the end of the region you want to fill, which would presumably be the start of the vectors.  Probably " . = 0xff80" or whatever value is appropriate for your chip.

     
  • marc_sp

    marc_sp - 2011-10-06

    Thanks for your fast response.

    I tried the following two options, but neither worked.

        _etext = .; _etext = 0xB6B;

       _etext = .; . = 0xB6B

    The second option resulted in a linker script error message (parse error). Since I am not very into this linker scripting stuff, could you please be a bit more specific on how to deal with this?

    Thanks in advance.

    Kind regards,
    Marc

     
  • Peter A. Bigot

    Peter A. Bigot - 2011-10-06

    Not without actually doing the work myself.  Try your second command but with a trailing semicolon.  If that doesn't work, review http://sourceware.org/binutils/docs/ld/Output-Section-Description.html#Output-Section-Description.  Nothing about what you want to accomplish is specific to the mspgcc toolchain; it's pure binutils ld script coding.

     
  • Peter A. Bigot

    Peter A. Bigot - 2011-10-06

    BTW: I'm the maintainer of the whole toolchain and am probably the only active monitor of this forum.  You'll reach a much wider community, including people who may have done what you want to do (I have not, hence my being less than helpful as it would require work to verify), if you subscribe to and post on the mspgcc-users mailing list, which you can reach from the banner tab above.

     

Log in to post a comment.