www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 879] New: support for --gc-sections

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=879

           Summary: support for --gc-sections
           Product: D
           Version: 1.00
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: thomas-dloop kuehne.cn


--gc-sections is ld's flag to "Enable garbage collection of unused input 
sections."


I think I've found the cause and know a simple fix.







dmd a.d -ofa; nm --numeric-sort a
[...]
 000000000805c4b0 R _D3std6thread6Thread6__vtblZ
 000000000805c508 R _deh_beg
 000000000805c508 r _TMP3
 000000000805c514 r _TMP1
[...]
 000000000805c604 r _TMP14
 000000000805c610 r _TMP27
 000000000805c61c R _deh_end
 000000000805c61c r __FRAME_END__
[...] dmd a.d -ofa -L--gc-sections; nm --numeric-sort a
 [...]
 0000000008053270 R _D3std6thread6Thread6__vtblZ
 00000000080532c8 R _deh_beg
 00000000080532c8 R _deh_end
 00000000080532c8 r __FRAME_END__
 [...]
The missing _TMP... symbols are of type internal.deh2.FuncTable and describe where to find the exception handlers of a given function. BUG 1: ld rightfully removed those as they are never directly referenced. However they are accessed indirectly via _deh_beg and _deh_end (-> internal/deh2.d:98-100). FIX 1: Define an elf symbol with the following characteristics: address: _deh_beg size: _deh_end - _deh_beg + sizeof(_deh_end) and ensure that this symbol is guaranteed to be referenced somewhere regardless of compiler flags like -O, -release and -inline. BUG 2: from above:
 00000000080532c8 R _deh_beg
 00000000080532c8 R _deh_end
 00000000080532c8 r __FRAME_END__
_deh_beg, _deh_end and __FRAME_END__ have the same addresses because _deh_beg and _deh_end claim to be of size zero. FIX 2: --
Jan 23 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=879






Created an attachment (id=106)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=106&action=view)
Binutils workaround


-- 
Mar 31 2007
prev sibling next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=879






Daniel Jacobowitz suggested a much more straight forward solution on the 
binutils mailing list(http://sourceware.org/ml/binutils/):

 Another way to fix this would be to emit R_arch_NONE relocations from
 the code sections to the EH tables they require.
--
Apr 04 2007
parent Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
d-bugmail puremagic.com wrote:

 Daniel Jacobowitz suggested a much more straight forward solution on the 
 binutils mailing list(http://sourceware.org/ml/binutils/):
 
 Another way to fix this would be to emit R_arch_NONE relocations from
 the code sections to the EH tables they require.
Interesting. And should be easy enough to implement. An added advantage to this approach would be that no relatively new version of binutils will be required to use --gc-sections[1], which might require working around (Linux) package managers. It'd just a recent version of DMD (after this is implemented) which is more likely to be manually installed (and frequently updated) anyway. [1]: (Assuming R_arch_NONE isn't a recent feature)
Apr 04 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=879






Walter, are you going to implement the R_arch_NONE solution or should we patch 
binutils?


-- 
Apr 25 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=879


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nfxjfg gmail.com



---
*** Issue 4758 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 29 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=879


Trass3r <mrmocool gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
                 CC|                            |mrmocool gmx.de
           Platform|x86                         |All
            Version|1.00                        |D1 & D2
           Severity|enhancement                 |normal



--gc-sections breaks everything, even hello world.

import std.stdio;
void main()
{
    writefln("FIXME!");
}

$ dmd -L--gc-sections -L--print-gc-sections test.d
ld: Removing unused section '.deh_eh' in file 'test.o'
ld: Removing unused section '.minfo' in file 'test.o'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__34_85a.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__54_915.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__5a_ff3.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__5e_8d3.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__60_fb1.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__62_882.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__63_f60.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(dmain2_44e_47b.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(dmain2_44e_47b.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_455_482.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_462_7db.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_467_46f.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_475_60d.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_478_6c8.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_47b_4cd.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_47c_53b.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_480_2a1.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(sections_linux.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__4db_e8d.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(console.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(container.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__551_86e.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(array.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(conv.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(exception.o)'
ld: Removing unused section '.minfo' in file
'libphobos2.a(exception_599_8af.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(format.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(functional.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(math.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(range.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(stdio.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(stdio_c2b_180.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(stdio_c2b_180.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(stdiobase.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(string.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(traits.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(typecons.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(typetuple.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(utf.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(object__6_32e.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(object__1b_3a8.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__57_ef0.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(runtime_e3_76e.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(runtime_e3_76e.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_12d_5a0.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(gc.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(gcx_2f3_8a.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(deh2.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__434_e4b.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(dmain2.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(lifetime.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_459_856.o)'
ld: Removing unused section '.deh_eh' in file
'libphobos2.a(lifetime_459_856.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_45e_4a3.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_461_4e2.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_463_4df.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_464_548.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_471_4c9.o)'
ld: Removing unused section '.deh_eh' in file
'libphobos2.a(lifetime_471_4c9.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(monitor_.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(tlsgc.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(algorithm.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(ascii.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(bitmanip.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(container.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(exception_5c8_d27.o)'
ld: Removing unused section '.deh_eh' in file
'libphobos2.a(exception_5c8_d27.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(random.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(regex.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(uni.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(uni_tab.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object_.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(exception.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__d9_929.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(runtime.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(runtime_e2_2e4.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(thread.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_109_236.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_10b_1b0.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_10e_330.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(thread_10e_330.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_110_3bd.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_117_2e5.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(thread_117_2e5.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_118_1b8.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_120_21c.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_124_28e.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(thread_124_28e.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_126_48b.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_128_6e4.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(thread_128_6e4.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_130_6f2.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_131_291.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_132_681.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(thread_132_681.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_136_595.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_13a_85e.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_13e_762.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(thread_13f_465.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_144_236.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_14e_1b8.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(time.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(time_177_5cc.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(mutex_225_213.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(gcx.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__343_b3c.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(critical_.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(dmain2_448_2f9.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(dmain2_448_2f9.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(dmain2_44a_2fd.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(dmain2_44a_2fd.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_46f_815.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_470_809.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(numeric.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object_891_87d.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(demangle_b8_ab6.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(demangle_b8_ab6.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_105_897.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_106_826.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_107_1b8.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_108_1b8.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_10a_22e.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(thread_10a_22e.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_113_219.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_115_2d8.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_121_129.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(thread_121_129.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_123_129.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(thread_123_129.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_12e_726.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_12f_302.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_134_737.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_135_5f2.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(thread_135_5f2.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_13b_469.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(time_16b_346.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(time_16b_346.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(time_178_297.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(time_17e_48a.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(time_17e_48a.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(aaA.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__340_aeb.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(lifetime_474_7cc.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(complex.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(demangle_b4_31d.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(demangle_b9_81f.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(demangle_b9_81f.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_104_713.o)'
ld: Removing unused section '.deh_eh' in file 'libphobos2.a(thread_104_713.o)'
ld: Removing unused section '.data' in file 'libphobos2.a(thread_119_155.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__341_c78.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__344_c36.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__345_be5.o)'
ld: Removing unused section '.minfo' in file 'libphobos2.a(object__33f_b6c.o)'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 23 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=879




As far as I remember the flag works fine with gdc.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 23 2013