aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@vmware.com>2001-12-19 05:18:34 +0000
committerMichael Snyder <msnyder@vmware.com>2001-12-19 05:18:34 +0000
commit4dd67f29188d3bfefaebff926310e40b0a710bc8 (patch)
treedac4a6cb62b88f225a1059bf2a9afef22afd1a90 /binutils/objcopy.c
parent52e9b6196ae25776c0ed348b4b1d823c3b356854 (diff)
downloadgdb-4dd67f29188d3bfefaebff926310e40b0a710bc8.zip
gdb-4dd67f29188d3bfefaebff926310e40b0a710bc8.tar.gz
gdb-4dd67f29188d3bfefaebff926310e40b0a710bc8.tar.bz2
2001-12-18 Michael Snyder <msnyder@redhat.com>
* objcopy.c (copy_file): Accept corefiles (format bfd_core). (copy_object): Don't set the start address or flags of a core file. (copy_section): Don't relocate a core file. Don't copy contents if the input section has the contents flag set, but the output section does not (which happens with the fake 'note' pseudo- sections that BFD creates for corefiles).
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 9a5971d..ddd0197 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -958,11 +958,16 @@ copy_object (ibfd, obfd)
start = bfd_get_start_address (ibfd);
start += change_start;
- if (!bfd_set_start_address (obfd, start)
- || !bfd_set_file_flags (obfd,
- (bfd_get_file_flags (ibfd)
- & bfd_applicable_file_flags (obfd))))
- RETURN_NONFATAL (bfd_get_filename (ibfd));
+ /* Neither the start address nor the flags
+ need to be set for a core file. */
+ if (bfd_get_format (obfd) != bfd_core)
+ {
+ if (!bfd_set_start_address (obfd, start)
+ || !bfd_set_file_flags (obfd,
+ (bfd_get_file_flags (ibfd)
+ & bfd_applicable_file_flags (obfd))))
+ RETURN_NONFATAL (bfd_get_filename (ibfd));
+ }
/* Copy architecture of input file to output file. */
if (!bfd_set_arch_mach (obfd, bfd_get_arch (ibfd),
@@ -1403,7 +1408,8 @@ copy_file (input_filename, output_filename, input_target, output_target)
copy_archive (ibfd, obfd, output_target);
}
- else if (bfd_check_format_matches (ibfd, bfd_object, &matching))
+ else if (bfd_check_format_matches (ibfd, bfd_object, &matching)
+ || bfd_check_format_matches (ibfd, bfd_core, &matching))
{
bfd *obfd;
@@ -1674,7 +1680,12 @@ copy_section (ibfd, isection, obfdarg)
if (size == 0 || osection == 0)
return;
- relsize = bfd_get_reloc_upper_bound (ibfd, isection);
+ /* Core files do not need to be relocated. */
+ if (bfd_get_format (obfd) == bfd_core)
+ relsize = 0;
+ else
+ relsize = bfd_get_reloc_upper_bound (ibfd, isection);
+
if (relsize < 0)
RETURN_NONFATAL (bfd_get_filename (ibfd));
@@ -1713,7 +1724,8 @@ copy_section (ibfd, isection, obfdarg)
isection->_cooked_size = isection->_raw_size;
isection->reloc_done = true;
- if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS)
+ if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS
+ && bfd_get_section_flags (obfd, osection) & SEC_HAS_CONTENTS)
{
PTR memhunk = (PTR) xmalloc ((unsigned) size);