On Wednesday, 14 January 2015 at 14:34:48 UTC, Mike wrote:
I'll try to make a reduced test case on Linux that others can
run
and see.
Ok, here's my reduced test case that runs on Linux 64-bit. I
don't know if I really needed to implement the syscalls, but I
just wanted to get rid of everything I could so the important
stuff would stand out.
test.d
***************************************
void sys_exit(long arg1) nothrow
{
asm
{
"syscall"
:
: "a" 60,
"D" arg1,
: "memory", "cc", "rcx", "r11";
}
}
long sys_write(long arg1, in void* arg2, long arg3) nothrow
{
long result;
asm
{
"syscall"
: "=a" result
: "a" 1,
"D" arg1,
"S" arg2,
"m" arg2,
"d" arg3
: "memory", "cc", "rcx", "r11";
}
return result;
}
void write(in string text) nothrow
{
sys_write(2, text.ptr, text.length);
}
void write(A...)(in A a) nothrow
{
foreach(t; a)
{
write(t);
}
}
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("x");
sys_exit(0);
}
***************************************
compile with:
gdc -static -frelease -fno-emit-moduleinfo -nophoboslib -nostdlib
test.d --entry=main -ffunction-sections -fdata-sections
-Wl,--gc-sections -o test
show .rodata:
***************************************
objdump -s -j .rodata test
Contents of section .rodata:
4001c4 74657374 2e546573 74436c61 73733100 test.TestClass1.
4001d4 78 x
See the "test.TestClass1" string there? That's the problem. Now
uncomment the other `TestClass`s.
show .rodata with more types:
***************************************
objdump -s -j .rodata test
Contents of section .rodata:
4001c4 74657374 2e546573 74436c61 73733100 test.TestClass1.
4001d4 74657374 2e546573 74436c61 73733200 test.TestClass2.
4001e4 74657374 2e546573 74436c61 73733300 test.TestClass3.
4001f4 74657374 2e546573 74436c61 73733400 test.TestClass4.
400204 74657374 2e546573 74436c61 73733500 test.TestClass5.
400214 74657374 2e546573 74436c61 73733600 test.TestClass6.
400224 74657374 2e546573 74436c61 73733700 test.TestClass7.
400234 74657374 2e546573 74436c61 73733800 test.TestClass8.
400244 74657374 2e546573 74436c61 73733900 test.TestClass9.
400254 78 x
Now imagine I have a highly templated library generating 100s of
these little classes.
Now, comment out the `write("x")`.
show .rodata `write("x")` commented out:
***************************************
objdump -s -j .rodata test
objdump: section '.rodata' mentioned in a -j option, but not
found in any input file
No .rodata at all!!
IMO the toolchain should be able to recognize that the
TypeInfo.name property is not being used and strip it out.
If you can explain the mechanics causing this, please enlighten
me. Bug? Enhancement? By design?
Thanks for the help,
Mike