From 028368e4ee4f780f649d55c702e5fd1e7b0d5506 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Fri, 14 Jul 2017 12:00:32 -0700 Subject: [PATCH] [build] create separate linker map files for each application binary (#1992) Previously, a global 'map.map' filename was used. However, when building FTD and MTD versions of a given application, the 'map.map' files would overwrite each other. This commit gives different filenames to each .map file for a given binary. --- configure.ac | 25 +++++++++++++++++++++++++ examples/Makefile-cc2538 | 2 +- examples/Makefile-cc2650 | 2 +- examples/Makefile-da15000 | 2 +- examples/Makefile-efr32 | 2 +- examples/Makefile-emsk | 2 +- examples/Makefile-gp712 | 1 - examples/Makefile-kw41z | 2 +- examples/Makefile-nrf52840 | 2 +- examples/apps/cli/Makefile.am | 5 +++++ examples/apps/ncp/Makefile.am | 5 +++++ 11 files changed, 42 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 50271ea2c..7cf0d3c06 100644 --- a/configure.ac +++ b/configure.ac @@ -1078,6 +1078,30 @@ AC_SUBST(OPENTHREAD_ENABLE_BORDER_ROUTER) AM_CONDITIONAL([OPENTHREAD_ENABLE_BORDER_ROUTER], [test "${enable_border_router}" = "yes"]) AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_BORDER_ROUTER],[${OPENTHREAD_ENABLE_BORDER_ROUTER}],[Define to 1 if you want to enable Border Router]) +# +# Linker Map Output +# + +AC_ARG_ENABLE(linker-map, + [AS_HELP_STRING([--enable-linker-map],[Enable linker map output @<:@default=no@:>@.])], + [ + case "${enableval}" in + + no|yes) + enable_linker_map=${enableval} + ;; + + *) + AC_MSG_ERROR([Invalid value ${enable_linker_map} for --enable-linker-map]) + ;; + esac + ], + [enable_linker_map=no]) + +AC_MSG_CHECKING([whether to enable linker map output]) +AC_MSG_RESULT(${enable_linker_map}) +AM_CONDITIONAL([OPENTHREAD_ENABLE_LINKER_MAP], [test "${enable_linker_map}" = "yes"]) + # # Examples # @@ -1410,6 +1434,7 @@ AC_MSG_NOTICE([ Assembler flags : ${CCASFLAGS:--} Link flags : ${LDFLAGS:--} Link libraries : ${LIBS} + Link maps : ${enable_linker_map} Pretty : ${PRETTY:--} Pretty args : ${PRETTY_ARGS:--} Pretty check : ${PRETTY_CHECK:--} diff --git a/examples/Makefile-cc2538 b/examples/Makefile-cc2538 index c354d1074..d1bf0c14f 100644 --- a/examples/Makefile-cc2538 +++ b/examples/Makefile-cc2538 @@ -48,6 +48,7 @@ configure_OPTIONS = \ --enable-diag \ --with-examples=cc2538 \ --with-platform-info=CC2538 \ + --enable-linker-map \ $(NULL) include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk @@ -91,7 +92,6 @@ LDFLAGS += \ -specs=nano.specs \ -specs=nosys.specs \ -Wl,--gc-sections \ - -Wl,-Map=map.map \ $(NULL) ECHO := @echo diff --git a/examples/Makefile-cc2650 b/examples/Makefile-cc2650 index 090b5f299..ef0a5690c 100644 --- a/examples/Makefile-cc2650 +++ b/examples/Makefile-cc2650 @@ -47,6 +47,7 @@ configure_OPTIONS = \ --with-ncp-bus=uart \ --with-examples=cc2650 \ --with-platform-info=cc2650 \ + --enable-linker-map \ MBEDTLS_CPPFLAGS="$(CC2650_MBEDTLS_CPPFLAGS)" \ $(NULL) @@ -93,7 +94,6 @@ LDFLAGS += \ -specs=nano.specs \ -specs=nosys.specs \ -Wl,--gc-sections \ - -Wl,-Map=map.map \ $(NULL) ECHO := @echo diff --git a/examples/Makefile-da15000 b/examples/Makefile-da15000 index e349c1ae2..ee0527487 100644 --- a/examples/Makefile-da15000 +++ b/examples/Makefile-da15000 @@ -47,6 +47,7 @@ configure_OPTIONS = \ --with-ncp-bus=uart \ --with-examples=da15000 \ --with-platform-info=DA15000 \ + --enable-linker-map \ $(NULL) include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk @@ -90,7 +91,6 @@ LDFLAGS += \ -specs=nano.specs \ -specs=nosys.specs \ -Wl,--gc-sections \ - -Wl,-Map=map.map \ $(NULL) ECHO := @echo diff --git a/examples/Makefile-efr32 b/examples/Makefile-efr32 index 103a1442f..f0bd622d5 100644 --- a/examples/Makefile-efr32 +++ b/examples/Makefile-efr32 @@ -48,6 +48,7 @@ configure_OPTIONS = \ --enable-diag \ --with-examples=efr32 \ --with-platform-info=EFR32 \ + --enable-linker-map \ MBEDTLS_CPPFLAGS="$(EFR32_MBEDTLS_CPPFLAGS)" \ $(NULL) @@ -105,7 +106,6 @@ LDFLAGS += \ -specs=nano.specs \ -specs=nosys.specs \ -Wl,--gc-sections \ - -Wl,-Map=map.map \ $(NULL) ECHO := @echo diff --git a/examples/Makefile-emsk b/examples/Makefile-emsk index 01a4f07c3..ee56252b4 100644 --- a/examples/Makefile-emsk +++ b/examples/Makefile-emsk @@ -47,6 +47,7 @@ configure_OPTIONS = \ --with-ncp-bus=uart \ --with-examples=emsk \ --with-platform-info=EMSK \ + --enable-linker-map \ $(NULL) ifeq ($(CERT_LOG),1) @@ -112,7 +113,6 @@ LDFLAGS += \ -nostartfiles \ -specs=nano.specs \ -Wl,--gc-sections \ - -Wl,-Map=map.map \ -Wl,--defsym=_STACKSIZE=524288 \ -Wl,--defsym=_HEAPSIZE=524288 \ $(NULL) diff --git a/examples/Makefile-gp712 b/examples/Makefile-gp712 index 9969d75e7..5ca06fecd 100644 --- a/examples/Makefile-gp712 +++ b/examples/Makefile-gp712 @@ -94,7 +94,6 @@ LDFLAGS += \ $(COMMONCFLAGS) \ $(target_LDFLAGS) \ -Wl,--gc-sections \ - -Wl,-Map=map.map \ -lrt \ -lpthread \ $(NULL) diff --git a/examples/Makefile-kw41z b/examples/Makefile-kw41z index 3f228038b..664e5b66f 100644 --- a/examples/Makefile-kw41z +++ b/examples/Makefile-kw41z @@ -48,6 +48,7 @@ configure_OPTIONS = \ --enable-diag \ --with-examples=kw41z \ --with-platform-info=KW41Z \ + --enable-linker-map \ $(NULL) include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk @@ -90,7 +91,6 @@ LDFLAGS += \ -specs=nano.specs \ -specs=nosys.specs \ -Wl,--gc-sections \ - -Wl,-Map=map.map \ $(NULL) ECHO := @echo diff --git a/examples/Makefile-nrf52840 b/examples/Makefile-nrf52840 index 3c7a0b408..3da491a17 100644 --- a/examples/Makefile-nrf52840 +++ b/examples/Makefile-nrf52840 @@ -48,6 +48,7 @@ configure_OPTIONS = \ --enable-diag \ --with-examples=nrf52840 \ --with-platform-info=NRF52840 \ + --enable-linker-map \ MBEDTLS_CPPFLAGS="$(NRF52840_MBEDTLS_CPPFLAGS)" \ $(NULL) @@ -106,7 +107,6 @@ LDFLAGS += \ -specs=nano.specs \ -specs=nosys.specs \ -Wl,--gc-sections \ - -Wl,-Map=map.map \ $(NULL) CCASFLAGS += \ diff --git a/examples/apps/cli/Makefile.am b/examples/apps/cli/Makefile.am index f2cf41690..3e861401a 100644 --- a/examples/apps/cli/Makefile.am +++ b/examples/apps/cli/Makefile.am @@ -199,6 +199,11 @@ ot_cli_mtd_SOURCES = \ $(SOURCES_COMMON) \ $(NULL) +if OPENTHREAD_ENABLE_LINKER_MAP +ot_cli_ftd_LDFLAGS += -Wl,-Map=ot-cli-ftd.map +ot_cli_mtd_LDFLAGS += -Wl,-Map=ot-cli-mtd.map +endif + if OPENTHREAD_BUILD_COVERAGE CLEANFILES = $(wildcard *.gcda *.gcno) endif # OPENTHREAD_BUILD_COVERAGE diff --git a/examples/apps/ncp/Makefile.am b/examples/apps/ncp/Makefile.am index 7ffe39284..1f67fbd64 100644 --- a/examples/apps/ncp/Makefile.am +++ b/examples/apps/ncp/Makefile.am @@ -191,6 +191,11 @@ ot_ncp_mtd_SOURCES = \ $(SOURCES_COMMON) \ $(NULL) +if OPENTHREAD_ENABLE_LINKER_MAP +ot_ncp_ftd_LDFLAGS += -Wl,-Map=ot-ncp-ftd.map +ot_ncp_mtd_LDFLAGS += -Wl,-Map=ot-ncp-mtd.map +endif + if OPENTHREAD_BUILD_COVERAGE CLEANFILES = $(wildcard *.gcda *.gcno) endif # OPENTHREAD_BUILD_COVERAGE