From f8580268194ca65d578b1d3b3c819d9b86f5e4c3 Mon Sep 17 00:00:00 2001 From: liwenxiang1 Date: Wed, 9 Oct 2024 16:31:06 +0800 Subject: [PATCH] arch/x86_64:Add allsymbol functionality Signed-off-by: liwenxiang1 --- arch/x86_64/src/Makefile | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/arch/x86_64/src/Makefile b/arch/x86_64/src/Makefile index b841aeef3d2f6..111b39a2a0169 100644 --- a/arch/x86_64/src/Makefile +++ b/arch/x86_64/src/Makefile @@ -123,17 +123,48 @@ $(KBIN): $(OBJS) board/libboard$(LIBEXT): $(Q) $(MAKE) -C board libboard$(LIBEXT) EXTRAFLAGS="$(EXTRAFLAGS)" -nuttx$(EXEEXT): board/libboard$(LIBEXT) $(ARCHSCRIPT) - @echo "LD: nuttx$(EXEEXT)" +ifeq ($(CONFIG_ALLSYMS),y) +EXTRA_LIBS += allsyms$(OBJEXT) +endif + +define LINK_ALLSYMS_KASAN + $(if $(CONFIG_ALLSYMS), + $(Q) $(TOPDIR)/tools/mkallsyms.py $(NUTTX) allsyms.tmp --orderbyname $(CONFIG_SYMTAB_ORDEREDBYNAME) + $(Q) $(call COMPILE, allsyms.tmp, allsyms$(OBJEXT), -x c) + $(Q) $(call DELFILE, allsyms.tmp)) + $(if $(CONFIG_MM_KASAN_GLOBAL), + $(Q) $(TOPDIR)/tools/kasan_global.py -e $(NUTTX) -o kasan_globals.tmp -a $(CONFIG_MM_KASAN_GLOBAL_ALIGN) + $(Q) $(call COMPILE, kasan_globals.tmp, kasan_globals$(OBJEXT) -fno-sanitize=kernel-address, -x c) + $(Q) $(call DELFILE, kasan_globals.tmp)) $(Q) $(LD) $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ - -o $(NUTTX) $(EXTRA_OBJS) \ + -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ $(LDSTARTGROUP) $(EXTRA_LIBS) --no-relax $(LDLIBS) $(LDENDGROUP) +endef + +$(addsuffix .tmp,$(ARCHSCRIPT)): $(ARCHSCRIPT) + $(call PREPROCESS, $(patsubst %.tmp,%,$@), $@) + +nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) $(addsuffix .tmp,$(ARCHSCRIPT)) + @echo "LD: nuttx$(EXEEXT)" + ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ sort > $(TOPDIR)/System.map endif +ifeq ($(CONFIG_ALLSYMS)$(CONFIG_MM_KASAN_GLOBAL),) + $(Q) $(LD) $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ + -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ + $(LDSTARTGROUP) $(EXTRA_LIBS) --no-relax $(LDLIBS) $(LDENDGROUP) +else + $(Q) $(call LINK_ALLSYMS_KASAN) + $(Q) $(call LINK_ALLSYMS_KASAN) + $(Q) $(call LINK_ALLSYMS_KASAN) + $(Q) $(call LINK_ALLSYMS_KASAN) +endif + $(Q) $(call DELFILE, $(addsuffix .tmp,$(ARCHSCRIPT))) + ifeq ($(CONFIG_ARCH_MULTIBOOT1),y) @echo "Generating: nuttx32 in ELF32/multiboot1" $(Q) $(OBJCOPY) -R.realmode -R.note.* -O binary $(NUTTX) $(NUTTX).bin \