Skip to content

Commit 15cfb8f

Browse files
committed
Merge pull request #1718 from 0xc0170/fix_rtos_idle
gcc - use group for ld to resolve symbols from libraries
2 parents c5b4c54 + 58e47dc commit 15cfb8f

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

workspace_tools/export/gcc_arm_common.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ clean:
8181

8282
{% block target_project_elf %}
8383
$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
84-
$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
84+
$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ -Wl,--start-group $(LIBRARIES) $(LD_SYS_LIBS) -Wl,--end-group
8585
{% endblock %}
8686

8787
$(PROJECT).bin: $(PROJECT).elf

workspace_tools/toolchains/gcc.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class GCC(mbedToolchain):
2727
LIBRARY_EXT = '.a'
2828

2929
STD_LIB_NAME = "lib%s.a"
30-
CIRCULAR_DEPENDENCIES = True
3130
DIAGNOSTIC_PATTERN = re.compile('((?P<line>\d+):)(\d+:)? (?P<severity>warning|error): (?P<message>.+)')
3231

3332
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):
171170
libs.append("-l%s" % name[3:])
172171
libs.extend(["-l%s" % l for l in self.sys_libs])
173172

174-
# NOTE: There is a circular dependency between the mbed library and the clib
175-
# We could define a set of week symbols to satisfy the clib dependencies in "sys.o",
176-
# but if an application uses only clib symbols and not mbed symbols, then the final
177-
# image is not correctly retargeted
178-
if self.CIRCULAR_DEPENDENCIES:
179-
libs.extend(libs)
180-
181173
self.default_cmd(self.hook.get_cmdline_linker(self.ld + ["-T%s" % mem_map, "-o", output] +
182-
objects + ["-L%s" % L for L in lib_dirs] + libs))
174+
objects + ["-L%s" % L for L in lib_dirs] + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"]))
183175

184176
@hook_tool
185177
def binary(self, resources, elf, bin):

0 commit comments

Comments
 (0)