Index: head/contrib/libunwind/src/UnwindLevel1-gcc-ext.c =================================================================== --- head/contrib/libunwind/src/UnwindLevel1-gcc-ext.c (revision 355802) +++ head/contrib/libunwind/src/UnwindLevel1-gcc-ext.c (revision 355803) @@ -1,363 +1,363 @@ //===--------------------- UnwindLevel1-gcc-ext.c -------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // // Implements gcc extensions to the C++ ABI Exception Handling Level 1. // //===----------------------------------------------------------------------===// #include #include #include #include #include #include #include "config.h" #include "libunwind_ext.h" #include "libunwind.h" #include "Unwind-EHABI.h" #include "unwind.h" #if defined(_LIBUNWIND_BUILD_ZERO_COST_APIS) #if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) #define private_1 private_[0] #endif /// Called by __cxa_rethrow(). _LIBUNWIND_EXPORT _Unwind_Reason_Code _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) { #if defined(_LIBUNWIND_ARM_EHABI) _LIBUNWIND_TRACE_API("_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%ld", (void *)exception_object, (long)exception_object->unwinder_cache.reserved1); #else _LIBUNWIND_TRACE_API("_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%" PRIdPTR, (void *)exception_object, (intptr_t)exception_object->private_1); #endif #if defined(_LIBUNWIND_ARM_EHABI) // _Unwind_RaiseException on EHABI will always set the reserved1 field to 0, // which is in the same position as private_1 below. return _Unwind_RaiseException(exception_object); #else // If this is non-forced and a stopping place was found, then this is a // re-throw. // Call _Unwind_RaiseException() as if this was a new exception if (exception_object->private_1 == 0) { return _Unwind_RaiseException(exception_object); // Will return if there is no catch clause, so that __cxa_rethrow can call // std::terminate(). } // Call through to _Unwind_Resume() which distiguishes between forced and // regular exceptions. _Unwind_Resume(exception_object); _LIBUNWIND_ABORT("_Unwind_Resume_or_Rethrow() called _Unwind_RaiseException()" " which unexpectedly returned"); #endif } /// Called by personality handler during phase 2 to get base address for data /// relative encodings. _LIBUNWIND_EXPORT uintptr_t _Unwind_GetDataRelBase(struct _Unwind_Context *context) { (void)context; _LIBUNWIND_TRACE_API("_Unwind_GetDataRelBase(context=%p)", (void *)context); _LIBUNWIND_ABORT("_Unwind_GetDataRelBase() not implemented"); } /// Called by personality handler during phase 2 to get base address for text /// relative encodings. _LIBUNWIND_EXPORT uintptr_t _Unwind_GetTextRelBase(struct _Unwind_Context *context) { (void)context; _LIBUNWIND_TRACE_API("_Unwind_GetTextRelBase(context=%p)", (void *)context); _LIBUNWIND_ABORT("_Unwind_GetTextRelBase() not implemented"); } /// Scans unwind information to find the function that contains the /// specified code address "pc". _LIBUNWIND_EXPORT void *_Unwind_FindEnclosingFunction(void *pc) { _LIBUNWIND_TRACE_API("_Unwind_FindEnclosingFunction(pc=%p)", pc); // This is slow, but works. // We create an unwind cursor then alter the IP to be pc unw_cursor_t cursor; unw_context_t uc; unw_proc_info_t info; __unw_getcontext(&uc); __unw_init_local(&cursor, &uc); __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc); if (__unw_get_proc_info(&cursor, &info) == UNW_ESUCCESS) return (void *)(intptr_t) info.start_ip; else return NULL; } /// Walk every frame and call trace function at each one. If trace function /// returns anything other than _URC_NO_REASON, then walk is terminated. _LIBUNWIND_EXPORT _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { unw_cursor_t cursor; unw_context_t uc; __unw_getcontext(&uc); __unw_init_local(&cursor, &uc); _LIBUNWIND_TRACE_API("_Unwind_Backtrace(callback=%p)", (void *)(uintptr_t)callback); #if defined(_LIBUNWIND_ARM_EHABI) // Create a mock exception object for force unwinding. _Unwind_Exception ex; memset(&ex, '\0', sizeof(ex)); ex.exception_class = 0x434C4E47554E5700; // CLNGUNW\0 #endif // walk each frame while (true) { _Unwind_Reason_Code result; #if !defined(_LIBUNWIND_ARM_EHABI) // ask libunwind to get next frame (skip over first frame which is // _Unwind_Backtrace()) if (__unw_step(&cursor) <= 0) { _LIBUNWIND_TRACE_UNWINDING(" _backtrace: ended because cursor reached " "bottom of stack, returning %d", _URC_END_OF_STACK); return _URC_END_OF_STACK; } #else // Get the information for this frame. unw_proc_info_t frameInfo; if (__unw_get_proc_info(&cursor, &frameInfo) != UNW_ESUCCESS) { return _URC_END_OF_STACK; } // Update the pr_cache in the mock exception object. const uint32_t* unwindInfo = (uint32_t *) frameInfo.unwind_info; ex.pr_cache.fnstart = frameInfo.start_ip; ex.pr_cache.ehtp = (_Unwind_EHT_Header *) unwindInfo; ex.pr_cache.additional= frameInfo.flags; struct _Unwind_Context *context = (struct _Unwind_Context *)&cursor; // Get and call the personality function to unwind the frame. __personality_routine handler = (__personality_routine) frameInfo.handler; if (handler == NULL) { return _URC_END_OF_STACK; } if (handler(_US_VIRTUAL_UNWIND_FRAME | _US_FORCE_UNWIND, &ex, context) != _URC_CONTINUE_UNWIND) { return _URC_END_OF_STACK; } #endif // defined(_LIBUNWIND_ARM_EHABI) // debugging if (_LIBUNWIND_TRACING_UNWINDING) { char functionName[512]; unw_proc_info_t frame; unw_word_t offset; __unw_get_proc_name(&cursor, functionName, 512, &offset); __unw_get_proc_info(&cursor, &frame); _LIBUNWIND_TRACE_UNWINDING( " _backtrace: start_ip=0x%" PRIxPTR ", func=%s, lsda=0x%" PRIxPTR ", context=%p", frame.start_ip, functionName, frame.lsda, (void *)&cursor); } // call trace function with this frame result = (*callback)((struct _Unwind_Context *)(&cursor), ref); if (result != _URC_NO_REASON) { _LIBUNWIND_TRACE_UNWINDING( " _backtrace: ended because callback returned %d", result); return result; } } } #ifdef __arm__ -/* Preserve legacy libgcc ARM ABI mistake. */ -__sym_compat(_Unwind_Backtrace, _Unwind_Backtrace, GCC_4.3.0); +/* Preserve legacy libgcc (pre r318024) ARM ABI mistake */ +__sym_compat(_Unwind_Backtrace, _Unwind_Backtrace, GCC_3.3); #endif /// Find DWARF unwind info for an address 'pc' in some function. _LIBUNWIND_EXPORT const void *_Unwind_Find_FDE(const void *pc, struct dwarf_eh_bases *bases) { // This is slow, but works. // We create an unwind cursor then alter the IP to be pc unw_cursor_t cursor; unw_context_t uc; unw_proc_info_t info; __unw_getcontext(&uc); __unw_init_local(&cursor, &uc); __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc); __unw_get_proc_info(&cursor, &info); bases->tbase = (uintptr_t)info.extra; bases->dbase = 0; // dbase not used on Mac OS X bases->func = (uintptr_t)info.start_ip; _LIBUNWIND_TRACE_API("_Unwind_Find_FDE(pc=%p) => %p", pc, (void *)(intptr_t) info.unwind_info); return (void *)(intptr_t) info.unwind_info; } /// Returns the CFA (call frame area, or stack pointer at start of function) /// for the current context. _LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) { unw_cursor_t *cursor = (unw_cursor_t *)context; unw_word_t result; __unw_get_reg(cursor, UNW_REG_SP, &result); _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p) => 0x%" PRIxPTR, (void *)context, result); return (uintptr_t)result; } /// Called by personality handler during phase 2 to get instruction pointer. /// ipBefore is a boolean that says if IP is already adjusted to be the call /// site address. Normally IP is the return address. _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context, int *ipBefore) { _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p)", (void *)context); *ipBefore = 0; return _Unwind_GetIP(context); } #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) #if defined(__FreeBSD__) // Based on LLVM's lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp // and XXX should be fixed to be alignment-safe. static void processFDE(const char *addr, bool isDeregister) { uint64_t length; while ((length = *((const uint32_t *)addr)) != 0) { const char *p = addr + 4; if (length == 0xffffffff) { length = *((const uint64_t *)p); p += 8; } uint32_t offset = *((const uint32_t *)p); if (offset != 0) { if (isDeregister) __unw_remove_dynamic_fde((unw_word_t)(uintptr_t)addr); else __unw_add_dynamic_fde((unw_word_t)(uintptr_t)addr); } addr = p + length; } } /// Called by programs with dynamic code generators that want to register /// dynamically generated FDEs, with a libgcc-compatible API. _LIBUNWIND_EXPORT void __register_frame(const void *addr) { _LIBUNWIND_TRACE_API("__register_frame(%p)", addr); processFDE(addr, false); } /// Called by programs with dynamic code generators that want to unregister /// dynamically generated FDEs, with a libgcc-compatible API. _LIBUNWIND_EXPORT void __deregister_frame(const void *addr) { _LIBUNWIND_TRACE_API("__deregister_frame(%p)", addr); processFDE(addr, true); } #else // defined(__FreeBSD__) /// Called by programs with dynamic code generators that want /// to register a dynamically generated FDE. /// This function has existed on Mac OS X since 10.4, but /// was broken until 10.6. _LIBUNWIND_EXPORT void __register_frame(const void *fde) { _LIBUNWIND_TRACE_API("__register_frame(%p)", fde); __unw_add_dynamic_fde((unw_word_t)(uintptr_t)fde); } /// Called by programs with dynamic code generators that want /// to unregister a dynamically generated FDE. /// This function has existed on Mac OS X since 10.4, but /// was broken until 10.6. _LIBUNWIND_EXPORT void __deregister_frame(const void *fde) { _LIBUNWIND_TRACE_API("__deregister_frame(%p)", fde); __unw_remove_dynamic_fde((unw_word_t)(uintptr_t)fde); } #endif // defined(__FreeBSD__) // The following register/deregister functions are gcc extensions. // They have existed on Mac OS X, but have never worked because Mac OS X // before 10.6 used keymgr to track known FDEs, but these functions // never got updated to use keymgr. // For now, we implement these as do-nothing functions to keep any existing // applications working. We also add the not in 10.6 symbol so that nwe // application won't be able to use them. #if defined(_LIBUNWIND_SUPPORT_FRAME_APIS) _LIBUNWIND_EXPORT void __register_frame_info_bases(const void *fde, void *ob, void *tb, void *db) { (void)fde; (void)ob; (void)tb; (void)db; _LIBUNWIND_TRACE_API("__register_frame_info_bases(%p,%p, %p, %p)", fde, ob, tb, db); // do nothing, this function never worked in Mac OS X } _LIBUNWIND_EXPORT void __register_frame_info(const void *fde, void *ob) { (void)fde; (void)ob; _LIBUNWIND_TRACE_API("__register_frame_info(%p, %p)", fde, ob); // do nothing, this function never worked in Mac OS X } _LIBUNWIND_EXPORT void __register_frame_info_table_bases(const void *fde, void *ob, void *tb, void *db) { (void)fde; (void)ob; (void)tb; (void)db; _LIBUNWIND_TRACE_API("__register_frame_info_table_bases" "(%p,%p, %p, %p)", fde, ob, tb, db); // do nothing, this function never worked in Mac OS X } _LIBUNWIND_EXPORT void __register_frame_info_table(const void *fde, void *ob) { (void)fde; (void)ob; _LIBUNWIND_TRACE_API("__register_frame_info_table(%p, %p)", fde, ob); // do nothing, this function never worked in Mac OS X } _LIBUNWIND_EXPORT void __register_frame_table(const void *fde) { (void)fde; _LIBUNWIND_TRACE_API("__register_frame_table(%p)", fde); // do nothing, this function never worked in Mac OS X } _LIBUNWIND_EXPORT void *__deregister_frame_info(const void *fde) { (void)fde; _LIBUNWIND_TRACE_API("__deregister_frame_info(%p)", fde); // do nothing, this function never worked in Mac OS X return NULL; } _LIBUNWIND_EXPORT void *__deregister_frame_info_bases(const void *fde) { (void)fde; _LIBUNWIND_TRACE_API("__deregister_frame_info_bases(%p)", fde); // do nothing, this function never worked in Mac OS X return NULL; } #endif // defined(_LIBUNWIND_SUPPORT_FRAME_APIS) #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) #endif // defined(_LIBUNWIND_BUILD_ZERO_COST_APIS) Index: head/lib/libgcc_s/Makefile =================================================================== --- head/lib/libgcc_s/Makefile (revision 355802) +++ head/lib/libgcc_s/Makefile (revision 355803) @@ -1,55 +1,57 @@ # $FreeBSD$ PACKAGE= clibs SHLIB_NAME= libgcc_s.so.1 SHLIBDIR?= /lib .include MK_SSP= no WARNS?= 2 LDFLAGS+= -nodefaultlibs LIBADD+= c .if ${MK_SYMVER} == "yes" VERSION_DEF= ${.CURDIR}/Versions.def SYMBOL_MAPS= ${.CURDIR}/Symbol.map # Export ARM AEABI unwind routines needed by libc and libthr. .if exists(${.CURDIR}/${MACHINE_CPUARCH}/Symbol.map) SYMBOL_MAPS+= ${.CURDIR}/${MACHINE_CPUARCH}/Symbol.map +.else +SYMBOL_MAPS+= ${.CURDIR}/SymbolDefault.map .endif .endif .include "../libcompiler_rt/Makefile.inc" .include "../libgcc_eh/Makefile.inc" # gcc has incompatible internal declarations for __divtc3 and __multc3, but has # no option to silence its warning, so make warnings non-fatal. NO_WERROR.gcc= LIBCSRCDIR= ${SRCTOP}/lib/libc LIBMSRCDIR= ${SRCTOP}/lib/msun/src CFLAGS+= -I${LIBCSRCDIR}/include -I${LIBCSRCDIR}/${MACHINE_CPUARCH} CFLAGS+= -I${LIBMSRCDIR} .PATH: ${LIBMSRCDIR} SRCS+= s_fabs.c SRCS+= s_fabsf.c SRCS+= s_fabsl.c SRCS+= s_fmax.c SRCS+= s_fmaxf.c SRCS+= s_logb.c SRCS+= s_logbf.c SRCS+= s_scalbn.c SRCS+= s_scalbnf.c # Don't include long double routines on architectures where long double # is the same size as double. .if ${MACHINE_CPUARCH} != "mips" && ${MACHINE_CPUARCH} != "arm" && \ ${MACHINE_CPUARCH} != "powerpc" SRCS+= s_fmaxl.c SRCS+= s_logbl.c SRCS+= s_scalbnl.c .endif .include Index: head/lib/libgcc_s/Symbol.map =================================================================== --- head/lib/libgcc_s/Symbol.map (revision 355802) +++ head/lib/libgcc_s/Symbol.map (revision 355803) @@ -1,151 +1,150 @@ /* * $FreeBSD$ */ GCC_3.0 { __absvdi2; __absvsi2; __addvdi3; __addvsi3; __ashldi3; __ashlti3; __ashrdi3; __ashrti3; __clear_cache; __cmpdi2; __cmpti2; __deregister_frame; __deregister_frame_info; __deregister_frame_info_bases; __divdi3; __divti3; __ffsdi2; __ffsti2; __fixdfdi; __fixdfti; __fixsfdi; __fixsfti; __fixunsdfdi; __fixunsdfsi; __fixunsdfti; __fixunssfdi; __fixunssfsi; __fixunssfti; __fixunsxfdi; __fixunsxfsi; __fixunsxfti; __fixxfdi; __fixxfti; __floatdidf; __floatdisf; __floatdixf; __floattidf; __floattisf; __floattixf; __lshrdi3; __lshrti3; __moddi3; __modti3; __muldi3; __multi3; __mulvdi3; __mulvsi3; __negdi2; __negti2; __negvdi2; __negvsi2; __register_frame; __register_frame_info; __register_frame_info_bases; __register_frame_info_table; __register_frame_info_table_bases; __register_frame_table; __subvdi3; __subvsi3; __ucmpdi2; __ucmpti2; __udivdi3; __udivmoddi4; __udivmodti4; __udivti3; __umoddi3; __umodti3; _Unwind_DeleteException; _Unwind_Find_FDE; _Unwind_ForcedUnwind; _Unwind_GetDataRelBase; _Unwind_GetGR; _Unwind_GetIP; _Unwind_GetLanguageSpecificData; _Unwind_GetRegionStart; _Unwind_GetTextRelBase; _Unwind_RaiseException; _Unwind_Resume; _Unwind_SetGR; _Unwind_SetIP; }; GCC_3.3 { - _Unwind_Backtrace; _Unwind_FindEnclosingFunction; _Unwind_GetCFA; _Unwind_Resume_or_Rethrow; }; GCC_3.3.1 { __gcc_personality_v0; }; GCC_3.4 { __clzdi2; __clzsi2; __clzti2; __ctzdi2; __ctzsi2; __ctzti2; __paritydi2; __paritysi2; __parityti2; __popcountdi2; __popcountsi2; __popcountti2; }; GCC_3.4.2 { __enable_execute_stack; }; GCC_3.4.4 { __absvti2; __addvti3; __mulvti3; __negvti2; __subvti3; }; GCC_4.0.0 { __divdc3; __divsc3; __divxc3; __muldc3; __mulsc3; __mulxc3; __powidf2; __powisf2; __powixf2; }; GCC_4.2.0 { __floatundidf; __floatundisf; __floatundixf; __floatuntidf; __floatuntisf; __floatuntixf; _Unwind_GetIPInfo; }; GCC_4.3.0 { __bswapdi2; __bswapsi2; }; Index: head/lib/libgcc_s/SymbolDefault.map =================================================================== --- head/lib/libgcc_s/SymbolDefault.map (nonexistent) +++ head/lib/libgcc_s/SymbolDefault.map (revision 355803) @@ -0,0 +1,7 @@ +/* + * $FreeBSD$ + */ +/* _Unwind_Backtrace should be exported with different version on ARM */ +GCC_3.3 { + _Unwind_Backtrace; +}; Property changes on: head/lib/libgcc_s/SymbolDefault.map ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/libgcc_s/arm/Symbol.map =================================================================== --- head/lib/libgcc_s/arm/Symbol.map (revision 355802) +++ head/lib/libgcc_s/arm/Symbol.map (revision 355803) @@ -1,12 +1,16 @@ /* * $FreeBSD$ */ GCC_3.5 { _Unwind_VRS_Get; _Unwind_VRS_Set; __aeabi_unwind_cpp_pr0; __aeabi_unwind_cpp_pr1; __aeabi_unwind_cpp_pr2; __gnu_unwind_frame; }; + +GCC_4.3.0 { + _Unwind_Backtrace; +};