Advertisement
doragasu

Corrected LM4F.ld linker script

Jan 27th, 2013
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * Copyright (c) 2012, Mauro Scomparin
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *     * Redistributions of source code must retain the above copyright
  8. *       notice, this list of conditions and the following disclaimer.
  9. *     * Redistributions in binary form must reproduce the above copyright
  10. *       notice, this list of conditions and the following disclaimer in the
  11. *       documentation and/or other materials provided with the distribution.
  12. *     * Neither the name of Mauro Scomparin nor the
  13. *       names of its contributors may be used to endorse or promote products
  14. *       derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY Mauro Scomparin ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL Mauro Scomparin BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. * File:         LM4F.ld.
  28. * Author:       Mauro Scomparin <http://scompoprojects.worpress.com>.
  29. * Version:      1.0.0.
  30. * Description:  Linker description file for LM4FXXX microcontrollers.
  31. */
  32.  
  33.  
  34. /*
  35. * Memory definition:
  36. * FLASH:    start point 0x00,       lenght 0x40000.
  37. * SRAM:     start point 0x20000000  length 0x8000.
  38. * STACK:    start point 0x20007FFF  lenght 0x0.
  39. */
  40. MEMORY
  41. {
  42.     FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
  43.     RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
  44.     STACK (rwx) : ORIGIN = 0x20007FFF , LENGTH = 0x00000000
  45. }
  46.  
  47. /*
  48. * Sections definitions:
  49. *
  50. * .text         - machine instructions.
  51. * .data         - initialized data defined in the program.
  52. * .bss          - un-initialized global and static variables (to be initialized to 0 before starting main).
  53. * .stack        - just contains the pointer to the stack end at the right place.
  54. */
  55. SECTIONS
  56. {  
  57.     /* This section it's the code, containing the NVIC Vector table that must start at 0x0
  58.     *   Look at the LM4F120H5QR datasheet for details. (Table 2-8. Exception Types)
  59.     */
  60.     .text :
  61.     {
  62.         /*_start_text = .;  /* This is an index to the beginning of .text segment. */
  63.         KEEP(*(.nvic_table)) /* I should keep the NVIC ISR Table because it's needed by the processor to start. */
  64.         *(.text*)           /* This contains the code after the ISR table. */
  65.         *(.rodata*)     /* Read only data.  */
  66.         _end_text = .;      /* This is an index to the end of .text segment. */
  67.     }>FLASH
  68.    
  69.     /*
  70.     * .data segment must be placed in RAM but it's originally stored in FLASH
  71.     * So I set the data segment in ram, but I specify the load address with the AT
  72.     * keyword to set that right after the .text section.
  73.     * (Look at the LD documentation. (Optional Section Attributes))
  74.     * Thanks https://github.com/utzig for the hints!
  75.     */
  76.     .data : AT(_end_text)
  77.     {
  78.         _start_data = .;    /* An index to the beginning of .data segment. */
  79.         *(.data*)           /* I should put there all my initialized data of my program. */
  80.         *(vtable)           /* vtable it's generated by stellarisware to store the NVIC table in ram*/
  81.         _end_data = .;      /* And another index to the end of .data segment. */
  82.     }>RAM
  83.    
  84.  
  85.     /*
  86.     * .bss contains the unitialized variables and must be set as 0x0 during runtime.
  87.     * It should be loaded in RAM and particula care should be taken initializing them in the startup file.
  88.     */
  89.     .bss :
  90.     {
  91.         _start_bss = .;     /* This is an index to the beginning of .bss segment. */
  92.         *(.bss*)        /* The un-initialized data should go there.  */
  93.         *(COMMON)           /* All the other stuff should be put there */
  94.         _end_bss = .;       /* End index for .bss segment */
  95.     }>RAM
  96.    
  97.     /*
  98.     * .stack contains nothing, but I use it to set the first vector item (SP R13).
  99.     */
  100.     .stack :
  101.     {
  102.         _stack_top = .; /* An index to the end of the stack */
  103.     }>STACK
  104.    
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement