Skip to content

Preprocessing of linker script does not include macro definitions #11214

@jacob-larsen-samsung

Description

@jacob-larsen-samsung

Description

Any linker scripts defined by a target are put through the C preprocessor before linking. Unfortunately, the macro definitions from config and COMPONENT/FEATURE/TARGET are not included in this process, which limits the usefulness of this.

I patched around a bit, and if I change to the following in gcc.py in the link() function, it works as expected:

        # Preprocess
        if mem_map:
            preproc_output = join(dirname(output), ".link_script.ld")
            cmd = (
                self.preproc + [mem_map] + self.ld[1:] + ["-o", preproc_output] +
                self.get_compile_options(self.get_symbols(), [])
            )
            self.notify.cc_verbose("Preproc: %s" % ' '.join(cmd))
            self.default_cmd(cmd)
            mem_map = preproc_output

Would this be something that can be patched into mbed?

Issue request type

[ ] Question
[ ] Enhancement
[x] Bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions