Skip to content

Commit 87304f8

Browse files
Updated to include user defined static lib files in the Linker object files path.
### Description This is to fix linker not finding symbols declared in object files inside static library files. For this case throwing:- > rm-none-eabi-g++: error: unrecognized command line option '--wrap=main'; did you mean '--warn-main'? For this case to include libmbed.a which contains mbed_alloc_wrappers.o: U __real__calloc_r U __real__free_r U __real__malloc_r U __real__memalign_r U __real__realloc_r 00000000 T __wrap__calloc_r 00000000 T __wrap__free_r 00000000 T __wrap__malloc_r 00000000 T __wrap__memalign_r 00000000 T __wrap__realloc_r 00000000 T free_wrapper 00000000 T malloc_wrapper 00000000 T mbed_stats_heap_get U memset This patch also changed the library order to system and then user. -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -lmbed Resolves: #7155 ### Pull request type [ x ] Fix [ ] Refactor [ ] Target update [ ] Feature [ ] Breaking change
1 parent 2a824a1 commit 87304f8

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

tools/export/e2studio/.cproject.tmpl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,20 @@
326326
{% endfor %}
327327
</option>
328328
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.libs.{{u.id}}" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.libs" valueType="libs">
329-
{% for lib in opts['ld']['user_libraries'] %}
329+
{% for lib in opts['ld']['system_libraries'] %}
330330
<listOptionValue builtIn="false" value="{{lib}}"/>
331331
{% endfor %}
332-
{% for lib in opts['ld']['system_libraries'] %}
332+
{% for lib in opts['ld']['user_libraries'] %}
333333
<listOptionValue builtIn="false" value="{{lib}}"/>
334334
{% endfor %}
335335
</option>
336336
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.otherobjs.{{u.id}}" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.otherobjs" valueType="userObjs">
337337
{% for path in opts['ld']['object_files'] %}
338338
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/{{path}}&quot;"/>
339339
{% endfor %}
340+
{% for path in opts['ld']['user_library_files'] %}
341+
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/{{path}}&quot;"/>
342+
{% endfor %}
340343
</option>
341344
{% if opts['ld']['gcsections'] %}
342345
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections.{{u.id}}" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections" value="true" valueType="boolean"/>

tools/export/gnuarmeclipse/.cproject.tmpl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,20 @@
326326
{% endfor %}
327327
</option>
328328
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.libs.{{u.id}}" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.libs" valueType="libs">
329-
{% for lib in opts['ld']['user_libraries'] %}
329+
{% for lib in opts['ld']['system_libraries'] %}
330330
<listOptionValue builtIn="false" value="{{lib}}"/>
331331
{% endfor %}
332-
{% for lib in opts['ld']['system_libraries'] %}
332+
{% for lib in opts['ld']['user_libraries'] %}
333333
<listOptionValue builtIn="false" value="{{lib}}"/>
334334
{% endfor %}
335335
</option>
336336
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.otherobjs.{{u.id}}" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.otherobjs" valueType="userObjs">
337337
{% for path in opts['ld']['object_files'] %}
338338
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/{{path}}&quot;"/>
339339
{% endfor %}
340+
{% for path in opts['ld']['user_library_files'] %}
341+
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/{{path}}&quot;"/>
342+
{% endfor %}
340343
</option>
341344
{% if opts['ld']['gcsections'] %}
342345
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections.{{u.id}}" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections" value="true" valueType="boolean"/>

tools/export/gnuarmeclipse/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ def create_jinja_ctx(self):
9090
# TODO: use some logger to display additional info if verbose
9191

9292
libraries = []
93+
library_files = []
9394
for lib in self.libraries:
95+
library_files.append(self.filter_dot(lib))
9496
l, _ = splitext(basename(lib))
9597
libraries.append(l[3:])
9698

@@ -178,6 +180,7 @@ def create_jinja_ctx(self):
178180

179181
opts['ld']['object_files'] = objects
180182
opts['ld']['user_libraries'] = libraries
183+
opts['ld']['user_library_files'] = library_files
181184
opts['ld']['system_libraries'] = self.system_libraries
182185
opts['ld']['script'] = join(id.capitalize(),
183186
"linker-script-%s.ld" % id)

0 commit comments

Comments
 (0)