C++ 的链接器脚本使用 Codesourcery lite 工具链进行 LM3S8962 非托管程序?

发布于 2024-10-13 07:42:56 字数 301 浏览 8 评论 0原文

有谁有专门用于 Stellaris LM3S8962 板的链接器脚本或者可以解释如何创建一个链接器脚本吗?我正在使用 codesourcery g++ lite 工具链,并且可以使用以下链接器脚本成功为托管环境创建 elf 文件:

这不适用于非托管库。我发现上面的所有示例仅适用于 C 而不是 C++,并且 cs3 启动代码似乎涉及一些魔法。任何帮助表示赞赏。

谢谢, 麦克风

Does anyone have a linker script specifically for the Stellaris LM3S8962 board or could explain how to create one? I am using the codesourcery g++ lite toolchain and can successfully create the elf file for the hosted environment using this linker script:

This does not work with the unhosted libraries. All the examples on I have found only work for C and not C++ and there seems to be some magic involved regarding the cs3 startup code. Any help appreciated.

Thanks,
Mike

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烙印 2024-10-20 07:42:56

这些是 C++ 链接器脚本(来自 STM32)中的额外部分:

  .preinit_array     :
  {
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array*))
    PROVIDE_HIDDEN (__preinit_array_end = .);
  } >FLASH
  .init_array :
  {
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT(.init_array.*)))
    KEEP (*(.init_array*))
    PROVIDE_HIDDEN (__init_array_end = .);
  } >FLASH
  .fini_array :
  {
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(.fini_array*))
    KEEP (*(SORT(.fini_array.*)))
    PROVIDE_HIDDEN (__fini_array_end = .);
  } >FLASH

在启动中的某处,您需要调用:

bl __libc_init_array

如果您使用 http://www.google.com/codesearch,您应该能够找到特定于设备的内容。

These are the extra sections in a C++ linker script (from STM32):

  .preinit_array     :
  {
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array*))
    PROVIDE_HIDDEN (__preinit_array_end = .);
  } >FLASH
  .init_array :
  {
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT(.init_array.*)))
    KEEP (*(.init_array*))
    PROVIDE_HIDDEN (__init_array_end = .);
  } >FLASH
  .fini_array :
  {
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(.fini_array*))
    KEEP (*(SORT(.fini_array.*)))
    PROVIDE_HIDDEN (__fini_array_end = .);
  } >FLASH

The somewhere in your startup, you need to call:

bl __libc_init_array

If you use http://www.google.com/codesearch, you should be able to find something device specific.

つ可否回来 2024-10-20 07:42:56

这是我最终得到的结果:

OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
GROUP(crti.o crtn.o crtbegin.o crtend.o)
ENTRY(Reset_Handler)                                         /* entry Point */

MEMORY {                                           /* memory map of LM3S811 */
    ROM (rx)  : ORIGIN = 0x00000000, LENGTH = 256K
    RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
}

/* The size of the stack used by the application. NOTE: you need to adjust  */
STACK_SIZE = 24K;


/* The size of the heap used by the application. NOTE: you need to adjust   */
HEAP_SIZE = 0K;

SECTIONS {
    .  = 0x0;
    .isr_vector : {                 /* the vector table goes FIRST into ROM */
        KEEP(*(.isr_vector))                                /* vector table */
        . = ALIGN(4);
    } >ROM

    .text : {                                         /* code and constants */
        . = ALIGN(4);
        *(.text)                                   /* .text sections (code) */
        *(.text*)                                 /* .text* sections (code) */
        *(.rodata)           /* .rodata sections (constants, strings, etc.) */
        *(.rodata*)         /* .rodata* sections (constants, strings, etc.) */

        KEEP (*(.init))
        KEEP (*(.fini))

        . = ALIGN(4);
    } >ROM

    __exidx_start = .;
    .ARM.exidx : {
        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } >ROM
    __exidx_end = .;


    .preinit_array : {
        PROVIDE_HIDDEN (__preinit_array_start = .);
        KEEP (*(.preinit_array*))
        PROVIDE_HIDDEN (__preinit_array_end = .);
    } >ROM

    .init_array : {
        PROVIDE_HIDDEN (__init_array_start = .);
        KEEP (*(SORT(.init_array.*)))
        KEEP (*(.init_array*))
        PROVIDE_HIDDEN (__init_array_end = .);
    } >ROM

    .fini_array : {
        PROVIDE_HIDDEN (__fini_array_start = .);
        KEEP (*(.fini_array*))
        KEEP (*(SORT(.fini_array.*)))
        PROVIDE_HIDDEN (__fini_array_end = .);
    } >ROM




    _etext = .;                            /* global symbols at end of code */
    .vtable : {                 /* the vector table goes FIRST into RAM */
        KEEP(*(.vtable))                                /* vector table */
        . = ALIGN(4);
    } >RAM
    .data :  AT (_etext) {
        __data_load = LOADADDR (.data);
        __data_start = .;
        *(.data)                                          /* .data sections */
        *(.data*)                                        /* .data* sections */
        . = ALIGN(7);
        __data_end__ = .;
        _edata = __data_end__;
    } >RAM

    .bss : {
        __bss_start__ = . ;
        *(.bss)
        *(.bss*)
        *(COMMON)
        . = ALIGN(4);
        _ebss = .;                     /* define a global symbol at bss end */
        __bss_end__ = .;
    } >RAM

    PROVIDE ( end = _ebss );
    PROVIDE ( _end = _ebss );
    PROVIDE ( __end__ = _ebss );

    .heap : {
        __heap_start__ = . ;
        . = . + HEAP_SIZE;
        . = ALIGN(8);
        __heap_end__ = . ;
    } >RAM

    .stack : {
        __stack_start__ = . ;
        . = . + STACK_SIZE;
        . = ALIGN(8);
        __c_stack_top__ = . ;
        __stack_end__ = . ;
    } >RAM

    /* Remove information from the standard libraries */
    /DISCARD/ : {
        libc.a ( * )
        libm.a ( * )
        libgcc.a ( * )
    }
}

