Removing RTTI from binaries

Mike via D.gnu d.gnu at puremagic.com
Wed Jan 14 06:28:42 PST 2015


On Wednesday, 14 January 2015 at 13:32:53 UTC, Mike wrote:

>
> Well, I was working a reduced test case and found that it has
> something to do with my trace.d file here:
> https://github.com/JinShil/stm32f42_discovery_demo/blob/master/source/stm32f42/trace.d
>
> If I add a trace.writeLine("x") in my program, then the binary
> goes from 2K to 130K.  Anyway, it appears it has nothing to do
> with TypeInfo.  I'll continue to try to reduce.
>
> Thanks for the help and useful information.
>
> Mike

Final update:

The problem was with this function here:

void write(A...)(in A a)
{
      foreach(t; a)
      {
          write(t);
      }
}

I think that since this is an open-ended template and I could
potentially pass any type to it, the compiler thinks it should
remember the TypeInfo.name values for every type in my program.

However, since I only ever used write("x") in my program, I
expect the linker to be able to see that those TypeInfo.name
values are never used, and strip them out when compiled with
-fdata-sections and -Wl,--gc-sections.  Perhaps it couldn't
because of the way the data is packed.

Anyway, I guess I'll see about modifying my code to be less
flexible in order to reign this data in.

Suggestions are welcome.

Mike


More information about the D.gnu mailing list