From patchwork Wed Jul 4 15:55:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 939448 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=st.com Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41LQfw2PQZz9s4c for ; Thu, 5 Jul 2018 01:59:52 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id DCA6410002; Wed, 4 Jul 2018 17:59:49 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by helium.openadk.org (Postfix) with ESMTPS id A645510002 for ; Wed, 4 Jul 2018 17:59:48 +0200 (CEST) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w64FsB9U004098; Wed, 4 Jul 2018 17:59:47 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2k0dnwvrb8-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 04 Jul 2018 17:59:47 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 33E0031; Wed, 4 Jul 2018 15:59:46 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E6FF8557C; Wed, 4 Jul 2018 15:59:45 +0000 (GMT) Received: from gnb.st.com (10.75.127.44) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 4 Jul 2018 17:59:45 +0200 From: Christophe Lyon To: , Date: Wed, 4 Jul 2018 17:55:22 +0200 Message-ID: <20180704155605.1892-10-christophe.lyon@st.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180704155605.1892-1-christophe.lyon@st.com> References: <20180704155605.1892-1-christophe.lyon@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG6NODE2.st.com (10.75.127.17) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-04_05:, , signatures=0 Subject: [uclibc-ng-devel] [PATCH 09/32] [ARM][FDPIC] Add runtime support needed for C++ exceptions X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" Implements __gnu_Unwind_Find_got(), which is called from libgcc while unwinding. * libc/sysdeps/linux/arm/Makefile.arch (CSRC): Add find._got.c. * libc/sysdeps/linux/arm/find_got.c: New file. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/libc/sysdeps/linux/arm/Makefile.arch b/libc/sysdeps/linux/arm/Makefile.arch index f9ac88b..40a0184 100644 --- a/libc/sysdeps/linux/arm/Makefile.arch +++ b/libc/sysdeps/linux/arm/Makefile.arch @@ -23,7 +23,7 @@ $(eval $(call cache-output-var,IS_EABI,$(CC_IS_EABI_CHECK) -x c - -E -dM . */ + +#include +#include + +#if __FDPIC__ +#include + +struct got_callback_data +{ + _Unwind_Ptr pc; + _Unwind_Ptr got; +}; + +static __always_inline int +__dl_addr_in_loadaddr(void *p, struct elf32_fdpic_loadaddr loadaddr) +{ + struct elf32_fdpic_loadmap *map = loadaddr.map; + int c; + + for (c = 0; c < map->nsegs; c++) + if ((void *)map->segs[c].addr <= p && + (char *)p < (char *)map->segs[c].addr + map->segs[c].p_memsz) + return 1; + + return 0; +} + +/* Callback to return the GOT value if the module contains PC. */ +static int +find_got_callback (struct dl_phdr_info * info, size_t size, void * ptr) +{ + int match = 0; + struct got_callback_data *data = (struct got_callback_data *) ptr; + + if (__dl_addr_in_loadaddr((void *) data->pc, info->dlpi_addr)) { + match = 1; + data->got = (_Unwind_Ptr) info->dlpi_addr.got_value; + } + + return match; +} + +/* Find the GOT that corresponds to the module containing PC. */ +_Unwind_Ptr __gnu_Unwind_Find_got (_Unwind_Ptr pc); +_Unwind_Ptr __gnu_Unwind_Find_got (_Unwind_Ptr pc) +{ + struct got_callback_data data; + + data.pc = pc; + if (dl_iterate_phdr (find_got_callback, &data) <= 0) + return 0; + + return data.got; +} +#endif +