<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 4/2/2014 1:23 PM, Reid Kleckner
wrote:<br>
</div>
<blockquote
cite="mid:CACs=tyKb5z+rAu72Aoi1Hu=3W1NvXUeSwZqsBiGpabpvk35eaQ@mail.gmail.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Wed, Apr 2, 2014 at 11:02 AM,
Shankar Easwaran <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span>
wrote:<br>
<blockquote class="gmail_quote">
<div class="">On 4/2/2014 12:23 PM, Nick Kledzik wrote:<br>
<blockquote class="gmail_quote">
On Apr 1, 2014, at 9:19 PM, Shankar Easwaran wrote:<br>
<br>
<blockquote class="gmail_quote">
Hi Nick, Bigcheese,<br>
<br>
When lld is used to link C++ code, it would be
required to demangle symbol names by default/user
driven option.<br>
<br>
The Gnu linker has the following options :-<br>
<br>
--demangle=[style]<br>
--no-demangle<br>
<br>
I found that clang/llvm-symbolizer use
__cxx_demangle function.<br>
<br>
I would think that lld also need to call the same
function, and I think the way we want to demangle is
to have the function in LinkingContext as various
flavors may choose to use different API's to
demangle symbol names.<br>
<br>
The API's that would be in LinkingContext would be
:-<br>
<br>
* virtual bool canDemangle() = 0; // Does
the flavor provide a way to demangle symbol names ?<br>
* virtual std::string demangle(StringRef
symbolName) = 0; // demangle the symbol name<br>
Thoughts / Suggestions ?<br>
</blockquote>
Wouldn't it be simpler to have one demangle() method
that does nothing (returns input string) if demangling
is not available, the string is not a mangled symbol,
or demangling was turned off (--no-demangle). Then,
you just wrap a demangle() call around every use.<br>
</blockquote>
</div>
Are you mentioning that one demangle function in
LinkingContext ?<br>
<br>
One demangle method wouldnt work as the ItaniumABI uses
one method to demangle, ARMCXXABI uses a different method,
and MSVC uses a different one. I am not sure about Mach-O
here ?</blockquote>
<div><br>
</div>
<div>First, it's really easy to detect which ABI is being
used based on the prefix:</div>
<div>_Z -> standard Itanium demangler (__cxa_demangle)</div>
<div>__Z -> Itanium with a leading _</div>
<div>? -> MSVC</div>
<div><br>
</div>
<div>We don't need a virtual method. MinGW people might be
linking Itanium symbols on Windows, and that should
demangle just fine if __cxa_demangle is available.</div>
<div><br>
</div>
<div>Second, __cxa_demangle is not available on all
platforms, so lld should just test for it's availability
and use it for Itanium symbols if available.</div>
<div><br>
</div>
<div>I think the LLVM project has a demangler floating
around (libc++?). It might be nice to find a way to reuse
that across projects like this so the output of LLVM tools
doesn't change based on the capabilities of the host. In
other words, it'd be nice if we had a good story for
demangled diagnostics while cross-linking.</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
Thanks for the info, Reid. <br>
<br>
We will have a single demangler then, cross-linking is a very good
point that you raised.<br>
<br>
The demangler will check if the first character was a _ and if
__cxa_demangle is available, call __cxa_demangle<br>
<br>
If the first character is a ?, and if MSVC is defined, call
UnDecorateSymbolName<br>
<br>
The above should suffice for now, I think, and if there is a need we
could add more to it.<br>
<br>
-<br>
<br>
Shankar Easwaran<br>
<pre class="moz-signature" cols="72">--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation</pre>
</body>
</html>