github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/targets/avrtiny.ld (about)

     1  /* Linker script for AVRs with a unified flash and RAM address space. This
     2   * includes the ATtiny10 and the ATtiny1616.
     3   */
     4  
     5  MEMORY
     6  {
     7      FLASH_TEXT (x) : ORIGIN = 0,                    LENGTH = __flash_size
     8      FLASH_DATA (r) : ORIGIN = __mapped_flash_start, LENGTH = __flash_size
     9      RAM (xrw)      : ORIGIN = __ram_start,          LENGTH = __ram_size
    10  }
    11  
    12  ENTRY(main)
    13  
    14  SECTIONS
    15  {
    16      .text :
    17      {
    18          KEEP(*(.vectors))
    19          *(.text.__vector_RESET)
    20          KEEP(*(.text.__do_copy_data)) /* TODO: only use when __do_copy_data is requested */
    21          KEEP(*(.text.__do_clear_bss))
    22          KEEP(*(.text.main)) /* main must follow the reset handler */
    23          *(.text)
    24          *(.text.*)
    25      } > FLASH_TEXT
    26  
    27      /* Read-only data is stored in flash, but is read from an offset (0x4000 or
    28       * 0x8000 depending on the chip). This requires some weird math to get it in
    29       * the right place.
    30       */
    31      .rodata ORIGIN(FLASH_DATA) + ADDR(.text) + SIZEOF(.text):
    32      {
    33          *(.rodata)
    34          *(.rodata.*)
    35      } AT>FLASH_TEXT
    36  
    37      /* The address to which the data section should be copied by the startup
    38       * code.
    39       */
    40      __data_load_start = ORIGIN(FLASH_DATA) + LOADADDR(.data);
    41  
    42      .data :
    43      {
    44          __data_start = .;  /* used by startup code */
    45          *(.data)
    46          *(.data*)
    47          __data_end = .;    /* used by startup code */
    48      } >RAM AT>FLASH_TEXT
    49  
    50      .bss :
    51      {
    52          __bss_start = .;   /* used by startup code */
    53          *(.bss)
    54          *(.bss*)
    55          *(COMMON)
    56          __bss_end = .;     /* used by startup code */
    57      } >RAM
    58  }