]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Merge from mainline.
authorAlan Modra <amodra@gmail.com>
Thu, 28 Mar 2002 06:26:58 +0000 (06:26 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 28 Mar 2002 06:26:58 +0000 (06:26 +0000)
2002-03-21  Albert Chin-A-Young  <china@thewrittenword.com>
* genscripts.sh (LIB_SEARCH_DIRS): Quote path.

2002-03-20  Alan Modra  <amodra@bigpond.net.au>
* ldlang.c (ldlang_add_undef): If the output bfd has been opened,
add the symbol to the linker hash table immediately.
(lang_place_undefineds): Split symbol creation out..
(insert_undefined): ..to here.

2002-03-18  Alan Modra  <amodra@bigpond.net.au>
* ldmain.c (main): Move .text readonly flag fudges from here..
* ldlang.c (lang_process): ..to here.

2002-03-14  Alan Modra  <amodra@bigpond.net.au>
* ldlang.c (lang_check): Remove the word size check added in last
change.  Treat emitrelocations case as for relocatable links.

2002-03-13  Alan Modra  <amodra@bigpond.net.au>
* ldlang.c (lang_check): Do relocatable link checks first, so that
warn_mismatch can't override.  Check compatible and word size too.

2002-03-04  H.J. Lu <hjl@gnu.org>
* scripttempl/elf.sc: Put .preinit_array, .init_array and
.fini_array in the data segment.

2002-03-04  Alan Modra  <amodra@bigpond.net.au>
* scripttempl/elf.sc: Correct syntax errors in 2002-03-01 commit.

2002-03-01  David Mosberger  <davidm@hpl.hp.com>
* scripttempl/elf.sc (SECTIONS): Add entries for .preinit_array,
.init_array, and .fini_array.

ld/ChangeLog
ld/genscripts.sh
ld/ldlang.c
ld/ldmain.c
ld/scripttempl/elf.sc

index 941ffeb6db45c840f6047ec92f32cf846a697ad0..2042d248e03dfc7906282efaf832266d3b920450 100644 (file)
@@ -1,3 +1,38 @@
+2002-03-28  Alan Modra  <amodra@bigpond.net.au>
+
+       Merge from mainline.
+       2002-03-21  Albert Chin-A-Young  <china@thewrittenword.com>
+       * genscripts.sh (LIB_SEARCH_DIRS): Quote path.
+
+       2002-03-20  Alan Modra  <amodra@bigpond.net.au>
+       * ldlang.c (ldlang_add_undef): If the output bfd has been opened,
+       add the symbol to the linker hash table immediately.
+       (lang_place_undefineds): Split symbol creation out..
+       (insert_undefined): ..to here.
+
+       2002-03-18  Alan Modra  <amodra@bigpond.net.au>
+       * ldmain.c (main): Move .text readonly flag fudges from here..
+       * ldlang.c (lang_process): ..to here.
+
+       2002-03-14  Alan Modra  <amodra@bigpond.net.au>
+       * ldlang.c (lang_check): Remove the word size check added in last
+       change.  Treat emitrelocations case as for relocatable links.
+
+       2002-03-13  Alan Modra  <amodra@bigpond.net.au>
+       * ldlang.c (lang_check): Do relocatable link checks first, so that
+       warn_mismatch can't override.  Check compatible and word size too.
+
+       2002-03-04  H.J. Lu <hjl@gnu.org>
+       * scripttempl/elf.sc: Put .preinit_array, .init_array and
+       .fini_array in the data segment.
+
+       2002-03-04  Alan Modra  <amodra@bigpond.net.au>
+       * scripttempl/elf.sc: Correct syntax errors in 2002-03-01 commit.
+
+       2002-03-01  David Mosberger  <davidm@hpl.hp.com>
+       * scripttempl/elf.sc (SECTIONS): Add entries for .preinit_array,
+       .init_array, and .fini_array.
+
 2002-03-18  David O'Brien  <obrien@FreeBSD.org>
 
        * emultempl/elf32.em: Use lbasename vs. basename to fix problem where
@@ -8,10 +43,7 @@ Mon Mar 18 18:07:20 CET 2002  Jan Hubicka  <jh@suse.cz>
                              Andreas Jaeger  <aj@suse.de>
                              Andreas Schwab  <schwab@suse.de>
 
-       * cpu-i386.c (bfd_x86_64_arch): Rename to "i386:x86-64"
-
        * configure.tgt (x86_64-*-linux-gnu*): Configure i386 as native.
-       
        * elf_x86_64.sh (ARCH): Set to i386:x86-64
        set libraries to default to lib64 paths.
 
index 501a68c8b9a5b6bb53a26dfa0080be2a7f346a07..fe1fa499f5ab18a8fab02fc014df76a5973943c1 100755 (executable)
@@ -69,7 +69,7 @@ fi
 # Always search $(tooldir)/lib, aka /usr/local/TARGET/lib.
 LIB_PATH=${LIB_PATH}:${tool_lib}
 
-LIB_SEARCH_DIRS=`echo ${LIB_PATH} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'`
+LIB_SEARCH_DIRS=`echo ${LIB_PATH} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`
 
 # Generate 5 or 6 script files from a master script template in
 # ${srcdir}/scripttempl/${SCRIPT_NAME}.sh.  Which one of the 5 or 6
index a5b1dd7e7e6f336068c6036a2be7be0913f169ae..5257547b95245426560d4a808ac68293d367a4cd 100644 (file)
@@ -92,6 +92,7 @@ static bfd *open_output PARAMS ((const char *));
 static void ldlang_open_output PARAMS ((lang_statement_union_type *));
 static void open_input_bfds PARAMS ((lang_statement_union_type *, boolean));
 static void lang_reasonable_defaults PARAMS ((void));
+static void insert_undefined PARAMS ((const char *));
 static void lang_place_undefineds PARAMS ((void));
 static void map_input_to_output_sections
   PARAMS ((lang_statement_union_type *, const char *,
@@ -2007,7 +2008,11 @@ lang_reasonable_defaults ()
 }
 
 /* Add the supplied name to the symbol table as an undefined reference.
-   Remove items from the chain as we open input bfds.  */
+   This is a two step process as the symbol table doesn't even exist at
+   the time the ld command line is processed.  First we put the name
+   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;
@@ -2028,6 +2033,28 @@ ldlang_add_undef (name)
   ldlang_undef_chain_list_head = new;
 
   new->name = xstrdup (name);
+
+  if (output_bfd != NULL)
+    insert_undefined (new->name);
+}
+
+/* Insert NAME as undefined in the symbol table.  */
+
+static void
+insert_undefined (name)
+     const char *name;
+{
+  struct bfd_link_hash_entry *h;
+
+  h = bfd_link_hash_lookup (link_info.hash, name, true, false, true);
+  if (h == (struct bfd_link_hash_entry *) NULL)
+    einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n"));
+  if (h->type == bfd_link_hash_new)
+    {
+      h->type = bfd_link_hash_undefined;
+      h->u.undef.abfd = NULL;
+      bfd_link_add_undef (link_info.hash, h);
+    }
 }
 
 /* Run through the list of undefineds created above and place them
@@ -2043,17 +2070,7 @@ lang_place_undefineds ()
        ptr != (ldlang_undef_chain_list_type *) NULL;
        ptr = ptr->next)
     {
-      struct bfd_link_hash_entry *h;
-
-      h = bfd_link_hash_lookup (link_info.hash, ptr->name, true, false, true);
-      if (h == (struct bfd_link_hash_entry *) NULL)
-       einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n"));
-      if (h->type == bfd_link_hash_new)
-       {
-         h->type = bfd_link_hash_undefined;
-         h->u.undef.abfd = NULL;
-         bfd_link_add_undef (link_info.hash, h);
-       }
+      insert_undefined (ptr->name);
     }
 }
 
@@ -3517,8 +3534,25 @@ lang_check ()
        file = file->input_statement.next)
     {
       input_bfd = file->input_statement.the_bfd;
-      compatible = bfd_arch_get_compatible (input_bfd,
-                                           output_bfd);
+      compatible = bfd_arch_get_compatible (input_bfd, output_bfd);
+
+      /* In general it is not possible to perform a relocatable
+        link between differing object formats when the input
+        file has relocations, because the relocations in the
+        input format may not have equivalent representations in
+        the output format (and besides BFD does not translate
+        relocs for other link purposes than a final link).  */
+      if ((link_info.relocateable || link_info.emitrelocations)
+         && (compatible == NULL
+             || bfd_get_flavour (input_bfd) != bfd_get_flavour (output_bfd))
+         && (bfd_get_file_flags (input_bfd) & HAS_RELOC) != 0)
+       {
+         einfo (_("%P%F: Relocatable linking with relocations from format %s (%B) to format %s (%B) is not supported\n"),
+                bfd_get_target (input_bfd), input_bfd,
+                bfd_get_target (output_bfd), output_bfd);
+         /* einfo with %F exits.  */
+       }
+
       if (compatible == NULL)
        {
          if (command_line.warn_mismatch)
@@ -3526,18 +3560,6 @@ lang_check ()
                   bfd_printable_name (input_bfd), input_bfd,
                   bfd_printable_name (output_bfd));
        }
