D's Newfangled Name Mangling
Andrej Mitrovic
andrej.mitrovich at gmail.com
Thu Dec 21 09:43:54 UTC 2017
On Wednesday, 20 December 2017 at 13:57:20 UTC, Mike Parker wrote:
> The blog
> https://dlang.org/blog/2017/12/20/ds-newfangled-name-mangling/
> it won’t catch every error; for example, structs, classes and
> other user defined types are mangled > by name only, so that a
> change to their definition will still pass unnoticed by the
> linker.
Wouldn't it be possible to append the hash of the struct's type
definition to make the changes to the struct's definition
noticeable during linking?
e.g.:
-----
module test;
struct S
{
int x;
float y;
}
void foo ( S s ) { }
-----
You might create a hash this way:
hash = Fnv1a(mangle(Tint32), mangle(Tfloat32));
And then foo's name mangle changes from:
_D4test3fooFS4test1SZv
to:
_D4test3fooFS4test1S<hash>Zv
It may not be 100% fool-proof yet though, because we'd also have
to hash a bunch of other things like align() attributes.
Or is this is overkill?
More information about the Digitalmars-d-announce
mailing list