]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* ldlang.h (entry_sym): Make it a struct bfd_sym_chain.
authorAlan Modra <amodra@gmail.com>
Mon, 1 Jul 2002 08:07:31 +0000 (08:07 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 1 Jul 2002 08:07:31 +0000 (08:07 +0000)
* ldlang.c (entry_sym): Likewise.
(ldlang_undef_chain_list_type): Likewise.
(lang_finish): Adjust references to entry_symbol.
(lang_add_entry): Likewise.
(lang_gc_sections): Use link_info.gc_sym_list.
(lang_process): Set link_info.gc_sym_list.
* ldlex.l: Include bfdlink.h.
* ldmain.c (main): Init link_info.gc_sym_list.
* emultempl/aix.em: Adjust references to entry_symbol.
* emultempl/armcoff.em: Likewise.
* emultempl/armelf.em: Likewise.
* emultempl/pe.em: Likewise.
* emultempl/ppc64elf.em (ppc_after_open): New function.
(LDEMUL_AFTER_OPEN): Define.
* emulparams/elf64ppc.sh: KEEP .opd sections.

ld/ChangeLog
ld/emulparams/elf64ppc.sh
ld/emultempl/aix.em
ld/emultempl/armcoff.em
ld/emultempl/armelf.em
ld/emultempl/pe.em
ld/emultempl/ppc64elf.em
ld/ldlang.c
ld/ldlang.h
ld/ldlex.l
ld/ldmain.c

index b7a99c41e5854a4f8a86942ea1ffd84e81b12c05..a529f1b77215ee82b31fdcd6ef3ea65c4569343b 100644 (file)
@@ -1,3 +1,22 @@
+2002-07-01  Alan Modra  <amodra@bigpond.net.au>
+
+       * ldlang.h (entry_sym): Make it a struct bfd_sym_chain.
+       * ldlang.c (entry_sym): Likewise.
+       (ldlang_undef_chain_list_type): Likewise.
+       (lang_finish): Adjust references to entry_symbol.
+       (lang_add_entry): Likewise.
+       (lang_gc_sections): Use link_info.gc_sym_list.
+       (lang_process): Set link_info.gc_sym_list.
+       * ldlex.l: Include bfdlink.h.
+       * ldmain.c (main): Init link_info.gc_sym_list.
+       * emultempl/aix.em: Adjust references to entry_symbol.
+       * emultempl/armcoff.em: Likewise.
+       * emultempl/armelf.em: Likewise.
+       * emultempl/pe.em: Likewise.
+       * emultempl/ppc64elf.em (ppc_after_open): New function.
+       (LDEMUL_AFTER_OPEN): Define.
+       * emulparams/elf64ppc.sh: KEEP .opd sections.
+
 2002-06-29  Stephane Carrez  <stcarrez@nerim.fr>
 
        * emulparams/m68hc12elfb.sh (EEPROM_MEMORY): Define.
index f1647d50c0e9457b7ab7a43d400cb00adc20c23f..10593f21949367f464cd8b5811e78b354c8e83e6 100644 (file)
@@ -27,7 +27,7 @@ OTHER_GOT_RELOC_SECTIONS="
   .rela.toc    ${RELOCATING-0} : { *(.rela.toc) }"
 OTHER_READWRITE_SECTIONS="
   .toc1                ${RELOCATING-0}${RELOCATING+ALIGN(8)} : { *(.toc1) }
-  .opd         ${RELOCATING-0}${RELOCATING+ALIGN(8)} : { *(.opd) }"
+  .opd         ${RELOCATING-0}${RELOCATING+ALIGN(8)} : { KEEP (*(.opd)) }"
 
 # Treat a host that matches the target with the possible exception of "64"
 # in the name as if it were native.
index 3caa0187266c27c393504cf648d27a140fdd7c25..4388e05f7f88852f3aa2fc1522ebe72a7dff7286 100644 (file)
@@ -9,7 +9,7 @@ cat >e${EMULATION_NAME}.c <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* AIX emulation code for ${EMULATION_NAME}
-   Copyright 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2001
+   Copyright 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Steve Chamberlain <sac@cygnus.com>
    AIX support by Ian Lance Taylor <ian@cygnus.com>
@@ -682,7 +682,7 @@ gld${EMULATION_NAME}_before_allocation ()
 
   /* Let the XCOFF backend set up the .loader section.  */
   if (!bfd_xcoff_size_dynamic_sections 
-      (output_bfd, &link_info, libpath,        entry_symbol, file_align,
+      (output_bfd, &link_info, libpath,        entry_symbol.name, file_align,
        maxstack, maxdata, gc && !unix_ld ? true : false,
        modtype,        textro ? true : false, unix_ld, special_sections, 
        rtld ? true : false))
index c6a9895c3011339d57a14d77c6d5e55fec65c9a5..0b5e7bc97929083d6fd6ff2953f2054637692410 100644 (file)
@@ -4,7 +4,7 @@ cat >e${EMULATION_NAME}.c <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* emulate the original gld for the given ${EMULATION_NAME}
-   Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Steve Chamberlain steve@cygnus.com
 
@@ -203,10 +203,10 @@ gld${EMULATION_NAME}_finish PARAMS((void))
       
       sprintf_vma (buffer + 2, val);
 
-      if (entry_symbol != NULL && entry_from_cmdline)
+      if (entry_symbol.name != NULL && entry_from_cmdline)
        einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
-              thumb_entry_symbol, entry_symbol);
-      entry_symbol = buffer;
+              thumb_entry_symbol, entry_symbol.name);
+      entry_symbol.name = buffer;
     }
   else
     einfo (_("%P: warning: connot find thumb start symbol %s\n"), thumb_entry_symbol);
