Removing RTTI from binaries

Mike via D.gnu d.gnu at puremagic.com
Thu Jan 15 03:51:41 PST 2015


On Thursday, 15 January 2015 at 11:42:31 UTC, Dicebot wrote:
>
> Random guess: can it possibly confuse template-based variadics 
> with runtime variadics? Latter require RTTI to work. If 
> something like that happens it is surely a bug.
>

Thanks for the reply.  I have to apologize for the last post, as 
I didn't fully reduce the code, and posted prematurely.

Here's a further reduction without any templates or variadics, so 
I'm under the impression that neither templates nor variadics are 
contributing to the problem.

The following code won't execute, but it will reproduce the 
problem at hand:  Inflating .rodata with TypeInfo.name.

test.d
**************************************
void write(in string text) nothrow {}

final abstract class TestClass1 { }

final abstract class TestClass2 { }
final abstract class TestClass3 { }
final abstract class TestClass4 { }
final abstract class TestClass5 { }
final abstract class TestClass6 { }
final abstract class TestClass7 { }
final abstract class TestClass8 { }
final abstract class TestClass9 { }

extern(C) void main()
{
     write("");
}

compile with:
gdc -static -frelease -fno-emit-moduleinfo -nophoboslib -nostdlib 
test.d --entry=main -ffunction-sections -fdata-sections 
-Wl,--gc-sections -o test


objdump -s -j .rodata test
*************************************
Contents of section .rodata:
  400152 74657374 2e546573 74436c61 73733100  test.TestClass1.
  400162 74657374 2e546573 74436c61 73733200  test.TestClass2.
  400172 74657374 2e546573 74436c61 73733300  test.TestClass3.
  400182 74657374 2e546573 74436c61 73733400  test.TestClass4.
  400192 74657374 2e546573 74436c61 73733500  test.TestClass5.
  4001a2 74657374 2e546573 74436c61 73733600  test.TestClass6.
  4001b2 74657374 2e546573 74436c61 73733700  test.TestClass7.
  4001c2 74657374 2e546573 74436c61 73733800  test.TestClass8.
  4001d2 74657374 2e546573 74436c61 73733900  test.TestClass9.



Interestingly, if I change the argument to `write` from a string 
to a char, all is good.

test.d
**************************************
void write(in char text) nothrow {}

final abstract class TestClass1 { }

final abstract class TestClass2 { }
final abstract class TestClass3 { }
final abstract class TestClass4 { }
final abstract class TestClass5 { }
final abstract class TestClass6 { }
final abstract class TestClass7 { }
final abstract class TestClass8 { }
final abstract class TestClass9 { }

extern(C) void main()
{
     write(' ');
}

objdump -s -j .rodata test
**************************************
objdump: section '.rodata' mentioned in a -j option, but not 
found in any input file

I guess all I'm really showing is how little I understand about 
this problem.  Again, I ask for help.

Mike


More information about the D.gnu mailing list