<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/115266>115266</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [LLD] [AVR] ldscripts/avr6.x:115: ) expected, but got (
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            lld
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dakkshesh07
      </td>
    </tr>
</table>

<pre>
    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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVk1v4zwO_jXKhbBhy_k85JA2zaJ4szuDtjuLPQWyRduaypIhyUn67xeSnbRJ076DDQJ_SCT9kHxIkVkrKoW4JJM7MlmPWOdqbZacvb7aGm2dzEa55m_LF_MmVAVOQ2G0tVDophUSYfXrCVqjK8MayDsHrkYohWISpFCvXsUiNtYrlkxI4B36Z6sbBPumHDsCGqMNCBV0vRYaWxjRupgka5Kshus0Gf7htZBMVYTeEXoHUeSYqdCRbM32BiINpTDNgRmMUZYQNU3R-T3XYMXoZJpAFNk3a7T2KoSOyezu-b_PTz9-vOzWj09ktobo8dYyoRu2N4RuhCpkxxGiLaH0C0kpckIpRGXZqcIJrSKL4W4hKjlz7ON7i6YR1oo9QlQqHeGxwPa0qXTkaoOMW1ZiZB1zohjWjXMCov9IQu-jqCreTerOEbppmFDDLS7aNtbDuhT5yvBOKH2vDcYMItlAVHYWoz4BUSu7SqjTGifZWkp-MxP9NSSRZLeTJXnstbMVnMTAo1IeSkHo5t8WjfXPNVOM0M1aH5TUjPu1lSlqQjenfA1x3VRFcc5GOo7TOCF0E8efL71IryR5Tyzbr0_jI8lWaTrpAS0Ajy0WDjmh94HMlXZA6HzwKXvo_-B_fz08_CR0_vzj6cVL0BWhC0LnceG0d2Xh_1dqZPLwibsXMWF7E0nuS6thiod6QQ4H4WrAo3BQaI6QekSdRYj2oZAQQai9LpjP-_tXb-XoY22BVaL9K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