OSDN Git Service

binutils ChangeLog:
authorbwilson <bwilson>
Mon, 17 May 2004 16:39:58 +0000 (16:39 +0000)
committerbwilson <bwilson>
Mon, 17 May 2004 16:39:58 +0000 (16:39 +0000)
2004-05-17  David Heine  <dlheine@tensilica.com>
* objcopy.c (setup_bfd_headers): New function.
(copy_object): Call setup_bfd_headers.
bfd ChangeLog:
2004-05-17  David Heine  <dlheine@tensilica.com>
* aout-target.h (MY_bfd_copy_private_header_data): Define.
* aout-tic30.c (MY_bfd_copy_private_header_data): Define.
* bfd.c (bfd_copy_private_header_data): Define.
* coff-rs6000.c (rs6000coff_vec, pmac_xcoff_vec): Add entries for new
interface.
* coff64-rs6000.c (rs6000coff64_vec, aix5coff64_vec): Likewise.
* coffcode.h (coff_bfd_copy_private_header_data): Define.
* elf-bfd.h (_bfd_elf_copy_private_header_data): Declare.
* elf.c (_bfd_elf_copy_private_section_data): Remove code to set up
segments by calling copy_private_bfd_data.
(_bfd_elf_copy_private_header_data): Define.
* elfxx-target.h (bfd_elfNN_bfd_copy_private_header_data): Define.
* libbfd-in.h (_bfd_generic_bfd_copy_private_header_data): Define.
* libecoff.h (_bfd_ecoff_bfd_copy_private_header_data): Define.
* mach-o.c (bfd_mach_o_bfd_copy_private_header_data): Define.
* mmo.c (mmo_bfd_copy_private_header_data): Define.
* ppcboot.c (ppcboot_bfd_copy_private_header_data): Define.
* som.c (som_bfd_copy_private_header_data): Define.
* targets.c (BFD_JUMP_TABLE_COPY): Add _bfd_copy_private_header_data.
* vms.c (vms_bfd_copy_private_header_data): Define.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.

22 files changed:
bfd/ChangeLog
bfd/aout-target.h
bfd/aout-tic30.c
bfd/bfd-in2.h
bfd/bfd.c
bfd/coff-rs6000.c
bfd/coff64-rs6000.c
bfd/coffcode.h
bfd/elf-bfd.h
bfd/elf.c
bfd/elfxx-target.h
bfd/libbfd-in.h
bfd/libbfd.h
bfd/libecoff.h
bfd/mach-o.c
bfd/mmo.c
bfd/ppcboot.c
bfd/som.c
bfd/targets.c
bfd/vms.c
binutils/ChangeLog
binutils/objcopy.c

index b4b1d91..b5364ed 100644 (file)
@@ -1,3 +1,28 @@
+2004-05-17  David Heine  <dlheine@tensilica.com>
+
+       * aout-target.h (MY_bfd_copy_private_header_data): Define.
+       * aout-tic30.c (MY_bfd_copy_private_header_data): Define.
+       * bfd.c (bfd_copy_private_header_data): Define.
+       * coff-rs6000.c (rs6000coff_vec, pmac_xcoff_vec): Add entries for new
+       interface.
+       * coff64-rs6000.c (rs6000coff64_vec, aix5coff64_vec): Likewise.
+       * coffcode.h (coff_bfd_copy_private_header_data): Define.
+       * elf-bfd.h (_bfd_elf_copy_private_header_data): Declare.
+       * elf.c (_bfd_elf_copy_private_section_data): Remove code to set up
+       segments by calling copy_private_bfd_data.
+       (_bfd_elf_copy_private_header_data): Define.
+       * elfxx-target.h (bfd_elfNN_bfd_copy_private_header_data): Define.
+       * libbfd-in.h (_bfd_generic_bfd_copy_private_header_data): Define.
+       * libecoff.h (_bfd_ecoff_bfd_copy_private_header_data): Define.
+       * mach-o.c (bfd_mach_o_bfd_copy_private_header_data): Define.
+       * mmo.c (mmo_bfd_copy_private_header_data): Define.
+       * ppcboot.c (ppcboot_bfd_copy_private_header_data): Define.
+       * som.c (som_bfd_copy_private_header_data): Define.
+       * targets.c (BFD_JUMP_TABLE_COPY): Add _bfd_copy_private_header_data.
+       * vms.c (vms_bfd_copy_private_header_data): Define.
+       * bfd-in2.h: Regenerate.
+       * libbfd.h: Regenerate.
+
 2004-05-15  Thiemo Seufer  <seufer@csv.ica.uni-stuttgart.de>
 
        * elfxx-mips.c (MINUS_TWO): Define.