Here is what I've ended up with:

OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
GROUP(crti.o crtn.o crtbegin.o crtend.o)
ENTRY(Reset_Handler)                                         /* entry Point */

MEMORY {                                           /* memory map of LM3S811 */
    ROM (rx)  : ORIGIN = 0x00000000, LENGTH = 256K
    RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
}

/* The size of the stack used by the application. NOTE: you need to adjust  */
STACK_SIZE = 24K;


/* The size of the heap used by the application. NOTE: you need to adjust   */
HEAP_SIZE = 0K;

SECTIONS {
    .  = 0x0;
    .isr_vector : {                 /* the vector table goes FIRST into ROM */
        KEEP(*(.isr_vector))                                /* vector table */
        . = ALIGN(4);
    } >ROM

    .text : {                                         /* code and constants */
        . = ALIGN(4);
        *(.text)                                   /* .text sections (code) */
        *(.text*)                                 /* .text* sections (code) */
        *(.rodata)           /* .rodata sections (constants, strings, etc.) */
        *(.rodata*)         /* .rodata* sections (constants, strings, etc.) */

        KEEP (*(.init))
        KEEP (*(.fini))

        . = ALIGN(4);
    } >ROM

    __exidx_start = .;
    .ARM.exidx : {
        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } >ROM
    __exidx_end = .;


    .preinit_array : {
        PROVIDE_HIDDEN (__preinit_array_start = .);
        KEEP (*(.preinit_array*))
        PROVIDE_HIDDEN (__preinit_array_end = .);
    } >ROM

    .init_array : {
        PROVIDE_HIDDEN (__init_array_start = .);
        KEEP (*(SORT(.init_array.*)))
        KEEP (*(.init_array*))
        PROVIDE_HIDDEN (__init_array_end = .);
    } >ROM

    .fini_array : {
        PROVIDE_HIDDEN (__fini_array_start = .);
        KEEP (*(.fini_array*))
        KEEP (*(SORT(.fini_array.*)))
        PROVIDE_HIDDEN (__fini_array_end = .);
    } >ROM




    _etext = .;                            /* global symbols at end of code */
    .vtable : {                 /* the vector table goes FIRST into RAM */
        KEEP(*(.vtable))                                /* vector table */
        . = ALIGN(4);
    } >RAM
    .data :  AT (_etext) {
        __data_load = LOADADDR (.data);
        __data_start = .;
        *(.data)                                          /* .data sections */
        *(.data*)                                        /* .data* sections */
        . = ALIGN(7);
        __data_end__ = .;
        _edata = __data_end__;
    } >RAM

    .bss : {
        __bss_start__ = . ;
        *(.bss)
        *(.bss*)
        *(COMMON)
        . = ALIGN(4);
        _ebss = .;                     /* define a global symbol at bss end */
        __bss_end__ = .;
    } >RAM

    PROVIDE ( end = _ebss );
    PROVIDE ( _end = _ebss );
    PROVIDE ( __end__ = _ebss );

    .heap : {
        __heap_start__ = . ;
        . = . + HEAP_SIZE;
        . = ALIGN(8);
        __heap_end__ = . ;
    } >RAM

    .stack : {
        __stack_start__ = . ;
        . = . + STACK_SIZE;
        . = ALIGN(8);
        __c_stack_top__ = . ;
        __stack_end__ = . ;
    } >RAM

    /* Remove information from the standard libraries */
    /DISCARD/ : {
        libc.a ( * )
        libm.a ( * )
        libgcc.a ( * )
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文