mirror of https://github.com/ARMmbed/mbed-os.git
Use the C Pre-Processor on GCC Linker scirpts
This allows us to define parts of the linker script outside of the linker script itself. In particular, we are interested in restricting ROM to a subsection.pull/3706/head
parent
160455c972
commit
af4d848144
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
"""
|
||||
import re
|
||||
from os.path import join, basename, splitext
|
||||
from os.path import join, basename, splitext, dirname
|
||||
|
||||
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
|
||||
from tools.hooks import hook_tool
|
||||
|
@ -93,6 +93,7 @@ class GCC(mbedToolchain):
|
|||
self.flags['ld'] += self.cpu
|
||||
self.ld = [join(tool_path, "arm-none-eabi-gcc")] + self.flags['ld']
|
||||
self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc"]
|
||||
self.preproc = [join(tool_path, "arm-none-eabi-cpp"), "-E", "-P"]
|
||||
|
||||
self.ar = join(tool_path, "arm-none-eabi-ar")
|
||||
self.elf2bin = join(tool_path, "arm-none-eabi-objcopy")
|
||||
|
@ -213,6 +214,15 @@ class GCC(mbedToolchain):
|
|||
libs.append("-l%s" % name[3:])
|
||||
libs.extend(["-l%s" % l for l in self.sys_libs])
|
||||
|
||||
# Preprocess
|
||||
if mem_map:
|
||||
preproc_output = join(dirname(output), ".link_script.ld")
|
||||
cmd = (self.preproc + [mem_map] + self.ld[1:] +
|
||||
[ "-o", preproc_output])
|
||||
self.cc_verbose("Preproc: %s" % ' '.join(cmd))
|
||||
self.default_cmd(cmd)
|
||||
mem_map = preproc_output
|
||||
|
||||
# Build linker command
|
||||
map_file = splitext(output)[0] + ".map"
|
||||
cmd = self.ld + ["-o", output, "-Wl,-Map=%s" % map_file] + objects + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"]
|
||||
|
|
Loading…
Reference in New Issue