bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/28045] New: add --warn-uncaught-exceptions to linker


From: woodard at redhat dot com
Subject: [Bug ld/28045] New: add --warn-uncaught-exceptions to linker
Date: Thu, 01 Jul 2021 19:59:48 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=28045

            Bug ID: 28045
           Summary: add --warn-uncaught-exceptions to linker
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: woodard at redhat dot com
  Target Milestone: ---

Right now given some random library it is very difficult and requires an awful
amount of digging to just figure out what you should try to catch. It would be
great if the linker which can observe these things as it is linking the binary
could point out uncaught exceptions.

So when gcc links the developer could pass:
-Wl,--warn-uncaught-exceptions

Then for every type thrown as listed in the LSDA, if at least one of the
libraries doesn't have an entry in the TType table then it prints something
like:

Warning: thus_and_such_function throws type ExceptionType at line N there is no
corresponding catch block that can catch that type.

Then when they see that they could look at their code that either directly or
indirectly calls the named function and insert a catch block. And like most
warnings vs. errors they can look at it and say — yeah I don’t really care and
ignore it.

The simplest blunt way to fix that warning would be wrap the contents of main
in a try block and put catch blocks for the types being pointed out there. It
obviously would be better to be more targeted in where they insert their catch
blocks.

This would just be a first approximation, it wouldn't necessarily be able to
guarantee that there isn't a way to reach some code where an exception wouldn't
be caught. To be able to do that, you would have to do call chain analysis.
However, it would insure that somewhere in the totality of the program being
linked there is a catch block that can handle that type.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]