* scripttempl/epiphany_4x4.sc, emulparams/elf32epiphany_4x4.sh: Add.
[deliverable/binutils-gdb.git] / ld / emultempl / lnk960.em
index aa5afcc11fe5397819d2e20df3e0a9ff54043eab..e556d432352656382fac0f5578a9d5d2a68d9599 100644 (file)
@@ -130,15 +130,73 @@ lnk960_after_parse (void)
   add_on (syslib_list, lang_input_file_is_search_file_enum);
 }
 
+/* Create a symbol with the given name with the value of the
+   address of first byte of the section named.
+
+   If the symbol already exists, then do nothing.  */
+
+static void
+symbol_at_beginning_of (const char *secname, const char *name)
+{
+  struct bfd_link_hash_entry *h;
+
+  h = bfd_link_hash_lookup (link_info.hash, name, TRUE, TRUE, TRUE);
+  if (h == NULL)
+    einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n"));
+
+  if (h->type == bfd_link_hash_new
+      || h->type == bfd_link_hash_undefined)
+    {
+      asection *sec;
+
+      h->type = bfd_link_hash_defined;
+
+      sec = bfd_get_section_by_name (link_info.output_bfd, secname);
+      if (sec == NULL)
+       sec = bfd_abs_section_ptr;
+      h->u.def.value = 0;
+      h->u.def.section = sec;
+    }
+}
+
+/* Create a symbol with the given name with the value of the
+   address of the first byte after the end of the section named.
+
+   If the symbol already exists, then do nothing.  */
+
+static void
+symbol_at_end_of (const char *secname, const char *name)
+{
+  struct bfd_link_hash_entry *h;
+
+  h = bfd_link_hash_lookup (link_info.hash, name, TRUE, TRUE, TRUE);
+  if (h == NULL)
+    einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n"));
+
+  if (h->type == bfd_link_hash_new
+      || h->type == bfd_link_hash_undefined)
+    {
+      asection *sec;
+
+      h->type = bfd_link_hash_defined;
+
+      sec = bfd_get_section_by_name (link_info.output_bfd, secname);
+      if (sec == NULL)
+       sec = bfd_abs_section_ptr;
+      h->u.def.value = sec->size;
+      h->u.def.section = sec;
+    }
+}
+
 static void
 lnk960_after_allocation (void)
 {
   if (!link_info.relocatable)
     {
-      lang_abs_symbol_at_end_of (".text", "_etext");
-      lang_abs_symbol_at_end_of (".data", "_edata");
-      lang_abs_symbol_at_beginning_of (".bss", "_bss_start");
-      lang_abs_symbol_at_end_of (".bss", "_end");
+      symbol_at_end_of (".text", "_etext");
+      symbol_at_end_of (".data", "_edata");
+      symbol_at_beginning_of (".bss", "_bss_start");
+      symbol_at_end_of (".bss", "_end");
     }
 }
 
@@ -189,7 +247,7 @@ lnk960_set_output_arch (void)
          break;
        }
     }
-  bfd_set_arch_mach (output_bfd, ldfile_output_architecture,
+  bfd_set_arch_mach (link_info.output_bfd, ldfile_output_architecture,
                     ldfile_output_machine);
 }
 
@@ -265,7 +323,7 @@ struct ld_emulation_xfer_struct ld_lnk960_emulation =
   lnk960_syslib,
   lnk960_hll,
   lnk960_after_parse,
-  NULL,                        /* after_open */
+  after_open_default,
   lnk960_after_allocation,
   lnk960_set_output_arch,
   lnk960_choose_target,
This page took 0.024426 seconds and 4 git commands to generate.