logan created this revision. logan added reviewers: rengolin, joerg, danalbert, asl, compnerd. logan added a subscriber: cfe-commits. logan added a dependency: D11190: unwind: Fix libc++abi and libgcc build.. Herald added subscribers: rengolin, aemerson.
I have removed the exported symbols of _Unwind_{Get,Set}{GR,IP}() from libunwind.so in D11190. However, it is debatable whether we should export those symbols. Thus, I am uploading this patch for discussion. Arguments for this patch: * The programs that do not include <unwind.h> and declares their own function declarations can still be linked with our libunwind.so. * _Unwind_{Get,Set}{GR,IP}() are listed in C++ Itanium Level 1 unwinding API. Arguments against this patch: * libgcc does not provide these symbols at all. We should not extend the ABI without deliberate consideration. * Programs that didn't include <unwind.h> deserves not being compiled. If the application developers have tried to port their code to ARM, they should already found the problem. * ARM EHABI only specified _Unwind_VRS_{Get,Set}() for such purpose. I personally against this patch, but I would like to see if there are other comments/concerns. Depends on D11190 http://reviews.llvm.org/D11191 Files: include/unwind.h src/UnwindLevel1.c Index: src/UnwindLevel1.c =================================================================== --- src/UnwindLevel1.c +++ src/UnwindLevel1.c @@ -12,6 +12,13 @@ // //===----------------------------------------------------------------------===// +// ARM EHABI does not specify _Unwind_{Get,Set}{GR,IP}(). Thus, we are +// defining inline functions to delegate the function calls to +// _Unwind_VRS_{Get,Set}(). However, some applications might declare the +// function protetype directly (instead of including <unwind.h>), thus we need +// to export these functions in libunwind.so as well. +#define __LIBUNWIND_DONT_INLINE_UNWIND_LEVEL1 1 + #include <inttypes.h> #include <stdint.h> #include <stdbool.h> Index: include/unwind.h =================================================================== --- include/unwind.h +++ include/unwind.h @@ -214,32 +214,40 @@ #else // LIBCXXABI_ARM_EHABI +#if !defined(__LIBUNWIND_DONT_INLINE_UNWIND_LEVEL1) +#define __LIBUNWIND_EXPORT_UNWIND_LEVEL1 static __inline__ +#else +#define __LIBUNWIND_EXPORT_UNWIND_LEVEL1 extern +#endif + // These are de facto helper functions for ARM, which delegate the function // calls to _Unwind_VRS_Get/Set(). These are not a part of ARM EHABI // specification, thus these function MUST be inlined. Please don't replace // these with the "extern" functin declaration; otherwise, the program // including this <unwind.h> header won't be ABI compatible and will result in // link error when we are linking the program with libgcc. -static __inline__ uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, - int index) { +__LIBUNWIND_EXPORT_UNWIND_LEVEL1 +uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index) { uintptr_t value = 0; _Unwind_VRS_Get(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value); return value; } -static __inline__ void _Unwind_SetGR(struct _Unwind_Context *context, - int index, uintptr_t value) { +__LIBUNWIND_EXPORT_UNWIND_LEVEL1 +void _Unwind_SetGR(struct _Unwind_Context *context, int index, + uintptr_t value) { _Unwind_VRS_Set(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value); } -static __inline__ uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) { +__LIBUNWIND_EXPORT_UNWIND_LEVEL1 +uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) { // remove the thumb-bit before returning return _Unwind_GetGR(context, 15) & (~(uintptr_t)0x1); } -static __inline__ void _Unwind_SetIP(struct _Unwind_Context *context, - uintptr_t value) { +__LIBUNWIND_EXPORT_UNWIND_LEVEL1 +void _Unwind_SetIP(struct _Unwind_Context *context, uintptr_t value) { uintptr_t thumb_bit = _Unwind_GetGR(context, 15) & ((uintptr_t)0x1); _Unwind_SetGR(context, 15, value | thumb_bit); }
Index: src/UnwindLevel1.c =================================================================== --- src/UnwindLevel1.c +++ src/UnwindLevel1.c @@ -12,6 +12,13 @@ // //===----------------------------------------------------------------------===// +// ARM EHABI does not specify _Unwind_{Get,Set}{GR,IP}(). Thus, we are +// defining inline functions to delegate the function calls to +// _Unwind_VRS_{Get,Set}(). However, some applications might declare the +// function protetype directly (instead of including <unwind.h>), thus we need +// to export these functions in libunwind.so as well. +#define __LIBUNWIND_DONT_INLINE_UNWIND_LEVEL1 1 + #include <inttypes.h> #include <stdint.h> #include <stdbool.h> Index: include/unwind.h =================================================================== --- include/unwind.h +++ include/unwind.h @@ -214,32 +214,40 @@ #else // LIBCXXABI_ARM_EHABI +#if !defined(__LIBUNWIND_DONT_INLINE_UNWIND_LEVEL1) +#define __LIBUNWIND_EXPORT_UNWIND_LEVEL1 static __inline__ +#else +#define __LIBUNWIND_EXPORT_UNWIND_LEVEL1 extern +#endif + // These are de facto helper functions for ARM, which delegate the function // calls to _Unwind_VRS_Get/Set(). These are not a part of ARM EHABI // specification, thus these function MUST be inlined. Please don't replace // these with the "extern" functin declaration; otherwise, the program // including this <unwind.h> header won't be ABI compatible and will result in // link error when we are linking the program with libgcc. -static __inline__ uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, - int index) { +__LIBUNWIND_EXPORT_UNWIND_LEVEL1 +uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index) { uintptr_t value = 0; _Unwind_VRS_Get(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value); return value; } -static __inline__ void _Unwind_SetGR(struct _Unwind_Context *context, - int index, uintptr_t value) { +__LIBUNWIND_EXPORT_UNWIND_LEVEL1 +void _Unwind_SetGR(struct _Unwind_Context *context, int index, + uintptr_t value) { _Unwind_VRS_Set(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value); } -static __inline__ uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) { +__LIBUNWIND_EXPORT_UNWIND_LEVEL1 +uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) { // remove the thumb-bit before returning return _Unwind_GetGR(context, 15) & (~(uintptr_t)0x1); } -static __inline__ void _Unwind_SetIP(struct _Unwind_Context *context, - uintptr_t value) { +__LIBUNWIND_EXPORT_UNWIND_LEVEL1 +void _Unwind_SetIP(struct _Unwind_Context *context, uintptr_t value) { uintptr_t thumb_bit = _Unwind_GetGR(context, 15) & ((uintptr_t)0x1); _Unwind_SetGR(context, 15, value | thumb_bit); }
_______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits