Skip to content

[LLD] [AVR] Linker script error: LLD unable to SORT by filename pattern #115266

Open
@beakthoven

Description

@beakthoven

Trying to cross compile AVR program but the final linking seems to fail due to some syntax error in the linkerscript.

clang++ --target=avr -o firmware.elf -mmcu=atmega2560 --sysroot=${SYSROOT_DIR} -I${SYSROOT_DIR}/avr/include -L"${SYSROOT_DIR}/lib" -ffunction-sections -fdata-sections -fpermissive -fno-exceptions -fno-threadsafe-statics -fno-rtti -Wl,--gc-sections out/main/main.cpp.o out/libArduinoCore.a -lm -fuse-linker-plugin -fuse-ld=lld

error:

ld.lld: error: /mnt/c/Users/chana/Downloads/Arch/sysroot/lib/gcc/avr/14.1.0/../../../../avr/lib/ldscripts/avr6.x:115: ) expected, but got (
>>>     KEEP(SORT(*)(.ctors))
>>>                 ^
clang++: error: avr-ld command failed with exit code 1 (use -v to see invocation)

linkerscript snip:

/* Internal text space or external memory.  */
  .text   :
  {
    *(.vectors)
    KEEP(*(.vectors))
    /* 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.*)
    . = ALIGN(2);
    /* For code that needs to reside in the lower 128k progmem.  */
    *(.lowtext)
    *(.lowtext*)
     __ctors_start = . ;
     *(.ctors)
     __ctors_end = . ;
     __dtors_start = . ;
     *(.dtors)
     __dtors_end = . ;
    KEEP(SORT(*)(.ctors))
    KEEP(SORT(*)(.dtors))
    /* From this point on, we do not bother about whether the insns are
       below or above the 16 bits boundary.  */
    *(.init0)  /* Start here after reset.  */
    KEEP (*(.init0))
    *(.init1)
    KEEP (*(.init1))

Is this because LLD expects it in a different syntax? because all these linkerscripts from gnu binutils have been in use with gcc avr from a long time. Im just trying to fix things and get it working with LLVM as well.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions