nuttx/symtab/Makefile

108 lines
3.3 KiB
Makefile
Raw Normal View History

symtab/, tools/: NuttX provides lists of available syscalls and library functions and tools to process them. The lists can be used to build symbol table which allows runtime program loading which can reuse functions already compiled into NuttX system image. List processing, compilation and linking to the final system image has been possible only under manual control until now. Provided changes add option (CONFIG_EXECFUNCS_GENERATE_SYSTEM_SYMTAB) to build complete list of available functions and syscalls automatically. The symbolic table is generated in form libsymtab.a which can be reused by application or directly pull in when "g_symtab" and "g_nsymbols" variables are requested by EXECFUNCS configuration. I have tried to follow mechanisms for library compilation in different kernel protection modes but tested only flat no-MMU build. The basic assumption is that this library and libraries providing syscall stubs and C-library functions are available in user-space context and initial application (usually NSH) registers the symbol table through IOCTL. The table can be reused then by another applications in their address space as kernel allows. Simple for flat or protected mode, I am not sure if really support in MMU mode. It is highly probable that I have made some mistake, overlooked something, but functionality is optional (should not cause troubles in any mode if disabled) and main purpose is to lower memory overhead when more applications are loaded on memory constrained system which usually use direct kernel calling without protection or address space separation. If the table should be provided by kernel to applications then makefiles has to be adjusted.
2019-08-13 17:09:43 +02:00
############################################################################
# symtab/Makefile
#
# Copyright (C) 2019 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@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.
#
###########################################################################
-include $(TOPDIR)/Make.defs
MKSYMTAB = $(TOPDIR)$(DELIM)tools$(DELIM)mksymtab$(HOSTEXEEXT)
# C library and math library symbols should be available in the FLAT
# and PROTECTED builds. KERNEL builds are separately linked and so should
# not need symbol tables.
CSVFILES = $(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)libc.csv
CSVFILES += $(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)math.csv
# In the PROTECTED and KERNEL builds, the syscall symbol table is not
# necessary. In those build modes, the applications should link with
# libproxy which will provide symbol-compatible access to OS functions
# via a call gate.
ifeq ($(CONFIG_BUILD_FLAT),y)
CSVFILES += $(TOPDIR)$(DELIM)syscall$(DELIM)syscall.csv
endif
symtab/, tools/: NuttX provides lists of available syscalls and library functions and tools to process them. The lists can be used to build symbol table which allows runtime program loading which can reuse functions already compiled into NuttX system image. List processing, compilation and linking to the final system image has been possible only under manual control until now. Provided changes add option (CONFIG_EXECFUNCS_GENERATE_SYSTEM_SYMTAB) to build complete list of available functions and syscalls automatically. The symbolic table is generated in form libsymtab.a which can be reused by application or directly pull in when "g_symtab" and "g_nsymbols" variables are requested by EXECFUNCS configuration. I have tried to follow mechanisms for library compilation in different kernel protection modes but tested only flat no-MMU build. The basic assumption is that this library and libraries providing syscall stubs and C-library functions are available in user-space context and initial application (usually NSH) registers the symbol table through IOCTL. The table can be reused then by another applications in their address space as kernel allows. Simple for flat or protected mode, I am not sure if really support in MMU mode. It is highly probable that I have made some mistake, overlooked something, but functionality is optional (should not cause troubles in any mode if disabled) and main purpose is to lower memory overhead when more applications are loaded on memory constrained system which usually use direct kernel calling without protection or address space separation. If the table should be provided by kernel to applications then makefiles has to be adjusted.
2019-08-13 17:09:43 +02:00
DEPPATH = --dep-path .
SYMTAB_CSRCS =
BIN = libsymtab$(LIBEXT)
ifeq ($(CONFIG_EXECFUNCS_GENERATE_SYSTEM_SYMTAB),y)
all: symtab.c $(BIN)
.PHONY: all
SYMTAB_CSRCS += symtab.c
SYMTAB_COBJS = $(SYMTAB_CSRCS:.c=$(OBJEXT))
SYMTAB_SRCS = $(SYMTAB_CSRCS)
SYMTAB_OBJS = $(SYMTAB_COBJS)
%$(OBJEXT): %.c
$(call COMPILE, $<, $@)
$(BIN): $(SYMTAB_OBJS)
$(call ARCHIVE, $@, $(SYMTAB_OBJS))
$(MKSYMTAB):
$(Q) $(MAKE) -C $(TOPDIR)$(DELIM)tools -f Makefile.host mksymtab
symtab.c : $(CSVFILES) $(MKSYMTAB)
$(Q) rm -f tmp.csv $@
$(Q) cat $(CSVFILES) | LC_ALL=C sort >tmp.csv
symtab/, tools/: NuttX provides lists of available syscalls and library functions and tools to process them. The lists can be used to build symbol table which allows runtime program loading which can reuse functions already compiled into NuttX system image. List processing, compilation and linking to the final system image has been possible only under manual control until now. Provided changes add option (CONFIG_EXECFUNCS_GENERATE_SYSTEM_SYMTAB) to build complete list of available functions and syscalls automatically. The symbolic table is generated in form libsymtab.a which can be reused by application or directly pull in when "g_symtab" and "g_nsymbols" variables are requested by EXECFUNCS configuration. I have tried to follow mechanisms for library compilation in different kernel protection modes but tested only flat no-MMU build. The basic assumption is that this library and libraries providing syscall stubs and C-library functions are available in user-space context and initial application (usually NSH) registers the symbol table through IOCTL. The table can be reused then by another applications in their address space as kernel allows. Simple for flat or protected mode, I am not sure if really support in MMU mode. It is highly probable that I have made some mistake, overlooked something, but functionality is optional (should not cause troubles in any mode if disabled) and main purpose is to lower memory overhead when more applications are loaded on memory constrained system which usually use direct kernel calling without protection or address space separation. If the table should be provided by kernel to applications then makefiles has to be adjusted.
2019-08-13 17:09:43 +02:00
$(Q) $(MKSYMTAB) tmp.csv $@
$(Q) echo >>$@
$(Q) echo >>$@ 'int g_nsymbols = NSYMBOLS;'
else
all:
endif
.depend: Makefile $(SYMTAB_SRCS)
$(Q) $(MKDEP) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SYMTAB_SRCS) >Make.dep
$(Q) touch $@
depend: .depend
clean:
$(call DELFILE, $(BIN))
distclean: clean
$(call DELFILE, symtab.c)
$(call DELFILE, tmp.csv)
symtab/, tools/: NuttX provides lists of available syscalls and library functions and tools to process them. The lists can be used to build symbol table which allows runtime program loading which can reuse functions already compiled into NuttX system image. List processing, compilation and linking to the final system image has been possible only under manual control until now. Provided changes add option (CONFIG_EXECFUNCS_GENERATE_SYSTEM_SYMTAB) to build complete list of available functions and syscalls automatically. The symbolic table is generated in form libsymtab.a which can be reused by application or directly pull in when "g_symtab" and "g_nsymbols" variables are requested by EXECFUNCS configuration. I have tried to follow mechanisms for library compilation in different kernel protection modes but tested only flat no-MMU build. The basic assumption is that this library and libraries providing syscall stubs and C-library functions are available in user-space context and initial application (usually NSH) registers the symbol table through IOCTL. The table can be reused then by another applications in their address space as kernel allows. Simple for flat or protected mode, I am not sure if really support in MMU mode. It is highly probable that I have made some mistake, overlooked something, but functionality is optional (should not cause troubles in any mode if disabled) and main purpose is to lower memory overhead when more applications are loaded on memory constrained system which usually use direct kernel calling without protection or address space separation. If the table should be provided by kernel to applications then makefiles has to be adjusted.
2019-08-13 17:09:43 +02:00
-include Make.dep