index 80513c7..fd344a4 100644 (file)
@@ -559,6 +559,10 @@ MY_bfd_final_link (abfd, info)
 #define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
 #endif
 
+#ifndef MY_bfd_copy_private_header_data
+#define MY_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
+#endif
+
 #ifndef MY_bfd_print_private_bfd_data
 #define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
 #endif
index 1ae0ebf..af99c4b 100644 (file)
@@ -1016,6 +1016,10 @@ tic30_aout_set_arch_mach (abfd, arch, machine)
 #define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
 #endif
 
+#ifndef MY_bfd_copy_private_header_data
+#define MY_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
+#endif
+
 #ifndef MY_bfd_print_private_bfd_data
 #define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
 #endif
index ee194f9..3f38b6a 100644 (file)
@@ -3945,6 +3945,11 @@ void bfd_set_gp_size (bfd *abfd, unsigned int i);
 
 bfd_vma bfd_scan_vma (const char *string, const char **end, int base);
 
+bfd_boolean bfd_copy_private_header_data (bfd *ibfd, bfd *obfd);
+
+#define bfd_copy_private_header_data(ibfd, obfd) \
+     BFD_SEND (obfd, _bfd_copy_private_header_data, \
+               (ibfd, obfd))
 bfd_boolean bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd);
 
 #define bfd_copy_private_bfd_data(ibfd, obfd) \
@@ -4225,6 +4230,7 @@ typedef struct bfd_target
   NAME##_bfd_merge_private_bfd_data, \
   NAME##_bfd_copy_private_section_data, \
   NAME##_bfd_copy_private_symbol_data, \
+  NAME##_bfd_copy_private_header_data, \
   NAME##_bfd_set_private_flags, \
   NAME##_bfd_print_private_bfd_data
 
@@ -4242,6 +4248,10 @@ typedef struct bfd_target
      to another.  */
   bfd_boolean (*_bfd_copy_private_symbol_data)
     (bfd *, asymbol *, bfd *, asymbol *);
+  /* Called to copy BFD private header data from one object file
+     to another.  */
+  bfd_boolean (*_bfd_copy_private_header_data)
+    (bfd *, bfd *);
   /* Called to set private backend flags.  */
   bfd_boolean (*_bfd_set_private_flags) (bfd *, flagword);
 
