D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4758 - --gc-sections breaks exception handling on Linux
Summary: --gc-sections breaks exception handling on Linux
Status: RESOLVED DUPLICATE of issue 879
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-29 11:07 UTC by nfxjfg
Modified: 2015-06-09 05:11 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description nfxjfg 2010-08-29 11:07:50 UTC
$ cat exc.d
void main() {
    try {
        throw new Exception("muh");
    } catch (Exception e) {
    }
}

$ dmd exc.d -L--gc-sections -L--print-gc-sections 2>&1 |grep exc
/usr/bin/ld: Removing unused section '.deh_eh' in file 'exc.o'
/usr/bin/ld: Removing unused section '.tdata' in file 'exc.o'

$ ./exc
unhandled exception

This "unhandled exception" thing is printed when the D runtime (Tango; based on Phobos1 runtime) doesn't find any exception records. It seems --gc-sections removes all D sections (including the bottom most exception handler in the runtime). It seems the linker removes all entries from section .deh_eh.

I wonder if this can be fixed. It works in g++.
Comment 1 Brad Roberts 2010-08-29 12:35:37 UTC

*** This issue has been marked as a duplicate of issue 879 ***