<div dir="ltr">Hello.<div><br></div><div>I got link error when I try build code on arm target.</div><div>It seems that It could'n use "-=" operation when using arm.<br><div>The following is what we tried.<br></div><div><br></div><div>$ cat sample.c<br>void __init_array_start(void){};<br>void __init_array_end(void){};<br>int main()<br>{<br> return 0;<br>}<br></div><div><br></div><div>$ cat sample.ld <br>SECTIONS<br>{<br> sample = 0;<br> sample += 1;<br> sample -= 1;<br> . = 0x08048000 + SIZEOF_HEADERS;<br> .text : {*(.text)}<br> .rodata : {*(.rodata)}<br> .data : {*(.data)}<br> .bss : {*(.bss)}<br>}<br></div><div><br></div><div># There is no error that build x86_64 target.</div><div>$ clang -fPIE -target x86_64-unknown-none-elf -nodefaultlibs sample.c -T sample.ld<br><br></div><div># But I get a error when build arm target.</div><div>$ clang -target arm-none-eabi -march=armv7-m -mcpu=cortex-m4 -nodefaultlibs sample.c -T sample.ld<br>ld.lld: error: sample.ld:5: malformed number: =<br>>>> sample -= 1;<br>>>> ^<br>clang-12: error: ld.lld command failed with exit code 1 (use -v to see invocation)<br></div><div><br></div><div># The version of clang I use using is 12.</div><div>$ clang --version<br>clang version 12.0.0 (<a href="https://github.com/llvm/llvm-project/" target="_blank">https://github.com/llvm/llvm-project/</a> b978a93635b584db380274d7c8963c73989944a1)<br>Target: x86_64-unknown-linux-gnu<br>Thread model: posix<br></div><div><br></div><div>Is there some linker script difference depend on target?<br></div><div><br></div></div><div id="m_-9052632302107401771DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2">Thanks.</div><div id="m_-9052632302107401771DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2">Saito Yutaka</div><div id="m_-9052632302107401771DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br> <table style="border-top:1px solid #d3d4de">
<tbody><tr>
<td style="width:55px;padding-top:18px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width:46px;height:29px"></a></td>
<td style="width:470px;padding-top:17px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">ウイルス フリー。 <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" style="color:#4453ea" target="_blank">www.avast.com</a> </td>
</tr>
</tbody></table>
<a href="#m_-9052632302107401771_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div></div>