index e184781..3ead0ee 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -982,6 +982,29 @@ bfd_scan_vma (const char *string, const char **end, int base)
 
 /*
 FUNCTION
+       bfd_copy_private_header_data
+
+SYNOPSIS
+       bfd_boolean bfd_copy_private_header_data (bfd *ibfd, bfd *obfd);
+
+DESCRIPTION
+       Copy private BFD header information from the BFD @var{ibfd} to the
+       the BFD @var{obfd}.  This copies information that may require
+       sections to exist, but does not require symbol tables.  Return
+       <<true>> on success, <<false>> on error.
+       Possible error returns are:
+
+       o <<bfd_error_no_memory>> -
+       Not enough memory exists to create private data for @var{obfd}.
+
+.#define bfd_copy_private_header_data(ibfd, obfd) \
+.     BFD_SEND (obfd, _bfd_copy_private_header_data, \
+.              (ibfd, obfd))
+
+*/
+
+/*
+FUNCTION
        bfd_copy_private_bfd_data
 
 SYNOPSIS
index 22d47c5..cbd3a91 100644 (file)
@@ -4142,6 +4142,7 @@ const bfd_target rs6000coff_vec =
     ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
     ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
     ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
+    ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
     ((bfd_boolean (*) (bfd *, flagword)) bfd_true),
     ((bfd_boolean (*) (bfd *, void * )) bfd_true),
 
@@ -4386,6 +4387,7 @@ const bfd_target pmac_xcoff_vec =
     ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
     ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
     ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
+    ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
     ((bfd_boolean (*) (bfd *, flagword)) bfd_true),
     ((bfd_boolean (*) (bfd *, void * )) bfd_true),
 
index 857a4b4..678ba93 100644 (file)
@@ -2683,6 +2683,7 @@ const bfd_target rs6000coff64_vec =
     ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
     ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
     ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
+    ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
     ((bfd_boolean (*) (bfd *, flagword)) bfd_true),
     ((bfd_boolean (*) (bfd *, void * )) bfd_true),
 
@@ -2928,6 +2929,7 @@ const bfd_target aix5coff64_vec =
     ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
     ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
     ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
+    ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
     ((bfd_boolean (*) (bfd *, flagword)) bfd_true),
     ((bfd_boolean (*) (bfd *, void * )) bfd_true),
 
index 35da7c9..d507446 100644 (file)
@@ -5511,6 +5511,10 @@ static const bfd_coff_backend_data ticoff1_swap_table =
 #define coff_bfd_copy_private_symbol_data   _bfd_generic_bfd_copy_private_symbol_data
 #endif
 
+#ifndef coff_bfd_copy_private_header_data
+#define coff_bfd_copy_private_header_data   _bfd_generic_bfd_copy_private_header_data
+#endif
+
 #ifndef coff_bfd_copy_private_section_data
 #define coff_bfd_copy_private_section_data  _bfd_generic_bfd_copy_private_section_data
 #endif
index 750cc1c..82da5bb 100644 (file)
@@ -1379,6 +1379,8 @@ extern void bfd_elf_set_group_contents
   (bfd *, asection *, void *);
 extern void _bfd_elf_link_just_syms
   (asection *, struct bfd_link_info *);
+extern bfd_boolean _bfd_elf_copy_private_header_data
+  (bfd *, bfd *);
 extern bfd_boolean _bfd_elf_copy_private_symbol_data
   (bfd *, asymbol *, bfd *, asymbol *);
 extern bfd_boolean _bfd_elf_copy_private_section_data
index 8e208c2..0317e35 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5290,24 +5290,6 @@ _bfd_elf_copy_private_section_data (bfd *ibfd,
       || obfd->xvec->flavour != bfd_target_elf_flavour)
     return TRUE;
 
-  if (elf_tdata (obfd)->segment_map == NULL && elf_tdata (ibfd)->phdr != NULL)
-    {
-       asection *s;
-
-       /* Only set up the segments if there are no more SEC_ALLOC
-          sections.  FIXME: This won't do the right thing if objcopy is
-          used to remove the last SEC_ALLOC section, since objcopy
-          won't call this routine in that case.  */
-       for (s = isec->next; s != NULL; s = s->next)
-         if ((s->flags & SEC_ALLOC) != 0)
-           break;
-       if (s == NULL)
-         {
-           if (! copy_private_bfd_data (ibfd, obfd))
-             return FALSE;
-         }
-    }
-
   ihdr = &elf_section_data (isec)->this_hdr;
   ohdr = &elf_section_data (osec)->this_hdr;
 
@@ -5330,6 +5312,29 @@ _bfd_elf_copy_private_section_data (bfd *ibfd,
   return TRUE;
 }
 
