From owner-svn-src-stable@FreeBSD.ORG Sun Aug 10 22:26:31 2014 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3E3C5BD7 for ; Sun, 10 Aug 2014 22:26:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2AF3E2720 for ; Sun, 10 Aug 2014 22:26:31 +0000 (UTC) Received: from ian (uid 1311) (envelope-from ian@FreeBSD.org) id 2402 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Sun, 10 Aug 2014 22:26:29 +0000 From: Ian Lepore Date: Sun, 10 Aug 2014 22:26:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r269792 - in stable/10: contrib/libstdc++/libsupc++ lib/libc lib/libc/arm lib/libc/arm/aeabi sys/arm/include sys/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53e7f196.2402.5912252@svn.freebsd.org> X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Aug 2014 22:26:31 -0000 Author: ian Date: Sun Aug 10 22:26:29 2014 New Revision: 269792 URL: http://svnweb.freebsd.org/changeset/base/269792 Log: MFC r268993, r268893, r268994, plus partial r264070, r264082 Fix C++ exception handling for ARM EABI. Just the part of r264070 that creates the FBSD_1.4 namespace in libc is hand-applied, and then r264082 which creates the Versions.def entry is MFC'd. Added: stable/10/lib/libc/arm/aeabi/aeabi_unwind_exidx.c - copied unchanged from r268893, head/lib/libc/arm/aeabi/aeabi_unwind_exidx.c Modified: stable/10/contrib/libstdc++/libsupc++/unwind-cxx.h stable/10/lib/libc/Versions.def stable/10/lib/libc/arm/Symbol.map stable/10/lib/libc/arm/aeabi/Makefile.inc stable/10/sys/arm/include/elf.h stable/10/sys/sys/link_elf.h Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/libstdc++/libsupc++/unwind-cxx.h ============================================================================== --- stable/10/contrib/libstdc++/libsupc++/unwind-cxx.h Sun Aug 10 22:24:14 2014 (r269791) +++ stable/10/contrib/libstdc++/libsupc++/unwind-cxx.h Sun Aug 10 22:26:29 2014 (r269792) @@ -142,9 +142,9 @@ typedef enum { ctm_succeeded = 1, ctm_succeeded_with_ptr_to_base = 2 } __cxa_type_match_result; -extern "C" bool __cxa_type_match(_Unwind_Exception*, const std::type_info*, +extern "C" __cxa_type_match_result __cxa_type_match(_Unwind_Exception*, const std::type_info*, bool, void**); -extern "C" void __cxa_begin_cleanup (_Unwind_Exception*); +extern "C" bool __cxa_begin_cleanup (_Unwind_Exception*); extern "C" void __cxa_end_cleanup (void); #endif Modified: stable/10/lib/libc/Versions.def ============================================================================== --- stable/10/lib/libc/Versions.def Sun Aug 10 22:24:14 2014 (r269791) +++ stable/10/lib/libc/Versions.def Sun Aug 10 22:26:29 2014 (r269792) @@ -23,6 +23,11 @@ FBSD_1.2 { FBSD_1.3 { } FBSD_1.2; +# This version was first added to 11.0-current. +FBSD_1.4 { +} FBSD_1.3; + + # This is our private namespace. Any global interfaces that are # strictly for use only by other FreeBSD applications and libraries # are listed here. We use a separate namespace so we can write @@ -30,4 +35,4 @@ FBSD_1.3 { # # Please do NOT increment the version of this namespace. FBSDprivate_1.0 { -} FBSD_1.3; +} FBSD_1.4; Modified: stable/10/lib/libc/arm/Symbol.map ============================================================================== --- stable/10/lib/libc/arm/Symbol.map Sun Aug 10 22:24:14 2014 (r269791) +++ stable/10/lib/libc/arm/Symbol.map Sun Aug 10 22:26:29 2014 (r269792) @@ -37,6 +37,11 @@ FBSD_1.3 { __flt_rounds; }; +FBSD_1.4 { + __gnu_Unwind_Find_exidx; + dl_unwind_find_exidx; +}; + FBSDprivate_1.0 { /* PSEUDO syscalls */ __sys_getlogin; Modified: stable/10/lib/libc/arm/aeabi/Makefile.inc ============================================================================== --- stable/10/lib/libc/arm/aeabi/Makefile.inc Sun Aug 10 22:24:14 2014 (r269791) +++ stable/10/lib/libc/arm/aeabi/Makefile.inc Sun Aug 10 22:26:29 2014 (r269792) @@ -5,7 +5,8 @@ SRCS+= aeabi_atexit.c \ aeabi_double.c \ aeabi_float.c \ - aeabi_unwind_cpp.c + aeabi_unwind_cpp.c \ + aeabi_unwind_exidx.c .if ${MACHINE_ARCH:Marmv6*} SRCS+= aeabi_vfp_double.S \ aeabi_vfp_float.S Copied: stable/10/lib/libc/arm/aeabi/aeabi_unwind_exidx.c (from r268893, head/lib/libc/arm/aeabi/aeabi_unwind_exidx.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/lib/libc/arm/aeabi/aeabi_unwind_exidx.c Sun Aug 10 22:26:29 2014 (r269792, copy of r268893, head/lib/libc/arm/aeabi/aeabi_unwind_exidx.c) @@ -0,0 +1,104 @@ +/*- + * Copyright (c) 2014 Ian Lepore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +/* + * ARM EABI unwind helper. + * + * This finds the exidx section address and size associated with a given code + * address. There are separate implementations for static and dynamic code. + * + * GCC expects this function to exist as __gnu_Unwind_Find_exidx(), clang and + * BSD tools expect it to be dl_unwind_find_exidx(). Both have the same API, so + * we set up an alias for GCC. + */ +__strong_reference(dl_unwind_find_exidx, __gnu_Unwind_Find_exidx); + +/* + * Each entry in the exidx section is a pair of 32-bit words. We don't + * interpret the contents of the entries here; this typedef is just a local + * convenience for using sizeof() and doing pointer math. + */ +typedef struct exidx_entry { + uint32_t data[2]; +} exidx_entry; + +#ifdef __PIC__ + +/* + * Unwind helper for dynamically linked code. + * + * This finds the shared object that contains the given address, and returns the + * address of the exidx section in that shared object along with the number of + * entries in that section, or NULL if it wasn't found. + */ +void * +dl_unwind_find_exidx(const void *pc, int *pcount) +{ + const Elf_Phdr *hdr; + struct dl_phdr_info info; + int i; + + if (_rtld_addr_phdr(pc, &info)) { + hdr = info.dlpi_phdr; + for (i = 0; i < info.dlpi_phnum; i++, hdr++) { + if (hdr->p_type == PT_ARM_EXIDX) { + *pcount = hdr->p_memsz / sizeof(exidx_entry); + return ((void *)(info.dlpi_addr + hdr->p_vaddr)); + } + } + } + return (NULL); +} + +#else /* !__PIC__ */ + +/* + * Unwind helper for statically linked code. + * + * In a statically linked program, the linker populates a pair of symbols with + * the addresses of the start and end of the exidx table, so returning the + * address and count of elements is pretty straighforward. + */ +void * +dl_unwind_find_exidx(const void *pc, int *pcount) +{ + extern struct exidx_entry __exidx_start; + extern struct exidx_entry __exidx_end; + + *pcount = (int)(&__exidx_end - &__exidx_start); + return (&__exidx_start); +} + +#endif /* __PIC__ */ + Modified: stable/10/sys/arm/include/elf.h ============================================================================== --- stable/10/sys/arm/include/elf.h Sun Aug 10 22:24:14 2014 (r269791) +++ stable/10/sys/arm/include/elf.h Sun Aug 10 22:26:29 2014 (r269792) @@ -55,6 +55,9 @@ __ElfType(Auxinfo); #define ELF_MACHINE_OK(x) ((x) == EM_ARM) +/* Unwind info section type */ +#define PT_ARM_EXIDX (PT_LOPROC + 1) + /* * Relocation types. */ Modified: stable/10/sys/sys/link_elf.h ============================================================================== --- stable/10/sys/sys/link_elf.h Sun Aug 10 22:24:14 2014 (r269791) +++ stable/10/sys/sys/link_elf.h Sun Aug 10 22:26:29 2014 (r269792) @@ -95,6 +95,10 @@ extern int dl_iterate_phdr(__dl_iterate_ int _rtld_addr_phdr(const void *, struct dl_phdr_info *); int _rtld_get_stack_prot(void); +#ifdef __ARM_EABI__ +void * dl_unwind_find_exidx(const void *, int *); +#endif + __END_DECLS #endif /* _SYS_LINK_ELF_H_ */