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

    <tr>
        <th>Summary</th>
        <td>
            [AVR] link failure: clang passes broken option `-T text=` and `-T data=` to the GNU linker
        </td>
    </tr>

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

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

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

<pre>
    The GNU linker supports options `-Ttext=`,  `-Tdata=` etc.  But when clang passes these options to GNU `ld`, it adds an additional blank after `T`:

```none
> echo 'int main(){};' | avr-gcc -xc - -o x.elf -mmcu=atmega2560 -Ttext=0x10000 -v # ok
```
shows that `ld` gets `-Ttext=0x10000`.  With clang however it passes `-T text=0x10000`:

```none
> echo 'int main(){};' | avr-clang -xc - -o x.elf -mmcu=atmega2560 -Ttext=0x10000 -v
...
"/usr/bin/avr-ld" -o x.elf --gc-sections -L... -Tdata=0x800200 --start-group -l:crtatmega2560.o -lgcc -lm -lc -latmega2560 /tmp/--17d6c3.o --end-group -T text=0x10000 -mavr6
/usr/bin/avr-ld: cannot open linker script file text=0x10000: No such file or directory
clang: error: avr-ld command failed with exit code 1 (use -v to see invocation)
```

Using `-Wl,Tdata=` to pass options through to the linker is not a good idea, because the driver program must omit `-Tdata=` if the user specifies `-Tdata=`.  Using `-Wl,-Tdata=` would lead to two incompatible specifictions of data start.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU-P46gT_TTkUsIiOLE7hxy6O7_8Lqs5rHp2zhjKNtsYLCgnmW-_wnb638xptVJkEvJ4VfXqUVYp2c4jHtn-ie1PGzVRH-IxjdF6wpiaTRPMz-NLj_D_b9_BWf-KEdI0jiFSgjCSDT4BqwR_IbwRK0-sEkw-w7JnFKllD5B0AfA0EVx79KCd8h2MKiVMQD0mfGOjMAdjlXBmZbMEypgEyufVZpx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