Skip to content

Commit b2bfe82

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 cca592d commit b2bfe82

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
@@ -519,6 +519,23 @@ def _copy_library(source, toolchain):
519519

520520
shutil.copy2(src_file, dst_file)
521521

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

523540
def _build_target(tgt, cmake_build_dir, args):
524541
"""

0 commit comments

Comments
 (0)