arch/sim: add all symbols support
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
99ba405535
commit
ba2cb65a91
@ -31,6 +31,8 @@ CFLAGS += $(INCLUDES)
|
||||
CXXFLAGS += $(INCLUDES)
|
||||
AFLAGS += $(INCLUDES)
|
||||
|
||||
NUTTX = $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx$(EXEEXT))
|
||||
|
||||
# Determine which objects are required in the link.The
|
||||
# up_head object normally draws in all that is needed, but
|
||||
# there are a fews that must be included because they
|
||||
@ -294,6 +296,17 @@ board/libboard$(LIBEXT):
|
||||
nuttx-names.dat: nuttx-names.in
|
||||
$(call PREPROCESS, nuttx-names.in, nuttx-names.dat)
|
||||
|
||||
define LINK_ALLSYMS
|
||||
$(Q) $(TOPDIR)/tools/mkallsyms.sh noconst $(NUTTX) $(CROSSDEV) > allsyms.tmp
|
||||
$(Q) $(call COMPILE, -x c allsyms.tmp, allsyms$(OBJEXT))
|
||||
$(if $(CONFIG_HAVE_CXX),\
|
||||
$(Q) "$(CXX)" $(CFLAGS) $(LDFLAGS) -o $(NUTTX) \
|
||||
$(HEADOBJ) nuttx.rel $(HOSTOBJS) $(STDLIBS) allsyms$(OBJEXT),\
|
||||
$(Q) "$(CC)" $(CFLAGS) $(LDFLAGS) -o $(NUTTX) \
|
||||
$(HEADOBJ) nuttx.rel $(HOSTOBJS) $(STDLIBS) allsyms$(OBJEXT))
|
||||
$(Q) $(call DELFILE, allsyms.tmp allsyms$(OBJEXT))
|
||||
endef
|
||||
|
||||
# Note: Use objcopy for Linux because for some reasons visibility=hidden
|
||||
# stuff doesn't work there as we expect.
|
||||
# Note: _stext stuff is for CONFIG_CXX_INITIALIZE_SINIT, which in not
|
||||
@ -309,9 +322,18 @@ ifneq ($(CONFIG_HOST_MACOS),y)
|
||||
-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
|
||||
ifneq ($(CONFIG_ALLSYMS),y)
|
||||
$(if $(CONFIG_HAVE_CXX),\
|
||||
$(Q) "$(CXX)" $(CFLAGS) $(LDFLAGS) -o $(TOPDIR)/$@ $(HEADOBJ) nuttx.rel $(HOSTOBJS) $(STDLIBS),\
|
||||
$(Q) "$(CC)" $(CFLAGS) $(LDFLAGS) -o $(TOPDIR)/$@ $(HEADOBJ) nuttx.rel $(HOSTOBJS) $(STDLIBS))
|
||||
else
|
||||
$(Q) # Link and generate default table
|
||||
$(Q) $(if $(wildcard $(shell echo $(NUTTX))),,$(call LINK_ALLSYMS, $@))
|
||||
$(Q) # Extract all symbols
|
||||
$(Q) $(call LINK_ALLSYMS, $^)
|
||||
$(Q) # Extract again since the table offset may changed
|
||||
$(Q) $(call LINK_ALLSYMS, $^)
|
||||
endif
|
||||
$(Q) $(NM) $(TOPDIR)/$@ | \
|
||||
grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
|
||||
sort > $(TOPDIR)/System.map
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <nuttx/init.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/symtab.h>
|
||||
#include <nuttx/syslog/syslog_rpmsg.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
@ -52,6 +53,46 @@ char **g_argv;
|
||||
static char g_logbuffer[4096];
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ALLSYMS
|
||||
extern struct symtab_s g_allsyms[];
|
||||
extern int g_nallsyms;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: allsyms_relocate
|
||||
*
|
||||
* Description:
|
||||
* Simple relocate to redirect the address from symbol table.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ALLSYMS
|
||||
static void allsyms_relocate(void)
|
||||
{
|
||||
uintptr_t offset;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < g_nallsyms; i++)
|
||||
{
|
||||
if (strcmp("allsyms_relocate", g_allsyms[i].sym_name) == 0)
|
||||
{
|
||||
offset = (uintptr_t)allsyms_relocate -
|
||||
(uintptr_t)g_allsyms[i].sym_value;
|
||||
for (i = 0; i < g_nallsyms; i++)
|
||||
{
|
||||
g_allsyms[i].sym_value =
|
||||
(void *)((uintptr_t)g_allsyms[i].sym_value + offset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -70,6 +111,10 @@ int main(int argc, char **argv, char **envp)
|
||||
g_argc = argc;
|
||||
g_argv = argv;
|
||||
|
||||
#ifdef CONFIG_ALLSYMS
|
||||
allsyms_relocate();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SYSLOG_RPMSG
|
||||
syslog_rpmsg_init_early(g_logbuffer, sizeof(g_logbuffer));
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ALLSYMS=y
|
||||
CONFIG_ARCH="sim"
|
||||
CONFIG_ARCH_BOARD="sim"
|
||||
CONFIG_ARCH_BOARD_SIM=y
|
||||
@ -65,4 +66,5 @@ CONFIG_SCHED_ONEXIT=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_MONTH=6
|
||||
CONFIG_START_YEAR=2008
|
||||
CONFIG_SYSTEM_DUMPSTACK=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
|
Loading…
Reference in New Issue
Block a user