www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - :wq

reply "Iain Buclaw" <ibuclaw ubuntu.com> writes:
Given the code:

module mangle;

extern (C) bool runModuleUnitTests()
{
     static struct Console
     {
         Console opCall( in char[] val )
         {
             return this;
         }
     }
     return false;
}


The D frontend will generate the mangled symbol (and its 
initialiser) as:

_D6mangle18runModuleUnitTestsUZb7Console6opCallMFxAaZSrunModuleUnitTests7Console
_DrunModuleUnitTests7Console6__initZ

Instead of the more desired:

_D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS6mangle18runModuleUnitTestsFZb7Console
_D18runModuleUnitTest7Console6__initZ


Is this desirable? It makes demangling such symbols difficult.
Jan 02 2014
next sibling parent "Iain Buclaw" <ibuclaw ubuntu.com> writes:
On Thursday, 2 January 2014 at 17:38:30 UTC, Iain Buclaw wrote:
 _D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS6mangle18runModuleUnitTestsFZb7Console

That should be: _D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS18runModuleUnitTestsFZb7Console
Jan 02 2014
prev sibling next sibling parent Martin Nowak <code dawg.eu> writes:
On 01/02/2014 06:38 PM, Iain Buclaw wrote:
 The D frontend will generate the mangled symbol (and its initialiser) as:

 _D6mangle18runModuleUnitTestsUZb7Console6opCallMFxAaZSrunModuleUnitTests7Console

 _DrunModuleUnitTests7Console6__initZ

 Instead of the more desired:

 _D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS6mangle18runModuleUnitTestsFZb7Console

 _D18runModuleUnitTest7Console6__initZ


 Is this desirable? It makes demangling such symbols difficult.

I think we should ignore extern(C) when mangling nested symbols. But we should obey the calling convention. So according to http://dlang.org/abi.html it's UZb instead of FZb.
Jan 02 2014
prev sibling parent Iain Buclaw <ibuclaw gdcproject.org> writes:
--001a11c1f15047fc4004ef03bcb5
Content-Type: text/plain; charset=ISO-8859-1

On 2 Jan 2014 19:50, "Martin Nowak" <code dawg.eu> wrote:
 On 01/02/2014 06:38 PM, Iain Buclaw wrote:
 The D frontend will generate the mangled symbol (and its initialiser) as:


 _DrunModuleUnitTests7Console6__initZ

 Instead of the more desired:


 _D18runModuleUnitTest7Console6__initZ


 Is this desirable? It makes demangling such symbols difficult.

I think we should ignore extern(C) when mangling nested symbols. But we should obey the calling convention. So according to http://dlang.org/abi.html it's UZb instead of FZb.

I should probably rewrite the message as I did it in an awful hurry. ;) The main point was getting across was that in the normal scheme of mangling it follows the convention in a nutshell: TypeStruct QualifiedSymbol (Int Symbol) ... Eg: S6foobar5inner... Should 'foobar' be an extern (C) function, then the initial string count is omitted. Sfoobar5inner Causing core.demangler to choke on it. This affects the demangler I've written for gdb as it follows the same rules to parse the mangled string. --001a11c1f15047fc4004ef03bcb5 Content-Type: text/html; charset=ISO-8859-1 <p dir="ltr">On 2 Jan 2014 19:50, &quot;Martin Nowak&quot; &lt;<a href="mailto:code dawg.eu">code dawg.eu</a>&gt; wrote:<br> &gt;<br> &gt; On 01/02/2014 06:38 PM, Iain Buclaw wrote:<br> &gt;&gt;<br> &gt;&gt;<br> &gt;&gt; The D frontend will generate the mangled symbol (and its initialiser) as:<br> &gt;&gt;<br> &gt;&gt; _D6mangle18runModuleUnitTestsUZb7Console6opCallMFxAaZSrunModuleUnitTests7Console<br> &gt;&gt;<br> &gt;&gt; _DrunModuleUnitTests7Console6__initZ<br> &gt;&gt;<br> &gt;&gt; Instead of the more desired:<br> &gt;&gt;<br> &gt;&gt; _D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS6mangle18runModuleUnitTestsFZb7Console<br> &gt;&gt;<br> &gt;&gt; _D18runModuleUnitTest7Console6__initZ<br> &gt;&gt;<br> &gt;&gt;<br> &gt;&gt; Is this desirable? It makes demangling such symbols difficult.<br> &gt;<br> &gt;<br> &gt; I think we should ignore extern(C) when mangling nested symbols.<br> &gt; But we should obey the calling convention.<br> &gt; So according to <a href="http://dlang.org/abi.html">http://dlang.org/abi.html</a> it&#39;s UZb instead of FZb.</p> <p dir="ltr">I should probably rewrite the message as I did it in an awful hurry. ;)</p> <p dir="ltr">The main point was getting across was that in the normal scheme of mangling it follows the convention in a nutshell:</p> <p dir="ltr">TypeStruct QualifiedSymbol (Int Symbol) ...</p> <p dir="ltr">Eg:<br> S6foobar5inner...</p> <p dir="ltr">Should &#39;foobar&#39; be an extern (C) function, then the initial string count is omitted.</p> <p dir="ltr">Sfoobar5inner</p> <p dir="ltr">Causing core.demangler to choke on it.</p> <p dir="ltr">This affects the demangler I&#39;ve written for gdb as it follows the same rules to parse the mangled string.</p> --001a11c1f15047fc4004ef03bcb5--
Jan 02 2014