diff --git a/Makefile b/Makefile index 6b1f47cf3..29027746c 100644 --- a/Makefile +++ b/Makefile @@ -372,6 +372,15 @@ endif ################################################################################ include lib/compiler-rt/compiler-rt.mk +# Allow overriding the timestamp, for example for reproducible builds, or to +# synchronize timestamps across multiple projects. +# This must be set to a C string (including quotes where applicable). +BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__ + +DEFINES += -DBUILD_MESSAGE_TIMESTAMP='$(BUILD_MESSAGE_TIMESTAMP)' +DEFINES += -DBUILD_MESSAGE_VERSION_STRING='"$(VERSION_STRING)"' +DEFINES += -DBUILD_MESSAGE_VERSION='"$(VERSION)"' + BL_COMMON_SOURCES += common/bl_common.c \ common/tf_log.c \ common/${ARCH}/debug.S \ @@ -1682,7 +1691,7 @@ else endif #(UNIX_MK) romlib.bin: libraries FORCE - ${Q}${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES='${INCLUDES}' DEFINES='${DEFINES}' --no-print-directory -C ${ROMLIBPATH} all + ${Q}${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES=$(call escape-shell,$(INCLUDES)) DEFINES=$(call escape-shell,$(DEFINES)) --no-print-directory -C ${ROMLIBPATH} all memmap: all ifdef UNIX_MK diff --git a/bl1/bl1_main.c b/bl1/bl1_main.c index 1dfdc459b..9f19b4a47 100644 --- a/bl1/bl1_main.c +++ b/bl1/bl1_main.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +74,7 @@ void bl1_main(void) /* Announce our arrival */ NOTICE(FIRMWARE_WELCOME_STR); - NOTICE("BL1: %s\n", version_string); + NOTICE("BL1: %s\n", build_version_string); NOTICE("BL1: %s\n", build_message); INFO("BL1: RAM %p - %p\n", (void *)BL1_RAM_BASE, (void *)BL1_RAM_LIMIT); diff --git a/bl2/bl2_main.c b/bl2/bl2_main.c index 923a554fb..4c68f076a 100644 --- a/bl2/bl2_main.c +++ b/bl2/bl2_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -92,7 +93,7 @@ void bl2_main(void) PMF_CAPTURE_TIMESTAMP(bl_svc, BL2_ENTRY, PMF_CACHE_MAINT); #endif - NOTICE("BL2: %s\n", version_string); + NOTICE("BL2: %s\n", build_version_string); NOTICE("BL2: %s\n", build_message); /* Perform remaining generic architectural setup in S-EL1 */ diff --git a/bl2u/bl2u_main.c b/bl2u/bl2u_main.c index fcb73b9c7..cd13defea 100644 --- a/bl2u/bl2u_main.c +++ b/bl2u/bl2u_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -27,7 +28,7 @@ ******************************************************************************/ void bl2u_main(void) { - NOTICE("BL2U: %s\n", version_string); + NOTICE("BL2U: %s\n", build_version_string); NOTICE("BL2U: %s\n", build_message); #if SCP_BL2U_BASE diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c index 98078171d..cae9b140f 100644 --- a/bl31/bl31_main.c +++ b/bl31/bl31_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -128,7 +129,7 @@ void bl31_main(void) /* Init per-world context registers for non-secure world */ manage_extensions_nonsecure_per_world(); - NOTICE("BL31: %s\n", version_string); + NOTICE("BL31: %s\n", build_version_string); NOTICE("BL31: %s\n", build_message); #if FEATURE_DETECTION diff --git a/bl32/sp_min/sp_min_main.c b/bl32/sp_min/sp_min_main.c index 26cf2079d..61feaeca5 100644 --- a/bl32/sp_min/sp_min_main.c +++ b/bl32/sp_min/sp_min_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -175,7 +176,7 @@ uintptr_t get_arm_std_svc_args(unsigned int svc_mask) *****************************************************************************/ void sp_min_main(void) { - NOTICE("SP_MIN: %s\n", version_string); + NOTICE("SP_MIN: %s\n", build_version_string); NOTICE("SP_MIN: %s\n", build_message); /* Perform the SP_MIN platform setup */ diff --git a/bl32/tsp/tsp_ffa_main.c b/bl32/tsp/tsp_ffa_main.c index 1c8c68f03..8273060bd 100644 --- a/bl32/tsp/tsp_ffa_main.c +++ b/bl32/tsp/tsp_ffa_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2022, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "ffa_helpers.h" #include @@ -554,7 +555,7 @@ uint64_t tsp_main(void) { smc_args_t smc_args = {0}; - NOTICE("TSP: %s\n", version_string); + NOTICE("TSP: %s\n", build_version_string); NOTICE("TSP: %s\n", build_message); INFO("TSP: Total memory base : 0x%lx\n", (unsigned long) BL32_BASE); INFO("TSP: Total memory size : 0x%lx bytes\n", BL32_TOTAL_SIZE); diff --git a/bl32/tsp/tsp_main.c b/bl32/tsp/tsp_main.c index 805575a21..ae38d6904 100644 --- a/bl32/tsp/tsp_main.c +++ b/bl32/tsp/tsp_main.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -27,7 +28,7 @@ ******************************************************************************/ uint64_t tsp_main(void) { - NOTICE("TSP: %s\n", version_string); + NOTICE("TSP: %s\n", build_version_string); NOTICE("TSP: %s\n", build_message); INFO("TSP: Total memory base : 0x%lx\n", (unsigned long) BL32_BASE); INFO("TSP: Total memory size : 0x%lx bytes\n", BL32_TOTAL_SIZE); diff --git a/common/bl_common.c b/common/bl_common.c index 8fce02fba..fe4de0ae7 100644 --- a/common/bl_common.c +++ b/common/bl_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -275,6 +276,5 @@ void print_entry_point_info(const entry_point_info_t *ep_info) */ const char *get_version(void) { - extern const char version[]; - return version; + return build_version; } diff --git a/include/common/bl_common.h b/include/common/bl_common.h index 4c8a17c5b..647ae853b 100644 --- a/include/common/bl_common.h +++ b/include/common/bl_common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2022, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -180,8 +180,6 @@ int load_auth_image(unsigned int image_id, image_info_t *image_data); void dyn_disable_auth(void); #endif -extern const char build_message[]; -extern const char version_string[]; const char *get_version(void); void print_entry_point_info(const entry_point_info_t *ep_info); diff --git a/include/common/build_message.h b/include/common/build_message.h new file mode 100644 index 000000000..b7c2f7245 --- /dev/null +++ b/include/common/build_message.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef BUILD_MESSAGE_H +#define BUILD_MESSAGE_H + +static const char build_message[] = "Built : " BUILD_MESSAGE_TIMESTAMP; +static const char build_version_string[] = BUILD_MESSAGE_VERSION_STRING; +static const char build_version[] = BUILD_MESSAGE_VERSION; + +#endif /* BUILD_MESSAGE_H */ diff --git a/make_helpers/build_macros.mk b/make_helpers/build_macros.mk index 36ac1269a..cfd46d9ef 100644 --- a/make_helpers/build_macros.mk +++ b/make_helpers/build_macros.mk @@ -438,11 +438,6 @@ define SOURCES_TO_OBJS $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1)))) endef -# Allow overriding the timestamp, for example for reproducible builds, or to -# synchronize timestamps across multiple projects. -# This must be set to a C string (including quotes where applicable). -BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__ - .PHONY: libraries # MAKE_LIB_DIRS macro defines the target for the directory where @@ -562,30 +557,19 @@ $(eval OBJS += $(MODULE_OBJS)) $(ELF): $(OBJS) $(DEFAULT_LINKER_SCRIPT) $(LINKER_SCRIPTS) | $(1)_dirs libraries $(BL_LIBS) $$(ECHO) " LD $$@" -ifdef MAKE_BUILD_STRINGS - $(call MAKE_BUILD_STRINGS,$(BUILD_DIR)/build_message.o) -else - @echo 'const char build_message[] = "Built : "$(BUILD_MESSAGE_TIMESTAMP); \ - const char version_string[] = "${VERSION_STRING}"; \ - const char version[] = "${VERSION}";' | \ - $($(ARCH)-cc) $$(TF_CFLAGS) $$(CFLAGS) -xc -c - -o $(BUILD_DIR)/build_message.o -endif ifeq ($($(ARCH)-ld-id),arm-link) $$(Q)$($(ARCH)-ld) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) $(BL_LDFLAGS) --entry=${1}_entrypoint \ --predefine="-D__LINKER__=$(__LINKER__)" \ --predefine="-DTF_CFLAGS=$(TF_CFLAGS)" \ --map --list="$(MAPFILE)" --scatter=${PLAT_DIR}/scat/${1}.scat \ - $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) \ - $(BUILD_DIR)/build_message.o $(OBJS) + $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) $(OBJS) else ifeq ($($(ARCH)-ld-id),gnu-gcc) $$(Q)$($(ARCH)-ld) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) $(BL_LDFLAGS) -Wl,-Map=$(MAPFILE) \ $(addprefix -Wl$(comma)--script$(comma),$(LINKER_SCRIPTS)) -Wl,--script,$(DEFAULT_LINKER_SCRIPT) \ - $(BUILD_DIR)/build_message.o \ $(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) else $$(Q)$($(ARCH)-ld) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) $(BL_LDFLAGS) -Map=$(MAPFILE) \ $(addprefix -T ,$(LINKER_SCRIPTS)) --script $(DEFAULT_LINKER_SCRIPT) \ - $(BUILD_DIR)/build_message.o \ $(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) endif ifeq ($(DISABLE_BIN_GENERATION),1) diff --git a/make_helpers/windows.mk b/make_helpers/windows.mk index a75a74021..de34eafb7 100644 --- a/make_helpers/windows.mk +++ b/make_helpers/windows.mk @@ -79,16 +79,4 @@ endif # This can be overridden from the command line or environment. BUILD_STRING ?= development build -# The DOS echo shell command does not strip ' characters from the command -# parameters before printing. We therefore use an alternative method invoked -# by defining the MAKE_BUILD_STRINGS macro. -BUILT_TIME_DATE_STRING = const char build_message[] = "Built : "${BUILD_MESSAGE_TIMESTAMP}; -VERSION_STRING_MESSAGE = const char version_string[] = "${VERSION_STRING}"; -VERSION_MESSAGE = const char version[] = "${VERSION}"; -define MAKE_BUILD_STRINGS - $$(file >$1.in,$$(TF_CFLAGS) $$(CFLAGS)) - @echo $$(BUILT_TIME_DATE_STRING) $$(VERSION_STRING_MESSAGE) $$(VERSION_MESSAGE) | \ - $($(ARCH)-cc) @$1.in -x c -c - -o $1 -endef - MSVC_NMAKE := nmake.exe diff --git a/plat/arm/board/fvp_r/fvp_r_bl1_main.c b/plat/arm/board/fvp_r/fvp_r_bl1_main.c index 29495cfcb..6fe2b5b36 100644 --- a/plat/arm/board/fvp_r/fvp_r_bl1_main.c +++ b/plat/arm/board/fvp_r/fvp_r_bl1_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -161,7 +162,7 @@ void bl1_main(void) /* Announce our arrival */ NOTICE(FIRMWARE_WELCOME_STR); - NOTICE("BL1: %s\n", version_string); + NOTICE("BL1: %s\n", build_version_string); NOTICE("BL1: %s\n", build_message); INFO("BL1: RAM %p - %p\n", (void *)BL1_RAM_BASE, (void *)BL1_RAM_LIMIT); @@ -244,4 +245,3 @@ void print_debug_loop_message(void) NOTICE("BL1: Please connect the debugger to continue\n"); } #endif - diff --git a/plat/arm/board/morello/morello_image_load.c b/plat/arm/board/morello/morello_image_load.c index cfe8bee58..b95903198 100644 --- a/plat/arm/board/morello/morello_image_load.c +++ b/plat/arm/board/morello/morello_image_load.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -142,7 +143,7 @@ static int plat_morello_append_config_node(struct morello_plat_info *plat_info, return -1; } - err = fdt_setprop_string(fdt, nodeoffset_fw, "tfa-fw-version", version_string); + err = fdt_setprop_string(fdt, nodeoffset_fw, "tfa-fw-version", build_version_string); if (err < 0) { WARN("NT_FW_CONFIG: Unable to set tfa-fw-version\n"); } diff --git a/plat/imx/common/imx_sip_handler.c b/plat/imx/common/imx_sip_handler.c index 5d2918686..49fdacf0b 100644 --- a/plat/imx/common/imx_sip_handler.c +++ b/plat/imx/common/imx_sip_handler.c @@ -9,9 +9,10 @@ #include #include #include -#include +#include #include #include +#include #include #include #include @@ -261,7 +262,7 @@ static uint64_t imx_get_commit_hash(u_register_t x2, u_register_t x4) { /* Parse the version_string */ - char *parse = (char *)version_string; + char *parse = (char *)build_version_string; uint64_t hash = 0; do { diff --git a/services/std_svc/rmmd/trp/trp_main.c b/services/std_svc/rmmd/trp/trp_main.c index 33f2fb088..b75483cb6 100644 --- a/services/std_svc/rmmd/trp/trp_main.c +++ b/services/std_svc/rmmd/trp/trp_main.c @@ -1,9 +1,10 @@ /* - * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ +#include #include #include #include @@ -86,7 +87,7 @@ int trp_validate_warmboot_args(uint64_t x0, uint64_t x1, /* Main function for TRP */ void trp_main(void) { - NOTICE("TRP: %s\n", version_string); + NOTICE("TRP: %s\n", build_version_string); NOTICE("TRP: %s\n", build_message); NOTICE("TRP: Supported RMM-EL3 Interface ABI: v.%u.%u\n", TRP_RMM_EL3_ABI_VERS_MAJOR, TRP_RMM_EL3_ABI_VERS_MINOR);