Skip to content

Commit df4ceee

Browse files
authored
Merge pull request #6096 from deepikabhavnani/secure_lib_creation
Generate/Link secure object file
2 parents 2fab524 + b21e93b commit df4ceee

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

tools/toolchains/arm.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ def __init__(self, target, *args, **kwargs):
309309
raise NotSupportedException(
310310
"this compiler does not support the core %s" % target.core)
311311

312+
build_dir = kwargs['build_dir']
312313
if not set(("ARM", "ARMC6")).intersection(set(target.supported_toolchains)):
313314
raise NotSupportedException("ARM/ARMC6 compiler support is required for ARMC6 build")
314315

@@ -346,6 +347,11 @@ def __init__(self, target, *args, **kwargs):
346347
if target.core == "Cortex-M23" or target.core == "Cortex-M33":
347348
self.flags['common'].append("-mcmse")
348349

350+
# Create Secure library
351+
if target.core == "Cortex-M23" or self.target.core == "Cortex-M33":
352+
secure_file = join(build_dir, "cmse_lib.o")
353+
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
354+
349355
asm_cpu = {
350356
"Cortex-M0+": "Cortex-M0",
351357
"Cortex-M4F": "Cortex-M4.fp",

tools/toolchains/gcc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ def link(self, output, objects, libraries, lib_dirs, mem_map):
214214
# Build linker command
215215
map_file = splitext(output)[0] + ".map"
216216
cmd = self.ld + ["-o", output, "-Wl,-Map=%s" % map_file] + objects + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"]
217+
# Create Secure library
218+
if self.target.core == "Cortex-M23" or self.target.core == "Cortex-M33":
219+
secure_file = join(dirname(output), "cmse_lib.o")
220+
cmd.extend(["-Wl,--cmse-implib"])
221+
cmd.extend(["-Wl,--out-implib=%s" % secure_file])
222+
217223
if mem_map:
218224
cmd.extend(['-T', mem_map])
219225

@@ -233,6 +239,8 @@ def link(self, output, objects, libraries, lib_dirs, mem_map):
233239
# Exec command
234240
self.cc_verbose("Link: %s" % ' '.join(cmd))
235241
self.default_cmd(cmd)
242+
if self.target.core == "Cortex-M23" or self.target.core == "Cortex-M33":
243+
self.info("Secure Library Object %s" %secure_file)
236244

237245
@hook_tool
238246
def archive(self, objects, lib_path):

tools/toolchains/iar.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ def __init__(self, target, notify=None, macros=None,
7474
c_flags_cmd.append("--fpu=VFPv5_sp")
7575
elif target.core == "Cortex-M23" or target.core == "Cortex-M33":
7676
self.flags["asm"] += ["--cmse"]
77+
self.flags["common"] += ["--cmse"]
78+
79+
# Create Secure library
80+
if target.core == "Cortex-M23" or self.target.core == "Cortex-M33":
81+
secure_file = join(build_dir, "cmse_lib.o")
82+
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
7783

7884
IAR_BIN = join(TOOLCHAIN_PATHS['IAR'], "bin")
7985
main_cc = join(IAR_BIN, "iccarm")

0 commit comments

Comments
 (0)