You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by da...@apache.org on 2020/07/11 17:34:34 UTC

[incubator-nuttx] branch master updated (9dff16e -> cfc58d1)

This is an automated email from the ASF dual-hosted git repository.

davids5 pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 9dff16e  fix nxstyle warning
     new fbfd9d6  libelf: Parse .ARM.exidx only for ARM architecture
     new aa0d57e  libc: Move unwind code to libs/libc/machine/arm
     new cfc58d1  nxstyle: Add some unwind name to the white list

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 binfmt/libelf/Kconfig                              |   2 +-
 binfmt/libelf/libelf_load.c                        |   2 +-
 libs/libc/machine/arm/Make.defs                    |   7 ++
 .../arm/gnu_unwind_find_exidx.c}                   |  92 ++++++++++--------
 libs/libxx/Makefile                                |   3 -
 libs/libxx/libxx__gnu_unwind_find_exidx.cxx        | 108 ---------------------
 libs/libxx/libxx__gnu_unwind_find_exidx.hxx        |  79 ---------------
 tools/nxstyle.c                                    |   5 +-
 8 files changed, 66 insertions(+), 232 deletions(-)
 copy libs/libc/{time/lib_dayofweek.c => machine/arm/gnu_unwind_find_exidx.c} (58%)
 delete mode 100644 libs/libxx/libxx__gnu_unwind_find_exidx.cxx
 delete mode 100644 libs/libxx/libxx__gnu_unwind_find_exidx.hxx


[incubator-nuttx] 02/03: libc: Move unwind code to libs/libc/machine/arm

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit aa0d57e8adc1b6dfdbe4cc61607c494cf0072764
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Jun 28 18:18:34 2020 +0800

    libc: Move unwind code to libs/libc/machine/arm
    
    because the logic:
    1.only work on arm platform
    2.couple with elf format
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: I25dc95b5fc7b24196e2e71fdcf82d71d621ee2d3
---
 libs/libc/machine/arm/Make.defs               |   7 ++
 libs/libc/machine/arm/gnu_unwind_find_exidx.c | 121 ++++++++++++++++++++++++++
 libs/libxx/Makefile                           |   3 -
 libs/libxx/libxx__gnu_unwind_find_exidx.cxx   | 108 -----------------------
 libs/libxx/libxx__gnu_unwind_find_exidx.hxx   |  79 -----------------
 5 files changed, 128 insertions(+), 190 deletions(-)

diff --git a/libs/libc/machine/arm/Make.defs b/libs/libc/machine/arm/Make.defs
index 5f8cd9e..0afb80c 100644
--- a/libs/libc/machine/arm/Make.defs
+++ b/libs/libc/machine/arm/Make.defs
@@ -50,3 +50,10 @@ include $(TOPDIR)/libs/libc/machine/arm/armv7-m/Make.defs
 else ifeq ($(CONFIG_ARCH_CORTEXM33),y)  # Cortex-M33 is ARMv8-M
 include $(TOPDIR)/libs/libc/machine/arm/armv8/Make.defs
 endif
+
+ifeq ($(CONFIG_CXX_EXCEPTION),y)
+CSRCS += gnu_unwind_find_exidx.c
+endif
+
+DEPPATH += --dep-path machine/arm
+VPATH += :machine/arm
diff --git a/libs/libc/machine/arm/gnu_unwind_find_exidx.c b/libs/libc/machine/arm/gnu_unwind_find_exidx.c
new file mode 100644
index 0000000..449208c
--- /dev/null
+++ b/libs/libc/machine/arm/gnu_unwind_find_exidx.c
@@ -0,0 +1,121 @@
+/****************************************************************************
+ * libs/libc/machine/arm/gnu_unwind_find_exidx.c
+ *
+ *   Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ *   Author: Gregory Nutt <gn...@nuttx.org>
+ *
+ * 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.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT OWNER 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/elf.h>
+#include <unwind.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+typedef struct __EIT_entry
+{
+  _uw fnoffset;
+  _uw content;
+} __EIT_entry;
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static __EIT_entry *__exidx_start_elf;
+static __EIT_entry *__exidx_end_elf;
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+extern __EIT_entry __exidx_start;
+extern __EIT_entry __exidx_end;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name:  __gnu_Unwind_Find_exidx
+ *
+ * Description:
+ *    This function is called (if exists) by the gcc generated unwind
+ *    run-time in order to retrieve an alternative .ARM.exidx Exception
+ *    index section.
+ *    This is the case for an ELF module loaded by the elf binary loader.
+ *    It is needed to support exception handling for loadable ELF modules.
+ *
+ *    NOTES:
+ *
+ *     1. The section to be searched is chosen by the address of the calling
+ *        site: if we are in a runtime loaded ELF, the code will be executed
+ *        in ram ( > 0x20000000 ) otherwise we will  be executing code  from
+ *        flash (0x08000000) (running nuttx from ram will break this logic)
+ *
+ *     2. __exidx_start  and  __exidx_end refers to main nuttx elf image and
+ *        are defined in its linker script.
+ *
+ *     2. __exidx_start_elf  and  __exidx_end_elf refers  to the elf module
+ *        loaded by the elf binary loader, and are initialized at run-time.
+ *
+ *     3. TODO: if nuttx itself is running from ram, this logic will not work
+ *
+ *     4. TODO: in order to support multiple elf modules running at the same
+ *        time, this error logic needs to be extended to store multiple
+ *        start/end ranges that refers to the loaded binaries.
+ *
+ ****************************************************************************/
+
+int up_init_exidx(Elf_Addr start, Elf_Word size)
+{
+  __exidx_start_elf = (__EIT_entry *)start;
+  __exidx_end_elf   = (__EIT_entry *)(start + size);
+  return 0;
+}
+
+_Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr return_address, int *nrecp)
+{
+  if (return_address < 0x20000000)
+    {
+      *nrecp = &__exidx_end - &__exidx_start;
+      return (_Unwind_Ptr)&__exidx_start;
+    }
+  else
+    {
+      *nrecp = __exidx_end_elf - __exidx_start_elf;
+      return (_Unwind_Ptr)__exidx_start_elf;
+    }
+}
diff --git a/libs/libxx/Makefile b/libs/libxx/Makefile
index 149b4b3..423e659 100644
--- a/libs/libxx/Makefile
+++ b/libs/libxx/Makefile
@@ -37,9 +37,6 @@ include $(TOPDIR)/Make.defs
 
 CXXSRCS  = libxx_cxapurevirtual.cxx libxx_eabi_atexit.cxx libxx_cxa_atexit.cxx
 CXXSRCS += libxx_cxa_guard.cxx
