From 8681a8d53e5d309b3f42b86e42ca6523ab61b34b Mon Sep 17 00:00:00 2001 From: 0xc0170 Date: Thu, 5 May 2016 17:28:42 -0500 Subject: [PATCH 1/2] gcc - use group for ld to resolve symbols from libraries This fixes problem we have seen with rtos_idle_loop. The symbols was not resolved as order played a role in this case. Remove circular dependencies member, as it should not be required anymore. --- workspace_tools/toolchains/gcc.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/workspace_tools/toolchains/gcc.py b/workspace_tools/toolchains/gcc.py index a292a69cb6b..76936529303 100644 --- a/workspace_tools/toolchains/gcc.py +++ b/workspace_tools/toolchains/gcc.py @@ -27,7 +27,6 @@ class GCC(mbedToolchain): LIBRARY_EXT = '.a' STD_LIB_NAME = "lib%s.a" - CIRCULAR_DEPENDENCIES = True DIAGNOSTIC_PATTERN = re.compile('((?P\d+):)(\d+:)? (?Pwarning|error): (?P.+)') def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False): @@ -171,15 +170,8 @@ def link(self, output, objects, libraries, lib_dirs, mem_map): libs.append("-l%s" % name[3:]) libs.extend(["-l%s" % l for l in self.sys_libs]) - # NOTE: There is a circular dependency between the mbed library and the clib - # We could define a set of week symbols to satisfy the clib dependencies in "sys.o", - # but if an application uses only clib symbols and not mbed symbols, then the final - # image is not correctly retargeted - if self.CIRCULAR_DEPENDENCIES: - libs.extend(libs) - self.default_cmd(self.hook.get_cmdline_linker(self.ld + ["-T%s" % mem_map, "-o", output] + - objects + ["-L%s" % L for L in lib_dirs] + libs)) + objects + ["-L%s" % L for L in lib_dirs] + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"])) @hook_tool def binary(self, resources, elf, bin): From 58e47dc500ea38f759923d9c59a660353e0d2482 Mon Sep 17 00:00:00 2001 From: 0xc0170 Date: Mon, 9 May 2016 12:06:33 -0500 Subject: [PATCH 2/2] gcc makefile - use group for ld to resolve symbols from libraries --- workspace_tools/export/gcc_arm_common.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace_tools/export/gcc_arm_common.tmpl b/workspace_tools/export/gcc_arm_common.tmpl index 6f9e76fcec4..d641b0af3dd 100644 --- a/workspace_tools/export/gcc_arm_common.tmpl +++ b/workspace_tools/export/gcc_arm_common.tmpl @@ -81,7 +81,7 @@ clean: {% block target_project_elf %} $(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) - $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) + $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ -Wl,--start-group $(LIBRARIES) $(LD_SYS_LIBS) -Wl,--end-group {% endblock %} $(PROJECT).bin: $(PROJECT).elf