I am sponsoring the following self-reviewed case for myself.

It adds the dl_iterate_phdr() function and the related ElfW()
macro to Solaris. The addition of dl_iterate_phdr() is the final
piece needed in order for Solaris to benefit from the better/more
efficient exception handling mechanism employed by the GNU compilers
under Linux and BSD.

dl_iterate_phdr() will reside in the Solaris runtime linker
(ld.so.1) along with all the other dl*() functions. As with
those functions, libdl.so, and libc.so act as filters to ld.so.1
for dl_iterate_phdr(). For most applications, it will appear to
be part of libc.

I believe this qualifies for self review:

     - This is a Linux familiarity case --- dl_iterate_phdr() was
       invented for Linux in order to improve the handling of
       C++ exceptions, and has subsequently been adopted by other
       systems such as FreeBSD. Solaris can benefit from that work
       by adopting the same interfaces.

     - Existing Solaris interfaces are not affected, and there is
       no impact upon the Sun Studio compilers or the code they generate.

The Linux manpage can be seen at

     http://linux.die.net/man/3/dl_iterate_phdr

A copy of the proposed Solaris manpage can be found in
the case materials.

Release Binding:                        Patch/Micro
dl_iterate_phdr function:               Committed
ElfW() macro:                           Committed

-----

When a C++ exception arises, the runtime system needs to map the address
where the exception occurred to the address of the exception handling code
that it corresponds to, and unwind the stack. The GNU C++ compiler (g++)
uses ELF sections named .eh_frame to dispatch exception code. When an exception
occurs, the runtime system uses the exception address as a key into this
table. This approach originated with the Itanium (IA-64) ABI, and from
the DWARF specification. The GNU compilers generate these sections on
all platforms.

The original GNU exception handling mechanism, still used under
Solaris, is described by Ian Lance Taylor in his blog:

     http://www.airs.com/blog/archives/166

At runtime, each GNU C++ object registers itself with an object named
libgcc_s.so that is provided with GCC. This registration happens from
object init code.

The GNU developers subsequently improved on this model:

     1) The link-editor builds a section named .eh_frame_hdr,
        that allows .eh_frame to be searched using an O(log N)
        binary search at runtime.

     2) A program header (PT_GNU_EH_FRAME) allows the runtime system
        to quickly find the .eh_frame_hdr section, and eliminates the
        need for the libgcc_s.so sharable object and the runtime
        registration that goes with it.

When the amd64 ABI was designed, it adopted the GNU/Linux model without
change. These features were therefore adopted by Solaris as part of
the amd64 port (our corresponding program header is PT_SUNW_UNWIND).
At the time, we viewed them solely as amd64 features, and did not supply
them on non-amd64 platforms.

In early 2009, I became aware of the fact that Solaris uses the older
GNU exception mechanism, and also that thanks to our amd64 work,
our linkers already contained the code necessary to do better. I
broadened our support of .eh_frame_hdr and PT_SUNW_UNWIND to non-amd64
platforms with

     6813909 generalize eh_frame support to non-amd64 platforms

The description of 6813909 provides additional details:

     
http://bugs.opensolaris.org/bugdatabase/view_bug.do;jsessionid=bce16a2ca2bf008d048677c940f2?bug_id=6813909

Despite the integration of 6813909, the GNU compilers still use
the older libgcc_s.so based mechanism on Solaris. The reason for
this is that the GNU code that implements the newer mechanism is
built around the presence of the dl_iterate_phdr() function. The
GCC configuration detects the lack of this function, and reverts
to the older generic support.

Reply via email to