-      else if (link_info.relocateable
-              /* In general it is not possible to perform a relocatable
-                 link between differing object formats when the input
-                 file has relocations, because the relocations in the
-                 input format may not have equivalent representations in
-                 the output format (and besides BFD does not translate
-                 relocs for other link purposes than a final link).  */
-              && bfd_get_flavour (input_bfd) != bfd_get_flavour (output_bfd)
-              && (bfd_get_file_flags (input_bfd) & HAS_RELOC) != 0)
-       einfo (_("%P%F: Relocatable linking with relocations from format %s (%B) to format %s (%B) is not supported\n"),
-              bfd_get_target (input_bfd), input_bfd,
-              bfd_get_target (output_bfd), output_bfd);
       else if (bfd_count_sections (input_bfd))
        {
          /* If the input bfd has no contents, it shouldn't set the
@@ -4141,6 +4163,22 @@ lang_process ()
   /* Find any sections not attached explicitly and handle them.  */
   lang_place_orphans ();
 
+  if (! link_info.relocateable)
+    {
+      /* Look for a text section and set the readonly attribute in it.  */
+      asection *found = bfd_get_section_by_name (output_bfd, ".text");
+
+      if (found != (asection *) NULL)
+       {
+         if (config.text_read_only)
+           found->flags |= SEC_READONLY;
+         else
+           found->flags &= ~SEC_READONLY;
+       }
+    }
+
+  /* Do anything special before sizing sections.  This is where ELF
+     and other back-ends size dynamic sections.  */
   ldemul_before_allocation ();
 
   /* We must record the program headers before we try to fix the
index 12e31dd91fbe7184a8f6398537335c7197f83295..5bda3d3928c8c2814aaa099c8ac94a6602f6dac0 100644 (file)
@@ -404,20 +404,6 @@ main (argc, argv)
   /* Print error messages for any missing symbols, for any warning
      symbols, and possibly multiple definitions.  */
 
-  if (! link_info.relocateable)
-    {
-      /* Look for a text section and switch the readonly attribute in it.  */
-      asection *found = bfd_get_section_by_name (output_bfd, ".text");
-
-      if (found != (asection *) NULL)
-       {
-         if (config.text_read_only)
-           found->flags |= SEC_READONLY;
-         else
-           found->flags &= ~SEC_READONLY;
-       }
-    }
-
   if (link_info.relocateable)
     output_bfd->flags &= ~EXEC_P;
   else
index fe8e2422dd55f7da6a6989c66ca7c2aca7828138..fd31d0378063e5dc6e9b6bd3037922a563b4781f 100644 (file)
@@ -272,6 +272,23 @@ cat <<EOF
   ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
 
+  /* Ensure the __preinit_array_start label is properly aligned.  We
+     could instead move the label definition inside the section, but
+     the linker would then create the section even if it turns out to
+     be empty, which isn't pretty.  */
+  ${RELOCATING+. = ALIGN(${ALIGNMENT});}
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}}
+  .preinit_array   ${RELOCATING-0} : { *(.preinit_array) }
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}}
+
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .);}}
+  .init_array   ${RELOCATING-0} : { *(.init_array) }
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}}
+
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}}
+  .fini_array   ${RELOCATING-0} : { *(.fini_array) }
+  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
+
   .data         ${RELOCATING-0} :
   {
     ${RELOCATING+${DATA_START_SYMBOLS}}