czkkkcs 发表于 2013-6-15 10:36:37

arm-gcc链接脚本如何修改将程序链接到外部flash

我使用LPC1788处理器,因为程序比较大,所以打算将一部分程序烧写到外部的nor flash中,MDK下添加了nor flash的烧写算法,而且测试也已经通过并可以烧写程序,程序可正常运行。keil的链接脚本比较简单,而且生成方便。
因为用到了一些标准库以及.a的静态库,所以使用gnu的工具链,但是链接脚本不会编写,求指教,外部nor flash起始地址为0x90000000,MEMORY段已经标识,比如放一个lib.a和一个hello.o到外部的nor flash中 脚本应该如何编写
原链接脚本如下:/*
* linker script for LPC1788 (512kB Flash, 48kB + 48kB SRAM ) with GNU ld
* yiyue.fang 2012-04-14
*/

/* Program Entry, set to mark it as "used" and avoid gc */
MEMORY
{
    CODE (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000
    DATA (rw) : ORIGIN = 0x10000000, LENGTH = 0x00010000
    EXCODE (rx) : ORIGIN = 0x90000000, LENGTH = 0x00400000
}
ENTRY(Reset_Handler)
_system_stack_size = 0x200;

SECTIONS
{
    .text :
    {
      . = ALIGN(4);
      KEEP(*(.isr_vector))      /* Startup code */
      . = ALIGN(4);
      *(.text)                        /* remaining code */
      *(.text.*)                      /* remaining code */
      *(.rodata)                      /* read-only data (constants) */
      *(.rodata*)
      *(.glue_7)
      *(.glue_7t)
      *(.gnu.linkonce.t*)

      /* section information for finsh shell */
      . = ALIGN(4);
      __fsymtab_start = .;
      KEEP(*(FSymTab))
      __fsymtab_end = .;
      . = ALIGN(4);
      __vsymtab_start = .;
      KEEP(*(VSymTab))
      __vsymtab_end = .;
      . = ALIGN(4);

      . = ALIGN(4);
      _etext = .;
    } > CODE = 0
   
    /* .ARM.exidx is sorted, so has to go in its own output section.*/
    __exidx_start = .;
    .ARM.exidx :
    {
      *(.ARM.exidx* .gnu.linkonce.armexidx.*)

      /* This is used by the startup in order to initialize the .data secion */
      _sidata = .;
    } > CODE
    __exidx_end = .;

    /* .data section which is used for initialized data */

    .data : AT (_sidata)
    {
      . = ALIGN(4);
      /* This is used by the startup in order to initialize the .data secion */
      _sdata = . ;

      *(.data)
      *(.data.*)
      *(.gnu.linkonce.d*)

      . = ALIGN(4);
      /* This is used by the startup in order to initialize the .data secion */
      _edata = . ;
    } >DATA

    .stack :
    {
      . = . + _system_stack_size;
      . = ALIGN(4);
      _estack = .;
    } >DATA

    __bss_start = .;
    .bss :
    {
      . = ALIGN(4);
      /* This is used by the startup in order to initialize the .bss secion */
      _sbss = .;

      *(.bss)
      *(.bss.*)
      *(COMMON)

      . = ALIGN(4);
      /* This is used by the startup in order to initialize the .bss secion */
      _ebss = . ;      
      *(.bss.init)
    } > DATA
    __bss_end = .;

    _end = .;

    /* Stabs debugging sections.*/
    .stab          0 : { *(.stab) }
    .stabstr       0 : { *(.stabstr) }
    .stab.excl   0 : { *(.stab.excl) }
    .stab.exclstr0 : { *(.stab.exclstr) }
    .stab.index    0 : { *(.stab.index) }
    .stab.indexstr 0 : { *(.stab.indexstr) }
    .comment       0 : { *(.comment) }
    /* DWARF debug sections.
   * Symbols in the DWARF debugging sections are relative to the beginning
   * of the section so we begin them at 0.*/
    /* DWARF 1 */
    .debug          0 : { *(.debug) }
    .line         0 : { *(.line) }
    /* GNU DWARF 1 extensions */
    .debug_srcinfo0 : { *(.debug_srcinfo) }
    .debug_sfnames0 : { *(.debug_sfnames) }
    /* DWARF 1.1 and DWARF 2 */
    .debug_aranges0 : { *(.debug_aranges) }
    .debug_pubnames 0 : { *(.debug_pubnames) }
    /* DWARF 2 */
    .debug_info   0 : { *(.debug_info .gnu.linkonce.wi.*) }
    .debug_abbrev   0 : { *(.debug_abbrev) }
    .debug_line   0 : { *(.debug_line) }
    .debug_frame    0 : { *(.debug_frame) }
    .debug_str      0 : { *(.debug_str) }
    .debug_loc      0 : { *(.debug_loc) }
    .debug_macinfo0 : { *(.debug_macinfo) }
    /* SGI/MIPS DWARF 2 extensions */
    .debug_weaknames 0 : { *(.debug_weaknames) }
    .debug_funcnames 0 : { *(.debug_funcnames) }
    .debug_typenames 0 : { *(.debug_typenames) }
    .debug_varnames0 : { *(.debug_varnames) }
}
页: [1]
查看完整版本: arm-gcc链接脚本如何修改将程序链接到外部flash