index 77cd4f778d2b33a4de15da1c3b61f2d0465e2c99..6f3cfc39b5f8a1173445c549b6eb0ddde50722eb 100644 (file)
@@ -172,10 +172,10 @@ arm_elf_finish ()
       
       sprintf_vma (buffer + 2, val);
 
-      if (entry_symbol != NULL && entry_from_cmdline)
+      if (entry_symbol.name != NULL && entry_from_cmdline)
        einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
-              thumb_entry_symbol, entry_symbol);
-      entry_symbol = buffer;
+              thumb_entry_symbol, entry_symbol.name);
+      entry_symbol.name = buffer;
     }
   else
     einfo (_("%P: warning: connot find thumb start symbol %s\n"),
index b84a3c75f7d609c2445b7616188995c1933fc1d6..a6dfe46373756ae0ca21589c98283627eea548f3 100644 (file)
@@ -758,8 +758,8 @@ gld_${EMULATION_NAME}_after_parse ()
      opened, so registering the symbol as undefined will make a
      difference.  */
 
-  if (! link_info.relocateable && entry_symbol != NULL)
-    ldlang_add_undef (entry_symbol);
+  if (! link_info.relocateable && entry_symbol.name != NULL)
+    ldlang_add_undef (entry_symbol.name);
 }
 
 /* pe-dll.c directly accesses pe_data_import_dll,
@@ -1418,10 +1418,10 @@ gld_${EMULATION_NAME}_finish ()
 
          sprintf_vma (buffer + 2, val);
 
-         if (entry_symbol != NULL && entry_from_cmdline)
+         if (entry_symbol.name != NULL && entry_from_cmdline)
            einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
-                  thumb_entry_symbol, entry_symbol);
-         entry_symbol = buffer;
+                  thumb_entry_symbol, entry_symbol.name);
+         entry_symbol.name = buffer;
        }
       else
        einfo (_("%P: warning: connot find thumb start symbol %s\n"), thumb_entry_symbol);
index 9ce7893b923bb047179f082a673998220b26ef49..cf6918eeed7edeabb0a50428ff1114fb9343ecf5 100644 (file)
@@ -42,6 +42,7 @@ static bfd_signed_vma group_size = 1;
 static int dotsyms = 1;
 
 static void ppc_create_output_section_statements PARAMS ((void));
+static void ppc_after_open PARAMS ((void));
 static asection *ppc_add_stub_section PARAMS ((const char *, asection *));
 static void ppc_layout_sections_again PARAMS ((void));
 static void gld${EMULATION_NAME}_after_allocation PARAMS ((void));
@@ -71,6 +72,17 @@ ppc_create_output_section_statements ()
   ldlang_add_file (stub_file);
 }
 
+static void
+ppc_after_open ()
+{
+  if (!ppc64_elf_mark_entry_syms (&link_info))
+    {
+      einfo ("%X%P: can not mark entry symbols %E\n");
+      return;
+    }
+
+  gld${EMULATION_NAME}_after_open ();
+}
 
 struct hook_stub_info
 {
@@ -473,6 +485,7 @@ PARSE_AND_LIST_ARGS_CASES='
 
 # Put these extra ppc64elf routines in ld_${EMULATION_NAME}_emulation
 #
+LDEMUL_AFTER_OPEN=ppc_after_open
 LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
 LDEMUL_FINISH=gld${EMULATION_NAME}_finish
 LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_create_output_section_statements
index abe38345fccf070701ae56193538f773534ea41d..f621e00dd329e44030f0e9ef0b6e2fd925f86d54 100644 (file)
@@ -184,7 +184,7 @@ lang_output_section_statement_type *abs_output_section;
 lang_statement_list_type lang_output_section_statement;
 lang_statement_list_type *stat_ptr = &statement_list;
 lang_statement_list_type file_chain = { NULL, NULL };
-const char *entry_symbol = NULL;
+struct bfd_sym_chain entry_symbol = { NULL, NULL };
 const char *entry_section = ".text";
 boolean entry_from_cmdline;
 boolean lang_has_input_file = false;
@@ -2030,13 +2030,9 @@ lang_reasonable_defaults ()
    on a list, then, once the output file has been opened, transfer the
    name to the symbol table.  */
 
-typedef struct ldlang_undef_chain_list
-{
-  struct ldlang_undef_chain_list *next;
-  char *name;
-}                       ldlang_undef_chain_list_type;
+typedef struct bfd_sym_chain ldlang_undef_chain_list_type;
 
-static ldlang_undef_chain_list_type *ldlang_undef_chain_list_head;
+#define ldlang_undef_chain_list_head entry_symbol.next
 
 void
 ldlang_add_undef (name)
@@ -3523,15 +3519,16 @@ lang_finish ()
   else
     warn = true;
 
-  if (entry_symbol == (char *) NULL)
+  if (entry_symbol.name == (const char *) NULL)
     {
       /* No entry has been specified.  Look for start, but don't warn
         if we don't find it.  */
-      entry_symbol = "start";
+      entry_symbol.name = "start";
       warn = false;
     }
 
-  h = bfd_link_hash_lookup (link_info.hash, entry_symbol, false, false, true);
+  h = bfd_link_hash_lookup (link_info.hash, entry_symbol.name,
+                           false, false, true);
   if (h != (struct bfd_link_hash_entry *) NULL
       && (h->type == bfd_link_hash_defined
          || h->type == bfd_link_hash_defweak)
@@ -3544,7 +3541,7 @@ lang_finish ()
                                    h->u.def.section->output_section)
             + h->u.def.section->output_offset);
       if (! bfd_set_start_address (output_bfd, val))
-       einfo (_("%P%F:%s: can't set start address\n"), entry_symbol);
+       einfo (_("%P%F:%s: can't set start address\n"), entry_symbol.name);
     }
   else
     {
@@ -3553,7 +3550,7 @@ lang_finish ()
 
       /* We couldn't find the entry symbol.  Try parsing it as a
          number.  */
-      val = bfd_scan_vma (entry_symbol, &send, 0);
+      val = bfd_scan_vma (entry_symbol.name, &send, 0);
       if (*send == '\0')
        {
          if (! bfd_set_start_address (output_bfd, val))
@@ -3570,7 +3567,8 @@ lang_finish ()
            {
              if (warn)
                einfo (_("%P: warning: cannot find entry symbol %s; defaulting to %V\n"),
-                      entry_symbol, bfd_get_section_vma (output_bfd, ts));
+                      entry_symbol.name,
+                      bfd_get_section_vma (output_bfd, ts));
              if (! bfd_set_start_address (output_bfd,
                                           bfd_get_section_vma (output_bfd,
                                                                ts)))
@@ -3580,7 +3578,7 @@ lang_finish ()
            {
              if (warn)
                einfo (_("%P: warning: cannot find entry symbol %s; not setting start address\n"),
-                      entry_symbol);
+                      entry_symbol.name);
            }
        }
     }
