[PATCH 0/2] ld: On defsym, PROVIDE, and MEMORY regions

Andrew Burgess andrew.burgess@embecosm.com
Mon Oct 12 13:49:13 GMT 2020


These two patches came from a simple idea, using --defsym to
optionally provide the origin and length for a MEMORY region, and
having a default origin and length written into the linker script
using PROVIDE, so:

  PROVIDE (the_origin = 0x....)
  PROVIDE (the_length = 0x....)

  MEMORY
  {
    REGION : ORIGIN = the_origin, LENGTH = the_length;
  }

and linking with one of:

  ld --defsym=the_origin=0x.... --defsym=the_length=0x.... -Tscript.ld ......
  ld -Tscript.ld ......

I was initially placing `--defsym` after `-Tscript.ld`, and it turns
out the ordering of these two options is important.  The documentation
doesn't really (I feel) make this clear, this is addressed in patch #1.

Then it turns out that you can't use PROVIDE with MEMORY regions like
I wanted, which is addressed in patch #2.

All feedback welcome.

Thanks,
Andrew


---

Andrew Burgess (2):
  ld: More documentation for --defsym
  ld: Allow symbols from PROVIDE to be use in MEMORY regions

 ld/ChangeLog                           | 20 +++++++++
 ld/ld.texi                             |  9 ++++
 ld/ldlang.c                            | 59 +++++++++++++++++---------
 ld/testsuite/ld-scripts/provide-10.d   |  3 ++
 ld/testsuite/ld-scripts/provide-10.map |  6 +++
 ld/testsuite/ld-scripts/provide-11.d   |  3 ++
 ld/testsuite/ld-scripts/provide-11.map |  6 +++
 ld/testsuite/ld-scripts/provide-12.d   |  3 ++
 ld/testsuite/ld-scripts/provide-12.map |  6 +++
 ld/testsuite/ld-scripts/provide-9.d    |  3 ++
 ld/testsuite/ld-scripts/provide-9.map  |  6 +++
 ld/testsuite/ld-scripts/provide-9.t    | 25 +++++++++++
 12 files changed, 129 insertions(+), 20 deletions(-)
 create mode 100644 ld/testsuite/ld-scripts/provide-10.d
 create mode 100644 ld/testsuite/ld-scripts/provide-10.map
 create mode 100644 ld/testsuite/ld-scripts/provide-11.d
 create mode 100644 ld/testsuite/ld-scripts/provide-11.map
 create mode 100644 ld/testsuite/ld-scripts/provide-12.d
 create mode 100644 ld/testsuite/ld-scripts/provide-12.map
 create mode 100644 ld/testsuite/ld-scripts/provide-9.d
 create mode 100644 ld/testsuite/ld-scripts/provide-9.map
 create mode 100644 ld/testsuite/ld-scripts/provide-9.t

-- 
2.25.4



More information about the Binutils mailing list