Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions arch/sim/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,8 @@ endif

# Override in Make.defs if linker is not 'ld'

ifeq ($(HOSTOS),Darwin)
LDSTARTGROUP ?=
LDENDGROUP ?=
LDUNEXPORTSYMBOLS ?= -unexported_symbols_list $(HOSTOS)-names.dat
else
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
LDUNEXPORTSYMBOLS ?=
endif
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group

EXTRA_LIBS ?=
EXTRA_LIBPATHS ?=
Expand Down Expand Up @@ -299,15 +292,10 @@ else
$(Q) cp nuttx-names.dat $@
endif

Darwin-names.dat: nuttx-names.dat
$(Q) cat $^ | sed -e "s/^\([^[:space:]][^[:space:]]*\)[[:space:]].*/_\1/g" >$@

nuttx.rel : libarch$(LIBEXT) board/libboard$(LIBEXT) $(HOSTOS)-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) $(LD) -r $(LDLINKFLAGS) $(RELPATHS) $(EXTRA_LIBPATHS) -o $@ $(REQUIREDOBJS) $(LDSTARTGROUP) $(RELLIBS) $(EXTRA_LIBS) $(LDENDGROUP)
$(Q) $(OBJCOPY) --redefine-syms=$(HOSTOS)-names.dat $@
endif

# Generate the final NuttX binary by linking the host-specific objects with the NuttX
# specific objects (with munged names)
Expand All @@ -318,6 +306,7 @@ nuttx$(EXEEXT): cleanrel nuttx.rel $(HOSTOBJS)
$(Q) $(NM) $(TOPDIR)/$@ | \
grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
sort > $(TOPDIR)/System.map
$(Q) rm -f nuttx.rel

# This is part of the top-level export target

Expand All @@ -338,7 +327,7 @@ export_startup: board/libboard$(LIBEXT) up_head.o $(HOSTOBJS)
depend: .depend

cleanrel:
$(Q) rm -f nuttx.rel $(HOSTOS)-names.dat
$(Q) rm -f nuttx.rel GNU/Linux-names.dat Cygwin-names.dat

clean: cleanrel
$(Q) if [ -e board/Makefile ]; then \
Expand Down
2 changes: 1 addition & 1 deletion arch/sim/src/sim/up_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@
void up_initial_state(struct tcb_s *tcb)
{
memset(&tcb->xcp, 0, sizeof(struct xcptcontext));
tcb->xcp.regs[JB_SP] = (xcpt_reg_t)tcb->adj_stack_ptr - sizeof(xcpt_reg_t);
tcb->xcp.regs[JB_SP] = (xcpt_reg_t)tcb->adj_stack_ptr;
tcb->xcp.regs[JB_PC] = (xcpt_reg_t)tcb->start;
}
12 changes: 4 additions & 8 deletions arch/sim/src/sim/up_setjmp32.S
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,16 @@
#ifdef __CYGWIN__
# define SYMBOL(s) _##s
#else
#ifdef __ELF__
# define SYMBOL(s) _##s
#else
# define SYMBOL(s) s
#endif
#endif

/**************************************************************************
* Public Functions
**************************************************************************/

.text
.globl SYMBOL(up_setjmp)
#ifdef __ELF__
#ifndef __CYGWIN__
.type SYMBOL(up_setjmp), @function
#endif
SYMBOL(up_setjmp):
Expand Down Expand Up @@ -90,11 +86,11 @@ SYMBOL(up_setjmp):

xorl %eax, %eax
ret
#ifdef __ELF__
#ifndef __CYGWIN__
.size SYMBOL(up_setjmp), . - SYMBOL(up_setjmp)
#endif
.globl SYMBOL(up_longjmp)
#ifdef __ELF__
#ifndef __CYGWIN__
.type SYMBOL(up_longjmp), @function
#endif
SYMBOL(up_longjmp):
Expand All @@ -116,7 +112,7 @@ SYMBOL(up_longjmp):
/* Jump to saved PC. */

jmp *%edx
#ifdef __ELF__
#ifndef __CYGWIN__
.size SYMBOL(up_longjmp), . - SYMBOL(up_longjmp)
#endif

12 changes: 4 additions & 8 deletions arch/sim/src/sim/up_setjmp64.S
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@
//# define SYMBOL(s) _##s
# define SYMBOL(s) s
#else
#ifdef __ELF__
# define SYMBOL(s) s
#else
# define SYMBOL(s) _##s
#endif
#endif

/**************************************************************************
Expand All @@ -95,7 +91,7 @@
.text
.align 4
.globl SYMBOL(up_setjmp)
#ifdef __ELF__
#ifndef __CYGWIN__
.type SYMBOL(up_setjmp), @function
#endif
SYMBOL(up_setjmp):
Expand Down Expand Up @@ -132,13 +128,13 @@ SYMBOL(up_setjmp):

ret

#ifdef __ELF__
#ifndef __CYGWIN__
.size SYMBOL(up_setjmp), . - SYMBOL(up_setjmp)
#endif

.align 4
.globl SYMBOL(up_longjmp)
#ifdef __ELF__
#ifndef __CYGWIN__
.type SYMBOL(up_longjmp), @function
#endif
SYMBOL(up_longjmp):
Expand All @@ -161,7 +157,7 @@ SYMBOL(up_longjmp):

jmp *JB_RSI(REGS) /* Save 8: rsi */

#ifdef __ELF__
#ifndef __CYGWIN__
.size SYMBOL(up_longjmp), . - SYMBOL(up_longjmp)
#endif

2 changes: 1 addition & 1 deletion arch/sim/src/sim/up_stackframe.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)

/* Reset the initial state */

tcb->xcp.regs[JB_SP] = (xcpt_reg_t)tcb->adj_stack_ptr - sizeof(xcpt_reg_t);
tcb->xcp.regs[JB_SP] = (xcpt_reg_t)tcb->adj_stack_ptr;

/* And return a pointer to the allocated memory */

Expand Down
2 changes: 1 addition & 1 deletion binfmt/binfmt_globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
* protection to simply disable pre-emption when accessing this list.
*/

FAR struct binfmt_s *g_binfmts = NULL;
FAR struct binfmt_s *g_binfmts;

