<div dir="ltr">In any way, it is better to add a comment here to describe why we check _Z prefix. I'll do that.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 13, 2016 at 1:36 PM, Davide Italiano <span dir="ltr"><<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Jan 13, 2016 at 1:13 PM, Ed Maste <<a href="mailto:emaste@freebsd.org">emaste@freebsd.org</a>> wrote:<br>
> On 13 January 2016 at 20:14, Davide Italiano <<a href="mailto:davide@freebsd.org">davide@freebsd.org</a>> wrote:<br>
>> On Wed, Jan 13, 2016 at 11:40 AM, Rui Ueyama via llvm-commits<br>
>> <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
>>> Author: ruiu<br>
>>> Date: Wed Jan 13 13:40:13 2016<br>
>>> New Revision: 257661<br>
>>><br>
>>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=257661&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=257661&view=rev</a><br>
>>> Log:<br>
>>> Attempt to make FreeBSD buildbot green.<br>
>>><br>
>>> It seems that __cxa_demangle function on the buildbot tried to demangle<br>
>>> a variable "tlsvar" as a C++ symbol. Do not call that function unless<br>
>>> it does not start with "_Z" which is the prefix of mangled names.<br>
>>><br>
>>> Modified:<br>
>>>     lld/trunk/ELF/Symbols.cpp<br>
>>><br>
>>> Modified: lld/trunk/ELF/Symbols.cpp<br>
>>> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=257661&r1=257660&r2=257661&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=257661&r1=257660&r2=257661&view=diff</a><br>
>>> ==============================================================================<br>
>>> --- lld/trunk/ELF/Symbols.cpp (original)<br>
>>> +++ lld/trunk/ELF/Symbols.cpp Wed Jan 13 13:40:13 2016<br>
>>> @@ -145,6 +145,11 @@ std::string elf2::demangle(StringRef Nam<br>
>>>  #else<br>
>>>    if (!Config->Demangle)<br>
>>>      return Name;<br>
>>> +<br>
>>> +  // Return if it does not look like a C++ symbol.<br>
>>> +  if (!Name.startswith("_Z"))<br>
>>> +    return Name;<br>
>>> +<br>
>>>    char *Buf =<br>
>>>        abi::__cxa_demangle(Name.str().c_str(), nullptr, nullptr, nullptr);<br>
>>>    if (!Buf)<br>
>>><br>
>><br>
>> This seems to be a bug in libcxxabi.<br>
><br>
> If __cxa_demangle is being used to demangle external names the _Z test<br>
> is correct, and required. __cxa_demangle can also be used to demangle<br>
> types, and will for example correctly return "float" for input "f".<br>
><br>
> On FreeBSD __cxa_demangle is provided by libcxxrt, and this issue has<br>
> come up a few times in the past. libcxxrt's __cxa_demangle ought to<br>
> reject names with additional characters following a mangled string,<br>
> but it becomes much less of an issue once callers are fixed to add the<br>
> _Z test.<br>
><br>
> Some previous instances:<br>
> <a href="https://lists.freebsd.org/pipermail/freebsd-toolchain/2014-June/001153.html" rel="noreferrer" target="_blank">https://lists.freebsd.org/pipermail/freebsd-toolchain/2014-June/001153.html</a><br>
> <a href="http://reviews.llvm.org/D2552" rel="noreferrer" target="_blank">http://reviews.llvm.org/D2552</a><br>
<br>
</div></div>Thank you. I read the thread and I agree (therefore disagreeing with<br>
David C.) that this is an hack. Probably not a terrible one, but<br>
ideally lld (and all the other tools) shouldn't be concerned with this<br>
particular bit of the ABI.<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Davide<br>
<br>
"There are no solved problems; there are only problems that are more<br>
or less solved" -- Henri Poincare<br>
</div></div></blockquote></div><br></div>