Skip to content

Commit afe5522

Browse files
committed
Disable __stdout from libplatform_ns
TF-M redirects output to serial by declaring its own `FILE __stdout` and disables the toolchain's default version of this symbol using the flag `-nostdlib`. But stdlib is enabled and required by Mbed OS, so we need to disable the one from TF-M's libplatform_ns to avoid symbol duplication.
1 parent 7eb52ed commit afe5522

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

build_tfm.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,23 @@ def _copy_library(source, toolchain):
522522

523523
shutil.copy2(src_file, dst_file)
524524

525+
if dst_base == "libplatform_ns.ar":
526+
# TF-M redirects output to serial by declaring its own `FILE __stdout`
527+
# and disables the toolchain's default version of this symbol using
528+
# the flag `-nostdlib`. But stdlib is enabled and required by Mbed OS,
529+
# so we need to disable the one from TF-M's libplatform_ns to avoid
530+
# symbol duplication.
531+
cmd = [
532+
"fromelf",
533+
"--elf",
534+
"--localize",
535+
"__stdout",
536+
dst_file,
537+
"-o",
538+
dst_file,
539+
]
540+
run_cmd_and_return(cmd)
541+
525542

526543
def _build_target(tgt, cmake_build_dir, args):
527544
"""

0 commit comments

Comments
 (0)