arch/x86_64:Add allsymbol functionality

Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
This commit is contained in:
liwenxiang1 2024-10-09 16:31:06 +08:00 committed by Xiang Xiao
parent 93890321c5
commit f858026819
1 changed files with 34 additions and 3 deletions

View File

@ -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 \