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

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

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

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


    from cfc58d1  nxstyle: Add some unwind name to the white list
     new 159053a  sim/c++: correct the compile flags
     new f36bf5e  arch/sim: Avoid build nuttx.rel and cleanrel concurrently
     new 19aaf7b  arch/sim: Move the generation of nuttx-names.dat into nuttx target
     new dc55968  arch/sim: Don't construct global C++ objects before main

The 4 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:
 arch/sim/src/.gitignore              |  1 +
 arch/sim/src/Makefile                | 46 ++++++++++++++++++++++--------------
 boards/sim/sim/sim/scripts/Make.defs |  4 ----
 3 files changed, 29 insertions(+), 22 deletions(-)


[incubator-nuttx] 01/04: sim/c++: correct the compile flags

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

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

commit 159053ab629502b3db1dc5a14a2ba9c1fc450a77
Author: chao.an <an...@xiaomi.com>
AuthorDate: Fri May 8 20:10:45 2020 +0800

    sim/c++: correct the compile flags
    
    fix the following linker error:
    nuttx.rel:(.eh_frame+0x93): undefined reference to `__gxx_personality_v0'
    
    Change-Id: I94f43a15275194d42199c91f276e8848ad5189f6
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 arch/sim/src/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile
index abb9a9e..d6fdf23 100644
--- a/arch/sim/src/Makefile
+++ b/arch/sim/src/Makefile
@@ -292,7 +292,9 @@ endif
 
 nuttx$(EXEEXT): cleanrel nuttx.rel $(HOSTOBJS)
 	$(Q) echo "LD:  nuttx$(EXEEXT)"
-	$(Q) "$(CC)" $(CCLINKFLAGS) $(LIBPATHS) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(DRVLIB) $(STDLIBS)
+	$(if $(CONFIG_HAVE_CXX),\
+	$(Q) "$(CXX)" $(CCLINKFLAGS) $(LIBPATHS) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(DRVLIB) $(STDLIBS),\
+	$(Q) "$(CC)" $(CCLINKFLAGS) $(LIBPATHS) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(DRVLIB) $(STDLIBS))
 	$(Q) $(NM) $(TOPDIR)/$@ | \
 		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
 		sort > $(TOPDIR)/System.map


[incubator-nuttx] 04/04: arch/sim: Don't construct global C++ objects before main

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

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

commit dc559686783a97ebe6ff18210fd769440d9d4e3a
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Jul 10 01:20:18 2020 +0800

    arch/sim: Don't construct global C++ objects before main
    
    otherwise the crash will happen because NuttX doesn't initialize yet
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: Icc3f3fcd842a315bc68ae436d7a7a04aca1fc546
---
 arch/sim/src/.gitignore              |  1 +
 arch/sim/src/Makefile                | 21 +++++++++++++++++++--
 boards/sim/sim/sim/scripts/Make.defs |  4 ----
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/arch/sim/src/.gitignore b/arch/sim/src/.gitignore
index 0af52c2..685f699 100644
--- a/arch/sim/src/.gitignore
+++ b/arch/sim/src/.gitignore
@@ -1,4 +1,5 @@
 /nuttx-names.dat
+/nuttx.ld
 /hostfs.h
 /chip
 /board
diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile
index d460162..8dfe106 100644
--- a/arch/sim/src/Makefile
+++ b/arch/sim/src/Makefile
@@ -230,6 +230,7 @@ OBJS = $(AOBJS) $(COBJS) $(HOSTOBJS)
 ifeq ($(HOSTOS),Darwin)
   LDUNEXPORTSYMBOLS ?= -unexported_symbols_list nuttx-names.dat
 else
+  ARCHSCRIPT += -T nuttx.ld
   LDSTARTGROUP ?= --start-group
   LDENDGROUP ?= --end-group
 endif
@@ -279,16 +280,31 @@ board/libboard$(LIBEXT):
 # Generate the final NuttX binary by linking the host-specific objects with the NuttX
 # specific objects (with munged names)
 
+# C++ global objects are constructed before main get executed, but it isn't a good
+# point for simulator because NuttX doesn't finish the kernel initialization yet.
+# So we have to skip the standard facilities and do the construction by ourself.
+# But how to achieve the goal?
+# 1.Command linker generate the default script(-verbose)
+# 2.Replace __init_array_start/__init_array_end with _sinit/_einit
+# 3.Append __init_array_start = .; __init_array_end = .;
+# Step 2 let nxtask_startup find objects need to construct
+# Step 3 cheat the host there is no object to construct
+# Note: the destructor can be fixed in the same way.
+
 nuttx$(EXEEXT): libarch$(LIBEXT) board/libboard$(LIBEXT) $(LINKOBJS) $(HOSTOBJS)
 	$(Q) echo "LD:  nuttx$(EXEEXT)"
 	$(call PREPROCESS, nuttx-names.in, nuttx-names.dat)
 	$(Q) $(LD) -r $(LDLINKFLAGS) $(RELPATHS) $(EXTRA_LIBPATHS) -o nuttx.rel $(REQUIREDOBJS) $(LDSTARTGROUP) $(RELLIBS) $(EXTRA_LIBS) $(LDENDGROUP) $(LDUNEXPORTSYMBOLS)
 ifneq ($(HOSTOS),Darwin)
 	$(Q) $(OBJCOPY) --redefine-syms=nuttx-names.dat nuttx.rel
+	$(Q) $(CC) $(CCLINKFLAGS) -Wl,-verbose 2>&1 | \
+	     sed -e '/====/,/====/!d;//d' -e 's/__executable_start/_stext/g' -e 's/__init_array_start/_sinit/g' \
+	         -e 's/__init_array_end/_einit/g' -e 's/__fini_array_start/_sfini/g' -e 's/__fini_array_end/_efini/g' >nuttx.ld
+	$(Q) echo "__init_array_start = .; __init_array_end = .; __fini_array_start = .; __fini_array_end = .;" >>nuttx.ld
 endif
 	$(if $(CONFIG_HAVE_CXX),\
-	$(Q) "$(CXX)" $(CCLINKFLAGS) $(LIBPATHS) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(DRVLIB) $(STDLIBS),\
-	$(Q) "$(CC)" $(CCLINKFLAGS) $(LIBPATHS) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(DRVLIB) $(STDLIBS))
+	$(Q) "$(CXX)" $(CCLINKFLAGS) $(LIBPATHS) $(ARCHSCRIPT) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(DRVLIB) $(STDLIBS),\
+	$(Q) "$(CC)" $(CCLINKFLAGS) $(LIBPATHS) $(ARCHSCRIPT) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(DRVLIB) $(STDLIBS))
 	$(Q) $(NM) $(TOPDIR)/$@ | \
 		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
 		sort > $(TOPDIR)/System.map
@@ -315,6 +331,7 @@ clean:
 	$(Q) if [ -e board/Makefile ]; then \
 		$(MAKE) -C board TOPDIR="$(TOPDIR)" clean ; \
 	fi
+	$(call DELFILE, nuttx.ld)
 	$(call DELFILE, nuttx.rel)
 	$(call DELFILE, nuttx-names.dat)
 	$(call DELFILE, libarch$(LIBEXT))
diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs
index edf45c2..6f6e040 100644
--- a/boards/sim/sim/sim/scripts/Make.defs
+++ b/boards/sim/sim/sim/scripts/Make.defs
@@ -122,10 +122,6 @@ else
   LDELFFLAGS += -T $(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld
 endif
 
-LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD)
-CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC)
-LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS
-
 ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   CCLINKFLAGS += -g
 endif


[incubator-nuttx] 03/04: arch/sim: Move the generation of nuttx-names.dat into nuttx target

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

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

commit 19aaf7b357db906b106af6c9019026721ac72ad2
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Jul 10 12:00:56 2020 +0800

    arch/sim: Move the generation of nuttx-names.dat into nuttx target
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: I04c612a56caee170742b07f87cea1b7feb4078c5
---
 arch/sim/src/Makefile | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile
index 4042337..d460162 100644
--- a/arch/sim/src/Makefile
+++ b/arch/sim/src/Makefile
@@ -276,15 +276,12 @@ board/libboard$(LIBEXT):
 
 # A partially linked object containing only NuttX code (no interface to host OS)
 # Change the names of most symbols that conflict with libc symbols.
-
-nuttx-names.dat: nuttx-names.in
-	$(call PREPROCESS, $<, $@)
-
 # Generate the final NuttX binary by linking the host-specific objects with the NuttX
 # specific objects (with munged names)
 
-nuttx$(EXEEXT): libarch$(LIBEXT) board/libboard$(LIBEXT) nuttx-names.dat $(LINKOBJS) $(HOSTOBJS)
+nuttx$(EXEEXT): libarch$(LIBEXT) board/libboard$(LIBEXT) $(LINKOBJS) $(HOSTOBJS)
 	$(Q) echo "LD:  nuttx$(EXEEXT)"
+	$(call PREPROCESS, nuttx-names.in, nuttx-names.dat)
 	$(Q) $(LD) -r $(LDLINKFLAGS) $(RELPATHS) $(EXTRA_LIBPATHS) -o nuttx.rel $(REQUIREDOBJS) $(LDSTARTGROUP) $(RELLIBS) $(EXTRA_LIBS) $(LDENDGROUP) $(LDUNEXPORTSYMBOLS)
 ifneq ($(HOSTOS),Darwin)
 	$(Q) $(OBJCOPY) --redefine-syms=nuttx-names.dat nuttx.rel


[incubator-nuttx] 02/04: arch/sim: Avoid build nuttx.rel and cleanrel concurrently

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

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

commit f36bf5e07973e57cb3fb4015c63ce06c31fd9485
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Jul 9 13:57:30 2020 +0800

    arch/sim: Avoid build nuttx.rel and cleanrel concurrently
    
    make can't guarantee the build order of prerequest with -jn where n > 1
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: I772fcc0775d15b385f28fc0abeeff383b3a52622
---
 arch/sim/src/Makefile | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile
index d6fdf23..4042337 100644
--- a/arch/sim/src/Makefile
+++ b/arch/sim/src/Makefile
@@ -280,18 +280,15 @@ board/libboard$(LIBEXT):
 nuttx-names.dat: nuttx-names.in
 	$(call PREPROCESS, $<, $@)
 
-nuttx.rel: libarch$(LIBEXT) board/libboard$(LIBEXT) nuttx-names.dat $(LINKOBJS)
-	$(Q) echo "LD:  nuttx.rel"
-	$(Q) $(LD) -r $(LDLINKFLAGS) $(RELPATHS) $(EXTRA_LIBPATHS) -o $@ $(REQUIREDOBJS) $(LDSTARTGROUP) $(RELLIBS) $(EXTRA_LIBS) $(LDENDGROUP) $(LDUNEXPORTSYMBOLS)
-ifneq ($(HOSTOS),Darwin)
-	$(Q) $(OBJCOPY) --redefine-syms=nuttx-names.dat $@
-endif
-
 # Generate the final NuttX binary by linking the host-specific objects with the NuttX
 # specific objects (with munged names)
 
-nuttx$(EXEEXT): cleanrel nuttx.rel $(HOSTOBJS)
+nuttx$(EXEEXT): libarch$(LIBEXT) board/libboard$(LIBEXT) nuttx-names.dat $(LINKOBJS) $(HOSTOBJS)
 	$(Q) echo "LD:  nuttx$(EXEEXT)"
+	$(Q) $(LD) -r $(LDLINKFLAGS) $(RELPATHS) $(EXTRA_LIBPATHS) -o nuttx.rel $(REQUIREDOBJS) $(LDSTARTGROUP) $(RELLIBS) $(EXTRA_LIBS) $(LDENDGROUP) $(LDUNEXPORTSYMBOLS)
+ifneq ($(HOSTOS),Darwin)
+	$(Q) $(OBJCOPY) --redefine-syms=nuttx-names.dat nuttx.rel
+endif
 	$(if $(CONFIG_HAVE_CXX),\
 	$(Q) "$(CXX)" $(CCLINKFLAGS) $(LIBPATHS) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(DRVLIB) $(STDLIBS),\
 	$(Q) "$(CC)" $(CCLINKFLAGS) $(LIBPATHS) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(DRVLIB) $(STDLIBS))
@@ -317,15 +314,12 @@ export_startup: board/libboard$(LIBEXT) up_head.o $(HOSTOBJS)
 
 depend: .depend
 
-cleanrel:
-	$(call DELFILE, nuttx-names.dat)
-	$(call DELFILE, nuttx.rel)
-
-clean: cleanrel
+clean:
 	$(Q) if [ -e board/Makefile ]; then \
 		$(MAKE) -C board TOPDIR="$(TOPDIR)" clean ; \
 	fi
 	$(call DELFILE, nuttx.rel)
+	$(call DELFILE, nuttx-names.dat)
 	$(call DELFILE, libarch$(LIBEXT))
 	$(call CLEAN)