/****************************************************************************
* Private Functions
Expand Down
19 changes: 2 additions & 17 deletions boards/sim/sim/sim/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ The simulation build is a two pass build:
created called nuttx.rel. This includes all of the files that are part
of the NuttX "domain."

2. On the second pass, the files which are in the host OS domain are build
2. On the second pass, the files are are in the host OS domain are build
and then linked with nuttx.rel to generate the simulation program.

NuttX is a POSIX compliant RTOS and is normally build on a POSIX compliant
host environment (like Linux or Cygwin). As a result, the same symbols are
exported by both the NuttX domain and the host domain. How can we keep them
exported by both the NuttX doman and the host domain. How can we keep them
separate?

This is done using the special file nuttx-name.dat. This file just contains
Expand All @@ -181,10 +181,6 @@ which version of strlen() you call. Other times, it can cause subtle,
mysterious errors. Usually, however, callng the wrong function in the wrong
OS results in a fatal crash.

On macOS, instead of objcopy, -unexported_symbols_list linker option is
used to hide symbols in the NuttX domain, using the same list of symbols
from nuttx-name.dat.

Networking Issues
-----------------
I never did get networking to work on the sim target. It tries to use the
Expand Down Expand Up @@ -491,17 +487,6 @@ Common Configuration Information
CONFIG_SIM_X8664_SYSTEMV=n
CONFIG_SIM_M32=n

g. macOS, 64-bit, 64-bit build

CONFIG_HOST_LINUX=n
CONFIG_HOST_MACOS=y
CONFIG_HOST_WINDOWS=n
CONFIG_HOST_X86=n
CONFIG_HOST_X86_64=y
CONFIG_SIM_X8664_MICROSOFT=n
CONFIG_SIM_X8664_SYSTEMV=y
CONFIG_SIM_M32=n

Configuration Sub-Directories
-----------------------------

Expand Down
4 changes: 3 additions & 1 deletion boards/sim/sim/sim/configs/cxxtest/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk

HOSTOS = ${shell uname -o 2>/dev/null || uname -s 2>/dev/null || echo "Other"}
HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"}

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
Expand Down Expand Up @@ -116,7 +116,9 @@ EXTRA_LIBPATHS = -L "${shell dirname "$(LIBSUPXX)"}"
EXTRA_LIBS = -lsupc++

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDLINKFLAGS += -g
CCLINKFLAGS += -g
LDFLAGS += -g
endif

ifeq ($(CONFIG_SIM_M32),y)
Expand Down
4 changes: 3 additions & 1 deletion boards/sim/sim/sim/configs/nsh2/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk

HOSTOS = ${shell uname -o 2>/dev/null || uname -s 2>/dev/null || echo "Other"}
HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"}

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
Expand Down Expand Up @@ -108,7 +108,9 @@ CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC)
LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDLINKFLAGS += -g
CCLINKFLAGS += -g
LDFLAGS += -g
endif

ifeq ($(CONFIG_SIM_M32),y)
Expand Down
4 changes: 3 additions & 1 deletion boards/sim/sim/sim/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk

HOSTOS = ${shell uname -o 2>/dev/null || uname -s 2>/dev/null || echo "Other"}
HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"}

ifeq ($(CONFIG_WINDOWS_MSYS),y)
DIRLINK = $(TOPDIR)/tools/copydir.sh
Expand Down Expand Up @@ -115,7 +115,9 @@ CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC)
LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDLINKFLAGS += -g
CCLINKFLAGS += -g
LDFLAGS += -g
endif

ifeq ($(CONFIG_SIM_M32),y)
Expand Down
4 changes: 1 addition & 3 deletions boards/sim/sim/sim/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@

include $(TOPDIR)/Make.defs

# Add dummy.c to ensure that we have at least one object.
# On some platforms like macOS, we can't create an empty archive.
ASRCS =
CSRCS = dummy.c
CSRCS =

ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
CSRCS += sim_boot.c
Expand Down
Empty file removed boards/sim/sim/sim/src/dummy.c
Empty file.
2 changes: 1 addition & 1 deletion boards/x86/qemu/qemu-i486/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk

HOSTOS = ${shell uname -o 2>/dev/null || uname -s 2>/dev/null || echo "Other"}
HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"}

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
Expand Down
2 changes: 1 addition & 1 deletion mm/umm_heap/umm_globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@
#else
/* Otherwise, the user heap data structures are in common .bss */

struct mm_heap_s g_mmheap = {};
struct mm_heap_s g_mmheap;
#endif
2 changes: 1 addition & 1 deletion tools/Makefile.host
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ include ${TOPDIR}/tools/Config.mk
# Define HOSTCC on the make command line if it differs from these defaults
# Define HOSTCFLAGS with -g on the make command line to build debug versions

HOSTOS = ${shell uname -o 2>/dev/null || uname -s 2>/dev/null || echo "Other"}
HOSTOS = ${shell uname -o || echo "Other"}

ifeq ($(HOSTOS),MinGW)

Expand Down
4 changes: 2 additions & 2 deletions tools/sethost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ echo " Refreshing..."
cd $nuttx || { echo "ERROR: failed to cd to $nuttx"; exit 1; }
make clean_context 1>/dev/null 2>&1
if [ "X${debug}" = "Xy" ]; then
make olddefconfig V=1 || { echo "ERROR: failed to refresh"; exit 1; }
make olddefconfig V=1
else
make olddefconfig 1>/dev/null || { echo "ERROR: failed to refresh"; exit 1; }
make olddefconfig 1>/dev/null 2>&1
fi

# Move config file to correct location and restore any previous .config
Expand Down