This is the mail archive of the binutils@sources.redhat.com 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: Problem with objcopy phdrs and patch


Alan Modra wrote:
Hmm, I should have mentioned that you need --enable-64-bit-bfd also if
your host and target are both 32 bit; The list of files changed looked
suspiciously small.  I see you caught som.c, which I missed in my last
change in this area.  Good!  :)  However, there's no mention of
coff-rs6000.c and coff64-rs6000.c in the patch.  I think you'll need a
change there too.

Otherwise OK.  Further mechanical change to rs6000 files pre-approved,
plus any other missing changes if --enable-64-bit-bfd shows some are
needed.  Thanks!

You were right about the coff*-rs6000 files. I fixed them and there were no other problems exposed by the --enable-64-bit-bfd build. Here are the revised patches that I've committed.


--Bob

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.

binutils ChangeLog:

2004-05-17 David Heine <dlheine@tensilica.com>

        * objcopy.c (setup_bfd_headers): New function.
        (copy_object): Call setup_bfd_headers.

Index: aout-target.h
===================================================================
RCS file: /cvs/src/src/bfd/aout-target.h,v
retrieving revision 1.23
diff -u -r1.23 aout-target.h
--- aout-target.h	30 Apr 2004 14:23:39 -0000	1.23
+++ aout-target.h	17 May 2004 16:18:25 -0000
@@ -559,6 +559,10 @@
 #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: aout-tic30.c
===================================================================
RCS file: /cvs/src/src/bfd/aout-tic30.c,v
retrieving revision 1.22
diff -u -r1.22 aout-tic30.c
--- aout-tic30.c	30 Apr 2004 14:23:39 -0000	1.22
+++ aout-tic30.c	17 May 2004 16:18:26 -0000
@@ -1016,6 +1016,10 @@
 #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: bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.276
diff -u -r1.276 bfd-in2.h
--- bfd-in2.h	5 May 2004 14:33:13 -0000	1.276
+++ bfd-in2.h	17 May 2004 16:18:26 -0000
@@ -3945,6 +3945,11 @@
 
 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 @@
   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 @@
      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: bfd.c
