<div dir="ltr">Thanks for your prompt reply. <div><br></div><div>I didn't build the libc at all, I downloaded a pre-built version of the whole toolchain from <a href="https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads">https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads</a>, so I guess it is an official version provided by ARM and should work? This version targets ARM Cortex-M and Cortex-R family of processors...</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Son Tuan Vu</div></div></div>
<br><div class="gmail_quote">On Mon, Mar 12, 2018 at 4:15 PM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
On 12 March 2018 at 15:06, Son Tuan VU via llvm-dev<br>
<span class=""><<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> But libc code is in ARM mode:<br>
<br>
</span>That's very bad, because Cortex-M doesn't support ARM mode. I think<br>
your libc is broken.<br>
<span class=""><br>
> As you can see, the call to srand is just a bl (Branch with Link), not a blx<br>
> (Branch with Link and Exchange instruction set), so I think something is<br>
> going wrong here.<br>
<br>
</span>Yes, Cortex-M has no blx instruction.<br>
<span class=""><br>
> Can anyone kindly give me some pointers on how to debug this? Or at least<br>
> tell me whether this is a bug?<br>
<br>
</span>You don't mention how you build libc, but that's what you need to fix.<br>
<span class=""><br>
> I am a bit lost now, I've tried to look up<br>
> for more information on this but cannot find out why Clang doesn't generate<br>
> Thumb code for libc functions.<br>
<br>
</span>It'll be part of your libc's build system (Makefile?). Clang should<br>
simply refuse to produce ARM mode code if it knows it's targeting<br>
Cortex-M, so my guess is no -mcpu option is being specified. There<br>
might be subtle differences in how GCC has been compiled that means<br>
your version defaults to Thumb mode anyway, but Clang doesn't.<br>
<br>
Cheers.<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div>