-ifeq ($(CONFIG_CXX_EXCEPTION),y)
-CXXSRCS += libxx__gnu_unwind_find_exidx.cxx
-endif
 
 # Some of the libs/libxx/ files are not need if uClibc++ or libcxx is installed
 # because uClibx++ or libcxx will replace them
diff --git a/libs/libxx/libxx__gnu_unwind_find_exidx.cxx b/libs/libxx/libxx__gnu_unwind_find_exidx.cxx
deleted file mode 100644
index 08b67fa..0000000
--- a/libs/libxx/libxx__gnu_unwind_find_exidx.cxx
+++ /dev/null
@@ -1,108 +0,0 @@
-//***************************************************************************
-// libs/libxx/libxx__gnu_unwind_find_exidx.cxx
-//
-//   Copyright (C) 2015 Gregory Nutt. All rights reserved.
-//   Author: Gregory Nutt <gn...@nuttx.org>
-//
-// 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.
-// 3. Neither the name NuttX nor the names of its contributors may be
-//    used to endorse or promote products derived from this software
-//    without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
-// COPYRIGHT OWNER 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.
-//
-//***************************************************************************
-
-//***************************************************************************
-// Included Files
-//***************************************************************************
-
-#include <nuttx/elf.h>
-#include "libxx__gnu_unwind_find_exidx.hxx"
-
-//***************************************************************************
-// Pre-processor Definitions
-//***************************************************************************
-
-//***************************************************************************
-// Private Data
-//***************************************************************************
-
-//***************************************************************************
-// Operators
-//***************************************************************************
-
-//***************************************************************************
-// Name:  __gnu_Unwind_Find_exidx
-//
-// Description:
-//    This function is called (if exists) by the gcc generated unwind
-//    run-time in order to retrieve an alternative .ARM.exidx Exception
-//    index section.
-//    This is the case for an ELF module loaded by the elf binary loader.
-//    It is needed to support exception handling for loadable ELF modules.
-//
-//    NOTES:
-//
-//     1. The section to be searched is chosen by the address of the calling
-//        site: if we are in a runtime loaded ELF, the code will be executed
-//        in ram ( > 0x20000000 ) otherwise we will  be executing code  from
-//        flash (0x08000000) (running nuttx from ram will break this logic)
-//
-//     2. __exidx_start  and  __exidx_end refers to main nuttx elf image and
-//        are defined in its linker script.
-//
-//     2. __exidx_start_elf  and  __exidx_end_elf refers  to the elf module
-//        loaded by the elf binary loader, and are initialized at run-time.
-//
-//     3. TODO: if nuttx itself is running from ram, this logic will not work
-//
-//     4. TODO: in order to support multiple elf modules running at the same
-//        time, this error logic needs to be extended to store multiple
-//        start/end ranges that refers to the loaded binaries.
-//
-//***************************************************************************
-
-extern "C"
-{
-  int up_init_exidx(Elf_Addr start, Elf_Word size)
-  {
-    __exidx_start_elf = (__EIT_entry *) start;
-    __exidx_end_elf   = __exidx_start_elf + size;
-    return 0;
-  }
-
-  _Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr return_address, int *nrecp)
-  {
-    if (return_address < 0x20000000)
-      {
-        *nrecp = &__exidx_end - &__exidx_start;
-        return (_Unwind_Ptr) &__exidx_start;
-      }
-    else
-      {
-        *nrecp = (__exidx_end_elf - __exidx_start_elf) / sizeof(__EIT_entry);
-        return (_Unwind_Ptr) __exidx_start_elf;
-      }
-  }
-}
diff --git a/libs/libxx/libxx__gnu_unwind_find_exidx.hxx b/libs/libxx/libxx__gnu_unwind_find_exidx.hxx
deleted file mode 100644
index 63925b0..0000000
--- a/libs/libxx/libxx__gnu_unwind_find_exidx.hxx
+++ /dev/null
@@ -1,79 +0,0 @@
-//***************************************************************************
-// lib/libxx__gnu_unwind_find_exidx.hxx
-//
-//   Copyright (C) 2015 Gregory Nutt. All rights reserved.
-//   Author: Gregory Nutt <gn...@nuttx.org>
-//
-// 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.
-// 3. Neither the name NuttX nor the names of its contributors may be
-//    used to endorse or promote products derived from this software
-//    without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
-// COPYRIGHT OWNER 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.
-//
-//***************************************************************************
-
-#ifndef __LIBXX_LIBXX__GNU_UNWIND_FIND_EXIDX_HXX
-#define __LIBXX_LIBXX__GNU_UNWIND_FIND_EXIDX_HXX
-
-extern "C"
-{
-//***************************************************************************
-// Included Files
-//***************************************************************************
-
-#include <unwind.h>
-
-//***************************************************************************
-// Pre-processor Definitions
-//***************************************************************************
-
-//***************************************************************************
-// Public Types
-//***************************************************************************/
-
-typedef struct __EIT_entry
-{
-  _uw fnoffset;
-  _uw content;
-} __EIT_entry;
-
-//***************************************************************************
-// Public Data
-//***************************************************************************
-
-extern __EIT_entry __exidx_start;
-extern __EIT_entry __exidx_end;
-
-__EIT_entry *__exidx_start_elf;
-__EIT_entry *__exidx_end_elf;
-
-//***************************************************************************
-// Public Function Prototypes
-//***************************************************************************
-
- _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr return_address, int *nrecp);
-
-} // extern "C"
-
-#endif // __LIBXX__GNU_UNWIND_FIND_EXIDX_HXX


