Skip to content

Generate/Link secure object file #6096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tools/toolchains/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ def __init__(self, target, *args, **kwargs):
raise NotSupportedException(
"this compiler does not support the core %s" % target.core)

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

Expand Down Expand Up @@ -337,6 +338,11 @@ def __init__(self, target, *args, **kwargs):
if target.core == "Cortex-M23" or target.core == "Cortex-M33":
self.flags['common'].append("-mcmse")

# Create Secure library
if target.core == "Cortex-M23" or self.target.core == "Cortex-M33":
secure_file = join(build_dir, "cmse_lib.o")
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]

asm_cpu = {
"Cortex-M0+": "Cortex-M0",
"Cortex-M4F": "Cortex-M4.fp",
Expand Down
8 changes: 8 additions & 0 deletions tools/toolchains/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ def link(self, output, objects, libraries, lib_dirs, mem_map):
# Build linker command
map_file = splitext(output)[0] + ".map"
cmd = self.ld + ["-o", output, "-Wl,-Map=%s" % map_file] + objects + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"]
# Create Secure library
if self.target.core == "Cortex-M23" or self.target.core == "Cortex-M33":
secure_file = join(dirname(output), "cmse_lib.o")
cmd.extend(["-Wl,--cmse-implib"])
cmd.extend(["-Wl,--out-implib=%s" % secure_file])

if mem_map:
cmd.extend(['-T', mem_map])

Expand All @@ -238,6 +244,8 @@ def link(self, output, objects, libraries, lib_dirs, mem_map):
# Exec command
self.cc_verbose("Link: %s" % ' '.join(cmd))
self.default_cmd(cmd)
if self.target.core == "Cortex-M23" or self.target.core == "Cortex-M33":
self.info("Secure Library Object %s" %secure_file)

@hook_tool
def archive(self, objects, lib_path):
Expand Down
6 changes: 6 additions & 0 deletions tools/toolchains/iar.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def __init__(self, target, notify=None, macros=None,
c_flags_cmd.append("--fpu=VFPv5_sp")
elif target.core == "Cortex-M23" or target.core == "Cortex-M33":
self.flags["asm"] += ["--cmse"]
self.flags["common"] += ["--cmse"]

# Create Secure library
if target.core == "Cortex-M23" or self.target.core == "Cortex-M33":
secure_file = join(build_dir, "cmse_lib.o")
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]

IAR_BIN = join(TOOLCHAIN_PATHS['IAR'], "bin")
main_cc = join(IAR_BIN, "iccarm")
Expand Down