msp430-rt 0.4.0

Minimal runtime / startup for MSP430 microcontrollers
INCLUDE memory.x

/* Entry point */
ENTRY(Reset);
EXTERN(__RESET_VECTOR);

/* Create an undefined reference to the INTERRUPTS symbol. This is required to
   force the linker to *not* drop the INTERRUPTS symbol if it comes from an
   object file that's passed to the linker *before* this crate */
EXTERN(__INTERRUPTS);

/* # Pre-initialization function */
/* If the user overrides this using the `pre_init!` macro or by creating a `__pre_init` function,
then the function this points to will be called before the RAM is initialized. */
PROVIDE(PreInit = PreInit_);

/* # Default interrupt handler */
EXTERN(DefaultHandler); /* If this line is not here, all unused interrupt
                           handlers will be zeroed out instead of doing
                           to the DefaultHandler! */
PROVIDE(DefaultHandler = DefaultHandler_);

/* XXX Are there use cases for making this user overridable? */
_stack_start = ORIGIN(RAM) + LENGTH(RAM);

SECTIONS
{
  .vector_table ORIGIN(VECTORS) : ALIGN(2)
  {
    KEEP(*(.vector_table.interrupts));
    KEEP(*(.__RESET_VECTOR));
  } > VECTORS

  .text ORIGIN(ROM) :
  {
    /* Put the reset handler at the beginning of the .text section */
    KEEP(*(.Reset));

    *(.text .text.*);
  } > ROM

  .rodata : ALIGN(2)
  {
    *(.rodata .rodata.*);
    . = ALIGN(2);
  } > ROM

  .bss : ALIGN(2)
  {
    _sbss = .;
    *(.bss .bss.*);
    . = ALIGN(2);
    _ebss = .;
  } > RAM

  .data : ALIGN(2)
  {
    _sidata = LOADADDR(.data);
    _sdata = .;
    *(.data .data.*);
    . = ALIGN(2);
    _edata = .;
  } > RAM AT > ROM

  /* fake output .got section */
  /* Dynamic relocations are unsupported. This section is only used to detect
     relocatable code in the input files and raise an error if relocatable code
     is found */
  .got :
  {
    _sgot = .;
    KEEP(*(.got .got.*));
    _egot = .;
  } > RAM AT > ROM

  /* The heap starts right after the .bss + .data section ends */
  _sheap = _edata;
}

/* Do not exceed this mark in the error messages below                                    | */
ASSERT(ORIGIN(VECTORS) + LENGTH(VECTORS) == 0x10000, "
ERROR(msp430-rt): The VECTORS memory region must end at address 0x10000. Check memory.x");

ASSERT(ADDR(.vector_table) + SIZEOF(.vector_table) == 0x10000, "
ERROR(msp430-rt): .vector_table is shorter than expected.
Possible solutions, from most likely to less likely:
- Link to a svd2rust generated pac crate, if you are not
- Fix _sinterrupts in memory.x; it doesn't match the number of interrupts provided by the
  pac crate
- Disable the 'device' feature of msp430-rt to build a generic application; a dependency
may be enabling it
");

ASSERT(_sgot == _egot, "
ERROR(msp430-rt): .got section detected in the input object files
Dynamic relocations are not supported. If you are linking to C code compiled using
the 'cc' crate then modify your build script to compile the C code _without_
the -fPIC flag. See the documentation of the `cc::Build.pic` method for details.");
/* Do not exceed this mark in the error messages above                                    | */