Thread overview
:wq
Jan 02, 2014
Iain Buclaw
Jan 02, 2014
Iain Buclaw
Jan 02, 2014
Martin Nowak
Jan 02, 2014
Iain Buclaw
January 02, 2014
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.
January 02, 2014
On Thursday, 2 January 2014 at 17:38:30 UTC, Iain Buclaw wrote:
> _D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS6mangle18runModuleUnitTestsFZb7Console


That should be:

_D6mangle18runModuleUnitTestsFZb7Console6opCallMFxAaZS18runModuleUnitTestsFZb7Console

January 02, 2014
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.
January 02, 2014
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:
>>
>>
_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.

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.