Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: toolchains/arm.py
- Revision:
- 36:96847d42f010
- Parent:
- 35:da9c89f8be7d
- Child:
- 40:7d3fa6b99b2b
diff -r da9c89f8be7d -r 96847d42f010 toolchains/arm.py
--- a/toolchains/arm.py Wed Feb 15 13:53:18 2017 -0600
+++ b/toolchains/arm.py Thu Jun 22 11:12:28 2017 -0500
@@ -15,7 +15,9 @@
limitations under the License.
"""
import re
-from os.path import join, dirname, splitext, basename
+from os.path import join, dirname, splitext, basename, exists
+from os import makedirs, write
+from tempfile import mkstemp
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
from tools.hooks import hook_tool
@@ -38,8 +40,10 @@
return mbedToolchain.generic_check_executable("ARM", 'armcc', 2, 'bin')
def __init__(self, target, notify=None, macros=None,
- silent=False, extra_verbose=False, build_profile=None):
+ silent=False, extra_verbose=False, build_profile=None,
+ build_dir=None):
mbedToolchain.__init__(self, target, notify, macros, silent,
+ build_dir=build_dir,
extra_verbose=extra_verbose,
build_profile=build_profile)
@@ -179,6 +183,8 @@
else:
args = ["-o", output, "--info=totals", "--map", "--list=%s" % map_file]
+ args.extend(self.flags['ld'])
+
if mem_map:
args.extend(["--scatter", mem_map])
@@ -210,8 +216,10 @@
@hook_tool
def binary(self, resources, elf, bin):
+ _, fmt = splitext(bin)
+ bin_arg = {".bin": "--bin", ".hex": "--i32"}[fmt]
# Build binary command
- cmd = [self.elf2bin, '--bin', '-o', bin, elf]
+ cmd = [self.elf2bin, bin_arg, '-o', bin, elf]
# Call cmdline hook
cmd = self.hook.get_cmdline_binary(cmd)
@@ -220,6 +228,22 @@
self.cc_verbose("FromELF: %s" % ' '.join(cmd))
self.default_cmd(cmd)
+ @staticmethod
+ def name_mangle(name):
+ return "_Z%i%sv" % (len(name), name)
+
+ @staticmethod
+ def make_ld_define(name, value):
+ return "--predefine=\"-D%s=0x%x\"" % (name, value)
+
+ @staticmethod
+ def redirect_symbol(source, sync, build_dir):
+ if not exists(build_dir):
+ makedirs(build_dir)
+ handle, filename = mkstemp(prefix=".redirect-symbol.", dir=build_dir)
+ write(handle, "RESOLVE %s AS %s\n" % (source, sync))
+ return "--edit=%s" % filename
+
class ARM_STD(ARM):
pass
