+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.
#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
#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
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) \
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
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);
return value;
}
+/*
+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
((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),
((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),
((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),
((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),
#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
(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
|| 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;
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
#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
((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)
((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)
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);
/* 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.
#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
#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 *));
#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
#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
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
. 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
.
. 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);
.
#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
/*===========================================================================*/
+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
/* 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 *);
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;
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. */