+/* Copy private header information.  */
+
+bfd_boolean
+_bfd_elf_copy_private_header_data (bfd *ibfd, bfd *obfd)
+{
+  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+    return TRUE;
+
+  /* Copy over private BFD data if it has not already been copied.
+     This must be done here, rather than in the copy_private_bfd_data
+     entry point, because the latter is called after the section
+     contents have been set, which means that the program headers have
+     already been worked out.  */
+  if (elf_tdata (obfd)->segment_map == NULL && elf_tdata (ibfd)->phdr != NULL)
+    {
+      if (! copy_private_bfd_data (ibfd, obfd))
+       return FALSE;
+    }
+
+  return TRUE;
+}
+
 /* Copy private symbol information.  If this symbol is in a section
    which we did not map into a BFD section, try to map the section
    index correctly.  We use special macro definitions for the mapped
index 61ed197..d0773e5 100644 (file)
 #define bfd_elfNN_bfd_copy_private_section_data \
   _bfd_elf_copy_private_section_data
 #endif
+#ifndef bfd_elfNN_bfd_copy_private_header_data
+#define bfd_elfNN_bfd_copy_private_header_data \
+  _bfd_elf_copy_private_header_data
+#endif
 #ifndef bfd_elfNN_bfd_copy_private_bfd_data
 #define bfd_elfNN_bfd_copy_private_bfd_data \
   _bfd_elf_copy_private_bfd_data
index fb021d3..6d3a335 100644 (file)
@@ -212,6 +212,8 @@ extern bfd_boolean _bfd_generic_get_section_contents_in_window
   ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true)
 #define _bfd_generic_bfd_copy_private_symbol_data \
   ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true)
+#define _bfd_generic_bfd_copy_private_header_data \
+  ((bfd_boolean (*) (bfd *, bfd *)) bfd_true)
 #define _bfd_generic_bfd_print_private_bfd_data \
   ((bfd_boolean (*) (bfd *, void *)) bfd_true)
 
index 6841e29..86819ff 100644 (file)
@@ -217,6 +217,8 @@ extern bfd_boolean _bfd_generic_get_section_contents_in_window
   ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true)
 #define _bfd_generic_bfd_copy_private_symbol_data \
   ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true)
+#define _bfd_generic_bfd_copy_private_header_data \
+  ((bfd_boolean (*) (bfd *, bfd *)) bfd_true)
 #define _bfd_generic_bfd_print_private_bfd_data \
   ((bfd_boolean (*) (bfd *, void *)) bfd_true)
 
@@ -696,9 +698,9 @@ struct _bfd_window_internal {
 extern bfd *bfd_last_cache;
 
 #define bfd_cache_lookup(x) \
-    ((x)==bfd_last_cache? \
-      (FILE*) (bfd_last_cache->iostream): \
-       bfd_cache_lookup_worker(x))
+    ((x) == bfd_last_cache ? \
+      (FILE *) (bfd_last_cache->iostream): \
+       bfd_cache_lookup_worker (x))
 bfd_boolean bfd_cache_init (bfd *abfd);
 
 bfd_boolean bfd_cache_close (bfd *abfd);
index 7d4006a..b809f3a 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD ECOFF object file private structure.
-   Copyright 1993, 1994, 1995, 1996, 1999, 2001, 2002, 2003
+   Copyright 1993, 1994, 1995, 1996, 1999, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
@@ -249,6 +249,9 @@ extern bfd_boolean _bfd_ecoff_bfd_copy_private_bfd_data
 #define _bfd_ecoff_bfd_copy_private_symbol_data \
   _bfd_generic_bfd_copy_private_symbol_data
 
+#define _bfd_ecoff_bfd_copy_private_header_data \
+  _bfd_generic_bfd_copy_private_header_data
+
 #define _bfd_ecoff_bfd_print_private_bfd_data \
   _bfd_generic_bfd_print_private_bfd_data
 
index eaa7aba..b2401c4 100644 (file)
@@ -70,6 +70,7 @@
 #define bfd_mach_o_bfd_merge_sections bfd_generic_merge_sections
 #define bfd_mach_o_bfd_is_group_section bfd_generic_is_group_section
 #define bfd_mach_o_bfd_discard_group bfd_generic_discard_group
+#define bfd_mach_o_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
 
 static bfd_boolean bfd_mach_o_bfd_copy_private_symbol_data
   PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
index d791062..fc6c213 100644 (file)
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -3306,6 +3306,7 @@ mmo_canonicalize_reloc (abfd, section, relptr, symbols)
 #define mmo_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
 #define mmo_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
 #define mmo_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
+#define mmo_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
 #define mmo_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
 #define mmo_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
 
index d34f1a2..cc4dc27 100644 (file)
@@ -484,6 +484,7 @@ ppcboot_bfd_print_private_bfd_data (abfd, farg)
 #define ppcboot_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
 #define ppcboot_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
 #define ppcboot_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
+#define ppcboot_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
 #define ppcboot_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
 #define ppcboot_bfd_print_private_bfd_dat ppcboot_bfd_print_private_bfd_data
 
index 899a8a2..e05d4af 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -192,6 +192,8 @@ static bfd_boolean som_bfd_copy_private_section_data
   PARAMS ((bfd *, asection *, bfd *, asection *));
 static bfd_boolean som_bfd_copy_private_bfd_data
   PARAMS ((bfd *, bfd *));
+#define som_bfd_copy_private_header_data \
+  _bfd_generic_bfd_copy_private_header_data
 #define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
 #define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
 static bfd_boolean som_bfd_is_local_label_name
index ad6362a..bceb724 100644 (file)
@@ -265,6 +265,7 @@ BFD_JUMP_TABLE macros.
 .  NAME##_bfd_merge_private_bfd_data, \
 .  NAME##_bfd_copy_private_section_data, \
 .  NAME##_bfd_copy_private_symbol_data, \
+.  NAME##_bfd_copy_private_header_data, \
 .  NAME##_bfd_set_private_flags, \
 .  NAME##_bfd_print_private_bfd_data
 .
@@ -282,6 +283,10 @@ BFD_JUMP_TABLE macros.
 .     to another.  *}
 .  bfd_boolean (*_bfd_copy_private_symbol_data)
 .    (bfd *, asymbol *, bfd *, asymbol *);
+.  {* Called to copy BFD private header data from one object file
+.     to another.  *}
+.  bfd_boolean (*_bfd_copy_private_header_data)
+.    (bfd *, bfd *);
 .  {* Called to set private backend flags.  *}
 .  bfd_boolean (*_bfd_set_private_flags) (bfd *, flagword);
 .
index 329b056..f6d3c1a 100644 (file)
--- a/bfd/vms.c
+++ b/bfd/vms.c
@@ -168,6 +168,8 @@ static bfd_boolean vms_bfd_set_private_flags
 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
 #define vms_bfd_is_group_section bfd_generic_is_group_section
 #define vms_bfd_discard_group bfd_generic_discard_group
+#define vms_bfd_copy_private_header_data \
+  _bfd_generic_bfd_copy_private_header_data
 \f
 /*===========================================================================*/
 
