mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 05:08:41 +08:00
compile/opt: add config DEBUG_LINK_MAP
Selecting this option will pass "-Map=$(TOPDIR)$(DELIM)nuttx.map" to ld when linking NuttX ELF. That file can be useful for verifying and debugging magic section games, and for seeing which pieces of code get eliminated with DEBUG_OPT_UNUSED_SECTIONS. Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
64d7326ed5
commit
1c8e12406e
37 changed files with 78 additions and 35 deletions
10
Kconfig
10
Kconfig
|
@ -1969,6 +1969,16 @@ config DEBUG_OPT_UNUSED_SECTIONS
|
|||
linker by compiling with " -ffunction-sections -fdata-sections ", and
|
||||
linking with " --gc-sections ".
|
||||
|
||||
config DEBUG_LINK_MAP
|
||||
bool "Generate link map file"
|
||||
default y
|
||||
depends on ARCH_TOOLCHAIN_GNU
|
||||
---help---
|
||||
Selecting this option will pass "-Map=$(TOPDIR)$(DELIM)nuttx.map" to ld
|
||||
when linking NuttX ELF. That file can be useful for verifying
|
||||
and debugging magic section games, and for seeing which
|
||||
pieces of code get eliminated with DEBUG_OPT_UNUSED_SECTIONS.
|
||||
|
||||
endmenu # Build Setup
|
||||
|
||||
menu "System Type"
|
||||
|
|
|
@ -105,6 +105,12 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
|
|||
MAXOPTIMIZATION += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Debug link map
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
|
||||
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
|
||||
endif
|
||||
|
||||
# Default toolchain
|
||||
|
||||
CC = $(CROSSDEV)gcc
|
||||
|
|
|
@ -161,6 +161,12 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
|
|||
MAXOPTIMIZATION += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Debug link map
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
|
||||
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
|
||||
endif
|
||||
|
||||
# Add the builtin library
|
||||
|
||||
COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)
|
||||
|
|
|
@ -136,6 +136,12 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
|
|||
MAXOPTIMIZATION += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Debug link map
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
|
||||
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
|
||||
endif
|
||||
|
||||
# NuttX buildroot under Linux or Cygwin
|
||||
|
||||
ifeq ($(CONFIG_ARMV7A_TOOLCHAIN),BUILDROOT)
|
||||
|
|
|
@ -216,6 +216,12 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
|
|||
MAXOPTIMIZATION += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Debug link map
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
|
||||
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
|
||||
endif
|
||||
|
||||
# Add the builtin library
|
||||
|
||||
COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)
|
||||
|
|
|
@ -128,6 +128,12 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
|
|||
MAXOPTIMIZATION += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Debug link map
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
|
||||
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
|
||||
endif
|
||||
|
||||
# Default toolchain
|
||||
|
||||
CC = $(CROSSDEV)gcc
|
||||
|
|
|
@ -225,6 +225,12 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
|
|||
MAXOPTIMIZATION += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Debug link map
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
|
||||
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
|
||||
endif
|
||||
|
||||
# Add the builtin library
|
||||
|
||||
COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)
|
||||
|
|
|
@ -121,8 +121,6 @@ LDFLAGS += "$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)bb_rom_sym_m0.gdbsym"
|
|||
|
||||
context:: .buildlib
|
||||
|
||||
LDFLAGS += -Map="../../../phyplus_build.map"
|
||||
|
||||
ifndef CONFIG_PHY6222_SDK
|
||||
EXTRA_LIBPATHS += -L$(TOPDIR)/arch/arm/src/chip
|
||||
EXTRA_LIBS += -lphy62xxble
|
||||
|
|
|
@ -284,6 +284,12 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
|
|||
MAXOPTIMIZATION += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Debug link map
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
|
||||
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
|
||||
endif
|
||||
|
||||
# Add the builtin library
|
||||
|
||||
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name))
|
||||
|
|
|
@ -73,6 +73,12 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
|
|||
MAXOPTIMIZATION += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Debug link map
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
|
||||
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
|
||||
endif
|
||||
|
||||
# Generic GNU RVG toolchain
|
||||
|
||||
ifeq ($(CONFIG_RISCV_TOOLCHAIN),GNU_RVG)
|
||||
|
|
|
@ -77,6 +77,12 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
|
|||
MAXOPTIMIZATION += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Debug link map
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
|
||||
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
|
||||
endif
|
||||
|
||||
# Default toolchain
|
||||
ifeq ($(CONFIG_XTENSA_TOOLCHAIN_XCC), y)
|
||||
CC = $(CROSSDEV)xcc
|
||||
|
|
|
@ -77,6 +77,12 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
|
|||
MAXOPTIMIZATION += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Debug link map
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
|
||||
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
|
||||
endif
|
||||
|
||||
# Default toolchain
|
||||
ifeq ($(CONFIG_XTENSA_TOOLCHAIN_XCC), y)
|
||||
CC = $(CROSSDEV)xcc
|
||||
|
|
|
@ -90,7 +90,7 @@ NUTTX = "$(TOPDIR)$(DELIM)nuttx$(EXEEXT)"
|
|||
nuttx$(EXEEXT): $(HEAD_OBJ) board$(DELIM)libboard$(LIBEXT) $(LINKCMD)
|
||||
$(Q) echo "LD: nuttx into $(NUTTX)"
|
||||
$(Q) "$(LD)" -o $(NUTTX) $(HEAD_OBJ) -T $(LINKCMD) --orphan-handling=error --print-memory-usage \
|
||||
$(LIBPATHS) "-(" $(LDLIBS) "-)" $(LDFLAGS) -Map="$(TOPDIR)$(DELIM)nuttx.map"
|
||||
$(LIBPATHS) "-(" $(LDLIBS) "-)" $(LDFLAGS)
|
||||
|
||||
.depend: Makefile chip$(DELIM)Make.defs $(DEPSRCS) $(TOPDIR)$(DELIM).config
|
||||
$(Q) if [ -e board$(DELIM)Makefile ]; then \
|
||||
|
|
|
@ -71,6 +71,12 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
|
|||
MAXOPTIMIZATION += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Debug link map
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
|
||||
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
|
||||
endif
|
||||
|
||||
# Tool names/paths.
|
||||
|
||||
CROSSDEV = ez80-none-elf-
|
||||
|
|
|
@ -84,7 +84,6 @@ endif
|
|||
|
||||
# Output map file with cross reference table
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
ifneq ($(CONFIG_ASMP_MEMSIZE),)
|
||||
LDFLAGS += --defsym=__reserved_ramsize=$(CONFIG_ASMP_MEMSIZE)
|
||||
endif
|
||||
|
|
|
@ -63,7 +63,6 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
|||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map)
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
|
@ -63,7 +63,6 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
|||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map)
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
|
@ -67,7 +67,6 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
|||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
|
@ -67,7 +67,6 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
|||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
|
@ -73,7 +73,6 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
|||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
|
@ -67,7 +67,6 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
|||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
|
@ -59,9 +59,6 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
|||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
# Provide map file needed by the "Memory Allocation" view in Eclipse:
|
||||
LDFLAGS += -Map=$(TOPDIR)/NuttX.map
|
||||
|
||||
# Embed absolute path to source file in debug information so that Eclipse
|
||||
# source level debugging won't get confused. See:
|
||||
# https://stackoverflow.com/questions/1275476/gcc-gdb-how-to-embed-absolute-path-to-source-file-in-debug-information
|
||||
|
|
|
@ -59,9 +59,6 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
|||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
# Provide map file needed by the "Memory Allocation" view in Eclipse:
|
||||
LDFLAGS += -Map=$(TOPDIR)/NuttX.map
|
||||
|
||||
# Embed absolute path to source file in debug information so that Eclipse
|
||||
# source level debugging won't get confused. See:
|
||||
# https://stackoverflow.com/questions/1275476/gcc-gdb-how-to-embed-absolute-path-to-source-file-in-debug-information
|
||||
|
|
|
@ -59,9 +59,6 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
|||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
# Provide map file needed by the "Memory Allocation" view in Eclipse:
|
||||
LDFLAGS += -Map=$(TOPDIR)/NuttX.map
|
||||
|
||||
# Embed absolute path to source file in debug information so that Eclipse
|
||||
# source level debugging won't get confused. See:
|
||||
# https://stackoverflow.com/questions/1275476/gcc-gdb-how-to-embed-absolute-path-to-source-file-in-debug-information
|
||||
|
|
|
@ -59,9 +59,6 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
|||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
# Provide map file needed by the "Memory Allocation" view in Eclipse:
|
||||
LDFLAGS += -Map=$(TOPDIR)/NuttX.map
|
||||
|
||||
# Embed absolute path to source file in debug information so that Eclipse
|
||||
# source level debugging won't get confused. See:
|
||||
# https://stackoverflow.com/questions/1275476/gcc-gdb-how-to-embed-absolute-path-to-source-file-in-debug-information
|
||||
|
|
|
@ -57,6 +57,5 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
|||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
#LDFLAGS += -Map=$(TOPDIR)/nuttx.map
|
||||
#CFLAGS += -Wa,-adhln
|
||||
#CXXFLAGS += -Wa,-adhln
|
||||
|
|
|
@ -55,6 +55,5 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
|||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
LDFLAGS += -Map=$(TOPDIR)/nuttx.map
|
||||
#CFLAGS += -Wa,-adhln
|
||||
#CXXFLAGS += -Wa,-adhln
|
||||
|
|
|
@ -57,6 +57,5 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
|||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
#LDFLAGS += -Map=$(TOPDIR)/nuttx.map
|
||||
#CFLAGS += -Wa,-adhln
|
||||
#CXXFLAGS += -Wa,-adhln
|
||||
|
|
|
@ -55,6 +55,5 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
|||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
LDFLAGS += -Map=$(TOPDIR)/nuttx.map
|
||||
#CFLAGS += -Wa,-adhln
|
||||
#CXXFLAGS += -Wa,-adhln
|
||||
|
|
|
@ -66,6 +66,5 @@ CXXELFFLAGS = $(CXXFLAGS)
|
|||
LDELFFLAGS = -melf32lriscv -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -melf32lriscv --cref
|
||||
LDFLAGS += -Map=$(TOPDIR)/nuttx.map
|
||||
LDFLAGS += -melf32lriscv
|
||||
|
||||
|
|
|
@ -69,5 +69,4 @@ CXXELFFLAGS = $(CXXFLAGS) -fno-common
|
|||
LDELFFLAGS = -melf32lriscv -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libelf$(DELIM)gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
LDFLAGS += -melf32lriscv
|
||||
|
|
|
@ -99,7 +99,6 @@ CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals
|
|||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libelf$(DELIM)gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
|
@ -99,7 +99,6 @@ CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals
|
|||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libelf$(DELIM)gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
|
@ -99,7 +99,6 @@ CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals
|
|||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libelf$(DELIM)gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
|
@ -99,7 +99,6 @@ CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals
|
|||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libelf$(DELIM)gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
|
@ -74,7 +74,6 @@ CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals
|
|||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
|
@ -64,7 +64,6 @@ CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals
|
|||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld)
|
||||
|
||||
LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
Loading…
Reference in a new issue