https://sourceware.org/bugzilla/show_bug.cgi?id=32968

            Bug ID: 32968
           Summary: [avr] Assert that .progmem is located in the lower 64
                    KiB of program memory
           Product: binutils
           Version: 2.44
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: gjl at gcc dot gnu.org
  Target Milestone: ---
            Target: avr

The default linker script (.xn) currently has in .text:

    /* For data that needs to reside in the lower 64k of progmem.  */
    *(.progmem.gcc*)
    /* PR 13812: Placing the trampolines here gives a better chance
       that they will be in range of the code that uses them.  */
    . = ALIGN(2);
    __trampolines_start = . ;
    /* The jump trampolines for the 16-bit limited relocs will reside here.  */
    *(.trampolines)
    *(.trampolines*)
    __trampolines_end = . ;
    /* avr-libc expects these data to reside in lower 64K. */
    *libprintf_flt.a:*(.progmem.data)
    *libc.a:*(.progmem.data)
    *(.progmem.*)

This is sub-optimal, since .progmem.* stuff must reside in the lower 64 KiB of
program memory, whereas the linker stubs / trampolines are only required to
live in the lower 128 KiB of program memory.

For data in flash that is not required to live in the lower 64 KiB, there is
.progmemx which is available since 2017 and located after the very code
sections.

The situation can be impeoved as follows:

1) Locate the linker stubs after the .progmem. sections.  Notice that the
comment about PR13812 is misleading, since the test case for PR13812 is invalid
(it locates more than 64 KiB to .progmem).

2) Assert that progmem is located in the lower 64 KiB.  When .progmem exceeds
0x10000, then wrong code will result since LPM is used to read from progmem
(e.g. pgm_read_byte from AVR-LibC's avr/pgmspace.h).  When the code reads using
pgm_read_xxx_far or one of the farfunc_PF() functions, the data should be
located in .progmemx so that it doesn't waste lower 64 KiB locations.

Notice that avr-gcc's address-spaces __memx and __flashx locate to .progmemx,
similar for PROGMEM_FAR which has been added to AVR-LibC v2.2.
See
https://avrdudes.github.io/avr-libc/avr-libc-user-manual/group__avr__pgmspace.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to