===================================================================
RCS file: /cvs/src/src/bfd/bfd.c,v
retrieving revision 1.61
diff -u -r1.61 bfd.c
--- bfd.c	30 Apr 2004 14:23:39 -0000	1.61
+++ bfd.c	17 May 2004 16:18:26 -0000
@@ -982,6 +982,29 @@
 
 /*
 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: coff-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-rs6000.c,v
retrieving revision 1.59
diff -u -r1.59 coff-rs6000.c
--- coff-rs6000.c	30 Apr 2004 14:23:39 -0000	1.59
+++ coff-rs6000.c	17 May 2004 16:18:26 -0000
@@ -4142,6 +4142,7 @@
     ((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 @@
     ((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: coff64-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff64-rs6000.c,v
retrieving revision 1.50
diff -u -r1.50 coff64-rs6000.c
--- coff64-rs6000.c	30 Apr 2004 14:23:39 -0000	1.50
+++ coff64-rs6000.c	17 May 2004 16:18:26 -0000
@@ -2683,6 +2683,7 @@
     ((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 @@
     ((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: coffcode.h
===================================================================
RCS file: /cvs/src/src/bfd/coffcode.h,v
retrieving revision 1.104
diff -u -r1.104 coffcode.h
--- coffcode.h	7 May 2004 15:08:48 -0000	1.104
+++ coffcode.h	17 May 2004 16:18:27 -0000
@@ -5511,6 +5511,10 @@
 #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: elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.140
diff -u -r1.140 elf-bfd.h
--- elf-bfd.h	11 May 2004 17:08:37 -0000	1.140
+++ elf-bfd.h	17 May 2004 16:18:27 -0000
@@ -1379,6 +1379,8 @@
   (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: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.225
diff -u -r1.225 elf.c
--- elf.c	11 May 2004 17:08:37 -0000	1.225
+++ elf.c	17 May 2004 16:18:28 -0000
@@ -5290,24 +5290,6 @@
       || 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;
 
@@ -5326,6 +5308,29 @@
   elf_group_name (osec) = elf_group_name (isec);
 
   osec->use_rela_p = isec->use_rela_p;
+
+  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;
 }
Index: elfxx-target.h
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-target.h,v
retrieving revision 1.64
diff -u -r1.64 elfxx-target.h
--- elfxx-target.h	30 Apr 2004 14:23:39 -0000	1.64
+++ elfxx-target.h	17 May 2004 16:18:28 -0000
@@ -158,6 +158,10 @@
 #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: libbfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd-in.h,v
retrieving revision 1.33
diff -u -r1.33 libbfd-in.h
--- libbfd-in.h	30 Apr 2004 14:23:39 -0000	1.33
+++ libbfd-in.h	17 May 2004 16:18:28 -0000
@@ -212,6 +212,8 @@
   ((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: libbfd.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd.h,v
retrieving revision 1.108
diff -u -r1.108 libbfd.h
--- libbfd.h	30 Apr 2004 14:23:40 -0000	1.108
+++ libbfd.h	17 May 2004 16:18:28 -0000
@@ -217,6 +217,8 @@
   ((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 @@
 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: libecoff.h
===================================================================
RCS file: /cvs/src/src/bfd/libecoff.h,v
retrieving revision 1.15
diff -u -r1.15 libecoff.h
--- libecoff.h	24 Apr 2004 06:12:24 -0000	1.15
+++ libecoff.h	17 May 2004 16:18:28 -0000
@@ -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.
 
@@ -248,6 +248,9 @@
 
 #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: mach-o.c
===================================================================
RCS file: /cvs/src/src/bfd/mach-o.c,v
retrieving revision 1.8
diff -u -r1.8 mach-o.c
--- mach-o.c	30 Apr 2004 14:23:39 -0000	1.8
+++ mach-o.c	17 May 2004 16:18:28 -0000
@@ -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: mmo.c
===================================================================
RCS file: /cvs/src/src/bfd/mmo.c,v
retrieving revision 1.17
diff -u -r1.17 mmo.c
--- mmo.c	30 Apr 2004 14:23:39 -0000	1.17
+++ mmo.c	17 May 2004 16:18:28 -0000
@@ -3306,6 +3306,7 @@
 #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: ppcboot.c
===================================================================
RCS file: /cvs/src/src/bfd/ppcboot.c,v
retrieving revision 1.17
diff -u -r1.17 ppcboot.c
--- ppcboot.c	30 Apr 2004 14:23:40 -0000	1.17
+++ ppcboot.c	17 May 2004 16:18:28 -0000
@@ -484,6 +484,7 @@
 #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: som.c
===================================================================
RCS file: /cvs/src/src/bfd/som.c,v
retrieving revision 1.42
diff -u -r1.42 som.c
--- som.c	14 May 2004 17:42:47 -0000	1.42
+++ som.c	17 May 2004 16:18:29 -0000
@@ -192,6 +192,8 @@
   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: targets.c
===================================================================
RCS file: /cvs/src/src/bfd/targets.c,v
retrieving revision 1.109
diff -u -r1.109 targets.c
--- targets.c	6 May 2004 02:46:29 -0000	1.109
+++ targets.c	17 May 2004 16:18:29 -0000
@@ -265,6 +265,7 @@
 .  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 @@
 .     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: vms.c
===================================================================
RCS file: /cvs/src/src/bfd/vms.c,v
retrieving revision 1.28
diff -u -r1.28 vms.c
--- vms.c	30 Apr 2004 14:23:40 -0000	1.28
+++ vms.c	17 May 2004 16:18:29 -0000
@@ -168,6 +168,8 @@
 #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
 
 /*===========================================================================*/
 
Index: objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.67
diff -u -r1.67 objcopy.c
--- objcopy.c	27 Apr 2004 06:31:16 -0000	1.67
+++ objcopy.c	17 May 2004 16:24:38 -0000
@@ -377,6 +377,7 @@
 
 /* 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 @@
      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;
@@ -1806,6 +1809,32 @@
       }
 
   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

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