Removing RTTI from binaries

Mike via D.gnu d.gnu at puremagic.com
Tue Jan 13 06:20:41 PST 2015


On Sunday, 11 January 2015 at 16:57:41 UTC, Johannes Pfau wrote:
>
> That's likely used/caused by the TypeInfo.name property.
>

Judging by what I'm seeing, I think you're right.

But I'm compiling with -fdata-sections and -Wl,--gc-sections, so 
shouldn't that put each TypeInfo.name in its own section and 
strip it out?

Here's what I'm seeing:

--------------------
arm-none-eabi-objdump -t binary/firmware

binary/firmware:     file format elf32-littlearm

SYMBOL TABLE:
08000000 l    d  .text  00000000 .text
08000a44 l    d  .rodata        00000000 .rodata
00000000 l    df *ABS*  00000000 start.d
0800001c l       .text  00000000 handler_address
00000000 l       *UND*  00000000 __aeabi_unwind_cpp_pr0
00000000 l       *UND*  00000000 __aeabi_unwind_cpp_pr1
00000000 l    df *ABS*  00000000
10010000 l       *ABS*  00000000 _stackStart
08000034 g     F .text  0000007e memcpy
08000010 g     F .text  00000014 _D5start7OnResetFZv
080202d4 g       .rodata        00000000 __text_end__
08000004 g     O .text  00000004 ResetHandler
20000000 g       .rodata        00000000 __data_end__
20000000 g       .rodata        00000000 __bss_start__
20000000 g       .rodata        00000000 __bss_end__
08000024 g     F .text  00000010 memset
20000000 g       .rodata        00000000 __data_start__
0800000c g     O .text  00000004 HardFaultHandler
080000b4 g     F .text  0000093c main
08000a28 g     F .text  0000001c _D5start11OnHardFaultFZv


I don't see anything in the symbol table, but...

---------------------
rm-none-eabi-readelf -S binary/firmware
There are 6 section headers, starting at offset 0x28300:

Section Headers:
[Nr] Name       Type      Addr     Off    Size   ES Flg
[0]             NULL      00000000 000000 000000 00
[1] .text       PROGBITS  08000000 008000 000a44 00  AX
[2] .rodata     PROGBITS  08000a44 008a44 01f890 00   A
[3] .shstrtab   STRTAB    00000000 0282d4 000029 00
[4] .symtab     SYMTAB    00000000 0283f0 000270 10
[5] .strtab     STRTAB    00000000 028660 000128 00
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)


You can see the .rodata section is orders of magnitude larger 
than any other section.

Mike



More information about the D.gnu mailing list