@@ -4146,25 +4144,16 @@ static void
 lang_gc_sections ()
 {
   struct bfd_link_hash_entry *h;
-  ldlang_undef_chain_list_type *ulist, fake_list_start;
+  ldlang_undef_chain_list_type *ulist;
 
   /* Keep all sections so marked in the link script.  */
 
   lang_gc_sections_1 (statement_list.head);
 
-  /* Keep all sections containing symbols undefined on the command-line.
-     Handle the entry symbol at the same time.  */
-
-  if (entry_symbol != NULL)
-    {
-      fake_list_start.next = ldlang_undef_chain_list_head;
-      fake_list_start.name = (char *) entry_symbol;
-      ulist = &fake_list_start;
-    }
-  else
-    ulist = ldlang_undef_chain_list_head;
+  /* Keep all sections containing symbols undefined on the command-line,
+     and the section containing the entry symbol.  */
 
-  for (; ulist; ulist = ulist->next)
+  for (ulist = link_info.gc_sym_list; ulist; ulist = ulist->next)
     {
       h = bfd_link_hash_lookup (link_info.hash, ulist->name,
                                false, false, false);
@@ -4201,6 +4190,10 @@ lang_process ()
   current_target = default_target;
   open_input_bfds (statement_list.head, false);
 
+  link_info.gc_sym_list = &entry_symbol;
+  if (entry_symbol.name == NULL)
+    link_info.gc_sym_list = ldlang_undef_chain_list_head;
+
   ldemul_after_open ();
 
   already_linked_table_free ();
@@ -4391,11 +4384,11 @@ lang_add_entry (name, cmdline)
      const char *name;
      boolean cmdline;
 {
-  if (entry_symbol == NULL
+  if (entry_symbol.name == NULL
       || cmdline
       || ! entry_from_cmdline)
     {
-      entry_symbol = name;
+      entry_symbol.name = name;
       entry_from_cmdline = cmdline;
     }
 }
index 26c4121fa7e5151c7194128353e2c6ae211f5979..cb4b6d332dc1faf208ecea664440107e8c22cb92 100644 (file)
@@ -364,7 +364,7 @@ extern etree_type *base;
 extern lang_statement_list_type *stat_ptr;
 extern boolean delete_output_file_on_failure;
 
-extern const char *entry_symbol;
+extern struct bfd_sym_chain entry_symbol;
 extern const char *entry_section;
 extern boolean entry_from_cmdline;
 extern lang_statement_list_type file_chain;
index cacec192917462288a01489a4d0b6b90b727690c..68ed7fc3ce86143677e4d1be2395c297d4c0f64b 100644 (file)
@@ -37,6 +37,7 @@ This was written by steve chamberlain
 #include "bfd.h"
 #include "sysdep.h"
 #include "safe-ctype.h"
+#include "bfdlink.h"
 #include "ld.h"
 #include "ldmisc.h"
 #include "ldexp.h"
index 2c406eb1a74d9c90a23b6506f2c3a101fac620ce..7943a9eddfdfb351145584dbd7a38f923cf7b565 100644 (file)
@@ -245,6 +245,7 @@ main (argc, argv)
   link_info.keep_memory = true;
   link_info.input_bfds = NULL;
   link_info.create_object_symbols_section = NULL;
+  link_info.gc_sym_list = NULL;
   link_info.hash = NULL;
   link_info.keep_hash = NULL;
   link_info.notice_all = false;