[incubator-nuttx] 03/03: nxstyle: Add some unwind name to the white list

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit cfc58d1913619a070c114bec4dd80d282efee3fb
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Jul 2 19:50:50 2020 +0800

    nxstyle: Add some unwind name to the white list
    
    we can't change the case because it is defined by ARM
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 tools/nxstyle.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index 9a3a471..7e9136b 100644
--- a/tools/nxstyle.c
+++ b/tools/nxstyle.c
@@ -197,7 +197,10 @@ static const char *g_white_prefix[] =
 
 static const char *g_white_list[] =
 {
-  "_Exit",   /* Ref:  stdlib.h */
+  "__EIT_entry",             /* Ref:  gnu_unwind_find_exidx.c */
+  "__gnu_Unwind_Find_exidx", /* Ref:  gnu_unwind_find_exidx.c */
+  "_Exit",                   /* Ref:  stdlib.h */
+  "_Unwind_Ptr",             /* Ref:  unwind-arm-common.h */
   NULL
 };
 


[incubator-nuttx] 01/03: libelf: Parse .ARM.exidx only for ARM architecture

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit fbfd9d62da045f1b566029828093ef8554175850
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Jun 28 18:18:53 2020 +0800

    libelf: Parse .ARM.exidx only for ARM architecture
    
    since other arch has the different unwind approach
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: Icefa0d4bc31bff967372949216d337770cd7e768
---
 binfmt/libelf/Kconfig       | 2 +-
 binfmt/libelf/libelf_load.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/binfmt/libelf/Kconfig b/binfmt/libelf/Kconfig
index 859ae66..ff91164 100644
--- a/binfmt/libelf/Kconfig
+++ b/binfmt/libelf/Kconfig
@@ -42,7 +42,7 @@ config ELF_DUMPBUFFER
 config ELF_EXIDX_SECTNAME
 	string "ELF Section Name for Exception Index"
 	default ".ARM.exidx"
-	depends on CXX_EXCEPTION
+	depends on CXX_EXCEPTION && ARCH_ARM
 	---help---
 		Set the name string for the exception index section on the ELF modules to
 		be loaded by the ELF binary loader.
diff --git a/binfmt/libelf/libelf_load.c b/binfmt/libelf/libelf_load.c
index 5eaf8d3..0b73aa5 100644
--- a/binfmt/libelf/libelf_load.c
+++ b/binfmt/libelf/libelf_load.c
@@ -342,7 +342,7 @@ int elf_load(FAR struct elf_loadinfo_s *loadinfo)
     }
 #endif
 
-#ifdef CONFIG_CXX_EXCEPTION
+#ifdef CONFIG_ELF_EXIDX_SECTNAME
   exidx = elf_findsection(loadinfo, CONFIG_ELF_EXIDX_SECTNAME);
   if (exidx < 0)
     {