index 0cbdf4b..2dab43f 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-17  David Heine  <dlheine@tensilica.com>
+
+        * objcopy.c (setup_bfd_headers): New function.
+       (copy_object): Call setup_bfd_headers.
+
 2004-05-13  Paul Brook  <paul@codesourcery.com>
 
        * readelf.c (display_debug_frames): Handle dwarf3 format CIE
index aad68ad..839d27b 100644 (file)
@@ -377,6 +377,7 @@ extern unsigned long          bfd_external_machine;
 
 /* Forward declarations.  */
 static void setup_section (bfd *, asection *, void *);
+static void setup_bfd_headers (bfd *, bfd *);
 static void copy_section (bfd *, asection *, void *);
 static void get_sections (bfd *, asection *, void *);
 static int compare_section_lma (const void *, const void *);
@@ -1178,6 +1179,8 @@ copy_object (bfd *ibfd, bfd *obfd)
      any output is done.  Thus, we traverse all sections multiple times.  */
   bfd_map_over_sections (ibfd, setup_section, obfd);
 
+  setup_bfd_headers (ibfd, obfd);
+
   if (add_sections != NULL)
     {
       struct section_add *padd;
@@ -1808,6 +1811,32 @@ find_section_rename (bfd * ibfd ATTRIBUTE_UNUSED, sec_ptr isection,
   return old_name;
 }
 
+/* Once each of the sections is copied, we may still need to do some
+   finalization work for private section headers.  Do that here.  */
+
+static void
+setup_bfd_headers (bfd *ibfd, bfd *obfd)
+{
+  const char *err;
+
+  /* Allow the BFD backend to copy any private data it understands
+     from the input section to the output section.  */
+  if (! bfd_copy_private_header_data (ibfd, obfd))
+    {
+      err = _("private header data");
+      goto loser;
+    }
+
+  /* All went well.  */
+  return;
+
+loser:
+  non_fatal (_("%s: error in %s: %s"),
+            bfd_get_filename (ibfd),
+            err, bfd_errmsg (bfd_get_error ()));
+  status = 1;
+}
+
 /* Create a section in OBFD with the same
    name and attributes as ISECTION in IBFD.  */