Skip to content

Commit 71b306a

Browse files
author
Bogdan Marinescu
committed
Improvements to Sam's platform_init.c commit
1 parent d4c04e8 commit 71b306a

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

workspace_tools/build_api.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -181,23 +181,20 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=F
181181
# Common Sources
182182
mbed_resources = toolchain.scan_resources(MBED_COMMON)
183183
objects += toolchain.compile_sources(mbed_resources, TMP_PATH, [MBED_LIBRARIES, BUILD_TARGET])
184-
185-
# Keep retargeting as a standalone object to be sure the
186-
# C standard library symbols get overridden
187-
retargeting = None
184+
185+
# A number of compiled files need to be copied as objects as opposed to
186+
# being part of the mbed library, for reasons that have to do with the way
187+
# the linker search for symbols in archives. These are:
188+
# - retarget.o: to make sure that the C standard lib symbols get overridden
189+
# - board.o: mbed_die is weak
190+
# - mbed_overrides.o: this contains platform overrides of various weak SDK functions
191+
separate_names, separate_objects = ['retarget.o', 'board.o', 'mbed_overrides.o'], []
188192
for o in objects:
189-
if o.endswith('retarget.o'):
190-
retargeting = o
191-
objects.remove(retargeting)
192-
# We need to have a file that overrides weak delcatations on a per board basis and the
193-
# lesser evil is to pull in this file if it extist rather than add board specific
194-
# startup code in the /targets/cmsis directory
195-
platform_initialize = None
196-
for p in objects:
197-
if p.endswith('platform_init.o'):
198-
platform_initialize = p
199-
objects.remove(platform_initialize)
193+
for name in separate_names:
194+
if o.endswith(name):
195+
separate_objects.append(o)
196+
for o in separate_objects:
197+
objects.remove(o)
200198
toolchain.build_library(objects, BUILD_TOOLCHAIN, "mbed")
201-
toolchain.copy_files(retargeting, BUILD_TOOLCHAIN)
202-
toolchain.copy_files(platform_initialize, BUILD_TOOLCHAIN)
203-
199+
for o in separate_objects:
200+
toolchain.copy_files(o, BUILD_TOOLCHAIN)

0 commit comments

Comments
 (0)