Skip to content

Commit 579f1be

Browse files
committed
options: add support of using any file as linker script
Modify logic of LINKER_SCRIPT_FILE=xxx, the file provided in this option now will be sent directly to linker. Add LINKER_USE_TEMPLATE=0|1 toggle, when set to 1, LINKER_SCRIPT_FILE will be treated as a template and be sent to compiler. It then generates .ldf file as linker script. Signed-off-by: Yuguo Zou <yuguo.zou@synopsys.com>
1 parent 44ec68d commit 579f1be

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/documents/getting_started/makefile_manual.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ In the following part of this manual, we will only use ``make`` in example, you
7878
" DIG_NAME=xxx - Specify Digilent JTAG which to be used, most useful when more than one Digilent USB-JTAG plugged in"
7979
" HEAPSZ=xxx - Specify heap size for program, xxx stands for size in bytes"
8080
" STACKSZ=xxx - Specify stack size for program, xxx stands for size in bytes"
81-
" LINKER_SCRIPT_FILE=xxx - Specify customized linker script (.ld .lcf), xxx stands for the relative path of linker script file to current directory"
81+
" LINKER_SCRIPT_FILE=xxx - Specify customized linker script, the script will be sent directly to linker. xxx stands for the relative path of linker script file to current directory"
82+
" LINKER_USE_TEMPLATE=0|1 - If set this option to 1, then use LINKER_SCRIPT_FILE=xxx file as template and send it to compiler. Compiler only accept .ld .lcf files as template and will generate .ldf file as linker script"
8283
"Example Usage:"
8384
" make all - build example in current directory using default configuration"
8485
" make BOARD=emsk BD_VER=22 CUR_CORE=arcem7d OLEVEL=O2 TOOLCHAIN=gnu all - build example using configuration (emsk, 22, arcem7d, O2, gnu)"

options/rules.mk

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ help :
135135
@$(ECHO) ' DIG_NUM=xxx - Specify device serial number which to be used for OpenOCD, most useful when more than one device plugged in'
136136
@$(ECHO) ' HEAPSZ=xxx - Specify heap size for program, xxx stands for size in bytes'
137137
@$(ECHO) ' STACKSZ=xxx - Specify stack size for program, xxx stands for size in bytes'
138-
@$(ECHO) ' LINKER_SCRIPT_FILE=xxx - Specify customized linker script (.ld .lcf), xxx stands for the relative path of linker script file to current directory'
138+
@$(ECHO) ' LINKER_SCRIPT_FILE=xxx - Specify customized linker script, the script will be sent directly to linker. xxx stands for the relative path of linker script file to current directory'
139+
@$(ECHO) ' LINKER_USE_TEMPLATE=0|1 - If set this option to 1, then use LINKER_SCRIPT_FILE=xxx file as template and send it to compiler. Compiler only accept .ld .lcf files as template and will generate .ldf file as linker script'
139140
@$(ECHO) 'Example Usage:'
140141
@$(ECHO) ' make all - build example in current directory using default configuration'
141142
@$(ECHO) ' make BOARD=emsk BD_VER=22 CUR_CORE=arcem7d OLEVEL=O2 TOOLCHAIN=gnu all - build example using configuration (emsk, 22, arcem7d, O2, gnu)'
@@ -326,10 +327,14 @@ $(EMBARC_GENERATED_DIR)/$(GENE_MEMORY_X): $(EMBARC_GENERATED_DIR)/$(GENE_TCF)
326327

327328

328329
#####RULES FOR GENERATING LINK FILE FROM TEMPLATE#####
330+
ifeq ($(LINKER_USE_TEMPLATE), 1)
329331
.SECONDEXPANSION:
330332
$(APPL_LINK_FILE): $(LINKER_SCRIPT_FILE) $$(COMMON_COMPILE_PREREQUISITES)
331333
$(TRACE_GEN_LINKFILE)
332334
$(Q)$(CC) -c $(ALL_DEFINES) $(LINK_FILE_OPT) $< -o $@
335+
else
336+
APPL_LINK_FILE = $(LINKER_SCRIPT_FILE)
337+
endif
333338

334339
#####RULES FOR GENERATING ELF FILE#####
335340
.SECONDEXPANSION:

options/toolchain.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ VALID_TOOLCHAIN = $(call check_item_exist, $(TOOLCHAIN), $(SUPPORTED_TOOLCHAINS)
2525
ifneq ($(VALID_TOOLCHAIN), )
2626
COMMON_COMPILE_PREREQUISITES += $(EMBARC_ROOT)/options/toolchain/toolchain_$(VALID_TOOLCHAIN).mk
2727
include $(EMBARC_ROOT)/options/toolchain/toolchain_$(VALID_TOOLCHAIN).mk
28+
ifeq ($(LINKER_SCRIPT_FILE), )
29+
LINKER_USE_TEMPLATE ?= 1
30+
endif
2831
LINKER_SCRIPT_FILE ?= $(EMBARC_ROOT)/options/toolchain/linker_template_$(VALID_TOOLCHAIN).ld
2932
else
3033
$(info TOOLCHAIN - $(SUPPORTED_TOOLCHAINS) are supported)

0 commit comments

Comments
 (0)