lpcware

Global symbols come up as 0x00 after linking

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by pflieger on Wed Sep 02 14:10:04 MST 2015
I'm using a custom script (for an lpc1549), and there are no errors during linking. The problem is, global variables, like SystemCoreClock, are coming up as 0x00 instead of the actual RAM location, which is listed as 0x02002c44 (ram) in the map file. The other big mess up is __section_table_start (flash), so I had to hardcode an address into the cr_startup in order to make it to main().

The linker script is pretty small, am I missing something?



GROUP(libcr_semihost.a libcr_c.a libcr_eabihelpers.a)


MEMORY
{
  /* Define each memory region */
  BootFlash24 (rx)    : ORIGIN = 0x0,        LENGTH = 0x6000  /* 24K bytes  */
  MFlash232 (rx)      : ORIGIN = 0x6000,     LENGTH = 0x3a000 /* 232K bytes */
  Ram0_16_32_36 (rwx) : ORIGIN = 0x02000000, LENGTH = 0x9000  /* 36K bytes  */
}

/* Define a symbol for the top of each memory region */
__top_MFlash232 = 0x6000 + 0x0003a000;
__top_BootFlash24 = 0x0 + 0x6000;
__top_Ram0_16_32_36 = 0x2000000 + 0x9000;

ENTRY(ResetISR)



SECTIONS
{

    .boot_vector : ALIGN(4)
    {
       FILL(0xFFFF)
       KEEP(*(.boot_vector))

       . = ALIGN(0x40);
       KEEP(*(.debug_boot_id))
       KEEP(*(.boot_redirects))
       KEEP(*(.debug_boot_data))
    } > BootFlash24

    /* MAIN TEXT SECTION */
    .text : ALIGN(4)
    {
        FILL(0xff)
        __vectors_start__ = ABSOLUTE(.) ;
        KEEP(*(.isr_vector))

        /* Global Section Table */
        . = ALIGN(4);
        __section_table_start = .;
        __data_section_table = .;
        LONG(LOADADDR(.data));
        LONG(    ADDR(.data));
        LONG(  SIZEOF(.data));
        __data_section_table_end = .;
        __bss_section_table = .;
        LONG(    ADDR(.bss));
        LONG(  SIZEOF(.bss));
        __bss_section_table_end = .;
        __section_table_end = . ;
        /* End of Global Section Table */

        *(.after_vectors*)

    } >MFlash232

    .text : ALIGN(4)
    {
        *(.text*)
        *(.rodata .rodata.* .constdata .constdata.*)
        . = ALIGN(4);

    } > MFlash232

    /*
     * for exception handling/unwind - some Newlib functions (in common
     * with C++ and STDC++) use this.
     */
    .ARM.extab : ALIGN(4)
    {
        *(.ARM.extab* .gnu.linkonce.armextab.*)
    } > MFlash232
    __exidx_start = .;

    .ARM.exidx : ALIGN(4)
    {
        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } > MFlash232
    __exidx_end = .;

    _etext = .;


    /* MAIN DATA SECTION */


    .uninit_RESERVED : ALIGN(4)
    {
        KEEP(*(.bss.$RESERVED*))
        . = ALIGN(4) ;
        _end_uninit_RESERVED = .;
    } > Ram0_16_32_36


    /* Main DATA section (Ram0_16_32_36) */
    .data : ALIGN(4)
    {
       FILL(0xff)
       _data = . ;
       *(vtable)
       *(.ramfunc*)
       *(.data*)
       . = ALIGN(4) ;
       _edata = . ;
    } > Ram0_16_32_36 AT>MFlash232


    /* MAIN BSS SECTION */
    .bss : ALIGN(4)
    {
        _bss = .;
        *(.bss*)
        *(COMMON)
        . = ALIGN(4) ;
        _ebss = .;
        PROVIDE(end = .);
    } > Ram0_16_32_36


    /* DEFAULT NOINIT SECTION */
    .noinit (NOLOAD): ALIGN(4)
    {
        _noinit = .;
        *(.noinit*)
         . = ALIGN(4) ;
        _end_noinit = .;
    } > Ram0_16_32_36

    PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
    PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_Ram0_16_32_36 - 64);
}

Outcomes