This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ld: How to build + install a 2nd set of default linker scripts?

On 12.05.2017 12:10, Georg-Johann Lay wrote:
In order to support default linker description files which
can be selected by a command line option, I added the following
hook and option avr_no_rodata_in_ram to emultempl/avrelf.em:

diff --git a/ld/emultempl/avrelf.em b/ld/emultempl/avrelf.em
index 2072124..7781e9f 100644
--- a/ld/emultempl/avrelf.em
+++ b/ld/emultempl/avrelf.em
@@ ...
@@ -60,6 +61,37 @@ avr_elf_set_global_bfd_parameters (void)

+static char *
+gld${EMULATION_NAME}_get_script (int *isfile)
+  *isfile = 1;
+  if (avr_no_rodata_in_ram
+      && 0 == strcmp ("avrxmega2", "${EMULATION_NAME}"))
+    {
+      if (bfd_link_relocatable (&link_info) && config.build_constructors)
+    return "ldscripts/${EMULATION_NAME}-rodata.xu";
+      else if (bfd_link_relocatable (&link_info))
+    return "ldscripts/${EMULATION_NAME}-rodata.xr";
+      else if (!config.text_read_only)
+    return "ldscripts/${EMULATION_NAME}-rodata.xbn";
+      else if (!config.magic_demand_paged)
+    return "ldscripts/${EMULATION_NAME}-rodata.xn";
+      else
+    return "ldscripts/${EMULATION_NAME}-rodata.x";
+    }
+  if (bfd_link_relocatable (&link_info) && config.build_constructors)
+    return "ldscripts/${EMULATION_NAME}.xu";
+  else if (bfd_link_relocatable (&link_info))
+    return "ldscripts/${EMULATION_NAME}.xr";
+  else if (!config.text_read_only)
+    return "ldscripts/${EMULATION_NAME}.xbn";
+  else if (!config.magic_demand_paged)
+    return "ldscripts/${EMULATION_NAME}.xn";
+  else
+    return "ldscripts/${EMULATION_NAME}.x";

 /* Makes a conservative estimate of the trampoline section size that could
    be corrected later on.  */
@@ ...
@@ -311,3 +350,4 @@



The purpose it to introduce a new command line option to use the
${EMULATION_NAME}-rodata.x* set of default ld files instead of the
common ${EMULATION_NAME}-rodata.x* ones.

All this works out as expected, but where I am stuck is how to
build and install that new flavour of default scripts.

I extended scripttempl/ so that it can generate the two
variants depending on whether a specific variable is set,
but how / where do I generate the 2nd flavour of scripts?

Skimming doesn't give much of a clue, and as I
don't want to extend that script I am asking here for some
guidance on how to achieve $subject.

Ok, so at least the installation part is trivial because
anything that's found in ld/ldscripts will be installed.

But still no clue about how to generate the ld scripts...


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]