This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: The unwind specification draft for GNU/Linux/ia64


On Thu, Jul 08, 2004 at 08:05:36PM -0700, H. J. Lu wrote:
> On Thu, Jul 08, 2004 at 04:50:51PM -0700, Richard Henderson wrote:
> > On Thu, Jul 08, 2004 at 01:59:34PM -0700, H. J. Lu wrote:
> > > The current unwind specification for GNU/Linux/ia64 does't specify how
> > > to provide the binary compatibilty when the 3rd part unwind library
> > > is used.
> > 
> > I'm certain I don't want to get into this, but ...
> > 
> > > 1. An implementation of GNU/Linux compiler shall provide the personality
> > > routine, __gnu_linux_[language]_personality_v0.
> > > h. For C, it will be __gnu_linux_c_personality_v0.
> > > i. For C++, it will be __gnu_linux_cxx_personality_v0.
> > 
> > Why are you specifying this at all?  The LSDA is entirely private
> > to the generating compiler and the personality routine it chose
> > to install.  I object to this.
> 
> At first, I thought it would be nice to mix .o files compiled by
> gcc and icc with either gcc or icc as driver to create executables.
> It turns out that it wouldn't be easy for the reasons you have
> mentioned. I hoped that maybe we could do it in the future. But
> it looks very unlikely. I will drop it from the proposal.
> 
> > 
> > > 1. __libunwind_Unwind_Backtrace: Alias of _Unwind_Backtrace
> > [...]
> > 
> > What are your plans for libgcc_s.so?
> 
> For platforms using the Linux unwind ABI:
> 
> 1. Move unwind functions from libgcc_s.so to libunwind.so.
> 2. Turn the old versioned functions in libgcc_s.so into stubs calling
> the real ones in libunwind.so for backward binary compatibility and
> don't export them.
> 3. Make libgcc_s.so depend on libunwind.so.
> 4. Pass --no-add-needed -lunwind --add-needed to ld.
> 
> Maybe we can do it for all platforms. But it may require symbol
> versioning support in ld.so.
> 
> 

Here is the updated draft. I am waiting for the final word on the
libunwind soname.

My gcc patch is mostly done for Linux/ia64. I changed

AC_ARG_ENABLE(libunwind-exceptions
[  --enable-libunwind-exceptions  force use libunwind for exceptions],
...

to

AC_ARG_WITH(system-libunwind,
[  --with-system-libunwind use installed libunwind])

since libunwind should only be used when it is called for by ABI. The
question is if other Linux platforms should adopt the new unwind ABI.
It will be nice that we can use the system unwind library on all
supported Linux platforms.


H.J.
----
This is the unwind specification draft for GNU/Linux/ia64 which extends the exception ABI:

http://www.codesourcery.com/cxx-abi/abi-eh.html

The goal is to allow any ABI conforming shared unwind library to be used with output from any ABI compliant GNU/Linux compiler.

The GNU/Linux/ia64 extension of the "Level I. Base ABI" section in the exception ABI:

1. An implementation of a shared unwind library shall place the unwind library in a DSO named libunwind.so.7 or in auxiliary DSOs automatically loaded by it.
2. A new unwind action:

	const _Unwind_Action _UA_END_OF_STACK = 16;

In order to allow _Unwind_ForcedUnwind to perform special processing when it reaches the end of the stack, the unwind runtime will call it after the last frame is rejected, with the _UA_END_OF_STACK bit in action on, and the stop function must catch this condition (i.e. by noticing that the _UA_END_OF_STACK bit in action is on). It may return this reason code if it cannot handle end-of-stack.

3. Additional functions:

a. Use unwind data to perform a stack backtrace.  The trace callback is called for every stack frame in the call chain, but no cleanup actions are performed.

    typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
    (struct _Unwind_Context *, void *);

    extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
b. Retrieve the CFA of the given context.
    extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
c. Resume propagation of an FORCE_UNWIND exception, or to rethrow a normal exception that was handled.  */
    extern _Unwind_Reason_Code _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *);
d. Given an address, return the entry point of the function that contains it.
    extern void * _Unwind_FindEnclosingFunction (void *pc);
e. Retrieve the Backing Store Pointer of the given context. Only for ia64.
    extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
f. Retrieve the base addresses for data-relative addressing in the LDSA. Only for non-ia64 platforms.
   extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
g. Retrieve the base addresses for text-relative addressing in the LDSA. Only for non-ia64 platforms.
   extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
h. Retrieve the object containing the address. Only for non-ia64 platforms.
    extern const fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);

Other GNU/Linux platforms shall adopt the above specification if the platform ABI doesn't specify an alternate unwind mechanism.

Backward compatibility for the existing libgcc-based unwinder:

If there is an existing libgcc-based unwinder in gcc and an unwind library supports gcc, a set of compatibility symbols should be defined.

1. __libunwind_Unwind_Backtrace: Alias of _Unwind_Backtrace
2. __libunwind_Unwind_DeleteException: Alias of _Unwind_DeleteException
3. __libunwind_Unwind_FindEnclosingFunction: Alias of _Unwind_FindEnclosingFunction
4. __libunwind_Unwind_ForcedUnwind: Alias of _Unwind_ForcedUnwind
5. __libunwind_Unwind_GetCFA: Alias of _Unwind_GetCFA
6. __libunwind_Unwind_GetGR: Alias of _Unwind_GetGR
7. __libunwind_Unwind_GetIP: Alias of _Unwind_GetIP
8. __libunwind_Unwind_GetLanguageSpecificData: Alias of _Unwind_GetLanguageSpecificData
9. __libunwind_Unwind_GetRegionStart: Alias of _Unwind_GetRegionStart
10. __libunwind_Unwind_RaiseException: Alias of _Unwind_RaiseException
11. __libunwind_Unwind_Resume: Alias of _Unwind_Resume
12. __libunwind_Unwind_Resume_or_Rethrow: Alias of _Unwind_Resume_or_Rethrow
13. __libunwind_Unwind_SetGR: Alias of _Unwind_SetGR
14. __libunwind_Unwind_SetIP: Alias of _Unwind_SetIP
15. __libunwind_Unwind_GetBSP: Alias of _Unwind_GetBSP. Only for ia64.
16. __libunwind_Unwind_GetDataRelBase: Alias of _Unwind_GetDataRelBase. Only for non-ia64 platforms.
17. __libunwind_Unwind_GetTextRelBase: Alias of _Unwind_GetTextRelBase. Only for non-ia64 platforms.
18. __libunwind_Unwind_Find_FDE: Alias of _Unwind_Find_FDE. Only for non-ia64 platforms.

Those symbols can be used by the new libgcc to provide the backward binary compatibility.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]