mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-16 09:34:18 +00:00
build: clarify linker script generation
The following build system variables have been renamed: - `LINKERFILE` -> `DEFAULT_LINKER_SCRIPT` - `BL_LINKERFILE` -> `DEFAULT_LINKER_SCRIPT_SOURCE` - `<IMAGE>_LINKERFILE` -> `<IMAGE>_DEFAULT_LINKER_SCRIPT_SOURCE` These new names better reflect how each variable is used: 1. the default linker script is passed via `-dT` instead of `-T` 2. linker script source files are first preprocessed Additionally, linker scripts are now placed in the build directory relative to where they exist in the source directory. For example, the `bl32/sp_min/sp_min.ld.S` would now preprocess to `sp_min/sp_min.ld` instead of just `bl32.ld` BREAKING-CHANGE: The `LINKERFILE`, `BL_LINKERFILE` and `<IMAGE_LINKERFILE>` build system variables have been renamed. See the commit message for more information. Change-Id: If8cef65dcb8820e8993736702c8741e97a66e6cc Signed-off-by: Chris Kay <chris.kay@arm.com>
This commit is contained in:
parent
f90fe02f06
commit
8227493637
10 changed files with 41 additions and 34 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013-2021, ARM Limited and Contributors. All rights reserved.
|
# Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
@ -29,4 +29,4 @@ ifeq (${TRUSTED_BOARD_BOOT},1)
|
||||||
BL1_SOURCES += bl1/bl1_fwu.c
|
BL1_SOURCES += bl1/bl1_fwu.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BL1_LINKERFILE := bl1/bl1.ld.S
|
BL1_DEFAULT_LINKER_SCRIPT_SOURCE := bl1/bl1.ld.S
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013-2021, Arm Limited and Contributors. All rights reserved.
|
# Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
@ -23,12 +23,12 @@ BL2_SOURCES += bl2/${ARCH}/bl2_rme_entrypoint.S \
|
||||||
bl2/${ARCH}/bl2_el3_exceptions.S \
|
bl2/${ARCH}/bl2_el3_exceptions.S \
|
||||||
bl2/${ARCH}/bl2_run_next_image.S \
|
bl2/${ARCH}/bl2_run_next_image.S \
|
||||||
${GPT_LIB_SRCS}
|
${GPT_LIB_SRCS}
|
||||||
BL2_LINKERFILE := bl2/bl2.ld.S
|
BL2_DEFAULT_LINKER_SCRIPT_SOURCE := bl2/bl2.ld.S
|
||||||
|
|
||||||
else ifeq (${BL2_AT_EL3},0)
|
else ifeq (${BL2_AT_EL3},0)
|
||||||
# Normal operation, no RME, no BL2 at EL3
|
# Normal operation, no RME, no BL2 at EL3
|
||||||
BL2_SOURCES += bl2/${ARCH}/bl2_entrypoint.S
|
BL2_SOURCES += bl2/${ARCH}/bl2_entrypoint.S
|
||||||
BL2_LINKERFILE := bl2/bl2.ld.S
|
BL2_DEFAULT_LINKER_SCRIPT_SOURCE := bl2/bl2.ld.S
|
||||||
|
|
||||||
else
|
else
|
||||||
# BL2 at EL3, no RME
|
# BL2 at EL3, no RME
|
||||||
|
@ -46,5 +46,5 @@ ifeq (${ARCH},aarch64)
|
||||||
BL2_SOURCES += lib/cpus/aarch64/dsu_helpers.S
|
BL2_SOURCES += lib/cpus/aarch64/dsu_helpers.S
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BL2_LINKERFILE := bl2/bl2_el3.ld.S
|
BL2_DEFAULT_LINKER_SCRIPT_SOURCE := bl2/bl2_el3.ld.S
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
|
# Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
@ -12,4 +12,4 @@ ifeq (${ARCH},aarch64)
|
||||||
BL2U_SOURCES += common/aarch64/early_exceptions.S
|
BL2U_SOURCES += common/aarch64/early_exceptions.S
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BL2U_LINKERFILE := bl2u/bl2u.ld.S
|
BL2U_DEFAULT_LINKER_SCRIPT_SOURCE := bl2u/bl2u.ld.S
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013-2022, ARM Limited and Contributors. All rights reserved.
|
# Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
@ -157,7 +157,7 @@ BL31_SOURCES += services/std_svc/drtm/drtm_main.c \
|
||||||
${MBEDTLS_SOURCES}
|
${MBEDTLS_SOURCES}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BL31_LINKERFILE := bl31/bl31.ld.S
|
BL31_DEFAULT_LINKER_SCRIPT_SOURCE := bl31/bl31.ld.S
|
||||||
|
|
||||||
# Flag used to indicate if Crash reporting via console should be included
|
# Flag used to indicate if Crash reporting via console should be included
|
||||||
# in BL31. This defaults to being present in DEBUG builds only
|
# in BL31. This defaults to being present in DEBUG builds only
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2016-2022, Arm Limited and Contributors. All rights reserved.
|
# Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
@ -54,7 +54,7 @@ ifeq (${ENABLE_TRF_FOR_NS},1)
|
||||||
BL32_SOURCES += lib/extensions/trf/aarch32/trf.c
|
BL32_SOURCES += lib/extensions/trf/aarch32/trf.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BL32_LINKERFILE := bl32/sp_min/sp_min.ld.S
|
BL32_DEFAULT_LINKER_SCRIPT_SOURCE := bl32/sp_min/sp_min.ld.S
|
||||||
|
|
||||||
# Include the platform-specific SP_MIN Makefile
|
# Include the platform-specific SP_MIN Makefile
|
||||||
# If no platform-specific SP_MIN Makefile exists, it means SP_MIN is not supported
|
# If no platform-specific SP_MIN Makefile exists, it means SP_MIN is not supported
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013-2022, ARM Limited and Contributors. All rights reserved.
|
# Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
@ -22,7 +22,7 @@ BL32_SOURCES += bl32/tsp/aarch64/tsp_entrypoint.S \
|
||||||
common/aarch64/early_exceptions.S \
|
common/aarch64/early_exceptions.S \
|
||||||
lib/locks/exclusive/aarch64/spinlock.S
|
lib/locks/exclusive/aarch64/spinlock.S
|
||||||
|
|
||||||
BL32_LINKERFILE := bl32/tsp/tsp.ld.S
|
BL32_DEFAULT_LINKER_SCRIPT_SOURCE := bl32/tsp/tsp.ld.S
|
||||||
|
|
||||||
# This flag determines if the TSPD initializes BL32 in tspd_init() (synchronous
|
# This flag determines if the TSPD initializes BL32 in tspd_init() (synchronous
|
||||||
# method) or configures BL31 to pass control to BL32 instead of BL33
|
# method) or configures BL31 to pass control to BL32 instead of BL33
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015-2022, Arm Limited and Contributors. All rights reserved.
|
# Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
@ -97,12 +97,6 @@ $(if $(word $(2), $($(1))),\
|
||||||
)
|
)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# IMG_LINKERFILE defines the linker script corresponding to a BL stage
|
|
||||||
# $(1) = BL stage
|
|
||||||
define IMG_LINKERFILE
|
|
||||||
${BUILD_DIR}/$(1).ld
|
|
||||||
endef
|
|
||||||
|
|
||||||
# IMG_MAPFILE defines the output file describing the memory map corresponding
|
# IMG_MAPFILE defines the output file describing the memory map corresponding
|
||||||
# to a BL stage
|
# to a BL stage
|
||||||
# $(1) = BL stage
|
# $(1) = BL stage
|
||||||
|
@ -457,6 +451,15 @@ ${LIB_DIR}/lib$(1).a: $(OBJS)
|
||||||
$$(Q)$$(AR) cr $$@ $$?
|
$$(Q)$$(AR) cr $$@ $$?
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
# Generate the path to one or more preprocessed linker scripts given the paths
|
||||||
|
# of their sources.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# $(1) = path to one or more linker script sources
|
||||||
|
define linker_script_path
|
||||||
|
$(patsubst %.S,$(BUILD_DIR)/%,$(1))
|
||||||
|
endef
|
||||||
|
|
||||||
# MAKE_BL macro defines the targets and options to build each BL image.
|
# MAKE_BL macro defines the targets and options to build each BL image.
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# $(1) = BL stage
|
# $(1) = BL stage
|
||||||
|
@ -468,17 +471,19 @@ define MAKE_BL
|
||||||
$(eval BL_SOURCES := $($(call uppercase,$(1))_SOURCES))
|
$(eval BL_SOURCES := $($(call uppercase,$(1))_SOURCES))
|
||||||
$(eval SOURCES := $(BL_SOURCES) $(BL_COMMON_SOURCES) $(PLAT_BL_COMMON_SOURCES))
|
$(eval SOURCES := $(BL_SOURCES) $(BL_COMMON_SOURCES) $(PLAT_BL_COMMON_SOURCES))
|
||||||
$(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES))))
|
$(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES))))
|
||||||
$(eval LINKERFILE := $(call IMG_LINKERFILE,$(1)))
|
|
||||||
$(eval MAPFILE := $(call IMG_MAPFILE,$(1)))
|
$(eval MAPFILE := $(call IMG_MAPFILE,$(1)))
|
||||||
$(eval ELF := $(call IMG_ELF,$(1)))
|
$(eval ELF := $(call IMG_ELF,$(1)))
|
||||||
$(eval DUMP := $(call IMG_DUMP,$(1)))
|
$(eval DUMP := $(call IMG_DUMP,$(1)))
|
||||||
$(eval BIN := $(call IMG_BIN,$(1)))
|
$(eval BIN := $(call IMG_BIN,$(1)))
|
||||||
$(eval ENC_BIN := $(call IMG_ENC_BIN,$(1)))
|
$(eval ENC_BIN := $(call IMG_ENC_BIN,$(1)))
|
||||||
$(eval BL_LINKERFILE := $($(call uppercase,$(1))_LINKERFILE))
|
|
||||||
$(eval BL_LIBS := $($(call uppercase,$(1))_LIBS))
|
$(eval BL_LIBS := $($(call uppercase,$(1))_LIBS))
|
||||||
|
|
||||||
|
$(eval DEFAULT_LINKER_SCRIPT_SOURCE := $($(call uppercase,$(1))_DEFAULT_LINKER_SCRIPT_SOURCE))
|
||||||
|
$(eval DEFAULT_LINKER_SCRIPT := $(call linker_script_path,$(DEFAULT_LINKER_SCRIPT_SOURCE)))
|
||||||
|
|
||||||
# We use sort only to get a list of unique object directory names.
|
# We use sort only to get a list of unique object directory names.
|
||||||
# ordering is not relevant but sort removes duplicates.
|
# ordering is not relevant but sort removes duplicates.
|
||||||
$(eval TEMP_OBJ_DIRS := $(sort $(dir ${OBJS} ${LINKERFILE})))
|
$(eval TEMP_OBJ_DIRS := $(sort $(dir ${OBJS} ${DEFAULT_LINKER_SCRIPT})))
|
||||||
# The $(dir ) function leaves a trailing / on the directory names
|
# The $(dir ) function leaves a trailing / on the directory names
|
||||||
# Rip off the / to match directory names with make rule targets.
|
# Rip off the / to match directory names with make rule targets.
|
||||||
$(eval OBJ_DIRS := $(patsubst %/,%,$(TEMP_OBJ_DIRS)))
|
$(eval OBJ_DIRS := $(patsubst %/,%,$(TEMP_OBJ_DIRS)))
|
||||||
|
@ -487,7 +492,8 @@ define MAKE_BL
|
||||||
|
|
||||||
$(eval $(call MAKE_PREREQ_DIR,${BUILD_DIR},${BUILD_PLAT}))
|
$(eval $(call MAKE_PREREQ_DIR,${BUILD_DIR},${BUILD_PLAT}))
|
||||||
|
|
||||||
$(eval $(foreach objd,${OBJ_DIRS},$(call MAKE_PREREQ_DIR,${objd},${BUILD_DIR})))
|
$(eval $(foreach objd,${OBJ_DIRS},
|
||||||
|
$(call MAKE_PREREQ_DIR,${objd},${BUILD_DIR})))
|
||||||
|
|
||||||
.PHONY : ${1}_dirs
|
.PHONY : ${1}_dirs
|
||||||
|
|
||||||
|
@ -496,7 +502,7 @@ $(eval $(foreach objd,${OBJ_DIRS},$(call MAKE_PREREQ_DIR,${objd},${BUILD_DIR})))
|
||||||
${1}_dirs: | ${OBJ_DIRS}
|
${1}_dirs: | ${OBJ_DIRS}
|
||||||
|
|
||||||
$(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),$(1)))
|
$(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),$(1)))
|
||||||
$(eval $(call MAKE_LD,$(LINKERFILE),$(BL_LINKERFILE),$(1)))
|
$(eval $(call MAKE_LD,$(DEFAULT_LINKER_SCRIPT),$(DEFAULT_LINKER_SCRIPT_SOURCE),$(1)))
|
||||||
$(eval BL_LDFLAGS := $($(call uppercase,$(1))_LDFLAGS))
|
$(eval BL_LDFLAGS := $($(call uppercase,$(1))_LDFLAGS))
|
||||||
|
|
||||||
ifeq ($(USE_ROMLIB),1)
|
ifeq ($(USE_ROMLIB),1)
|
||||||
|
@ -507,7 +513,7 @@ endif
|
||||||
# object file path, and prebuilt object file path.
|
# object file path, and prebuilt object file path.
|
||||||
$(eval OBJS += $(MODULE_OBJS))
|
$(eval OBJS += $(MODULE_OBJS))
|
||||||
|
|
||||||
$(ELF): $(OBJS) $(LINKERFILE) | $(1)_dirs libraries $(BL_LIBS)
|
$(ELF): $(OBJS) $(DEFAULT_LINKER_SCRIPT) | $(1)_dirs libraries $(BL_LIBS)
|
||||||
$$(ECHO) " LD $$@"
|
$$(ECHO) " LD $$@"
|
||||||
ifdef MAKE_BUILD_STRINGS
|
ifdef MAKE_BUILD_STRINGS
|
||||||
$(call MAKE_BUILD_STRINGS, $(BUILD_DIR)/build_message.o)
|
$(call MAKE_BUILD_STRINGS, $(BUILD_DIR)/build_message.o)
|
||||||
|
@ -526,11 +532,11 @@ ifneq ($(findstring armlink,$(notdir $(LD))),)
|
||||||
$(BUILD_DIR)/build_message.o $(OBJS)
|
$(BUILD_DIR)/build_message.o $(OBJS)
|
||||||
else ifneq ($(findstring gcc,$(notdir $(LD))),)
|
else ifneq ($(findstring gcc,$(notdir $(LD))),)
|
||||||
$$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) -Wl,-Map=$(MAPFILE) \
|
$$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) -Wl,-Map=$(MAPFILE) \
|
||||||
-Wl,-dT $(LINKERFILE) $(EXTRA_LINKERFILE) $(BUILD_DIR)/build_message.o \
|
$(EXTRA_LINKERFILE) -Wl,--script,$(DEFAULT_LINKER_SCRIPT) $(BUILD_DIR)/build_message.o \
|
||||||
$(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS)
|
$(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS)
|
||||||
else
|
else
|
||||||
$$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) $(BL_LDFLAGS) -Map=$(MAPFILE) \
|
$$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) $(BL_LDFLAGS) -Map=$(MAPFILE) \
|
||||||
--script $(LINKERFILE) $(BUILD_DIR)/build_message.o \
|
--script $(DEFAULT_LINKER_SCRIPT) $(BUILD_DIR)/build_message.o \
|
||||||
$(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS)
|
$(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS)
|
||||||
endif
|
endif
|
||||||
ifeq ($(DISABLE_BIN_GENERATION),1)
|
ifeq ($(DISABLE_BIN_GENERATION),1)
|
||||||
|
|
|
@ -21,7 +21,7 @@ MV_DDR_INCLUDES := -I$(CURDIR)/include \
|
||||||
-I$(CURDIR)/include/lib/libc \
|
-I$(CURDIR)/include/lib/libc \
|
||||||
-I$(CURDIR)/include/lib/libc/aarch64
|
-I$(CURDIR)/include/lib/libc/aarch64
|
||||||
|
|
||||||
BLE_LINKERFILE := $(BLE_PATH)/ble.ld.S
|
BLE_DEFAULT_LINKER_SCRIPT_SOURCE := $(BLE_PATH)/ble.ld.S
|
||||||
|
|
||||||
BLE_OBJS := $(addprefix $(BUILD_PLAT)/ble/,$(call SOURCES_TO_OBJS,$(BLE_SOURCES)))
|
BLE_OBJS := $(addprefix $(BUILD_PLAT)/ble/,$(call SOURCES_TO_OBJS,$(BLE_SOURCES)))
|
||||||
$(BLE_OBJS): PLAT_INCLUDES += -I$(MV_DDR_PATH)
|
$(BLE_OBJS): PLAT_INCLUDES += -I$(MV_DDR_PATH)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* (C) COPYRIGHT 2021 Arm Limited or its affiliates.
|
* Copyright (c) 2021-2023, Arm Limited and Contributors. All rights reserved.
|
||||||
* ALL RIGHTS RESERVED
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common/bl_common.ld.h>
|
#include <common/bl_common.ld.h>
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2021-2022 Arm Limited and Contributors. All rights reserved.
|
# Copyright (c) 2021-2023 Arm Limited and Contributors. All rights reserved.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
@ -8,7 +8,7 @@ RMM_SOURCES += services/std_svc/rmmd/trp/trp_entry.S \
|
||||||
services/std_svc/rmmd/trp/trp_main.c \
|
services/std_svc/rmmd/trp/trp_main.c \
|
||||||
services/std_svc/rmmd/trp/trp_helpers.c
|
services/std_svc/rmmd/trp/trp_helpers.c
|
||||||
|
|
||||||
RMM_LINKERFILE := services/std_svc/rmmd/trp/linker.lds
|
RMM_DEFAULT_LINKER_SCRIPT_SOURCE := services/std_svc/rmmd/trp/linker.ld.S
|
||||||
|
|
||||||
# Include the platform-specific TRP Makefile
|
# Include the platform-specific TRP Makefile
|
||||||
# If no platform-specific TRP Makefile exists, it means TRP is not supported
|
# If no platform-specific TRP Makefile exists, it means TRP is not supported
|
||||||
|
|
Loading…
Add table
Reference in a new issue